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 (3 of 3 files). Show all

Unified · Split

3 files
  1. codec/decoder/core/inc/dec_golomb.h +1 −1
  2. codec/decoder/core/src/cabac_decoder.cpp +2 −2
  3. codec/decoder/core/src/decoder_core.cpp +12 −14
codec/decoder/core/inc/dec_golomb.h+1−1
@@ -179,7 +179,7 @@ static inline uint32_t BsGetUe (PBitStringAux pBs, uint32_t* pCode) { · 178 unmodified lines
179 DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iLeadingZeroBits, iAllowedBytes, iReadBytes);179 DUMP_BITS (pBs->uiCurBits, pBs->pCurBuf, pBs->iLeftBits, iLeadingZeroBits, iAllowedBytes, iReadBytes);
180 }180 }
181 181
182 *pCode = ((1 << iLeadingZeroBits) - 1 + iValue);182 *pCode = ((1u << iLeadingZeroBits) - 1 + iValue);
183 return ERR_NONE;183 return ERR_NONE;
184}184}
185 185
codec/decoder/core/src/cabac_decoder.cpp+2−2
@@ -273,8 +273,8 @@ int32_t DecodeExpBypassCabac (PWelsCabacDecEngine pDecEngine, int32_t iCount, ui · 272 unmodified lines
273 iSymTmp += (1 << iCount);273 iSymTmp += (1 << iCount);
274 ++iCount;274 ++iCount;
275 }275 }
276 } while (uiCode != 0 && iCount != 31);276 } while (uiCode != 0 && iCount != 16);
277 if (iCount == 31) {277 if (iCount == 16) {
278 return ERR_CABAC_UNEXPECTED_VALUE;278 return ERR_CABAC_UNEXPECTED_VALUE;
279 }279 }
280 280
codec/decoder/core/src/decoder_core.cpp+12−14
@@ -389,25 +389,25 @@ int32_t ParseDecRefPicMarking (PWelsDecoderContext pCtx, PBitStringAux pBs, PSli · 388 unmodified lines
389 int32_t iIdx = 0;389 int32_t iIdx = 0;
390 do {390 do {
391 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //memory_management_control_operation391 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //memory_management_control_operation
392 const int32_t kiMmco = uiCode;392 const uint32_t kuiMmco = uiCode;
393 393
394 kpRefMarking->sMmcoRef[iIdx].uiMmcoType = kiMmco;394 kpRefMarking->sMmcoRef[iIdx].uiMmcoType = kuiMmco;
395 if (kiMmco == MMCO_END)395 if (kuiMmco == MMCO_END)
396 break;396 break;
397 397
398 if (kiMmco == MMCO_SHORT2UNUSED || kiMmco == MMCO_SHORT2LONG) {398 if (kuiMmco == MMCO_SHORT2UNUSED || kuiMmco == MMCO_SHORT2LONG) {
399 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_pic_nums_minus1399 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_pic_nums_minus1
400 kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum = 1 + uiCode;400 kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum = 1 + uiCode;
401 kpRefMarking->sMmcoRef[iIdx].iShortFrameNum = (pSh->iFrameNum - kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum) & ((401 kpRefMarking->sMmcoRef[iIdx].iShortFrameNum = (pSh->iFrameNum - kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum) & ((
402 1 << pSps->uiLog2MaxFrameNum) - 1);402 1 << pSps->uiLog2MaxFrameNum) - 1);
403 } else if (kiMmco == MMCO_LONG2UNUSED) {403 } else if (kuiMmco == MMCO_LONG2UNUSED) {
404 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_pic_num404 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_pic_num
405 kpRefMarking->sMmcoRef[iIdx].uiLongTermPicNum = uiCode;405 kpRefMarking->sMmcoRef[iIdx].uiLongTermPicNum = uiCode;
406 }406 }
407 if (kiMmco == MMCO_SHORT2LONG || kiMmco == MMCO_LONG) {407 if (kuiMmco == MMCO_SHORT2LONG || kuiMmco == MMCO_LONG) {
408 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_frame_idx408 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_frame_idx
409 kpRefMarking->sMmcoRef[iIdx].iLongTermFrameIdx = uiCode;409 kpRefMarking->sMmcoRef[iIdx].iLongTermFrameIdx = uiCode;
410 } else if (kiMmco == MMCO_SET_MAX_LONG) {410 } else if (kuiMmco == MMCO_SET_MAX_LONG) {
411 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_long_term_frame_idx_plus1411 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_long_term_frame_idx_plus1
412 kpRefMarking->sMmcoRef[iIdx].iMaxLongTermFrameIdx = -1 + uiCode;412 kpRefMarking->sMmcoRef[iIdx].iMaxLongTermFrameIdx = -1 + uiCode;
413 }413 }
@@ -690,6 +690,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 276 unmodified lines
690 690
691 // first_mb_in_slice691 // first_mb_in_slice
692 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //first_mb_in_slice692 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));
693 pSliceHead->iFirstMbInSlice = uiCode;695 pSliceHead->iFirstMbInSlice = uiCode;
694 696
695 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //slice_type697 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //slice_type
@@ -721,13 +723,10 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 25 unmodified lines
721 pSliceHead->eSliceType = static_cast <EWelsSliceType> (uiSliceType);723 pSliceHead->eSliceType = static_cast <EWelsSliceType> (uiSliceType);
722 724
723 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_parameter_set_id725 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));
724 iPpsId = uiCode;728 iPpsId = uiCode;
725 729
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
731 //add check PPS available here730 //add check PPS available here
732 if (pCtx->bPpsAvailFlags[iPpsId] == false) {731 if (pCtx->bPpsAvailFlags[iPpsId] == false) {
733 pCtx->sDecoderStatistics.iPpsReportErrorNum++;732 pCtx->sDecoderStatistics.iPpsReportErrorNum++;
@@ -939,9 +938,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 205 unmodified lines
939 if (pPps->bEntropyCodingModeFlag) {938 if (pPps->bEntropyCodingModeFlag) {
940 if (pSliceHead->eSliceType != I_SLICE && pSliceHead->eSliceType != SI_SLICE) {939 if (pSliceHead->eSliceType != I_SLICE && pSliceHead->eSliceType != SI_SLICE) {
941 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode));940 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);
942 pSliceHead->iCabacInitIdc = uiCode;942 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);
945 } else943 } else
946 pSliceHead->iCabacInitIdc = 0;944 pSliceHead->iCabacInitIdc = 0;
947 }945 }

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