Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 32 files). Show all
Unified · Split
| @@ -139,7 +139,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 138 unmodified lines | |||
| 139 | pCtx->uiCpuFlag = 0; | 139 | pCtx->uiCpuFlag = 0; |
| 140 | 140 | ||
| 141 | pCtx->bAuReadyFlag = 0; // au data is not ready | 141 | pCtx->bAuReadyFlag = 0; // au data is not ready |
| 142 | 142 | pCtx->bCabacInited = false; | |
| 143 | 143 | ||
| 144 | pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); | 144 | pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); |
| 145 | 145 | ||
| @@ -241,6 +241,10 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 95 unmodified lines | |||
| 241 | 241 | ||
| 242 | pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested | 242 | pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested |
| 243 | pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed | 243 | 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 | |||
| 244 | return ERR_NONE; | 248 | return ERR_NONE; |
| 245 | } | 249 | } |
| 246 | 250 | ||
| @@ -267,7 +271,7 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 20 unmodified lines | |||
| 267 | pCtx->iImgWidthInPixel = 0; | 271 | pCtx->iImgWidthInPixel = 0; |
| 268 | pCtx->iImgHeightInPixel = 0; | 272 | pCtx->iImgHeightInPixel = 0; |
| 269 | pCtx->bHaveGotMemory = false; | 273 | pCtx->bHaveGotMemory = false; |
| 270 | 274 | WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); | |
| 271 | } | 275 | } |
| 272 | 276 | ||
| 273 | /*! | 277 | /*! |
| @@ -464,6 +468,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 190 unmodified lines | |||
| 464 | } else { | 468 | } else { |
| 465 | 469 | ||
| 466 | iConsumedBytes = 0; | 470 | iConsumedBytes = 0; |
| 471 | pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = 0; // set 4 reserved bytes to zero | ||
| 467 | pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); | 472 | pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); |
| 468 | if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { | 473 | if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { |
| 469 | CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo); | 474 | CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo); |
| @@ -502,13 +507,12 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 32 unmodified lines | |||
| 502 | return pCtx->iErrorCode; | 507 | return pCtx->iErrorCode; |
| 503 | } | 508 | } |
| 504 | 509 | ||
| 505 | pDstNal += iDstIdx; //update current position | 510 | pDstNal += (iDstIdx + 4); //init, increase 4 reserved zero bytes, used to store the next NAL |
| 506 | if ((iSrcLength - iSrcConsumed + 4) > (pRawData->pEnd - pDstNal)) { | 511 | if ((iSrcLength - iSrcConsumed + 4) > (pRawData->pEnd - pDstNal)) { |
| 507 | pRawData->pCurPos = pRawData->pHead; | 512 | pDstNal = pRawData->pCurPos = pRawData->pHead; |
| 508 | } else { | 513 | } else { |
| 509 | pRawData->pCurPos = pDstNal; | 514 | pRawData->pCurPos = pDstNal; |
| 510 | } | 515 | } |
| 511 | pDstNal = pRawData->pCurPos + 4; //init, 4 bytes used to store the next NAL | ||
| 512 | 516 | ||
| 513 | pSrcNal += iSrcIdx + 3; | 517 | pSrcNal += iSrcIdx + 3; |
| 514 | iSrcConsumed += 3; | 518 | iSrcConsumed += 3; |
| @@ -524,6 +528,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 9 unmodified lines | |||
| 524 | //last NAL decoding | 528 | //last NAL decoding |
| 525 | 529 | ||
| 526 | iConsumedBytes = 0; | 530 | iConsumedBytes = 0; |
| 531 | pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = 0; // set 4 reserved bytes to zero | ||
| 527 | pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); | 532 | pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); |
| 528 | if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { | 533 | if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { |
| 529 | CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo); | 534 | CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo); |
| @@ -557,8 +562,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 27 unmodified lines | |||
| 557 | } | 562 | } |
| 558 | return pCtx->iErrorCode; | 563 | return pCtx->iErrorCode; |
| 559 | } | 564 | } |
| 560 | pDstNal += iDstIdx; | 565 | pRawData->pCurPos = pDstNal + iDstIdx + 4; //init, increase 4 reserved zero bytes, used to store the next NAL |
| 561 | pRawData->pCurPos = pDstNal; //init the pCurPos for next NAL(s) storage | ||
| 562 | } else { /* no supplementary picture payload input, but stored a picture */ | 566 | } else { /* no supplementary picture payload input, but stored a picture */ |
| 563 | PAccessUnit pCurAu = | 567 | PAccessUnit pCurAu = |
| 564 | pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization | 568 | pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization |