Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 71 files). Show all
Unified · Split
| @@ -54,8 +54,6 @@ · 53 unmodified lines | |||
| 54 | #include "memory_align.h" | 54 | #include "memory_align.h" |
| 55 | #include "wels_decoder_thread.h" | 55 | #include "wels_decoder_thread.h" |
| 56 | 56 | ||
| 57 | namespace WelsDec { | ||
| 58 | |||
| 59 | extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight); | 57 | extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight); |
| 60 | 58 | ||
| 61 | extern void FreePicture (PPicture pPic, CMemoryAlign* pMa); | 59 | extern void FreePicture (PPicture pPic, CMemoryAlign* pMa); |
| @@ -64,7 +62,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 2 unmodified lines | |||
| 64 | const int32_t kiPicWidth, const int32_t kiPicHeight) { | 62 | const int32_t kiPicWidth, const int32_t kiPicHeight) { |
| 65 | 63 | ||
| 66 | PPicBuff pPicBuf = NULL; | 64 | PPicBuff pPicBuf = NULL; |
| 67 | int32_t iPicIdx = 0; | 65 | int32_t iPicIdx; |
| 68 | if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { | 66 | if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { |
| 69 | return ERR_INFO_INVALID_PARAM; | 67 | return ERR_INFO_INVALID_PARAM; |
| 70 | } | 68 | } |
| @@ -108,7 +106,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 37 unmodified lines | |||
| 108 | const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) { | 106 | const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) { |
| 109 | PPicBuff pPicOldBuf = *ppPicBuf; | 107 | PPicBuff pPicOldBuf = *ppPicBuf; |
| 110 | PPicBuff pPicNewBuf = NULL; | 108 | PPicBuff pPicNewBuf = NULL; |
| 111 | int32_t iPicIdx = 0; | 109 | int32_t iPicIdx; |
| 112 | if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { | 110 | if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { |
| 113 | return ERR_INFO_INVALID_PARAM; | 111 | return ERR_INFO_INVALID_PARAM; |
| 114 | } | 112 | } |
| @@ -162,7 +160,6 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 47 unmodified lines | |||
| 162 | pPicOldBuf->iCapacity = 0; | 160 | pPicOldBuf->iCapacity = 0; |
| 163 | pPicOldBuf->iCurrentIdx = 0; | 161 | pPicOldBuf->iCurrentIdx = 0; |
| 164 | pMa->WelsFree (pPicOldBuf, "pPicOldBuf"); | 162 | pMa->WelsFree (pPicOldBuf, "pPicOldBuf"); |
| 165 | pPicOldBuf = NULL; | ||
| 166 | return ERR_NONE; | 163 | return ERR_NONE; |
| 167 | } | 164 | } |
| 168 | 165 | ||
| @@ -170,7 +167,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 1 unmodified line | |||
| 170 | const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) { | 167 | const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) { |
| 171 | PPicBuff pPicOldBuf = *ppPicBuf; | 168 | PPicBuff pPicOldBuf = *ppPicBuf; |
| 172 | PPicBuff pPicNewBuf = NULL; | 169 | PPicBuff pPicNewBuf = NULL; |
| 173 | int32_t iPicIdx = 0; | 170 | int32_t iPicIdx; |
| 174 | if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { | 171 | if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { |
| 175 | return ERR_INFO_INVALID_PARAM; | 172 | return ERR_INFO_INVALID_PARAM; |
| 176 | } | 173 | } |
| @@ -193,7 +190,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 16 unmodified lines | |||
| 193 | 190 | ||
| 194 | ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false); | 191 | ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false); |
| 195 | 192 | ||
| 196 | int32_t iPrevPicIdx = -1; | 193 | int32_t iPrevPicIdx; |
| 197 | for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) { | 194 | for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) { |
| 198 | if (pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) { | 195 | if (pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) { |
| 199 | break; | 196 | break; |
| @@ -250,13 +247,12 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 50 unmodified lines | |||
| 250 | pPicOldBuf->iCapacity = 0; | 247 | pPicOldBuf->iCapacity = 0; |
| 251 | pPicOldBuf->iCurrentIdx = 0; | 248 | pPicOldBuf->iCurrentIdx = 0; |
| 252 | pMa->WelsFree (pPicOldBuf, "pPicOldBuf"); | 249 | pMa->WelsFree (pPicOldBuf, "pPicOldBuf"); |
| 253 | pPicOldBuf = NULL; | ||
| 254 | 250 | ||
| 255 | return ERR_NONE; | 251 | return ERR_NONE; |
| 256 | } | 252 | } |
| 257 | 253 | ||
| 258 | void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa) { | 254 | void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa) { |
| 259 | PPicBuff pPicBuf = NULL; | 255 | PPicBuff pPicBuf; |
| 260 | 256 | ||
| 261 | ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false); | 257 | ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false); |
| 262 | 258 | ||
| @@ -271,7 +267,6 @@ void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* · 8 unmodified lines | |||
| 271 | if (pPic != NULL) { | 267 | if (pPic != NULL) { |
| 272 | FreePicture (pPic, pMa); | 268 | FreePicture (pPic, pMa); |
| 273 | } | 269 | } |
| 274 | pPic = NULL; | ||
| 275 | ++ iPicIdx; | 270 | ++ iPicIdx; |
| 276 | } | 271 | } |
| 277 | 272 | ||
| @@ -284,15 +279,14 @@ void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* · 6 unmodified lines | |||
| 284 | 279 | ||
| 285 | pMa->WelsFree (pPicBuf, "pPicBuf"); | 280 | pMa->WelsFree (pPicBuf, "pPicBuf"); |
| 286 | 281 | ||
| 287 | pPicBuf = NULL; | ||
| 288 | *ppPicBuf = NULL; | 282 | *ppPicBuf = NULL; |
| 289 | } | 283 | } |
| 290 | 284 | ||
| 291 | //reset picture reodering buffer list | 285 | //reset picture reodering buffer list |
| 292 | void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo, | 286 | void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo, |
| 293 | const bool& fullReset) { | 287 | const bool *fullReset) { |
| 294 | if (pPictReoderingStatus != NULL && pPictInfo != NULL) { | 288 | if (pPictReoderingStatus != NULL && pPictInfo != NULL) { |
| 295 | int32_t pictInfoListCount = fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1); | 289 | int32_t pictInfoListCount = *fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1); |
| 296 | pPictReoderingStatus->iPictInfoIndex = 0; | 290 | pPictReoderingStatus->iPictInfoIndex = 0; |
| 297 | pPictReoderingStatus->iMinPOC = IMinInt32; | 291 | pPictReoderingStatus->iMinPOC = IMinInt32; |
| 298 | pPictReoderingStatus->iNumOfPicts = 0; | 292 | pPictReoderingStatus->iNumOfPicts = 0; |
| @@ -367,33 +361,33 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 68 unmodified lines | |||
| 367 | /* | 361 | /* |
| 368 | * fill data fields in SPS and PPS default for decoder context | 362 | * fill data fields in SPS and PPS default for decoder context |
| 369 | */ | 363 | */ |
| 370 | void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx) { | 364 | void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX *sSpsPpsCtx) { |
| 371 | sSpsPpsCtx.bSpsExistAheadFlag = false; | 365 | sSpsPpsCtx->bSpsExistAheadFlag = false; |
| 372 | sSpsPpsCtx.bSubspsExistAheadFlag = false; | 366 | sSpsPpsCtx->bSubspsExistAheadFlag = false; |
| 373 | sSpsPpsCtx.bPpsExistAheadFlag = false; | 367 | sSpsPpsCtx->bPpsExistAheadFlag = false; |
| 374 | sSpsPpsCtx.bAvcBasedFlag = true; | 368 | sSpsPpsCtx->bAvcBasedFlag = true; |
| 375 | sSpsPpsCtx.iSpsErrorIgnored = 0; | 369 | sSpsPpsCtx->iSpsErrorIgnored = 0; |
| 376 | sSpsPpsCtx.iSubSpsErrorIgnored = 0; | 370 | sSpsPpsCtx->iSubSpsErrorIgnored = 0; |
| 377 | sSpsPpsCtx.iPpsErrorIgnored = 0; | 371 | sSpsPpsCtx->iPpsErrorIgnored = 0; |
| 378 | sSpsPpsCtx.iPPSInvalidNum = 0; | 372 | sSpsPpsCtx->iPPSInvalidNum = 0; |
| 379 | sSpsPpsCtx.iPPSLastInvalidId = -1; | 373 | sSpsPpsCtx->iPPSLastInvalidId = -1; |
| 380 | sSpsPpsCtx.iSPSInvalidNum = 0; | 374 | sSpsPpsCtx->iSPSInvalidNum = 0; |
| 381 | sSpsPpsCtx.iSPSLastInvalidId = -1; | 375 | sSpsPpsCtx->iSPSLastInvalidId = -1; |
| 382 | sSpsPpsCtx.iSubSPSInvalidNum = 0; | 376 | sSpsPpsCtx->iSubSPSInvalidNum = 0; |
| 383 | sSpsPpsCtx.iSubSPSLastInvalidId = -1; | 377 | sSpsPpsCtx->iSubSPSLastInvalidId = -1; |
| 384 | sSpsPpsCtx.iSeqId = -1; | 378 | sSpsPpsCtx->iSeqId = -1; |
| 385 | } | 379 | } |
| 386 | 380 | ||
| 387 | /* | 381 | /* |
| 388 | * fill last decoded picture info | 382 | * fill last decoded picture info |
| 389 | */ | 383 | */ |
| 390 | void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo) { | 384 | void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo *sLastDecPicInfo) { |
| 391 | sLastDecPicInfo.iPrevPicOrderCntMsb = 0; | 385 | sLastDecPicInfo->iPrevPicOrderCntMsb = 0; |
| 392 | sLastDecPicInfo.iPrevPicOrderCntLsb = 0; | 386 | sLastDecPicInfo->iPrevPicOrderCntLsb = 0; |
| 393 | sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL; | 387 | sLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL; |
| 394 | sLastDecPicInfo.iPrevFrameNum = -1; | 388 | sLastDecPicInfo->iPrevFrameNum = -1; |
| 395 | sLastDecPicInfo.bLastHasMmco5 = false; | 389 | sLastDecPicInfo->bLastHasMmco5 = false; |
| 396 | sLastDecPicInfo.uiDecodingTimeStamp = 0; | 390 | sLastDecPicInfo->uiDecodingTimeStamp = 0; |
| 397 | } | 391 | } |
| 398 | 392 | ||
| 399 | /*! | 393 | /*! |
| @@ -432,7 +426,7 @@ void CopySpsPps (PWelsDecoderContext pFromCtx, PWelsDecoderContext pToCtx) { · 32 unmodified lines | |||
| 432 | * get size of reference picture list in target layer incoming, = (iNumRefFrames | 426 | * get size of reference picture list in target layer incoming, = (iNumRefFrames |
| 433 | */ | 427 | */ |
| 434 | static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { | 428 | static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { |
| 435 | int32_t iNumRefFrames = 0; | 429 | int32_t iNumRefFrames; |
| 436 | // +2 for EC MV Copy buffer exchange | 430 | // +2 for EC MV Copy buffer exchange |
| 437 | if ((pCtx == NULL) || (pCtx->pSps == NULL)) { | 431 | if ((pCtx == NULL) || (pCtx->pSps == NULL)) { |
| 438 | iNumRefFrames = MAX_REF_PIC_COUNT + 2; | 432 | iNumRefFrames = MAX_REF_PIC_COUNT + 2; |
| @@ -458,13 +452,13 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { · 19 unmodified lines | |||
| 458 | * request memory blocks for decoder avc part | 452 | * request memory blocks for decoder avc part |
| 459 | */ | 453 | */ |
| 460 | int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight, | 454 | int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight, |
| 461 | bool& bReallocFlag) { | 455 | bool *bReallocFlag) { |
| 462 | const int32_t kiPicWidth = kiMbWidth << 4; | 456 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 463 | const int32_t kiPicHeight = kiMbHeight << 4; | 457 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 464 | int32_t iErr = ERR_NONE; | 458 | int32_t iErr; |
| 465 | 459 | ||
| 466 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 460 | int32_t iPicQueueSize; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 467 | bReallocFlag = false; | 461 | *bReallocFlag = false; |
| 468 | bool bNeedChangePicQueue = true; | 462 | bool bNeedChangePicQueue = true; |
| 469 | CMemoryAlign* pMa = pCtx->pMemAlign; | 463 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 470 | 464 | ||
| @@ -537,7 +531,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 66 unmodified lines | |||
| 537 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); | 531 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); |
| 538 | WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine)) | 532 | WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine)) |
| 539 | 533 | ||
| 540 | bReallocFlag = true; // memory re-allocation successfully finished | 534 | *bReallocFlag = true; // memory re-allocation successfully finished |
| 541 | return ERR_NONE; | 535 | return ERR_NONE; |
| 542 | } | 536 | } |
| 543 | 537 | ||
| @@ -594,7 +588,7 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 50 unmodified lines | |||
| 594 | * \brief Open decoder | 588 | * \brief Open decoder |
| 595 | */ | 589 | */ |
| 596 | int32_t WelsOpenDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { | 590 | int32_t WelsOpenDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { |
| 597 | int iRet = ERR_NONE; | 591 | int iRet; |
| 598 | // function pointers | 592 | // function pointers |
| 599 | InitDecFuncs (pCtx, pCtx->uiCpuFlag); | 593 | InitDecFuncs (pCtx, pCtx->uiCpuFlag); |
| 600 | 594 | ||
| @@ -735,21 +729,22 @@ void GetVclNalTemporalId (PWelsDecoderContext pCtx) { · 134 unmodified lines | |||
| 735 | */ | 729 | */ |
| 736 | int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const int32_t kiBsLen, | 730 | int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const int32_t kiBsLen, |
| 737 | uint8_t** ppDst, SBufferInfo* pDstBufInfo, SParserBsInfo* pDstBsInfo) { | 731 | uint8_t** ppDst, SBufferInfo* pDstBufInfo, SParserBsInfo* pDstBsInfo) { |
| 732 | USED(pDstBsInfo); | ||
| 738 | if (!pCtx->bEndOfStreamFlag) { | 733 | if (!pCtx->bEndOfStreamFlag) { |
| 739 | SDataBuffer* pRawData = &pCtx->sRawData; | 734 | SDataBuffer* pRawData = &pCtx->sRawData; |
| 740 | SDataBuffer* pSavedData = NULL; | 735 | SDataBuffer* pSavedData; |
| 741 | 736 | ||
| 742 | int32_t iSrcIdx = 0; //the index of source bit-stream till now after parsing one or more NALs | 737 | int32_t iSrcIdx = 0; //the index of source bit-stream till now after parsing one or more NALs |
| 743 | int32_t iSrcConsumed = 0; // consumed bit count of source bs | 738 | int32_t iSrcConsumed = 0; // consumed bit count of source bs |
| 744 | int32_t iDstIdx = 0; //the size of current NAL after 0x03 removal and 00 00 01 removal | 739 | int32_t iDstIdx = 0; //the size of current NAL after 0x03 removal and 00 00 01 removal |
| 745 | int32_t iSrcLength = 0; //the total size of current AU or NAL | 740 | int32_t iSrcLength; //the total size of current AU or NAL |
| 746 | int32_t iRet = 0; | 741 | int32_t iRet = 0; |
| 747 | int32_t iConsumedBytes = 0; | 742 | int32_t iConsumedBytes = 0; |
| 748 | int32_t iOffset = 0; | 743 | int32_t iOffset = 0; |
| 749 | 744 | ||
| 750 | uint8_t* pSrcNal = NULL; | 745 | uint8_t* pSrcNal; |
| 751 | uint8_t* pDstNal = NULL; | 746 | uint8_t* pDstNal; |
| 752 | uint8_t* pNalPayload = NULL; | 747 | uint8_t* pNalPayload; |
| 753 | 748 | ||
| 754 | 749 | ||
| 755 | if (NULL == DetectStartCodePrefix (kpBsBuf, &iOffset, | 750 | if (NULL == DetectStartCodePrefix (kpBsBuf, &iOffset, |
| @@ -758,7 +753,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 2 unmodified lines | |||
| 758 | return dsBitstreamError; | 753 | return dsBitstreamError; |
| 759 | } | 754 | } |
| 760 | 755 | ||
| 761 | pSrcNal = const_cast<uint8_t*> (kpBsBuf) + iOffset; | 756 | pSrcNal = (uint8_t*) (kpBsBuf) + iOffset; |
| 762 | iSrcLength = kiBsLen - iOffset; | 757 | iSrcLength = kiBsLen - iOffset; |
| 763 | 758 | ||
| 764 | if ((kiBsLen + 4) > (pRawData->pEnd - pRawData->pCurPos)) { | 759 | if ((kiBsLen + 4) > (pRawData->pEnd - pRawData->pCurPos)) { |
| @@ -834,7 +829,6 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 69 unmodified lines | |||
| 834 | } | 829 | } |
| 835 | } | 830 | } |
| 836 | if (iRet) { | 831 | if (iRet) { |
| 837 | iRet = 0; | ||
| 838 | if (dsNoParamSets & pCtx->iErrorCode) { | 832 | if (dsNoParamSets & pCtx->iErrorCode) { |
| 839 | #ifdef LONG_TERM_REF | 833 | #ifdef LONG_TERM_REF |
| 840 | pCtx->bParamSetsLostFlag = true; | 834 | pCtx->bParamSetsLostFlag = true; |
| @@ -896,7 +890,6 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 55 unmodified lines | |||
| 896 | return pCtx->iErrorCode; | 890 | return pCtx->iErrorCode; |
| 897 | } | 891 | } |
| 898 | if (iRet) { | 892 | if (iRet) { |
| 899 | iRet = 0; | ||
| 900 | if (dsNoParamSets & pCtx->iErrorCode) { | 893 | if (dsNoParamSets & pCtx->iErrorCode) { |
| 901 | #ifdef LONG_TERM_REF | 894 | #ifdef LONG_TERM_REF |
| 902 | pCtx->bParamSetsLostFlag = true; | 895 | pCtx->bParamSetsLostFlag = true; |
| @@ -942,7 +935,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 39 unmodified lines | |||
| 942 | * \return 0 - successful; none 0 - something wrong | 935 | * \return 0 - successful; none 0 - something wrong |
| 943 | */ | 936 | */ |
| 944 | int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { | 937 | int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { |
| 945 | int32_t iErr = ERR_NONE; | 938 | int32_t iErr; |
| 946 | const int32_t kiPicWidth = kiMbWidth << 4; | 939 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 947 | const int32_t kiPicHeight = kiMbHeight << 4; | 940 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 948 | //fix Bugzilla Bug1479656 reallocate temp dec picture | 941 | //fix Bugzilla Bug1479656 reallocate temp dec picture |
| @@ -952,7 +945,7 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 3 unmodified lines | |||
| 952 | pCtx->pTempDec = AllocPicture (pCtx, pCtx->pSps->iMbWidth << 4, pCtx->pSps->iMbHeight << 4); | 945 | pCtx->pTempDec = AllocPicture (pCtx, pCtx->pSps->iMbWidth << 4, pCtx->pSps->iMbHeight << 4); |
| 953 | } | 946 | } |
| 954 | bool bReallocFlag = false; | 947 | bool bReallocFlag = false; |
| 955 | iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, bReallocFlag); // common memory used | 948 | iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, &bReallocFlag); // common memory used |
| 956 | if (ERR_NONE != iErr) { | 949 | if (ERR_NONE != iErr) { |
| 957 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, | 950 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| 958 | "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure."); | 951 | "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure."); |
| @@ -969,7 +962,7 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 10 unmodified lines | |||
| 969 | #if defined(MEMORY_MONITOR) | 962 | #if defined(MEMORY_MONITOR) |
| 970 | if (bReallocFlag) { | 963 | if (bReallocFlag) { |
| 971 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes", | 964 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes", |
| 972 | static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage())); | 965 | (unsigned long long) (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage())); |
| 973 | } | 966 | } |
| 974 | #endif//MEMORY_MONITOR | 967 | #endif//MEMORY_MONITOR |
| 975 | return iErr; | 968 | return iErr; |
| @@ -983,23 +976,21 @@ void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 7 unmodified lines | |||
| 983 | DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag); | 976 | DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag); |
| 984 | } | 977 | } |
| 985 | 978 | ||
| 986 | namespace { | ||
| 987 | 979 | ||
| 988 | template<void pfIdctResAddPred (uint8_t* pPred, int32_t iStride, int16_t* pRs)> | 980 | |
| 989 | void IdctFourResAddPred_ (uint8_t* pPred, int32_t iStride, int16_t* pRs, const int8_t* pNzc) { | 981 | void IdctFourResAddPred_ (uint8_t* pPred, int32_t iStride, int16_t* pRs, const int8_t* pNzc) { |
| 990 | if (pNzc[0] || pRs[0 * 16]) | 982 | if (pNzc[0] || pRs[0 * 16]) |
| 991 | pfIdctResAddPred (pPred + 0 * iStride + 0, iStride, pRs + 0 * 16); | 983 | IdctResAddPred_c (pPred + 0 * iStride + 0, iStride, pRs + 0 * 16); |
| 992 | if (pNzc[1] || pRs[1 * 16]) | 984 | if (pNzc[1] || pRs[1 * 16]) |
| 993 | pfIdctResAddPred (pPred + 0 * iStride + 4, iStride, pRs + 1 * 16); | 985 | IdctResAddPred_c (pPred + 0 * iStride + 4, iStride, pRs + 1 * 16); |
| 994 | if (pNzc[4] || pRs[2 * 16]) | 986 | if (pNzc[4] || pRs[2 * 16]) |
| 995 | pfIdctResAddPred (pPred + 4 * iStride + 0, iStride, pRs + 2 * 16); | 987 | IdctResAddPred_c (pPred + 4 * iStride + 0, iStride, pRs + 2 * 16); |
| 996 | if (pNzc[5] || pRs[3 * 16]) | 988 | if (pNzc[5] || pRs[3 * 16]) |
| 997 | pfIdctResAddPred (pPred + 4 * iStride + 4, iStride, pRs + 3 * 16); | 989 | IdctResAddPred_c (pPred + 4 * iStride + 4, iStride, pRs + 3 * 16); |
| 998 | } | 990 | } |
| 999 | 991 | ||
| 1000 | } // anon ns | ||
| 1001 | |||
| 1002 | void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { | 992 | void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { |
| 993 | USED(uiCpuFlag); | ||
| 1003 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; | 994 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; |
| 1004 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; | 995 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; |
| 1005 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; | 996 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; |
| @@ -1047,7 +1038,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 41 unmodified lines | |||
| 1047 | pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_c; | 1038 | pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_c; |
| 1048 | 1039 | ||
| 1049 | pCtx->pIdctResAddPredFunc = IdctResAddPred_c; | 1040 | pCtx->pIdctResAddPredFunc = IdctResAddPred_c; |
| 1050 | pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_<IdctResAddPred_c>; | 1041 | pCtx->pIdctFourResAddPredFunc = (void*)IdctResAddPred_c; |
| 1051 | 1042 | ||
| 1052 | pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c; | 1043 | pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c; |
| 1053 | 1044 | ||
| @@ -1243,6 +1234,3 @@ void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput) { · 189 unmodified lines | |||
| 1243 | else if (kbOutput) | 1234 | else if (kbOutput) |
| 1244 | UpdateDecStatNoFreezingInfo (pCtx); | 1235 | UpdateDecStatNoFreezingInfo (pCtx); |
| 1245 | } | 1236 | } |
| 1246 | |||
| 1247 | |||
| 1248 | } // namespace WelsDec | ||