This reverts commit 27172bafd7ff2cc80b08768a32a23470f3d6d3fd, reversing changes made to 24916a652ee5d3e36d931c222df20966f7c158fa.
Showing the changes to codec/decoder (9 of 11 files). Show all
Unified · Split
| @@ -54,11 +54,6 @@ extern "C" { · 53 unmodified lines | ||
| 54 | 54 | */ |
| 55 | 55 | int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpParam); |
| 56 | 56 | |
| 57 | −/*! | |
| 58 | − * \brief fill in default values of decoder context | |
| 59 | − */ | |
| 60 | −void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx); | |
| 61 | − | |
| 62 | 57 | /*! |
| 63 | 58 | ************************************************************************************* |
| 64 | 59 | * \brief Initialize Wels decoder parameters and memory |
| @@ -73,7 +68,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx); · 8 unmodified lines | ||
| 73 | 68 | * \note N/A |
| 74 | 69 | ************************************************************************************* |
| 75 | 70 | */ |
| 76 | −int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx); | |
| 71 | +int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogContext* pLogCtx); | |
| 77 | 72 | |
| 78 | 73 | /*! |
| 79 | 74 | ************************************************************************************* |
| @@ -115,9 +110,9 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 35 unmodified lines | ||
| 115 | 110 | |
| 116 | 111 | |
| 117 | 112 | /* |
| 118 | − * free memory dynamically allocated during decoder | |
| 113 | + * free memory blocks in avc | |
| 119 | 114 | */ |
| 120 | − void WelsFreeDynamicMemory (PWelsDecoderContext pCtx); | |
| 115 | +void WelsFreeMem (PWelsDecoderContext pCtx); | |
| 121 | 116 | |
| 122 | 117 | /* |
| 123 | 118 | * set colorspace format in decoder |
| @@ -135,19 +130,7 @@ int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat); · 11 unmodified lines | ||
| 135 | 130 | */ |
| 136 | 131 | int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight); |
| 137 | 132 | |
| 138 | −/*! | |
| 139 | − * \brief init decoder predictive function pointers including ASM functions during MB reconstruction | |
| 140 | − * \param pCtx Wels decoder context | |
| 141 | − * \param uiCpuFlag cpu assembly indication | |
| 142 | − */ | |
| 143 | −void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag); | |
| 144 | − | |
| 145 | −/*! | |
| 146 | − * \brief init decoder internal function pointers including ASM functions | |
| 147 | − * \param pCtx Wels decoder context | |
| 148 | − * \param uiCpuFlag cpu assembly indication | |
| 149 | − */ | |
| 150 | −void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag); | |
| 133 | +void AssignFuncPointerForRec (PWelsDecoderContext pCtx); | |
| 151 | 134 | |
| 152 | 135 | void GetVclNalTemporalId (PWelsDecoderContext pCtx); //get the info that whether or not have VCL NAL in current AU, |
| 153 | 136 | //and if YES, get the temporal ID |
| @@ -376,6 +376,7 @@ typedef struct TagWelsDecoderContext { · 375 unmodified lines | ||
| 376 | 376 | ERROR_CON_IDC eErrorConMethod; // |
| 377 | 377 | |
| 378 | 378 | //for Parse only |
| 379 | + bool bParseOnly; | |
| 379 | 380 | bool bFramePending; |
| 380 | 381 | bool bFrameFinish; |
| 381 | 382 | int32_t iNalNum; |
| @@ -72,21 +72,21 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int32_t kiSrcLen); · 71 unmodified lines | ||
| 72 | 72 | int32_t CheckBsBuffer (PWelsDecoderContext pCtx, const int32_t kiSrcLen); |
| 73 | 73 | |
| 74 | 74 | /* |
| 75 | − * WelsInitStaticMemory | |
| 76 | − * Memory request for introduced data at decoder start | |
| 75 | + * WelsInitMemory | |
| 76 | + * Memory request for introduced data | |
| 77 | 77 | * Especially for: |
| 78 | 78 | * rbsp_au_buffer, cur_dq_layer_ptr and ref_dq_layer_ptr in MB info cache. |
| 79 | 79 | * return: |
| 80 | 80 | * 0 - success; otherwise returned error_no defined in error_no.h. |
| 81 | 81 | */ |
| 82 | −int32_t WelsInitStaticMemory (PWelsDecoderContext pCtx); | |
| 82 | +int32_t WelsInitMemory (PWelsDecoderContext pCtx); | |
| 83 | 83 | |
| 84 | 84 | /* |
| 85 | − * WelsFreeStaticMemory | |
| 86 | − * Free memory introduced in WelsInitStaticMemory at destruction of decoder. | |
| 85 | + * WelsFreeMemory | |
| 86 | + * Free memory introduced in WelsInitMemory at destruction of decoder. | |
| 87 | 87 | * |
| 88 | 88 | */ |
| 89 | −void WelsFreeStaticMemory (PWelsDecoderContext pCtx); | |
| 89 | +void WelsFreeMemory (PWelsDecoderContext pCtx); | |
| 90 | 90 | |
| 91 | 91 | /*! |
| 92 | 92 | * \brief request memory when maximal picture width and height are available |
| @@ -317,7 +317,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 316 unmodified lines | ||
| 317 | 317 | iNalSize -= NAL_UNIT_HEADER_EXT_SIZE; |
| 318 | 318 | *pConsumedBytes += NAL_UNIT_HEADER_EXT_SIZE; |
| 319 | 319 | |
| 320 | − if (pCtx->pParam->bParseOnly) { | |
| 320 | + if (pCtx->bParseOnly) { | |
| 321 | 321 | pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos; |
| 322 | 322 | int32_t iTrailingZeroByte = 0; |
| 323 | 323 | while (pSrcNal[iSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes |
| @@ -346,7 +346,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 22 unmodified lines | ||
| 346 | 346 | pSavedData->pCurPos += iActualLen - iOffset; |
| 347 | 347 | } |
| 348 | 348 | } else { |
| 349 | − if (pCtx->pParam->bParseOnly) { | |
| 349 | + if (pCtx->bParseOnly) { | |
| 350 | 350 | pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos; |
| 351 | 351 | int32_t iTrailingZeroByte = 0; |
| 352 | 352 | while (pSrcNal[iSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes |
| @@ -1113,7 +1113,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 760 unmodified lines | ||
| 1113 | 1113 | WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag |
| 1114 | 1114 | pSps->bVuiParamPresentFlag = !!uiCode; |
| 1115 | 1115 | |
| 1116 | − if (pCtx->pParam->bParseOnly) { | |
| 1116 | + if (pCtx->bParseOnly) { | |
| 1117 | 1117 | if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //sps bs exceeds! |
| 1118 | 1118 | pCtx->iErrorCode |= dsOutOfMemory; |
| 1119 | 1119 | return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_OUT_OF_MEMORY); |
| @@ -1416,7 +1416,7 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 296 unmodified lines | ||
| 1416 | 1416 | memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps)); |
| 1417 | 1417 | pCtx->bPpsAvailFlags[uiPpsId] = true; |
| 1418 | 1418 | } |
| 1419 | − if (pCtx->pParam->bParseOnly) { | |
| 1419 | + if (pCtx->bParseOnly) { | |
| 1420 | 1420 | if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //pps bs exceeds |
| 1421 | 1421 | pCtx->iErrorCode |= dsOutOfMemory; |
| 1422 | 1422 | return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_OUT_OF_MEMORY); |
| @@ -90,7 +90,7 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 89 unmodified lines | ||
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | − if (!pCtx->pParam->bParseOnly) { //for parse only, actual recon MB unnecessary | |
| 93 | + if (!pCtx->bParseOnly) { //for parse only, actual recon MB unnecessary | |
| 94 | 94 | if (WelsTargetMbConstruction (pCtx)) { |
| 95 | 95 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, |
| 96 | 96 | "WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d", |
| @@ -134,7 +134,7 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 37 unmodified lines | ||
| 134 | 134 | if ((pCurSlice->eSliceType != I_SLICE) && (pCurSlice->eSliceType != P_SLICE)) |
| 135 | 135 | return 0; |
| 136 | 136 | |
| 137 | − if (pCtx->pParam->bParseOnly) //for parse only, deblocking should not go on | |
| 137 | + if (pCtx->bParseOnly) //for parse only, deblocking should not go on | |
| 138 | 138 | return 0; |
| 139 | 139 | |
| 140 | 140 | pDeblockMb = WelsDeblockingMb; |
| @@ -272,13 +272,14 @@ void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { · 271 unmodified lines | ||
| 272 | 272 | pPicBuf = NULL; |
| 273 | 273 | *ppPicBuf = NULL; |
| 274 | 274 | } |
| 275 | − | |
| 276 | 275 | /* |
| 277 | 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 | 279 | int32_t iCpuCores = 1; |
| 280 | + memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first | |
| 281 | 281 | pCtx->sLogCtx = *pLogCtx; |
| 282 | + pCtx->pMemAlign = pMa; | |
| 282 | 283 | |
| 283 | 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 | 448 | int32_t iListIdx = 0; |
| 448 | 449 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 449 | 450 | |
| 450 | − //free dq layer memory | |
| 451 | − UninitialDqLayersContext (pCtx); | |
| 452 | − | |
| 453 | − //free FMO memory | |
| 451 | + /* TODO: free memory blocks introduced in avc */ | |
| 454 | 452 | ResetFmoList (pCtx); |
| 455 | 453 | |
| 456 | − //free ref-pic list & picture memory | |
| 457 | 454 | WelsResetRefPic (pCtx); |
| 455 | + | |
| 456 | + // for sPicBuff | |
| 458 | 457 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { |
| 459 | 458 | PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; |
| 460 | 459 | if (NULL != pPicBuff && NULL != *pPicBuff) { |
| @@ -469,8 +468,6 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 8 unmodified lines | ||
| 469 | 468 | pCtx->iLastImgHeightInPixel = 0; |
| 470 | 469 | pCtx->bFreezeOutput = true; |
| 471 | 470 | pCtx->bHaveGotMemory = false; |
| 472 | − | |
| 473 | − //free CABAC memory | |
| 474 | 471 | pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); |
| 475 | 472 | } |
| 476 | 473 | |
| @@ -478,15 +475,19 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 1 unmodified line | ||
| 478 | 475 | * \brief Open decoder |
| 479 | 476 | */ |
| 480 | 477 | int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { |
| 481 | − int iRet = ERR_NONE; | |
| 482 | 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 | 486 | // vlc tables |
| 486 | 487 | InitVlcTable (&pCtx->sVlcTable); |
| 487 | 488 | |
| 488 | − // static memory | |
| 489 | − iRet = WelsInitStaticMemory (pCtx); | |
| 489 | + // startup memory | |
| 490 | + iRet = WelsInitMemory (pCtx); | |
| 490 | 491 | if (ERR_NONE != iRet) |
| 491 | 492 | return iRet; |
| 492 | 493 | |
| @@ -506,9 +507,11 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { · 13 unmodified lines | ||
| 506 | 507 | * \brief Close decoder |
| 507 | 508 | */ |
| 508 | 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 | 516 | #ifdef LONG_TERM_REF |
| 514 | 517 | pCtx->bParamSetsLostFlag = false; |
| @@ -528,7 +531,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 13 unmodified lines | ||
| 528 | 531 | |
| 529 | 532 | memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam)); |
| 530 | 533 | pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat; |
| 531 | − if (!pCtx->pParam->bParseOnly) { | |
| 534 | + if (!pCtx->bParseOnly) { | |
| 532 | 535 | int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat); |
| 533 | 536 | if (iRet) |
| 534 | 537 | return iRet; |
| @@ -543,7 +546,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 8 unmodified lines | ||
| 543 | 546 | } |
| 544 | 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 | 550 | pCtx->eErrorConMethod = ERROR_CON_DISABLE; |
| 548 | 551 | InitErrorCon (pCtx); |
| 549 | 552 | |
| @@ -571,11 +574,15 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 21 unmodified lines | ||
| 571 | 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 | 578 | if (pCtx == NULL) { |
| 576 | 579 | return ERR_INFO_INVALID_PTR; |
| 577 | 580 | } |
| 578 | 581 | |
| 582 | + // default | |
| 583 | + WelsDecoderDefaults (pCtx, pLogCtx, pCtx->pMemAlign); | |
| 584 | + | |
| 585 | + pCtx->bParseOnly = bParseOnly; | |
| 579 | 586 | // open decoder |
| 580 | 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 | 659 | pRawData->pCurPos = pRawData->pHead; |
| 653 | 660 | } |
| 654 | 661 | |
| 655 | − if (pCtx->pParam->bParseOnly) { | |
| 662 | + if (pCtx->bParseOnly) { | |
| 656 | 663 | pSavedData = &pCtx->sSavedData; |
| 657 | 664 | if ((kiBsLen + 4) > (pSavedData->pEnd - pSavedData->pCurPos)) { |
| 658 | 665 | pSavedData->pCurPos = pSavedData->pHead; |
| @@ -857,15 +864,7 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 198 unmodified lines | ||
| 857 | 864 | return iErr; |
| 858 | 865 | } |
| 859 | 866 | |
| 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) { | |
| 867 | +void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { | |
| 869 | 868 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; |
| 870 | 869 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; |
| 871 | 870 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; |
| @@ -917,7 +916,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 45 unmodified lines | ||
| 917 | 916 | pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c; |
| 918 | 917 | |
| 919 | 918 | #if defined(HAVE_NEON) |
| 920 | − if (uiCpuFlag & WELS_CPU_NEON) { | |
| 919 | + if (pCtx->uiCpuFlag & WELS_CPU_NEON) { | |
| 921 | 920 | pCtx->pIdctResAddPredFunc = IdctResAddPred_neon; |
| 922 | 921 | |
| 923 | 922 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_neon; |
| @@ -942,7 +941,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 18 unmodified lines | ||
| 942 | 941 | #endif//HAVE_NEON |
| 943 | 942 | |
| 944 | 943 | #if defined(HAVE_NEON_AARCH64) |
| 945 | − if (uiCpuFlag & WELS_CPU_NEON) { | |
| 944 | + if (pCtx->uiCpuFlag & WELS_CPU_NEON) { | |
| 946 | 945 | pCtx->pIdctResAddPredFunc = IdctResAddPred_AArch64_neon; |
| 947 | 946 | |
| 948 | 947 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_AArch64_neon; |
| @@ -972,7 +971,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 23 unmodified lines | ||
| 972 | 971 | #endif//HAVE_NEON_AARCH64 |
| 973 | 972 | |
| 974 | 973 | #if defined(X86_ASM) |
| 975 | − if (uiCpuFlag & WELS_CPU_MMXEXT) { | |
| 974 | + if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) { | |
| 976 | 975 | pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; |
| 977 | 976 | |
| 978 | 977 | ///////mmx code opt--- |
| @@ -987,7 +986,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 8 unmodified lines | ||
| 987 | 986 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsDecoderI4x4LumaPredDDL_mmx; |
| 988 | 987 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsDecoderI4x4LumaPredVL_mmx; |
| 989 | 988 | } |
| 990 | − if (uiCpuFlag & WELS_CPU_SSE2) { | |
| 989 | + if (pCtx->uiCpuFlag & WELS_CPU_SSE2) { | |
| 991 | 990 | /////////sse2 code opt--- |
| 992 | 991 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_sse2; |
| 993 | 992 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_sse2; |
| @@ -1001,6 +1000,9 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 7 unmodified lines | ||
| 1001 | 1000 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_H] = WelsDecoderI4x4LumaPredH_sse2; |
| 1002 | 1001 | } |
| 1003 | 1002 | #endif |
| 1003 | + DeblockingInit (&pCtx->sDeblockingFunc, pCtx->uiCpuFlag); | |
| 1004 | + | |
| 1005 | + WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag); | |
| 1004 | 1006 | } |
| 1005 | 1007 | |
| 1006 | 1008 | //reset decoder number related statistics info |
| @@ -72,7 +72,7 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 71 unmodified lines | ||
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | − if (pCtx->pParam->bParseOnly) { //should exit for parse only to prevent access NULL pDstInfo | |
| 75 | + if (pCtx->bParseOnly) { //should exit for parse only to prevent access NULL pDstInfo | |
| 76 | 76 | PAccessUnit pCurAu = pCtx->pAccessUnitList; |
| 77 | 77 | if (dsErrorFree == pCtx->iErrorCode) { //correct decoding, add to data buffer |
| 78 | 78 | SParserBsInfo* pParser = pCtx->pParserBsInfo; |
| @@ -467,7 +467,7 @@ int32_t InitBsBuffer (PWelsDecoderContext pCtx) { · 388 unmodified lines | ||
| 467 | 467 | } |
| 468 | 468 | pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead; |
| 469 | 469 | pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte; |
| 470 | − if (pCtx->pParam->bParseOnly) { | |
| 470 | + if (pCtx->bParseOnly) { | |
| 471 | 471 | pCtx->pParserBsInfo = static_cast<SParserBsInfo*> (pMa->WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo")); |
| 472 | 472 | if (pCtx->pParserBsInfo == NULL) { |
| 473 | 473 | return ERR_INFO_OUT_OF_MEMORY; |
| @@ -538,14 +538,14 @@ int32_t CheckBsBuffer (PWelsDecoderContext pCtx, const int32_t kiSrcLen) { · 64 unmodified lines | ||
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /* |
| 541 | − * WelsInitStaticMemory | |
| 541 | + * WelsInitMemory | |
| 542 | 542 | * Memory request for new introduced data |
| 543 | 543 | * Especially for: |
| 544 | 544 | * rbsp_au_buffer, cur_dq_layer_ptr and ref_dq_layer_ptr in MB info cache. |
| 545 | 545 | * return: |
| 546 | 546 | * 0 - success; otherwise returned error_no defined in error_no.h. |
| 547 | 547 | */ |
| 548 | −int32_t WelsInitStaticMemory (PWelsDecoderContext pCtx) { | |
| 548 | +int32_t WelsInitMemory (PWelsDecoderContext pCtx) { | |
| 549 | 549 | if (pCtx == NULL) { |
| 550 | 550 | return ERR_INFO_INVALID_PTR; |
| 551 | 551 | } |
| @@ -563,16 +563,22 @@ int32_t WelsInitStaticMemory (PWelsDecoderContext pCtx) { · 11 unmodified lines | ||
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | /* |
| 566 | − * WelsFreeStaticMemory | |
| 567 | − * Free memory introduced in WelsInitStaticMemory at destruction of decoder. | |
| 566 | + * WelsFreeMemory | |
| 567 | + * Free memory introduced in WelsInitMemory at destruction of decoder. | |
| 568 | 568 | * |
| 569 | 569 | */ |
| 570 | −void WelsFreeStaticMemory (PWelsDecoderContext pCtx) { | |
| 570 | +void WelsFreeMemory (PWelsDecoderContext pCtx) { | |
| 571 | 571 | if (pCtx == NULL) |
| 572 | 572 | return; |
| 573 | 573 | |
| 574 | 574 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 575 | 575 | |
| 576 | + if (NULL != pCtx->pParam) { | |
| 577 | + pMa->WelsFree (pCtx->pParam, "pCtx->pParam"); | |
| 578 | + | |
| 579 | + pCtx->pParam = NULL; | |
| 580 | + } | |
| 581 | + | |
| 576 | 582 | MemFreeNalList (&pCtx->pAccessUnitList, pMa); |
| 577 | 583 | |
| 578 | 584 | if (pCtx->sRawData.pHead) { |
| @@ -582,7 +588,7 @@ void WelsFreeStaticMemory (PWelsDecoderContext pCtx) { · 3 unmodified lines | ||
| 582 | 588 | pCtx->sRawData.pEnd = NULL; |
| 583 | 589 | pCtx->sRawData.pStartPos = NULL; |
| 584 | 590 | pCtx->sRawData.pCurPos = NULL; |
| 585 | − if (pCtx->pParam->bParseOnly) { | |
| 591 | + if (pCtx->bParseOnly) { | |
| 586 | 592 | if (pCtx->sSavedData.pHead) { |
| 587 | 593 | pMa->WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead"); |
| 588 | 594 | } |
| @@ -599,12 +605,6 @@ void WelsFreeStaticMemory (PWelsDecoderContext pCtx) { · 10 unmodified lines | ||
| 599 | 605 | pCtx->pParserBsInfo = NULL; |
| 600 | 606 | } |
| 601 | 607 | } |
| 602 | − | |
| 603 | − if (NULL != pCtx->pParam) { | |
| 604 | − pMa->WelsFree (pCtx->pParam, "pCtx->pParam"); | |
| 605 | − | |
| 606 | − pCtx->pParam = NULL; | |
| 607 | − } | |
| 608 | 608 | } |
| 609 | 609 | /* |
| 610 | 610 | * DecodeNalHeaderExt |
| @@ -723,9 +723,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 112 unmodified lines | ||
| 723 | 723 | pSliceHead->eSliceType = static_cast <EWelsSliceType> (uiSliceType); |
| 724 | 724 | |
| 725 | 725 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_parameter_set_id |
| 726 | − WELS_CHECK_SE_UPPER_ERROR (uiCode, (MAX_PPS_COUNT - 1), "iPpsId out of range", | |
| 727 | − GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, | |
| 728 | − ERR_INFO_PPS_ID_OVERFLOW)); | |
| 726 | + WELS_CHECK_SE_UPPER_ERROR (uiCode, (MAX_PPS_COUNT - 1), "iPpsId out of range", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, | |
| 727 | + ERR_INFO_PPS_ID_OVERFLOW)); | |
| 729 | 728 | iPpsId = uiCode; |
| 730 | 729 | |
| 731 | 730 | //add check PPS available here |
| @@ -1975,7 +1974,7 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 1243 unmodified lines | ||
| 1975 | 1974 | |
| 1976 | 1975 | if (ERR_NONE != iErr) { |
| 1977 | 1976 | ForceResetCurrentAccessUnit (pCtx->pAccessUnitList); |
| 1978 | − if (!pCtx->pParam->bParseOnly) | |
| 1977 | + if (!pCtx->bParseOnly) | |
| 1979 | 1978 | pDstInfo->iBufferStatus = 0; |
| 1980 | 1979 | pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin; |
| 1981 | 1980 | pCtx->bNextNewSeqBegin = false; // reset it |
| @@ -2340,7 +2339,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 358 unmodified lines | ||
| 2340 | 2339 | |
| 2341 | 2340 | if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) { |
| 2342 | 2341 | if (!pCtx->bInstantDecFlag) { |
| 2343 | − if (!pCtx->pParam->bParseOnly) { | |
| 2342 | + if (!pCtx->bParseOnly) { | |
| 2344 | 2343 | //Do error concealment here |
| 2345 | 2344 | if ((NeedErrorCon (pCtx)) && (pCtx->eErrorConMethod != ERROR_CON_DISABLE)) { |
| 2346 | 2345 | ImplementErrorCon (pCtx); |
| @@ -2366,7 +2365,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 19 unmodified lines | ||
| 2366 | 2365 | return iRet; |
| 2367 | 2366 | } |
| 2368 | 2367 | } |
| 2369 | − if (!pCtx->pParam->bParseOnly) | |
| 2368 | + if (!pCtx->bParseOnly) | |
| 2370 | 2369 | ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel, |
| 2371 | 2370 | pCtx->pDec->iLinesize, |
| 2372 | 2371 | pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture); |
| @@ -2422,7 +2421,7 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn · 49 unmodified lines | ||
| 2422 | 2421 | if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) { |
| 2423 | 2422 | MarkECFrameAsRef (pCtx); |
| 2424 | 2423 | } |
| 2425 | − } else if (pCtx->pParam->bParseOnly) { //clear parse only internal data status | |
| 2424 | + } else if (pCtx->bParseOnly) { //clear parse only internal data status | |
| 2426 | 2425 | pCtx->pParserBsInfo->iNalNum = 0; |
| 2427 | 2426 | pCtx->bFrameFinish = true; //clear frame pending status here! |
| 2428 | 2427 | } else { |
| @@ -83,7 +83,7 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const · 82 unmodified lines | ||
| 83 | 83 | iLumaSize = iPicWidth * iPicHeight; |
| 84 | 84 | iChromaSize = iPicChromaWidth * iPicChromaHeight; |
| 85 | 85 | |
| 86 | − if (pCtx->pParam->bParseOnly) { | |
| 86 | + if (pCtx->bParseOnly) { | |
| 87 | 87 | pPic->pBuffer[0] = pPic->pBuffer[1] = pPic->pBuffer[2] = NULL; |
| 88 | 88 | pPic->pData[0] = pPic->pData[1] = pPic->pData[2] = NULL; |
| 89 | 89 | pPic->iLinesize[0] = iPicWidth; |
| @@ -243,7 +243,6 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 242 unmodified lines | ||
| 243 | 243 | "CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d", |
| 244 | 244 | VERSION_NUMBER, (int32_t)pParam->bParseOnly); |
| 245 | 245 | |
| 246 | − //reset decoder context | |
| 247 | 246 | if (m_pDecContext) //free |
| 248 | 247 | UninitDecoder(); |
| 249 | 248 | m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); |
| @@ -253,8 +252,8 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 3 unmodified lines | ||
| 253 | 252 | m_pDecContext->pMemAlign = new CMemoryAlign (iCacheLineSize); |
| 254 | 253 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == m_pDecContext->pMemAlign), UninitDecoder()) |
| 255 | 254 | |
| 256 | − //fill in default value into context | |
| 257 | − WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx); | |
| 255 | + WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (m_pDecContext, pParam->bParseOnly, | |
| 256 | + &m_pWelsTrace->m_sLogCtx), UninitDecoder()) | |
| 258 | 257 | |
| 259 | 258 | //check param and update decoder context |
| 260 | 259 | m_pDecContext->pParam = (SDecodingParam*) m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam), |
| @@ -263,9 +262,6 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 2 unmodified lines | ||
| 263 | 262 | int32_t iRet = DecoderConfigParam (m_pDecContext, pParam); |
| 264 | 263 | WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess); |
| 265 | 264 | |
| 266 | − //init decoder | |
| 267 | − WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx), UninitDecoder()) | |
| 268 | − | |
| 269 | 265 | return cmResultSuccess; |
| 270 | 266 | } |
| 271 | 267 | |
| @@ -295,7 +291,7 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 23 unmodified lines | ||
| 295 | 291 | return dsInitialOptExpected; |
| 296 | 292 | |
| 297 | 293 | if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame |
| 298 | − if (m_pDecContext->pParam->bParseOnly) { | |
| 294 | + if (m_pDecContext->bParseOnly) { | |
| 299 | 295 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, |
| 300 | 296 | "CWelsDecoder::SetOption for data format meaningless for parseonly."); |
| 301 | 297 | return cmResultSuccess; |
| @@ -322,7 +318,7 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 20 unmodified lines | ||
| 322 | 318 | iVal = * ((int*)pOption); // int value for error concealment idc |
| 323 | 319 | iVal = WELS_CLIP3 (iVal, (int32_t) ERROR_CON_DISABLE, (int32_t) ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE); |
| 324 | 320 | m_pDecContext->pParam->eEcActiveIdc = m_pDecContext->eErrorConMethod = (ERROR_CON_IDC) iVal; |
| 325 | − if ((m_pDecContext->pParam->bParseOnly) && (m_pDecContext->eErrorConMethod != ERROR_CON_DISABLE)) { | |
| 321 | + if ((m_pDecContext->bParseOnly) && (m_pDecContext->eErrorConMethod != ERROR_CON_DISABLE)) { | |
| 326 | 322 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 327 | 323 | "CWelsDecoder::SetOption for ERROR_CON_IDC = %d not allowd for parse only!.", iVal); |
| 328 | 324 | return cmInitParaError; |