This reverts commit 27172bafd7ff2cc80b08768a32a23470f3d6d3fd, reversing changes made to 24916a652ee5d3e36d931c222df20966f7c158fa.
Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 11 files). Show all
Unified · Split
| @@ -272,13 +272,14 @@ void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { · 271 unmodified lines | |||
| 272 | pPicBuf = NULL; | 272 | pPicBuf = NULL; |
| 273 | *ppPicBuf = NULL; | 273 | *ppPicBuf = NULL; |
| 274 | } | 274 | } |
| 275 | |||
| 276 | /* | 275 | /* |
| 277 | * fill data fields in default for decoder context | 276 | * fill data fields in default for decoder context |
| 278 | */ | 277 | */ |
| 279 | void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { | 278 | void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx, CMemoryAlign* pMa) { |
| 280 | int32_t iCpuCores = 1; | 279 | int32_t iCpuCores = 1; |
| 280 | memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first | ||
| 281 | pCtx->sLogCtx = *pLogCtx; | 281 | pCtx->sLogCtx = *pLogCtx; |
| 282 | pCtx->pMemAlign = pMa; | ||
| 282 | 283 | ||
| 283 | pCtx->pArgDec = NULL; | 284 | pCtx->pArgDec = NULL; |
| 284 | 285 | ||
| @@ -441,20 +442,18 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 156 unmodified lines | |||
| 441 | } | 442 | } |
| 442 | 443 | ||
| 443 | /* | 444 | /* |
| 444 | * free memory dynamically allocated during decoder | 445 | * free memory blocks in avc |
| 445 | */ | 446 | */ |
| 446 | void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { | 447 | void WelsFreeMem (PWelsDecoderContext pCtx) { |
| 447 | int32_t iListIdx = 0; | 448 | int32_t iListIdx = 0; |
| 448 | CMemoryAlign* pMa = pCtx->pMemAlign; | 449 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 449 | 450 | ||
| 450 | //free dq layer memory | 451 | /* TODO: free memory blocks introduced in avc */ |
| 451 | UninitialDqLayersContext (pCtx); | ||
| 452 | |||
| 453 | //free FMO memory | ||
| 454 | ResetFmoList (pCtx); | 452 | ResetFmoList (pCtx); |
| 455 | 453 | ||
| 456 | //free ref-pic list & picture memory | ||
| 457 | WelsResetRefPic (pCtx); | 454 | WelsResetRefPic (pCtx); |
| 455 | |||
| 456 | // for sPicBuff | ||
| 458 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { | 457 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { |
| 459 | PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; | 458 | PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; |
| 460 | if (NULL != pPicBuff && NULL != *pPicBuff) { | 459 | if (NULL != pPicBuff && NULL != *pPicBuff) { |
| @@ -469,8 +468,6 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 8 unmodified lines | |||
| 469 | pCtx->iLastImgHeightInPixel = 0; | 468 | pCtx->iLastImgHeightInPixel = 0; |
| 470 | pCtx->bFreezeOutput = true; | 469 | pCtx->bFreezeOutput = true; |
| 471 | pCtx->bHaveGotMemory = false; | 470 | pCtx->bHaveGotMemory = false; |
| 472 | |||
| 473 | //free CABAC memory | ||
| 474 | pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); | 471 | pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); |
| 475 | } | 472 | } |
| 476 | 473 | ||
| @@ -478,15 +475,19 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 1 unmodified line | |||
| 478 | * \brief Open decoder | 475 | * \brief Open decoder |
| 479 | */ | 476 | */ |
| 480 | int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { | 477 | int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { |
| 481 | int iRet = ERR_NONE; | ||
| 482 | // function pointers | 478 | // function pointers |
| 483 | InitDecFuncs (pCtx, pCtx->uiCpuFlag); | 479 | //initial MC function pointer-- |
| 480 | int iRet = ERR_NONE; | ||
| 481 | InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag); | ||
| 482 | |||
| 483 | InitExpandPictureFunc (& (pCtx->sExpandPicFunc), pCtx->uiCpuFlag); | ||
| 484 | AssignFuncPointerForRec (pCtx); | ||
| 484 | 485 | ||
| 485 | // vlc tables | 486 | // vlc tables |
| 486 | InitVlcTable (&pCtx->sVlcTable); | 487 | InitVlcTable (&pCtx->sVlcTable); |
| 487 | 488 | ||
| 488 | // static memory | 489 | // startup memory |
| 489 | iRet = WelsInitStaticMemory (pCtx); | 490 | iRet = WelsInitMemory (pCtx); |
| 490 | if (ERR_NONE != iRet) | 491 | if (ERR_NONE != iRet) |
| 491 | return iRet; | 492 | return iRet; |
| 492 | 493 | ||
| @@ -506,9 +507,11 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { · 13 unmodified lines | |||
| 506 | * \brief Close decoder | 507 | * \brief Close decoder |
| 507 | */ | 508 | */ |
| 508 | void WelsCloseDecoder (PWelsDecoderContext pCtx) { | 509 | void WelsCloseDecoder (PWelsDecoderContext pCtx) { |
| 509 | WelsFreeDynamicMemory (pCtx); | 510 | WelsFreeMem (pCtx); |
| 511 | |||
| 512 | WelsFreeMemory (pCtx); | ||
| 510 | 513 | ||
| 511 | WelsFreeStaticMemory (pCtx); | 514 | UninitialDqLayersContext (pCtx); |
| 512 | 515 | ||
| 513 | #ifdef LONG_TERM_REF | 516 | #ifdef LONG_TERM_REF |
| 514 | pCtx->bParamSetsLostFlag = false; | 517 | pCtx->bParamSetsLostFlag = false; |
| @@ -528,7 +531,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 13 unmodified lines | |||
| 528 | 531 | ||
| 529 | memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam)); | 532 | memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam)); |
| 530 | pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat; | 533 | pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat; |
| 531 | if (!pCtx->pParam->bParseOnly) { | 534 | if (!pCtx->bParseOnly) { |
| 532 | int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat); | 535 | int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat); |
| 533 | if (iRet) | 536 | if (iRet) |
| 534 | return iRet; | 537 | return iRet; |
| @@ -543,7 +546,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 8 unmodified lines | |||
| 543 | } | 546 | } |
| 544 | pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc; | 547 | pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc; |
| 545 | 548 | ||
| 546 | if (pCtx->pParam->bParseOnly) //parse only, disable EC method | 549 | if (pCtx->bParseOnly) //parse only, disable EC method |
| 547 | pCtx->eErrorConMethod = ERROR_CON_DISABLE; | 550 | pCtx->eErrorConMethod = ERROR_CON_DISABLE; |
| 548 | InitErrorCon (pCtx); | 551 | InitErrorCon (pCtx); |
| 549 | 552 | ||
| @@ -571,11 +574,15 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 21 unmodified lines | |||
| 571 | * \note N/A | 574 | * \note N/A |
| 572 | ************************************************************************************* | 575 | ************************************************************************************* |
| 573 | */ | 576 | */ |
| 574 | int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { | 577 | int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogContext* pLogCtx) { |
| 575 | if (pCtx == NULL) { | 578 | if (pCtx == NULL) { |
| 576 | return ERR_INFO_INVALID_PTR; | 579 | return ERR_INFO_INVALID_PTR; |
| 577 | } | 580 | } |
| 578 | 581 | ||
| 582 | // default | ||
| 583 | WelsDecoderDefaults (pCtx, pLogCtx, pCtx->pMemAlign); | ||
| 584 | |||
| 585 | pCtx->bParseOnly = bParseOnly; | ||
| 579 | // open decoder | 586 | // open decoder |
| 580 | return WelsOpenDecoder (pCtx); | 587 | return WelsOpenDecoder (pCtx); |
| 581 | } | 588 | } |
| @@ -652,7 +659,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 70 unmodified lines | |||
| 652 | pRawData->pCurPos = pRawData->pHead; | 659 | pRawData->pCurPos = pRawData->pHead; |
| 653 | } | 660 | } |
| 654 | 661 | ||
| 655 | if (pCtx->pParam->bParseOnly) { | 662 | if (pCtx->bParseOnly) { |
| 656 | pSavedData = &pCtx->sSavedData; | 663 | pSavedData = &pCtx->sSavedData; |
| 657 | if ((kiBsLen + 4) > (pSavedData->pEnd - pSavedData->pCurPos)) { | 664 | if ((kiBsLen + 4) > (pSavedData->pEnd - pSavedData->pCurPos)) { |
| 658 | pSavedData->pCurPos = pSavedData->pHead; | 665 | pSavedData->pCurPos = pSavedData->pHead; |
| @@ -857,15 +864,7 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 198 unmodified lines | |||
| 857 | return iErr; | 864 | return iErr; |
| 858 | } | 865 | } |
| 859 | 866 | ||
| 860 | void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { | 867 | void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { |
| 861 | WelsBlockFuncInit (&pCtx->sBlockFunc, uiCpuFlag); | ||
| 862 | InitPredFunc (pCtx, uiCpuFlag); | ||
| 863 | InitMcFunc (& (pCtx->sMcFunc), uiCpuFlag); | ||
| 864 | InitExpandPictureFunc (& (pCtx->sExpandPicFunc), uiCpuFlag); | ||
| 865 | DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag); | ||
| 866 | } | ||
| 867 | |||
| 868 | void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { | ||
| 869 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; | 868 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; |
| 870 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; | 869 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; |
| 871 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; | 870 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; |
| @@ -917,7 +916,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 45 unmodified lines | |||
| 917 | pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c; | 916 | pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c; |
| 918 | 917 | ||
| 919 | #if defined(HAVE_NEON) | 918 | #if defined(HAVE_NEON) |
| 920 | if (uiCpuFlag & WELS_CPU_NEON) { | 919 | if (pCtx->uiCpuFlag & WELS_CPU_NEON) { |
| 921 | pCtx->pIdctResAddPredFunc = IdctResAddPred_neon; | 920 | pCtx->pIdctResAddPredFunc = IdctResAddPred_neon; |
| 922 | 921 | ||
| 923 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_neon; | 922 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_neon; |
| @@ -942,7 +941,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 18 unmodified lines | |||
| 942 | #endif//HAVE_NEON | 941 | #endif//HAVE_NEON |
| 943 | 942 | ||
| 944 | #if defined(HAVE_NEON_AARCH64) | 943 | #if defined(HAVE_NEON_AARCH64) |
| 945 | if (uiCpuFlag & WELS_CPU_NEON) { | 944 | if (pCtx->uiCpuFlag & WELS_CPU_NEON) { |
| 946 | pCtx->pIdctResAddPredFunc = IdctResAddPred_AArch64_neon; | 945 | pCtx->pIdctResAddPredFunc = IdctResAddPred_AArch64_neon; |
| 947 | 946 | ||
| 948 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_AArch64_neon; | 947 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_AArch64_neon; |
| @@ -972,7 +971,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 23 unmodified lines | |||
| 972 | #endif//HAVE_NEON_AARCH64 | 971 | #endif//HAVE_NEON_AARCH64 |
| 973 | 972 | ||
| 974 | #if defined(X86_ASM) | 973 | #if defined(X86_ASM) |
| 975 | if (uiCpuFlag & WELS_CPU_MMXEXT) { | 974 | if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) { |
| 976 | pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; | 975 | pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; |
| 977 | 976 | ||
| 978 | ///////mmx code opt--- | 977 | ///////mmx code opt--- |
| @@ -987,7 +986,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 8 unmodified lines | |||
| 987 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsDecoderI4x4LumaPredDDL_mmx; | 986 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsDecoderI4x4LumaPredDDL_mmx; |
| 988 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsDecoderI4x4LumaPredVL_mmx; | 987 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsDecoderI4x4LumaPredVL_mmx; |
| 989 | } | 988 | } |
| 990 | if (uiCpuFlag & WELS_CPU_SSE2) { | 989 | if (pCtx->uiCpuFlag & WELS_CPU_SSE2) { |
| 991 | /////////sse2 code opt--- | 990 | /////////sse2 code opt--- |
| 992 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_sse2; | 991 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_sse2; |
| 993 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_sse2; | 992 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_sse2; |
| @@ -1001,6 +1000,9 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 7 unmodified lines | |||
| 1001 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_H] = WelsDecoderI4x4LumaPredH_sse2; | 1000 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_H] = WelsDecoderI4x4LumaPredH_sse2; |
| 1002 | } | 1001 | } |
| 1003 | #endif | 1002 | #endif |
| 1003 | DeblockingInit (&pCtx->sDeblockingFunc, pCtx->uiCpuFlag); | ||
| 1004 | |||
| 1005 | WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag); | ||
| 1004 | } | 1006 | } |
| 1005 | 1007 | ||
| 1006 | //reset decoder number related statistics info | 1008 | //reset decoder number related statistics info |