History

Add protection for emulation prevention bytes and profile_id

unknown committed 10 years ago

Commit cc6b4091 parent 404315a2 files · +24 −5Browse files

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

Unified · Split

codec/decoder/core/src/decoder.cpp+18−5
@@ -662,11 +662,23 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 661 unmodified lines
662662 //0x03 removal and extract all of NAL Unit from current raw data
663663 pDstNal = pRawData->pCurPos;
664664
665+ bool bNalStartBytes = false;
666+
665667 while (iSrcConsumed < iSrcLength) {
666− if ((2 + iSrcConsumed < iSrcLength) &&
667− (0 == LD16 (pSrcNal + iSrcIdx)) &&
668− ((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) {
669− if (pSrcNal[2 + iSrcIdx] == 0x03) {
668+ if ((2 + iSrcConsumed < iSrcLength) && (0 == LD16 (pSrcNal + iSrcIdx)) && (pSrcNal[2 + iSrcIdx] <= 0x03)) {
669+ if (bNalStartBytes && (pSrcNal[2 + iSrcIdx] != 0x00 && pSrcNal[2 + iSrcIdx] != 0x01)) {
670+ pCtx->iErrorCode |= dsBitstreamError;
671+ return pCtx->iErrorCode;
672+ }
673+
674+ if (pSrcNal[2 + iSrcIdx] == 0x02) {
675+ pCtx->iErrorCode |= dsBitstreamError;
676+ return pCtx->iErrorCode;
677+ } else if (pSrcNal[2 + iSrcIdx] == 0x00) {
678+ pDstNal[iDstIdx++] = pSrcNal[iSrcIdx++];
679+ iSrcConsumed++;
680+ bNalStartBytes = true;
681+ } else if (pSrcNal[2 + iSrcIdx] == 0x03) {
670682 if ((3 + iSrcConsumed < iSrcLength) && pSrcNal[3 + iSrcIdx] > 0x03) {
671683 pCtx->iErrorCode |= dsBitstreamError;
672684 return pCtx->iErrorCode;
@@ -676,7 +688,8 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 3 unmodified lines
676688 iSrcIdx += 3;
677689 iSrcConsumed += 3;
678690 }
679− } else {
691+ } else { // 0x01
692+ bNalStartBytes = false;
680693
681694 iConsumedBytes = 0;
682695 pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] =

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