History

add decoder cabac support and add UT

dong zhang committed 12 years ago

Commit cf857451 parent c7b505132 files · +2615 −470Browse files

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

Unified · Split

codec/decoder/core/src/au_parser.cpp+38−14
@@ -43,7 +43,6 @@ · 42 unmodified lines
4343 #include "error_code.h"
4444 #include "memmgr_nal_unit.h"
4545 #include "decoder_core.h"
46−#include "decoder_core.h"
4746
4847 namespace WelsDec {
4948 /*!
@@ -227,14 +226,18 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 177 unmodified lines
227226 pCurNal->sNalHeaderExt.sNalUnitHeader.uiForbiddenZeroBit = pNalUnitHeader->uiForbiddenZeroBit;
228227 pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc;
229228 pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType;
230−
231− pBs = &pCtx->sBs;
232−
233− iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit
234−
235− InitBits (pBs, pNal, iBitSize);
236−
237− ParsePrefixNalUnit (pCtx, pBs);
229+ if (pNalUnitHeader->uiNalRefIdc != 0) {
230+ pBs = &pCtx->sBs;
231+ iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit
232+
233+ iErr = InitBits (pBs, pNal, iBitSize);
234+ if (iErr) {
235+ WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_PREFIX: InitBits() fail due invalid access.");
236+ pCtx->iErrorCode |= dsBitstreamError;
237+ return NULL;
238+ }
239+ ParsePrefixNalUnit (pCtx, pBs);
240+ }
238241 pCurNal->sNalData.sPrefixNal.bPrefixNalCorrectFlag = true;
239242
240243 break;
@@ -309,7 +312,12 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 68 unmodified lines
309312
310313 pBs = &pCurAu->pNalUnitsList[uiAvailNalNum - 1]->sNalData.sVclNal.sSliceBitsRead;
311314 iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit
312− InitBits (pBs, pNal, iBitSize);
315+ iErr = InitBits (pBs, pNal, iBitSize);
316+ if (iErr) {
317+ WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_CODED_SLICE: InitBits() fail due invalid access.");
318+ pCtx->iErrorCode |= dsBitstreamError;
319+ return NULL;
320+ }
313321 iErr = ParseSliceHeaderSyntaxs (pCtx, pBs, bExtensionFlag);
314322 if (iErr != ERR_NONE) {
315323 if ((uiAvailNalNum == 1) && (pCurNal->sNalHeaderExt.bIdrFlag)) { //IDR parse error
@@ -505,8 +513,16 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t · 189 unmodified lines
505513 switch (eNalType) {
506514 case NAL_UNIT_SPS:
507515 case NAL_UNIT_SUBSET_SPS:
508− if (iBitSize > 0)
509− InitBits (pBs, pRbsp, iBitSize);
516+ if (iBitSize > 0) {
517+ iErr = InitBits (pBs, pRbsp, iBitSize);
518+ if (ERR_NONE != iErr) {
519+ if (pCtx->eErrorConMethod == ERROR_CON_DISABLE)
520+ pCtx->iErrorCode |= dsNoParamSets;
521+ else
522+ pCtx->iErrorCode |= dsBitstreamError;
523+ return iErr;
524+ }
525+ }
510526 iErr = ParseSps (pCtx, pBs, &iPicWidth, &iPicHeight);
511527 if (ERR_NONE != iErr) { // modified for pSps/pSubsetSps invalid, 12/1/2009
512528 if (pCtx->eErrorConMethod == ERROR_CON_DISABLE)
@@ -519,8 +535,16 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t · 6 unmodified lines
519535 break;
520536
521537 case NAL_UNIT_PPS:
522− if (iBitSize > 0)
523− InitBits (pBs, pRbsp, iBitSize);
538+ if (iBitSize > 0) {
539+ iErr = InitBits (pBs, pRbsp, iBitSize);
540+ if (ERR_NONE != iErr) {
541+ if (pCtx->eErrorConMethod == ERROR_CON_DISABLE)
542+ pCtx->iErrorCode |= dsNoParamSets;
543+ else
544+ pCtx->iErrorCode |= dsBitstreamError;
545+ return iErr;
546+ }
547+ }
524548 iErr = ParsePps (pCtx, &pCtx->sPpsBuffer[0], pBs);
525549 if (ERR_NONE != iErr) { // modified for pps invalid, 12/1/2009
526550 if (pCtx->eErrorConMethod == ERROR_CON_DISABLE)

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