Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 64 files). Show all
Unified · Split
| @@ -93,9 +93,9 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 92 unmodified lines | |||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | // initialize context in queue | 95 | // initialize context in queue |
| 96 | pPicBuf->iCapacity = kiSize; | 96 | pPicBuf->iCapacity = kiSize; |
| 97 | pPicBuf->iCurrentIdx = 0; | 97 | pPicBuf->iCurrentIdx = 0; |
| 98 | * ppPicBuf = pPicBuf; | 98 | * ppPicBuf = pPicBuf; |
| 99 | 99 | ||
| 100 | return 0; | 100 | return 0; |
| 101 | } | 101 | } |
| @@ -139,9 +139,9 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 37 unmodified lines | |||
| 139 | memcpy (pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiOldSize * sizeof (PPicture)); | 139 | memcpy (pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiOldSize * sizeof (PPicture)); |
| 140 | 140 | ||
| 141 | // initialize context in queue | 141 | // initialize context in queue |
| 142 | pPicNewBuf->iCapacity = kiNewSize; | 142 | pPicNewBuf->iCapacity = kiNewSize; |
| 143 | pPicNewBuf->iCurrentIdx = pPicOldBuf->iCurrentIdx; | 143 | pPicNewBuf->iCurrentIdx = pPicOldBuf->iCurrentIdx; |
| 144 | * ppPicBuf = pPicNewBuf; | 144 | * ppPicBuf = pPicNewBuf; |
| 145 | 145 | ||
| 146 | for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { | 146 | for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { |
| 147 | pPicNewBuf->ppPic[i]->bUsedAsRef = false; | 147 | pPicNewBuf->ppPic[i]->bUsedAsRef = false; |
| @@ -214,8 +214,8 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 66 unmodified lines | |||
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | // initialize context in queue | 216 | // initialize context in queue |
| 217 | pPicNewBuf->iCapacity = kiNewSize; | 217 | pPicNewBuf->iCapacity = kiNewSize; |
| 218 | *ppPicBuf = pPicNewBuf; | 218 | *ppPicBuf = pPicNewBuf; |
| 219 | 219 | ||
| 220 | for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { | 220 | for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { |
| 221 | pPicNewBuf->ppPic[i]->bUsedAsRef = false; | 221 | pPicNewBuf->ppPic[i]->bUsedAsRef = false; |
| @@ -277,35 +277,35 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 55 unmodified lines | |||
| 277 | 277 | ||
| 278 | pCtx->pArgDec = NULL; | 278 | pCtx->pArgDec = NULL; |
| 279 | 279 | ||
| 280 | pCtx->eOutputColorFormat = videoFormatI420; // yuv in default | 280 | pCtx->eOutputColorFormat = videoFormatI420; // yuv in default |
| 281 | pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related | 281 | pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related |
| 282 | pCtx->uiCpuFlag = 0; | 282 | pCtx->uiCpuFlag = 0; |
| 283 | 283 | ||
| 284 | pCtx->bAuReadyFlag = 0; // au data is not ready | 284 | pCtx->bAuReadyFlag = 0; // au data is not ready |
| 285 | pCtx->bCabacInited = false; | 285 | pCtx->bCabacInited = false; |
| 286 | 286 | ||
| 287 | pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); | 287 | pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); |
| 288 | 288 | ||
| 289 | pCtx->iImgWidthInPixel = 0; | 289 | pCtx->iImgWidthInPixel = 0; |
| 290 | pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available | 290 | pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available |
| 291 | pCtx->iLastImgWidthInPixel = 0; | 291 | pCtx->iLastImgWidthInPixel = 0; |
| 292 | pCtx->iLastImgHeightInPixel = 0; | 292 | pCtx->iLastImgHeightInPixel = 0; |
| 293 | pCtx->bFreezeOutput = true; | 293 | pCtx->bFreezeOutput = true; |
| 294 | 294 | ||
| 295 | pCtx->iFrameNum = -1; | 295 | pCtx->iFrameNum = -1; |
| 296 | pCtx->iPrevFrameNum = -1; | 296 | pCtx->iPrevFrameNum = -1; |
| 297 | pCtx->iErrorCode = ERR_NONE; | 297 | pCtx->iErrorCode = ERR_NONE; |
| 298 | 298 | ||
| 299 | pCtx->pDec = NULL; | 299 | pCtx->pDec = NULL; |
| 300 | 300 | ||
| 301 | WelsResetRefPic (pCtx); | 301 | WelsResetRefPic (pCtx); |
| 302 | 302 | ||
| 303 | pCtx->iActiveFmoNum = 0; | 303 | pCtx->iActiveFmoNum = 0; |
| 304 | 304 | ||
| 305 | pCtx->pPicBuff[LIST_0] = NULL; | 305 | pCtx->pPicBuff[LIST_0] = NULL; |
| 306 | pCtx->pPicBuff[LIST_1] = NULL; | 306 | pCtx->pPicBuff[LIST_1] = NULL; |
| 307 | 307 | ||
| 308 | pCtx->bAvcBasedFlag = true; | 308 | pCtx->bAvcBasedFlag = true; |
| 309 | pCtx->eErrorConMethod = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE; | 309 | pCtx->eErrorConMethod = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE; |
| 310 | pCtx->pPreviousDecodedPictureInDpb = NULL; | 310 | pCtx->pPreviousDecodedPictureInDpb = NULL; |
| 311 | pCtx->sDecoderStatistics.iAvgLumaQp = -1; | 311 | pCtx->sDecoderStatistics.iAvgLumaQp = -1; |
| @@ -353,13 +353,13 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { · 41 unmodified lines | |||
| 353 | * request memory blocks for decoder avc part | 353 | * request memory blocks for decoder avc part |
| 354 | */ | 354 | */ |
| 355 | int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { | 355 | int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { |
| 356 | const int32_t kiPicWidth = kiMbWidth << 4; | 356 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 357 | const int32_t kiPicHeight = kiMbHeight << 4; | 357 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 358 | int32_t iErr = ERR_NONE; | 358 | int32_t iErr = ERR_NONE; |
| 359 | 359 | ||
| 360 | int32_t iListIdx = 0; //, mb_blocks = 0; | 360 | int32_t iListIdx = 0; //, mb_blocks = 0; |
| 361 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 361 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 362 | bool bNeedChangePicQueue = true; | 362 | bool bNeedChangePicQueue = true; |
| 363 | 363 | ||
| 364 | WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0)) | 364 | WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0)) |
| 365 | 365 | ||
| @@ -418,11 +418,11 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 52 unmodified lines | |||
| 418 | return iErr; | 418 | return iErr; |
| 419 | 419 | ||
| 420 | 420 | ||
| 421 | pCtx->iImgWidthInPixel = kiPicWidth; // target width of image to be reconstruted while decoding | 421 | pCtx->iImgWidthInPixel = kiPicWidth; // target width of image to be reconstruted while decoding |
| 422 | pCtx->iImgHeightInPixel = kiPicHeight; // target height of image to be reconstruted while decoding | 422 | pCtx->iImgHeightInPixel = kiPicHeight; // target height of image to be reconstruted while decoding |
| 423 | 423 | ||
| 424 | pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested | 424 | pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested |
| 425 | pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed | 425 | pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed |
| 426 | 426 | ||
| 427 | if (pCtx->pCabacDecEngine == NULL) | 427 | if (pCtx->pCabacDecEngine == NULL) |
| 428 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); | 428 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); |
| @@ -450,12 +450,12 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 21 unmodified lines | |||
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | // added for safe memory | 452 | // added for safe memory |
| 453 | pCtx->iImgWidthInPixel = 0; | 453 | pCtx->iImgWidthInPixel = 0; |
| 454 | pCtx->iImgHeightInPixel = 0; | 454 | pCtx->iImgHeightInPixel = 0; |
| 455 | pCtx->iLastImgWidthInPixel = 0; | 455 | pCtx->iLastImgWidthInPixel = 0; |
| 456 | pCtx->iLastImgHeightInPixel = 0; | 456 | pCtx->iLastImgHeightInPixel = 0; |
| 457 | pCtx->bFreezeOutput = true; | 457 | pCtx->bFreezeOutput = true; |
| 458 | pCtx->bHaveGotMemory = false; | 458 | pCtx->bHaveGotMemory = false; |
| 459 | WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); | 459 | WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); |
| 460 | } | 460 | } |
| 461 | 461 | ||
| @@ -660,8 +660,8 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 198 unmodified lines | |||
| 660 | ((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) { | 660 | ((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) { |
| 661 | if (pSrcNal[2 + iSrcIdx] == 0x03) { | 661 | if (pSrcNal[2 + iSrcIdx] == 0x03) { |
| 662 | ST16 (pDstNal + iDstIdx, 0); | 662 | ST16 (pDstNal + iDstIdx, 0); |
| 663 | iDstIdx += 2; | 663 | iDstIdx += 2; |
| 664 | iSrcIdx += 3; | 664 | iSrcIdx += 3; |
| 665 | iSrcConsumed += 3; | 665 | iSrcConsumed += 3; |
| 666 | } else { | 666 | } else { |
| 667 | 667 | ||
| @@ -817,7 +817,7 @@ int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) { · 149 unmodified lines | |||
| 817 | */ | 817 | */ |
| 818 | int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { | 818 | int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { |
| 819 | int32_t iErr = ERR_NONE; | 819 | int32_t iErr = ERR_NONE; |
| 820 | const int32_t kiPicWidth = kiMbWidth << 4; | 820 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 821 | const int32_t kiPicHeight = kiMbHeight << 4; | 821 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 822 | 822 | ||
| 823 | iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used | 823 | iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used |