Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 54 files). Show all
Unified · Split
| @@ -67,7 +67,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 66 unmodified lines | |||
| 67 | return 1; | 67 | return 1; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | 70 | pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); |
| 71 | 71 | ||
| 72 | if (NULL == pPicBuf) { | 72 | if (NULL == pPicBuf) { |
| 73 | return 1; | 73 | return 1; |
| @@ -109,7 +109,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 35 unmodified lines | |||
| 109 | return 1; | 109 | return 1; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | 112 | pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); |
| 113 | 113 | ||
| 114 | if (NULL == pPicNewBuf) { | 114 | if (NULL == pPicNewBuf) { |
| 115 | return 1; | 115 | return 1; |
| @@ -153,9 +153,9 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 37 unmodified lines | |||
| 153 | // remove old PicBuf | 153 | // remove old PicBuf |
| 154 | if (pPicOldBuf->ppPic != NULL) { | 154 | if (pPicOldBuf->ppPic != NULL) { |
| 155 | WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); | 155 | WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); |
| 156 | pPicOldBuf->ppPic = NULL; | 156 | pPicOldBuf->ppPic = NULL; |
| 157 | } | 157 | } |
| 158 | pPicOldBuf->iCapacity = 0; | 158 | pPicOldBuf->iCapacity = 0; |
| 159 | pPicOldBuf->iCurrentIdx = 0; | 159 | pPicOldBuf->iCurrentIdx = 0; |
| 160 | WelsFree (pPicOldBuf, "pPicOldBuf"); | 160 | WelsFree (pPicOldBuf, "pPicOldBuf"); |
| 161 | pPicOldBuf = NULL; | 161 | pPicOldBuf = NULL; |
| @@ -171,7 +171,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 9 unmodified lines | |||
| 171 | return 1; | 171 | return 1; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | 174 | pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); |
| 175 | 175 | ||
| 176 | if (NULL == pPicNewBuf) { | 176 | if (NULL == pPicNewBuf) { |
| 177 | return 1; | 177 | return 1; |
| @@ -180,7 +180,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 2 unmodified lines | |||
| 180 | pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*"); | 180 | pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*"); |
| 181 | 181 | ||
| 182 | if (NULL == pPicNewBuf->ppPic) { | 182 | if (NULL == pPicNewBuf->ppPic) { |
| 183 | pPicNewBuf->iCapacity = 0; | 183 | pPicNewBuf->iCapacity = 0; |
| 184 | DestroyPicBuff (&pPicNewBuf); | 184 | DestroyPicBuff (&pPicNewBuf); |
| 185 | return 1; | 185 | return 1; |
| 186 | } | 186 | } |
| @@ -227,9 +227,9 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 40 unmodified lines | |||
| 227 | // remove old PicBuf | 227 | // remove old PicBuf |
| 228 | if (pPicOldBuf->ppPic != NULL) { | 228 | if (pPicOldBuf->ppPic != NULL) { |
| 229 | WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); | 229 | WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); |
| 230 | pPicOldBuf->ppPic = NULL; | 230 | pPicOldBuf->ppPic = NULL; |
| 231 | } | 231 | } |
| 232 | pPicOldBuf->iCapacity = 0; | 232 | pPicOldBuf->iCapacity = 0; |
| 233 | pPicOldBuf->iCurrentIdx = 0; | 233 | pPicOldBuf->iCurrentIdx = 0; |
| 234 | WelsFree (pPicOldBuf, "pPicOldBuf"); | 234 | WelsFree (pPicOldBuf, "pPicOldBuf"); |
| 235 | pPicOldBuf = NULL; | 235 | pPicOldBuf = NULL; |
| @@ -257,9 +257,9 @@ void DestroyPicBuff (PPicBuff* ppPicBuf) { · 21 unmodified lines | |||
| 257 | 257 | ||
| 258 | WelsFree (pPicBuf->ppPic, "pPicBuf->queue"); | 258 | WelsFree (pPicBuf->ppPic, "pPicBuf->queue"); |
| 259 | 259 | ||
| 260 | pPicBuf->ppPic = NULL; | 260 | pPicBuf->ppPic = NULL; |
| 261 | } | 261 | } |
| 262 | pPicBuf->iCapacity = 0; | 262 | pPicBuf->iCapacity = 0; |
| 263 | pPicBuf->iCurrentIdx = 0; | 263 | pPicBuf->iCurrentIdx = 0; |
| 264 | 264 | ||
| 265 | WelsFree (pPicBuf, "pPicBuf"); | 265 | WelsFree (pPicBuf, "pPicBuf"); |
| @@ -331,7 +331,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 65 unmodified lines | |||
| 331 | * get size of reference picture list in target layer incoming, = (iNumRefFrames | 331 | * get size of reference picture list in target layer incoming, = (iNumRefFrames |
| 332 | */ | 332 | */ |
| 333 | static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { | 333 | static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { |
| 334 | int32_t iNumRefFrames = 0; | 334 | int32_t iNumRefFrames = 0; |
| 335 | // +2 for EC MV Copy buffer exchange | 335 | // +2 for EC MV Copy buffer exchange |
| 336 | if ((pCtx == NULL) || (pCtx->pSps == NULL)) { | 336 | if ((pCtx == NULL) || (pCtx->pSps == NULL)) { |
| 337 | iNumRefFrames = MAX_REF_PIC_COUNT + 2; | 337 | iNumRefFrames = MAX_REF_PIC_COUNT + 2; |
| @@ -365,7 +365,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 27 unmodified lines | |||
| 365 | 365 | ||
| 366 | // Fixed the issue about different gop size over last, 5/17/2010 | 366 | // Fixed the issue about different gop size over last, 5/17/2010 |
| 367 | // get picture queue size currently | 367 | // get picture queue size currently |
| 368 | iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 368 | iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 369 | pCtx->iPicQueueNumber = iPicQueueSize; | 369 | pCtx->iPicQueueNumber = iPicQueueSize; |
| 370 | if (pCtx->pPicBuff[LIST_0] != NULL | 370 | if (pCtx->pPicBuff[LIST_0] != NULL |
| 371 | && pCtx->pPicBuff[LIST_0]->iCapacity == | 371 | && pCtx->pPicBuff[LIST_0]->iCapacity == |
| @@ -482,7 +482,7 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { · 110 unmodified lines | |||
| 482 | #ifdef LONG_TERM_REF | 482 | #ifdef LONG_TERM_REF |
| 483 | pCtx->bParamSetsLostFlag = true; | 483 | pCtx->bParamSetsLostFlag = true; |
| 484 | #else | 484 | #else |
| 485 | pCtx->bReferenceLostAtT0Flag = true; // should be true to waiting IDR at incoming AU bits following, 6/4/2010 | 485 | pCtx->bReferenceLostAtT0Flag = true; // should be true to waiting IDR at incoming AU bits following, 6/4/2010 |
| 486 | #endif //LONG_TERM_REF | 486 | #endif //LONG_TERM_REF |
| 487 | pCtx->bNewSeqBegin = true; | 487 | pCtx->bNewSeqBegin = true; |
| 488 | pCtx->bPrintFrameErrorTraceFlag = true; | 488 | pCtx->bPrintFrameErrorTraceFlag = true; |
| @@ -517,13 +517,13 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 28 unmodified lines | |||
| 517 | if (NULL == pCtx || NULL == kpParam) | 517 | if (NULL == pCtx || NULL == kpParam) |
| 518 | return 1; | 518 | return 1; |
| 519 | 519 | ||
| 520 | pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam"); | 520 | pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam"); |
| 521 | 521 | ||
| 522 | if (NULL == pCtx->pParam) | 522 | if (NULL == pCtx->pParam) |
| 523 | return 1; | 523 | return 1; |
| 524 | 524 | ||
| 525 | memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam)); | 525 | memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam)); |
| 526 | pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat; | 526 | pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat; |
| 527 | if (!pCtx->bParseOnly) { | 527 | if (!pCtx->bParseOnly) { |
| 528 | int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat); | 528 | int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat); |
| 529 | if (iRet) | 529 | if (iRet) |
| @@ -668,7 +668,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 138 unmodified lines | |||
| 668 | iConsumedBytes = 0; | 668 | iConsumedBytes = 0; |
| 669 | pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = | 669 | pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] = |
| 670 | 0; // set 4 reserved bytes to zero | 670 | 0; // set 4 reserved bytes to zero |
| 671 | pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); | 671 | pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); |
| 672 | if (pNalPayload) { //parse correct | 672 | if (pNalPayload) { //parse correct |
| 673 | if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) { | 673 | if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) { |
| 674 | iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3); | 674 | iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3); |
| @@ -758,8 +758,8 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 83 unmodified lines | |||
| 758 | return pCtx->iErrorCode; | 758 | return pCtx->iErrorCode; |
| 759 | } | 759 | } |
| 760 | } else { /* no supplementary picture payload input, but stored a picture */ | 760 | } else { /* no supplementary picture payload input, but stored a picture */ |
| 761 | PAccessUnit pCurAu = | 761 | PAccessUnit pCurAu = |
| 762 | pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization | 762 | pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization |
| 763 | 763 | ||
| 764 | if (pCurAu->uiAvailUnitsNum == 0) { | 764 | if (pCurAu->uiAvailUnitsNum == 0) { |
| 765 | return pCtx->iErrorCode; | 765 | return pCtx->iErrorCode; |
| @@ -789,9 +789,9 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 23 unmodified lines | |||
| 789 | int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) { | 789 | int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) { |
| 790 | WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)); | 790 | WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)); |
| 791 | 791 | ||
| 792 | pCtx->eOutputColorFormat = (EVideoFormatType) kiColorFormat; | 792 | pCtx->eOutputColorFormat = (EVideoFormatType) kiColorFormat; |
| 793 | if (pCtx->pParam != NULL) { | 793 | if (pCtx->pParam != NULL) { |
| 794 | pCtx->pParam->eOutputColorFormat = (EVideoFormatType) kiColorFormat; | 794 | pCtx->pParam->eOutputColorFormat = (EVideoFormatType) kiColorFormat; |
| 795 | } | 795 | } |
| 796 | 796 | ||
| 797 | //For now, support only videoFormatI420! | 797 | //For now, support only videoFormatI420! |