Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 2 files). Show all
Unified · Split
| @@ -662,11 +662,23 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 661 unmodified lines | |||
| 662 | //0x03 removal and extract all of NAL Unit from current raw data | 662 | //0x03 removal and extract all of NAL Unit from current raw data |
| 663 | pDstNal = pRawData->pCurPos; | 663 | pDstNal = pRawData->pCurPos; |
| 664 | 664 | ||
| 665 | bool bNalStartBytes = false; | ||
| 666 | |||
| 665 | while (iSrcConsumed < iSrcLength) { | 667 | while (iSrcConsumed < iSrcLength) { |
| 666 | if ((2 + iSrcConsumed < iSrcLength) && | 668 | if ((2 + iSrcConsumed < iSrcLength) && (0 == LD16 (pSrcNal + iSrcIdx)) && (pSrcNal[2 + iSrcIdx] <= 0x03)) { |
| 667 | (0 == LD16 (pSrcNal + iSrcIdx)) && | 669 | if (bNalStartBytes && (pSrcNal[2 + iSrcIdx] != 0x00 && pSrcNal[2 + iSrcIdx] != 0x01)) { |
| 668 | ((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) { | 670 | pCtx->iErrorCode |= dsBitstreamError; |
| 669 | if (pSrcNal[2 + iSrcIdx] == 0x03) { | 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) { | ||
| 670 | if ((3 + iSrcConsumed < iSrcLength) && pSrcNal[3 + iSrcIdx] > 0x03) { | 682 | if ((3 + iSrcConsumed < iSrcLength) && pSrcNal[3 + iSrcIdx] > 0x03) { |
| 671 | pCtx->iErrorCode |= dsBitstreamError; | 683 | pCtx->iErrorCode |= dsBitstreamError; |
| 672 | return pCtx->iErrorCode; | 684 | return pCtx->iErrorCode; |
| @@ -676,7 +688,8 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 3 unmodified lines | |||
| 676 | iSrcIdx += 3; | 688 | iSrcIdx += 3; |
| 677 | iSrcConsumed += 3; | 689 | iSrcConsumed += 3; |
| 678 | } | 690 | } |
| 679 | } else { | 691 | } else { // 0x01 |
| 692 | bNalStartBytes = false; | ||
| 680 | 693 | ||
| 681 | iConsumedBytes = 0; | 694 | iConsumedBytes = 0; |
| 682 | pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = | 695 | pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = |