Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 11 files). Show all
Unified · Split
| @@ -272,14 +272,13 @@ void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { · 271 unmodified lines | ||
| 272 | 272 | pPicBuf = NULL; |
| 273 | 273 | *ppPicBuf = NULL; |
| 274 | 274 | } |
| 275 | + | |
| 275 | 276 | /* |
| 276 | 277 | * fill data fields in default for decoder context |
| 277 | 278 | */ |
| 278 | −void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx, CMemoryAlign* pMa) { | |
| 279 | +void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { | |
| 279 | 280 | int32_t iCpuCores = 1; |
| 280 | − memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first | |
| 281 | 281 | pCtx->sLogCtx = *pLogCtx; |
| 282 | − pCtx->pMemAlign = pMa; | |
| 283 | 282 | |
| 284 | 283 | pCtx->pArgDec = NULL; |
| 285 | 284 | |
| @@ -441,18 +440,20 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 155 unmodified lines | ||
| 441 | 440 | } |
| 442 | 441 | |
| 443 | 442 | /* |
| 444 | − * free memory blocks in avc | |
| 443 | + * free memory dynamically allocated during decoder | |
| 445 | 444 | */ |
| 446 | −void WelsFreeMem (PWelsDecoderContext pCtx) { | |
| 445 | +void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { | |
| 447 | 446 | int32_t iListIdx = 0; |
| 448 | 447 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 449 | 448 | |
| 450 | − /* TODO: free memory blocks introduced in avc */ | |
| 449 | + //free dq layer memory | |
| 450 | + UninitialDqLayersContext (pCtx); | |
| 451 | + | |
| 452 | + //free FMO memory | |
| 451 | 453 | ResetFmoList (pCtx); |
| 452 | 454 | |
| 455 | + //free ref-pic list & picture memory | |
| 453 | 456 | WelsResetRefPic (pCtx); |
| 454 | − | |
| 455 | − // for sPicBuff | |
| 456 | 457 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { |
| 457 | 458 | PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; |
| 458 | 459 | if (NULL != pPicBuff && NULL != *pPicBuff) { |
| @@ -467,6 +468,8 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 8 unmodified lines | ||
| 467 | 468 | pCtx->iLastImgHeightInPixel = 0; |
| 468 | 469 | pCtx->bFreezeOutput = true; |
| 469 | 470 | pCtx->bHaveGotMemory = false; |
| 471 | + | |
| 472 | + //free CABAC memory | |
| 470 | 473 | pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); |
| 471 | 474 | } |
| 472 | 475 | |
| @@ -474,19 +477,15 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 1 unmodified line | ||
| 474 | 477 | * \brief Open decoder |
| 475 | 478 | */ |
| 476 | 479 | int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { |
| 477 | − // function pointers | |
| 478 | − //initial MC function pointer-- | |
| 479 | 480 | int iRet = ERR_NONE; |
| 480 | − InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag); | |
| 481 | − | |
| 482 | − InitExpandPictureFunc (& (pCtx->sExpandPicFunc), pCtx->uiCpuFlag); | |
| 483 | − AssignFuncPointerForRec (pCtx); | |
| 481 | + // function pointers | |
| 482 | + InitDecFuncs (pCtx, pCtx->uiCpuFlag); | |
| 484 | 483 | |
| 485 | 484 | // vlc tables |
| 486 | 485 | InitVlcTable (&pCtx->sVlcTable); |
| 487 | 486 | |
| 488 | − // startup memory | |
| 489 | − iRet = WelsInitMemory (pCtx); | |
| 487 | + // static memory | |
| 488 | + iRet = WelsInitStaticMemory (pCtx); | |
| 490 | 489 | if (ERR_NONE != iRet) |
| 491 | 490 | return iRet; |
| 492 | 491 | |
| @@ -506,11 +505,9 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { · 13 unmodified lines | ||
| 506 | 505 | * \brief Close decoder |
| 507 | 506 | */ |
| 508 | 507 | void WelsCloseDecoder (PWelsDecoderContext pCtx) { |
| 509 | − WelsFreeMem (pCtx); | |
| 510 | − | |
| 511 | − WelsFreeMemory (pCtx); | |
| 508 | + WelsFreeDynamicMemory (pCtx); | |
| 512 | 509 | |
| 513 | − UninitialDqLayersContext (pCtx); | |
| 510 | + WelsFreeStaticMemory (pCtx); | |
| 514 | 511 | |
| 515 | 512 | #ifdef LONG_TERM_REF |
| 516 | 513 | pCtx->bParamSetsLostFlag = false; |
| @@ -539,7 +536,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 22 unmodified lines | ||
| 539 | 536 | } |
| 540 | 537 | pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc; |
| 541 | 538 | |
| 542 | − if (pCtx->bParseOnly) //parse only, disable EC method | |
| 539 | + if (pCtx->pParam->bParseOnly) //parse only, disable EC method | |
| 543 | 540 | pCtx->eErrorConMethod = ERROR_CON_DISABLE; |
| 544 | 541 | InitErrorCon (pCtx); |
| 545 | 542 | |
| @@ -567,15 +564,11 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 21 unmodified lines | ||
| 567 | 564 | * \note N/A |
| 568 | 565 | ************************************************************************************* |
| 569 | 566 | */ |
| 570 | −int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogContext* pLogCtx) { | |
| 567 | +int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { | |
| 571 | 568 | if (pCtx == NULL) { |
| 572 | 569 | return ERR_INFO_INVALID_PTR; |
| 573 | 570 | } |
| 574 | 571 | |
| 575 | − // default | |
| 576 | − WelsDecoderDefaults (pCtx, pLogCtx, pCtx->pMemAlign); | |
| 577 | − | |
| 578 | − pCtx->bParseOnly = bParseOnly; | |
| 579 | 572 | // open decoder |
| 580 | 573 | return WelsOpenDecoder (pCtx); |
| 581 | 574 | } |
| @@ -652,7 +645,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 70 unmodified lines | ||
| 652 | 645 | pRawData->pCurPos = pRawData->pHead; |
| 653 | 646 | } |
| 654 | 647 | |
| 655 | − if (pCtx->bParseOnly) { | |
| 648 | + if (pCtx->pParam->bParseOnly) { | |
| 656 | 649 | pSavedData = &pCtx->sSavedData; |
| 657 | 650 | if ((kiBsLen + 4) > (pSavedData->pEnd - pSavedData->pCurPos)) { |
| 658 | 651 | pSavedData->pCurPos = pSavedData->pHead; |
| @@ -847,7 +840,15 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 188 unmodified lines | ||
| 847 | 840 | return iErr; |
| 848 | 841 | } |
| 849 | 842 | |
| 850 | −void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { | |
| 843 | +void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { | |
| 844 | + WelsBlockFuncInit (&pCtx->sBlockFunc, uiCpuFlag); | |
| 845 | + InitPredFunc (pCtx, uiCpuFlag); | |
| 846 | + InitMcFunc (& (pCtx->sMcFunc), uiCpuFlag); | |
| 847 | + InitExpandPictureFunc (& (pCtx->sExpandPicFunc), uiCpuFlag); | |
| 848 | + DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag); | |
| 849 | +} | |
| 850 | + | |
| 851 | +void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { | |
| 851 | 852 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; |
| 852 | 853 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; |
| 853 | 854 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; |
| @@ -899,7 +900,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 45 unmodified lines | ||
| 899 | 900 | pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c; |
| 900 | 901 | |
| 901 | 902 | #if defined(HAVE_NEON) |
| 902 | − if (pCtx->uiCpuFlag & WELS_CPU_NEON) { | |
| 903 | + if (uiCpuFlag & WELS_CPU_NEON) { | |
| 903 | 904 | pCtx->pIdctResAddPredFunc = IdctResAddPred_neon; |
| 904 | 905 | |
| 905 | 906 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_neon; |
| @@ -924,7 +925,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 18 unmodified lines | ||
| 924 | 925 | #endif//HAVE_NEON |
| 925 | 926 | |
| 926 | 927 | #if defined(HAVE_NEON_AARCH64) |
| 927 | − if (pCtx->uiCpuFlag & WELS_CPU_NEON) { | |
| 928 | + if (uiCpuFlag & WELS_CPU_NEON) { | |
| 928 | 929 | pCtx->pIdctResAddPredFunc = IdctResAddPred_AArch64_neon; |
| 929 | 930 | |
| 930 | 931 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_AArch64_neon; |
| @@ -954,7 +955,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 23 unmodified lines | ||
| 954 | 955 | #endif//HAVE_NEON_AARCH64 |
| 955 | 956 | |
| 956 | 957 | #if defined(X86_ASM) |
| 957 | − if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) { | |
| 958 | + if (uiCpuFlag & WELS_CPU_MMXEXT) { | |
| 958 | 959 | pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; |
| 959 | 960 | |
| 960 | 961 | ///////mmx code opt--- |
| @@ -969,7 +970,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 8 unmodified lines | ||
| 969 | 970 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsDecoderI4x4LumaPredDDL_mmx; |
| 970 | 971 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsDecoderI4x4LumaPredVL_mmx; |
| 971 | 972 | } |
| 972 | − if (pCtx->uiCpuFlag & WELS_CPU_SSE2) { | |
| 973 | + if (uiCpuFlag & WELS_CPU_SSE2) { | |
| 973 | 974 | /////////sse2 code opt--- |
| 974 | 975 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_sse2; |
| 975 | 976 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_sse2; |
| @@ -983,9 +984,6 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 7 unmodified lines | ||
| 983 | 984 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_H] = WelsDecoderI4x4LumaPredH_sse2; |
| 984 | 985 | } |
| 985 | 986 | #endif |
| 986 | − DeblockingInit (&pCtx->sDeblockingFunc, pCtx->uiCpuFlag); | |
| 987 | − | |
| 988 | − WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag); | |
| 989 | 987 | } |
| 990 | 988 | |
| 991 | 989 | //reset decoder number related statistics info |