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