History

(1) add protection for golomb GetUe output value (2) change the max length of cabac bypass to 16

Haibo Zhu committed 11 years ago

Commit 9ba2c981 parent fb617333 files · +15 −17Browse files

Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 3 files). Show all

Unified · Split

codec/decoder/core/src/decoder_core.cpp+12−14
@@ -389,25 +389,25 @@ int32_t ParseDecRefPicMarking (PWelsDecoderContext pCtx, PBitStringAux pBs, PSli · 388 unmodified lines
389389 int32_t iIdx = 0;
390390 do {
391391 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //memory_management_control_operation
392− const int32_t kiMmco = uiCode;
392+ const uint32_t kuiMmco = uiCode;
393393
394− kpRefMarking->sMmcoRef[iIdx].uiMmcoType = kiMmco;
395− if (kiMmco == MMCO_END)
394+ kpRefMarking->sMmcoRef[iIdx].uiMmcoType = kuiMmco;
395+ if (kuiMmco == MMCO_END)
396396 break;
397397
398− if (kiMmco == MMCO_SHORT2UNUSED || kiMmco == MMCO_SHORT2LONG) {
398+ if (kuiMmco == MMCO_SHORT2UNUSED || kuiMmco == MMCO_SHORT2LONG) {
399399 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_pic_nums_minus1
400400 kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum = 1 + uiCode;
401401 kpRefMarking->sMmcoRef[iIdx].iShortFrameNum = (pSh->iFrameNum - kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum) & ((
402402 1 << pSps->uiLog2MaxFrameNum) - 1);
403− } else if (kiMmco == MMCO_LONG2UNUSED) {
403+ } else if (kuiMmco == MMCO_LONG2UNUSED) {
404404 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_pic_num
405405 kpRefMarking->sMmcoRef[iIdx].uiLongTermPicNum = uiCode;
406406 }
407− if (kiMmco == MMCO_SHORT2LONG || kiMmco == MMCO_LONG) {
407+ if (kuiMmco == MMCO_SHORT2LONG || kuiMmco == MMCO_LONG) {
408408 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_frame_idx
409409 kpRefMarking->sMmcoRef[iIdx].iLongTermFrameIdx = uiCode;
410− } else if (kiMmco == MMCO_SET_MAX_LONG) {
410+ } else if (kuiMmco == MMCO_SET_MAX_LONG) {
411411 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_long_term_frame_idx_plus1
412412 kpRefMarking->sMmcoRef[iIdx].iMaxLongTermFrameIdx = -1 + uiCode;
413413 }
@@ -690,6 +690,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 276 unmodified lines
690690
691691 // first_mb_in_slice
692692 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //first_mb_in_slice
693+ WELS_CHECK_SE_UPPER_ERROR (uiCode, 36863u, "first_mb_in_slice", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER,
694+ ERR_INFO_INVALID_FIRST_MB_IN_SLICE));
693695 pSliceHead->iFirstMbInSlice = uiCode;
694696
695697 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //slice_type
@@ -721,13 +723,10 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 25 unmodified lines
721723 pSliceHead->eSliceType = static_cast <EWelsSliceType> (uiSliceType);
722724
723725 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_parameter_set_id
726+ WELS_CHECK_SE_UPPER_ERROR (uiCode, MAX_PPS_COUNT, "iPpsId out of range", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER,
727+ ERR_INFO_PPS_ID_OVERFLOW));
724728 iPpsId = uiCode;
725729
726− if (iPpsId >= MAX_PPS_COUNT) {
727− WelsLog (pLogCtx, WELS_LOG_WARNING, "iPpsId out of range");
728− return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_PPS_ID_OVERFLOW);
729− }
730−
731730 //add check PPS available here
732731 if (pCtx->bPpsAvailFlags[iPpsId] == false) {
733732 pCtx->sDecoderStatistics.iPpsReportErrorNum++;
@@ -939,9 +938,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 205 unmodified lines
939938 if (pPps->bEntropyCodingModeFlag) {
940939 if (pSliceHead->eSliceType != I_SLICE && pSliceHead->eSliceType != SI_SLICE) {
941940 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode));
941+ WELS_CHECK_SE_UPPER_ERROR (uiCode, SLICE_HEADER_CABAC_INIT_IDC_MAX, "cabac_init_idc", ERR_INFO_INVALID_CABAC_INIT_IDC);
942942 pSliceHead->iCabacInitIdc = uiCode;
943− WELS_CHECK_SE_UPPER_ERROR (pSliceHead->iCabacInitIdc, SLICE_HEADER_CABAC_INIT_IDC_MAX, "cabac_init_idc",
944− ERR_INFO_INVALID_CABAC_INIT_IDC);
945943 } else
946944 pSliceHead->iCabacInitIdc = 0;
947945 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t