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/decoder.cpp (1 of 32 files). Show all

Unified · Split

codec/decoder/core/src/decoder.cpp+11−7
@@ -139,7 +139,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 138 unmodified lines
139139 pCtx->uiCpuFlag = 0;
140140
141141 pCtx->bAuReadyFlag = 0; // au data is not ready
142−
142+ pCtx->bCabacInited = false;
143143
144144 pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores);
145145
@@ -241,6 +241,10 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 95 unmodified lines
241241
242242 pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested
243243 pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed
244+
245+ if (pCtx->pCabacDecEngine == NULL)
246+ pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMalloc (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
247+
244248 return ERR_NONE;
245249 }
246250
@@ -267,7 +271,7 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 20 unmodified lines
267271 pCtx->iImgWidthInPixel = 0;
268272 pCtx->iImgHeightInPixel = 0;
269273 pCtx->bHaveGotMemory = false;
270−
274+ WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");
271275 }
272276
273277 /*!
@@ -464,6 +468,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 190 unmodified lines
464468 } else {
465469
466470 iConsumedBytes = 0;
471+ pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = 0; // set 4 reserved bytes to zero
467472 pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes);
468473 if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) {
469474 CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
@@ -502,13 +507,12 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 32 unmodified lines
502507 return pCtx->iErrorCode;
503508 }
504509
505− pDstNal += iDstIdx; //update current position
510+ pDstNal += (iDstIdx + 4); //init, increase 4 reserved zero bytes, used to store the next NAL
506511 if ((iSrcLength - iSrcConsumed + 4) > (pRawData->pEnd - pDstNal)) {
507− pRawData->pCurPos = pRawData->pHead;
512+ pDstNal = pRawData->pCurPos = pRawData->pHead;
508513 } else {
509514 pRawData->pCurPos = pDstNal;
510515 }
511− pDstNal = pRawData->pCurPos + 4; //init, 4 bytes used to store the next NAL
512516
513517 pSrcNal += iSrcIdx + 3;
514518 iSrcConsumed += 3;
@@ -524,6 +528,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 9 unmodified lines
524528 //last NAL decoding
525529
526530 iConsumedBytes = 0;
531+ pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = 0; // set 4 reserved bytes to zero
527532 pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes);
528533 if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) {
529534 CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
@@ -557,8 +562,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 27 unmodified lines
557562 }
558563 return pCtx->iErrorCode;
559564 }
560− pDstNal += iDstIdx;
561− pRawData->pCurPos = pDstNal; //init the pCurPos for next NAL(s) storage
565+ pRawData->pCurPos = pDstNal + iDstIdx + 4; //init, increase 4 reserved zero bytes, used to store the next NAL
562566 } else { /* no supplementary picture payload input, but stored a picture */
563567 PAccessUnit pCurAu =
564568 pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization

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