diff --git a/codec/decoder/core/inc/decoder.h b/codec/decoder/core/inc/decoder.h index 4efef7d3..50f91c17 100644 --- a/codec/decoder/core/inc/decoder.h +++ b/codec/decoder/core/inc/decoder.h @@ -54,11 +54,6 @@ extern "C" { */ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpParam); -/*! - * \brief fill in default values of decoder context - */ -void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx); - /*! ************************************************************************************* * \brief Initialize Wels decoder parameters and memory @@ -73,7 +68,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx); * \note N/A ************************************************************************************* */ -int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx); +int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogContext* pLogCtx); /*! ************************************************************************************* @@ -115,9 +110,9 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const /* - * free memory dynamically allocated during decoder + * free memory blocks in avc */ - void WelsFreeDynamicMemory (PWelsDecoderContext pCtx); +void WelsFreeMem (PWelsDecoderContext pCtx); /* * set colorspace format in decoder @@ -135,19 +130,7 @@ int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat); */ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight); -/*! - * \brief init decoder predictive function pointers including ASM functions during MB reconstruction - * \param pCtx Wels decoder context - * \param uiCpuFlag cpu assembly indication - */ -void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag); - -/*! - * \brief init decoder internal function pointers including ASM functions - * \param pCtx Wels decoder context - * \param uiCpuFlag cpu assembly indication - */ -void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag); +void AssignFuncPointerForRec (PWelsDecoderContext pCtx); void GetVclNalTemporalId (PWelsDecoderContext pCtx); //get the info that whether or not have VCL NAL in current AU, //and if YES, get the temporal ID diff --git a/codec/decoder/core/inc/decoder_context.h b/codec/decoder/core/inc/decoder_context.h index 958627f1..8ffb473a 100644 --- a/codec/decoder/core/inc/decoder_context.h +++ b/codec/decoder/core/inc/decoder_context.h @@ -376,6 +376,7 @@ typedef struct TagWelsDecoderContext { ERROR_CON_IDC eErrorConMethod; // //for Parse only + bool bParseOnly; bool bFramePending; bool bFrameFinish; int32_t iNalNum; diff --git a/codec/decoder/core/inc/decoder_core.h b/codec/decoder/core/inc/decoder_core.h index 92e95576..61d96400 100644 --- a/codec/decoder/core/inc/decoder_core.h +++ b/codec/decoder/core/inc/decoder_core.h @@ -72,21 +72,21 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int32_t kiSrcLen); int32_t CheckBsBuffer (PWelsDecoderContext pCtx, const int32_t kiSrcLen); /* - * WelsInitStaticMemory - * Memory request for introduced data at decoder start + * WelsInitMemory + * Memory request for introduced data * Especially for: * rbsp_au_buffer, cur_dq_layer_ptr and ref_dq_layer_ptr in MB info cache. * return: * 0 - success; otherwise returned error_no defined in error_no.h. */ -int32_t WelsInitStaticMemory (PWelsDecoderContext pCtx); +int32_t WelsInitMemory (PWelsDecoderContext pCtx); /* - * WelsFreeStaticMemory - * Free memory introduced in WelsInitStaticMemory at destruction of decoder. + * WelsFreeMemory + * Free memory introduced in WelsInitMemory at destruction of decoder. * */ -void WelsFreeStaticMemory (PWelsDecoderContext pCtx); +void WelsFreeMemory (PWelsDecoderContext pCtx); /*! * \brief request memory when maximal picture width and height are available diff --git a/codec/decoder/core/src/au_parser.cpp b/codec/decoder/core/src/au_parser.cpp index de415457..fe8634f0 100644 --- a/codec/decoder/core/src/au_parser.cpp +++ b/codec/decoder/core/src/au_parser.cpp @@ -317,7 +317,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade iNalSize -= NAL_UNIT_HEADER_EXT_SIZE; *pConsumedBytes += NAL_UNIT_HEADER_EXT_SIZE; - if (pCtx->pParam->bParseOnly) { + if (pCtx->bParseOnly) { pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos; int32_t iTrailingZeroByte = 0; while (pSrcNal[iSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes @@ -346,7 +346,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade pSavedData->pCurPos += iActualLen - iOffset; } } else { - if (pCtx->pParam->bParseOnly) { + if (pCtx->bParseOnly) { pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos; int32_t iTrailingZeroByte = 0; 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 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag pSps->bVuiParamPresentFlag = !!uiCode; - if (pCtx->pParam->bParseOnly) { + if (pCtx->bParseOnly) { if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //sps bs exceeds! pCtx->iErrorCode |= dsOutOfMemory; 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, memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps)); pCtx->bPpsAvailFlags[uiPpsId] = true; } - if (pCtx->pParam->bParseOnly) { + if (pCtx->bParseOnly) { if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //pps bs exceeds pCtx->iErrorCode |= dsOutOfMemory; return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_OUT_OF_MEMORY); diff --git a/codec/decoder/core/src/decode_slice.cpp b/codec/decoder/core/src/decode_slice.cpp index bec44c69..a0b0b485 100644 --- a/codec/decoder/core/src/decode_slice.cpp +++ b/codec/decoder/core/src/decode_slice.cpp @@ -90,7 +90,7 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { break; } - if (!pCtx->pParam->bParseOnly) { //for parse only, actual recon MB unnecessary + if (!pCtx->bParseOnly) { //for parse only, actual recon MB unnecessary if (WelsTargetMbConstruction (pCtx)) { WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d", @@ -134,7 +134,7 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { if ((pCurSlice->eSliceType != I_SLICE) && (pCurSlice->eSliceType != P_SLICE)) return 0; - if (pCtx->pParam->bParseOnly) //for parse only, deblocking should not go on + if (pCtx->bParseOnly) //for parse only, deblocking should not go on return 0; pDeblockMb = WelsDeblockingMb; diff --git a/codec/decoder/core/src/decoder.cpp b/codec/decoder/core/src/decoder.cpp index 7e121928..f5291e16 100644 --- a/codec/decoder/core/src/decoder.cpp +++ b/codec/decoder/core/src/decoder.cpp @@ -272,13 +272,14 @@ void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { pPicBuf = NULL; *ppPicBuf = NULL; } - /* * fill data fields in default for decoder context */ -void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { +void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx, CMemoryAlign* pMa) { int32_t iCpuCores = 1; + memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first pCtx->sLogCtx = *pLogCtx; + pCtx->pMemAlign = pMa; pCtx->pArgDec = NULL; @@ -441,20 +442,18 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const } /* - * free memory dynamically allocated during decoder + * free memory blocks in avc */ -void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { +void WelsFreeMem (PWelsDecoderContext pCtx) { int32_t iListIdx = 0; CMemoryAlign* pMa = pCtx->pMemAlign; - //free dq layer memory - UninitialDqLayersContext (pCtx); - - //free FMO memory + /* TODO: free memory blocks introduced in avc */ ResetFmoList (pCtx); - //free ref-pic list & picture memory WelsResetRefPic (pCtx); + + // for sPicBuff for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; if (NULL != pPicBuff && NULL != *pPicBuff) { @@ -469,8 +468,6 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { pCtx->iLastImgHeightInPixel = 0; pCtx->bFreezeOutput = true; pCtx->bHaveGotMemory = false; - - //free CABAC memory pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); } @@ -478,15 +475,19 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { * \brief Open decoder */ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { - int iRet = ERR_NONE; // function pointers - InitDecFuncs (pCtx, pCtx->uiCpuFlag); + //initial MC function pointer-- + int iRet = ERR_NONE; + InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag); + + InitExpandPictureFunc (& (pCtx->sExpandPicFunc), pCtx->uiCpuFlag); + AssignFuncPointerForRec (pCtx); // vlc tables InitVlcTable (&pCtx->sVlcTable); - // static memory - iRet = WelsInitStaticMemory (pCtx); + // startup memory + iRet = WelsInitMemory (pCtx); if (ERR_NONE != iRet) return iRet; @@ -506,9 +507,11 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { * \brief Close decoder */ void WelsCloseDecoder (PWelsDecoderContext pCtx) { - WelsFreeDynamicMemory (pCtx); + WelsFreeMem (pCtx); - WelsFreeStaticMemory (pCtx); + WelsFreeMemory (pCtx); + + UninitialDqLayersContext (pCtx); #ifdef LONG_TERM_REF pCtx->bParamSetsLostFlag = false; @@ -528,7 +531,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam)); pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat; - if (!pCtx->pParam->bParseOnly) { + if (!pCtx->bParseOnly) { int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat); if (iRet) return iRet; @@ -543,7 +546,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa } pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc; - if (pCtx->pParam->bParseOnly) //parse only, disable EC method + if (pCtx->bParseOnly) //parse only, disable EC method pCtx->eErrorConMethod = ERROR_CON_DISABLE; InitErrorCon (pCtx); @@ -571,11 +574,15 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa * \note N/A ************************************************************************************* */ -int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { +int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogContext* pLogCtx) { if (pCtx == NULL) { return ERR_INFO_INVALID_PTR; } + // default + WelsDecoderDefaults (pCtx, pLogCtx, pCtx->pMemAlign); + + pCtx->bParseOnly = bParseOnly; // open decoder return WelsOpenDecoder (pCtx); } @@ -652,7 +659,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in pRawData->pCurPos = pRawData->pHead; } - if (pCtx->pParam->bParseOnly) { + if (pCtx->bParseOnly) { pSavedData = &pCtx->sSavedData; if ((kiBsLen + 4) > (pSavedData->pEnd - pSavedData->pCurPos)) { pSavedData->pCurPos = pSavedData->pHead; @@ -857,15 +864,7 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi return iErr; } -void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { - WelsBlockFuncInit (&pCtx->sBlockFunc, uiCpuFlag); - InitPredFunc (pCtx, uiCpuFlag); - InitMcFunc (& (pCtx->sMcFunc), uiCpuFlag); - InitExpandPictureFunc (& (pCtx->sExpandPicFunc), uiCpuFlag); - DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag); -} - -void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { +void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; @@ -917,7 +916,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c; #if defined(HAVE_NEON) - if (uiCpuFlag & WELS_CPU_NEON) { + if (pCtx->uiCpuFlag & WELS_CPU_NEON) { pCtx->pIdctResAddPredFunc = IdctResAddPred_neon; pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_neon; @@ -942,7 +941,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { #endif//HAVE_NEON #if defined(HAVE_NEON_AARCH64) - if (uiCpuFlag & WELS_CPU_NEON) { + if (pCtx->uiCpuFlag & WELS_CPU_NEON) { pCtx->pIdctResAddPredFunc = IdctResAddPred_AArch64_neon; pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_AArch64_neon; @@ -972,7 +971,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { #endif//HAVE_NEON_AARCH64 #if defined(X86_ASM) - if (uiCpuFlag & WELS_CPU_MMXEXT) { + if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) { pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; ///////mmx code opt--- @@ -987,7 +986,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsDecoderI4x4LumaPredDDL_mmx; pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsDecoderI4x4LumaPredVL_mmx; } - if (uiCpuFlag & WELS_CPU_SSE2) { + if (pCtx->uiCpuFlag & WELS_CPU_SSE2) { /////////sse2 code opt--- pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_sse2; pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_sse2; @@ -1001,6 +1000,9 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { pCtx->pGetI4x4LumaPredFunc[I4_PRED_H] = WelsDecoderI4x4LumaPredH_sse2; } #endif + DeblockingInit (&pCtx->sDeblockingFunc, pCtx->uiCpuFlag); + + WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag); } //reset decoder number related statistics info diff --git a/codec/decoder/core/src/decoder_core.cpp b/codec/decoder/core/src/decoder_core.cpp index 63bc75f6..03e8ce06 100644 --- a/codec/decoder/core/src/decoder_core.cpp +++ b/codec/decoder/core/src/decoder_core.cpp @@ -72,7 +72,7 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t } } - if (pCtx->pParam->bParseOnly) { //should exit for parse only to prevent access NULL pDstInfo + if (pCtx->bParseOnly) { //should exit for parse only to prevent access NULL pDstInfo PAccessUnit pCurAu = pCtx->pAccessUnitList; if (dsErrorFree == pCtx->iErrorCode) { //correct decoding, add to data buffer SParserBsInfo* pParser = pCtx->pParserBsInfo; @@ -467,7 +467,7 @@ int32_t InitBsBuffer (PWelsDecoderContext pCtx) { } pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead; pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte; - if (pCtx->pParam->bParseOnly) { + if (pCtx->bParseOnly) { pCtx->pParserBsInfo = static_cast (pMa->WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo")); if (pCtx->pParserBsInfo == NULL) { return ERR_INFO_OUT_OF_MEMORY; @@ -538,14 +538,14 @@ int32_t CheckBsBuffer (PWelsDecoderContext pCtx, const int32_t kiSrcLen) { } /* - * WelsInitStaticMemory + * WelsInitMemory * Memory request for new introduced data * Especially for: * rbsp_au_buffer, cur_dq_layer_ptr and ref_dq_layer_ptr in MB info cache. * return: * 0 - success; otherwise returned error_no defined in error_no.h. */ -int32_t WelsInitStaticMemory (PWelsDecoderContext pCtx) { +int32_t WelsInitMemory (PWelsDecoderContext pCtx) { if (pCtx == NULL) { return ERR_INFO_INVALID_PTR; } @@ -563,16 +563,22 @@ int32_t WelsInitStaticMemory (PWelsDecoderContext pCtx) { } /* - * WelsFreeStaticMemory - * Free memory introduced in WelsInitStaticMemory at destruction of decoder. + * WelsFreeMemory + * Free memory introduced in WelsInitMemory at destruction of decoder. * */ -void WelsFreeStaticMemory (PWelsDecoderContext pCtx) { +void WelsFreeMemory (PWelsDecoderContext pCtx) { if (pCtx == NULL) return; CMemoryAlign* pMa = pCtx->pMemAlign; + if (NULL != pCtx->pParam) { + pMa->WelsFree (pCtx->pParam, "pCtx->pParam"); + + pCtx->pParam = NULL; + } + MemFreeNalList (&pCtx->pAccessUnitList, pMa); if (pCtx->sRawData.pHead) { @@ -582,7 +588,7 @@ void WelsFreeStaticMemory (PWelsDecoderContext pCtx) { pCtx->sRawData.pEnd = NULL; pCtx->sRawData.pStartPos = NULL; pCtx->sRawData.pCurPos = NULL; - if (pCtx->pParam->bParseOnly) { + if (pCtx->bParseOnly) { if (pCtx->sSavedData.pHead) { pMa->WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead"); } @@ -599,12 +605,6 @@ void WelsFreeStaticMemory (PWelsDecoderContext pCtx) { pCtx->pParserBsInfo = NULL; } } - - if (NULL != pCtx->pParam) { - pMa->WelsFree (pCtx->pParam, "pCtx->pParam"); - - pCtx->pParam = NULL; - } } /* * DecodeNalHeaderExt @@ -723,9 +723,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co pSliceHead->eSliceType = static_cast (uiSliceType); WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_parameter_set_id - WELS_CHECK_SE_UPPER_ERROR (uiCode, (MAX_PPS_COUNT - 1), "iPpsId out of range", - GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, - ERR_INFO_PPS_ID_OVERFLOW)); + WELS_CHECK_SE_UPPER_ERROR (uiCode, (MAX_PPS_COUNT - 1), "iPpsId out of range", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, + ERR_INFO_PPS_ID_OVERFLOW)); iPpsId = uiCode; //add check PPS available here @@ -1975,7 +1974,7 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI if (ERR_NONE != iErr) { ForceResetCurrentAccessUnit (pCtx->pAccessUnitList); - if (!pCtx->pParam->bParseOnly) + if (!pCtx->bParseOnly) pDstInfo->iBufferStatus = 0; pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin; pCtx->bNextNewSeqBegin = false; // reset it @@ -2340,7 +2339,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) { if (!pCtx->bInstantDecFlag) { - if (!pCtx->pParam->bParseOnly) { + if (!pCtx->bParseOnly) { //Do error concealment here if ((NeedErrorCon (pCtx)) && (pCtx->eErrorConMethod != ERROR_CON_DISABLE)) { ImplementErrorCon (pCtx); @@ -2366,7 +2365,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf return iRet; } } - if (!pCtx->pParam->bParseOnly) + if (!pCtx->bParseOnly) ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel, pCtx->pDec->iLinesize, pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture); @@ -2422,7 +2421,7 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) { MarkECFrameAsRef (pCtx); } - } else if (pCtx->pParam->bParseOnly) { //clear parse only internal data status + } else if (pCtx->bParseOnly) { //clear parse only internal data status pCtx->pParserBsInfo->iNalNum = 0; pCtx->bFrameFinish = true; //clear frame pending status here! } else { diff --git a/codec/decoder/core/src/pic_queue.cpp b/codec/decoder/core/src/pic_queue.cpp index d1da2f1d..2383fbd6 100644 --- a/codec/decoder/core/src/pic_queue.cpp +++ b/codec/decoder/core/src/pic_queue.cpp @@ -83,7 +83,7 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const iLumaSize = iPicWidth * iPicHeight; iChromaSize = iPicChromaWidth * iPicChromaHeight; - if (pCtx->pParam->bParseOnly) { + if (pCtx->bParseOnly) { pPic->pBuffer[0] = pPic->pBuffer[1] = pPic->pBuffer[2] = NULL; pPic->pData[0] = pPic->pData[1] = pPic->pData[2] = NULL; pPic->iLinesize[0] = iPicWidth; diff --git a/codec/decoder/plus/src/welsDecoderExt.cpp b/codec/decoder/plus/src/welsDecoderExt.cpp index a6fd6ad8..8c23bb74 100644 --- a/codec/decoder/plus/src/welsDecoderExt.cpp +++ b/codec/decoder/plus/src/welsDecoderExt.cpp @@ -243,7 +243,6 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { "CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d", VERSION_NUMBER, (int32_t)pParam->bParseOnly); - //reset decoder context if (m_pDecContext) //free UninitDecoder(); m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); @@ -253,8 +252,8 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { m_pDecContext->pMemAlign = new CMemoryAlign (iCacheLineSize); WELS_VERIFY_RETURN_PROC_IF (1, (NULL == m_pDecContext->pMemAlign), UninitDecoder()) - //fill in default value into context - WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx); + WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (m_pDecContext, pParam->bParseOnly, + &m_pWelsTrace->m_sLogCtx), UninitDecoder()) //check param and update decoder context m_pDecContext->pParam = (SDecodingParam*) m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam), @@ -263,9 +262,6 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { int32_t iRet = DecoderConfigParam (m_pDecContext, pParam); WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess); - //init decoder - WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx), UninitDecoder()) - return cmResultSuccess; } @@ -295,7 +291,7 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { return dsInitialOptExpected; if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame - if (m_pDecContext->pParam->bParseOnly) { + if (m_pDecContext->bParseOnly) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "CWelsDecoder::SetOption for data format meaningless for parseonly."); return cmResultSuccess; @@ -322,7 +318,7 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { iVal = * ((int*)pOption); // int value for error concealment idc iVal = WELS_CLIP3 (iVal, (int32_t) ERROR_CON_DISABLE, (int32_t) ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE); m_pDecContext->pParam->eEcActiveIdc = m_pDecContext->eErrorConMethod = (ERROR_CON_IDC) iVal; - if ((m_pDecContext->pParam->bParseOnly) && (m_pDecContext->eErrorConMethod != ERROR_CON_DISABLE)) { + if ((m_pDecContext->bParseOnly) && (m_pDecContext->eErrorConMethod != ERROR_CON_DISABLE)) { WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::SetOption for ERROR_CON_IDC = %d not allowd for parse only!.", iVal); return cmInitParaError; diff --git a/test/decoder/DecUT_DecExt.cpp b/test/decoder/DecUT_DecExt.cpp index e230d2ff..7b40d4b9 100644 --- a/test/decoder/DecUT_DecExt.cpp +++ b/test/decoder/DecUT_DecExt.cpp @@ -26,8 +26,6 @@ class DecoderInterfaceTest : public ::testing::Test { } //Init members void Init(); - //Init valid members - void ValidInit(); //Uninit members void Uninit(); //Mock input data for test @@ -99,29 +97,6 @@ void DecoderInterfaceTest::Init() { ASSERT_EQ (eRet, cmResultSuccess); } -void DecoderInterfaceTest::ValidInit() { - memset (&m_sBufferInfo, 0, sizeof (SBufferInfo)); - memset (&m_sDecParam, 0, sizeof (SDecodingParam)); - m_sDecParam.pFileNameRestructed = NULL; - m_sDecParam.eOutputColorFormat = (EVideoFormatType) 23; - m_sDecParam.uiCpuLoad = 1; - m_sDecParam.uiTargetDqLayer = 1; - m_sDecParam.eEcActiveIdc = (ERROR_CON_IDC) (rand() & 7); - m_sDecParam.sVideoProperty.size = sizeof (SVideoProperty); - m_sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; - - m_pData[0] = m_pData[1] = m_pData[2] = NULL; - m_szBuffer[0] = m_szBuffer[1] = m_szBuffer[2] = 0; - m_szBuffer[3] = 1; - m_iBufLength = 4; - CM_RETURN eRet = (CM_RETURN) m_pDec->Initialize (&m_sDecParam); - if ((m_sDecParam.eOutputColorFormat != videoFormatI420) && - (m_sDecParam.eOutputColorFormat != videoFormatInternal)) - ASSERT_EQ (eRet, cmUnsupportedData); - else - ASSERT_EQ (eRet, cmResultSuccess); -} - void DecoderInterfaceTest::Uninit() { if (m_pDec) { CM_RETURN eRet = (CM_RETURN) m_pDec->Uninitialize(); @@ -283,7 +258,7 @@ void DecoderInterfaceTest::TestEndOfStream() { int iTmp, iOut; CM_RETURN eRet; - ValidInit(); + Init(); //invalid input eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, NULL); @@ -345,7 +320,7 @@ void DecoderInterfaceTest::TestVclNal() { int iTmp, iOut; CM_RETURN eRet; - ValidInit(); + Init(); //Test SetOption //VclNal never supports SetOption @@ -454,7 +429,7 @@ void DecoderInterfaceTest::TestGetDecStatistics() { SDecoderStatistics sDecStatic; int32_t iError = 0; - ValidInit(); + Init(); // setoption not support, eRet = (CM_RETURN)m_pDec->SetOption (DECODER_OPTION_GET_STATISTICS, NULL); EXPECT_EQ (eRet, cmInitParaError); @@ -477,7 +452,7 @@ void DecoderInterfaceTest::TestGetDecStatistics() { Uninit(); //Decoder error bs when the first IDR lost - ValidInit(); + Init(); iError = 2; m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError); DecoderBs ("res/BA_MW_D_IDR_LOST.264"); @@ -495,7 +470,7 @@ void DecoderInterfaceTest::TestGetDecStatistics() { Uninit(); //ecoder error bs when the first P lost - ValidInit(); + Init(); iError = 2; m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError); @@ -516,7 +491,7 @@ void DecoderInterfaceTest::TestGetDecStatistics() { //EC enable //EC Off UT just correc bitstream - ValidInit(); + Init(); iError = 0; m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError); DecoderBs ("res/test_vd_1d.264"); diff --git a/test/decoder/DecUT_ParseSyntax.cpp b/test/decoder/DecUT_ParseSyntax.cpp index ea6fcc63..776793c1 100644 --- a/test/decoder/DecUT_ParseSyntax.cpp +++ b/test/decoder/DecUT_ParseSyntax.cpp @@ -86,16 +86,13 @@ int32_t InitDecoder (const SDecodingParam* pParam, PWelsDecoderContext pCtx, SLo return cmMallocMemeError; } - pCtx->sLogCtx = *pLogCtx; - + WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (pCtx, pParam->bParseOnly, pLogCtx), UninitDecoder (pCtx)); //check param and update decoder context pCtx->pParam = (SDecodingParam*) pCtx->pMemAlign->WelsMallocz (sizeof (SDecodingParam), "SDecodingParam"); WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == pCtx->pParam), UninitDecoder (pCtx)); - int32_t iRet = DecoderConfigParam (pCtx, pParam); + int32_t iRet = DecoderConfigParam (pCtx, pCtx->pParam); WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess); - WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (pCtx, pLogCtx), UninitDecoder (pCtx)); - return cmResultSuccess; }