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