Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all
Unified · Split
| @@ -1946,35 +1946,13 @@ void OutputCpuFeaturesLog (SLogContext* pLogCtx, uint32_t uiCpuFeatureFlags, uin · 1945 unmodified lines | ||
| 1946 | 1946 | iCacheLineSize); |
| 1947 | 1947 | } |
| 1948 | 1948 | |
| 1949 | −/*! | |
| 1950 | − * \brief initialize Wels avc encoder core library | |
| 1951 | − * \pParam ppCtx sWelsEncCtx** | |
| 1952 | − * \pParam pParam SWelsSvcCodingParam* | |
| 1953 | − * \return successful - 0; otherwise none 0 for failed | |
| 1954 | − */ | |
| 1955 | −int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, SLogContext* pLogCtx) { | |
| 1956 | − sWelsEncCtx* pCtx = NULL; | |
| 1957 | − int32_t iRet = 0; | |
| 1958 | − uint32_t uiCpuFeatureFlags = 0; // CPU features | |
| 1949 | +int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, int16_t& iSliceNum, | |
| 1950 | + int32_t& iCacheLineSize, uint32_t& uiCpuFeatureFlags) { | |
| 1951 | + // for cpu features detection, Only detect once?? | |
| 1959 | 1952 | int32_t uiCpuCores = |
| 1960 | 1953 | 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported |
| 1961 | − int32_t iCacheLineSize = 16; // on chip cache line size in byte | |
| 1962 | − int16_t iSliceNum = 1; // number of slices used | |
| 1963 | − | |
| 1964 | − if (NULL == ppCtx || NULL == pCodingParam) { | |
| 1965 | − WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), NULL == ppCtx(0x%p) or NULL == pCodingParam(0x%p).", | |
| 1966 | − (void*)ppCtx, (void*)pCodingParam); | |
| 1967 | − return 1; | |
| 1968 | − } | |
| 1969 | − | |
| 1970 | − iRet = ParamValidationExt (pLogCtx, pCodingParam); | |
| 1971 | − if (iRet != 0) { | |
| 1972 | − WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet); | |
| 1973 | − return iRet; | |
| 1974 | − } | |
| 1975 | − | |
| 1976 | − // for cpu features detection, Only detect once?? | |
| 1977 | 1954 | uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features |
| 1955 | + | |
| 1978 | 1956 | #ifdef X86_ASM |
| 1979 | 1957 | if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128) |
| 1980 | 1958 | iCacheLineSize = 128; |
| @@ -2008,9 +1986,41 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 27 unmodified lines | ||
| 2008 | 1986 | uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM); |
| 2009 | 1987 | |
| 2010 | 1988 | if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { |
| 2011 | − WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), InitSliceSettings failed."); | |
| 1989 | + WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed."); | |
| 2012 | 1990 | return 1; |
| 2013 | 1991 | } |
| 1992 | + return 0; | |
| 1993 | +} | |
| 1994 | + | |
| 1995 | +/*! | |
| 1996 | + * \brief initialize Wels avc encoder core library | |
| 1997 | + * \pParam ppCtx sWelsEncCtx** | |
| 1998 | + * \pParam pParam SWelsSvcCodingParam* | |
| 1999 | + * \return successful - 0; otherwise none 0 for failed | |
| 2000 | + */ | |
| 2001 | +int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, SLogContext* pLogCtx) { | |
| 2002 | + sWelsEncCtx* pCtx = NULL; | |
| 2003 | + int32_t iRet = 0; | |
| 2004 | + int16_t iSliceNum = 1; // number of slices used | |
| 2005 | + int32_t iCacheLineSize = 16; // on chip cache line size in byte | |
| 2006 | + uint32_t uiCpuFeatureFlags = 0; | |
| 2007 | + if (NULL == ppCtx || NULL == pCodingParam) { | |
| 2008 | + WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), NULL == ppCtx(0x%p) or NULL == pCodingParam(0x%p).", | |
| 2009 | + (void*)ppCtx, (void*)pCodingParam); | |
| 2010 | + return 1; | |
| 2011 | + } | |
| 2012 | + | |
| 2013 | + iRet = ParamValidationExt (pLogCtx, pCodingParam); | |
| 2014 | + if (iRet != 0) { | |
| 2015 | + WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet); | |
| 2016 | + return iRet; | |
| 2017 | + } | |
| 2018 | + iRet = GetMultipleThreadIdc (pLogCtx, pCodingParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags); | |
| 2019 | + if (iRet != 0) { | |
| 2020 | + WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), GetMultipleThreadIdc failed return %d.", iRet); | |
| 2021 | + return iRet; | |
| 2022 | + } | |
| 2023 | + | |
| 2014 | 2024 | |
| 2015 | 2025 | *ppCtx = NULL; |
| 2016 | 2026 | |
| @@ -3605,7 +3615,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 1588 unmodified lines | ||
| 3605 | 3615 | } |
| 3606 | 3616 | |
| 3607 | 3617 | #ifdef ENABLE_FRAME_DUMP |
| 3608 | − DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - 1].sRecFileName[0], pSvcParam->iSpatialLayerNum - 1, pCtx->bRecFlag, pCtx->pCurDqLayer); // pDecPic: final reconstruction output | |
| 3618 | + DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - 1].sRecFileName[0], | |
| 3619 | + pSvcParam->iSpatialLayerNum - 1, pCtx->bRecFlag, pCtx->pCurDqLayer); // pDecPic: final reconstruction output | |
| 3609 | 3620 | pCtx->bRecFlag = true; |
| 3610 | 3621 | |
| 3611 | 3622 | #endif//ENABLE_FRAME_DUMP |
| @@ -3629,6 +3640,9 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 17 unmodified lines | ||
| 3629 | 3640 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 3630 | 3641 | int8_t iIndexD = 0; |
| 3631 | 3642 | bool bNeedReset = false; |
| 3643 | + int16_t iSliceNum = 1; // number of slices used | |
| 3644 | + int32_t iCacheLineSize = 16; // on chip cache line size in byte | |
| 3645 | + uint32_t uiCpuFeatureFlags = 0; | |
| 3632 | 3646 | |
| 3633 | 3647 | if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1; |
| 3634 | 3648 | |
| @@ -3636,6 +3650,14 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 1 unmodified line | ||
| 3636 | 3650 | iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam); |
| 3637 | 3651 | if (iReturn != ENC_RETURN_SUCCESS) return iReturn; |
| 3638 | 3652 | |
| 3653 | + iReturn = GetMultipleThreadIdc (& (*ppCtx)->sLogCtx, pNewParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags); | |
| 3654 | + if (iReturn != ENC_RETURN_SUCCESS) { | |
| 3655 | + WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR, "WelsEncoderParamAdjust(), GetMultipleThreadIdc failed return %d.", | |
| 3656 | + iReturn); | |
| 3657 | + return iReturn; | |
| 3658 | + } | |
| 3659 | + | |
| 3660 | + | |
| 3639 | 3661 | pOldParam = (*ppCtx)->pSvcParam; |
| 3640 | 3662 | |
| 3641 | 3663 | /* Decide whether need reset for IDR frame based on adjusting prarameters changed */ |