History

fix auto threadIdc issue

ruil2 committed 12 years ago

Commit d4eff951 parent 43e1c461 file · +50 −28Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+50−28
@@ -1946,35 +1946,13 @@ void OutputCpuFeaturesLog (SLogContext* pLogCtx, uint32_t uiCpuFeatureFlags, uin · 1945 unmodified lines
1946 iCacheLineSize);1946 iCacheLineSize);
1947}1947}
1948 1948
1949/*!1949int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, int16_t& iSliceNum,
1950 * \brief initialize Wels avc encoder core library1950 int32_t& iCacheLineSize, uint32_t& uiCpuFeatureFlags) {
1951 * \pParam ppCtx sWelsEncCtx**1951 // for cpu features detection, Only detect once??
1952 * \pParam pParam SWelsSvcCodingParam*
1953 * \return successful - 0; otherwise none 0 for failed
1954 */
1955int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, SLogContext* pLogCtx) {
1956 sWelsEncCtx* pCtx = NULL;
1957 int32_t iRet = 0;
1958 uint32_t uiCpuFeatureFlags = 0; // CPU features
1959 int32_t uiCpuCores =1952 int32_t uiCpuCores =
1960 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported1953 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 uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features1954 uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features
1955
1978#ifdef X86_ASM1956#ifdef X86_ASM
1979 if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128)1957 if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128)
1980 iCacheLineSize = 128;1958 iCacheLineSize = 128;
@@ -2008,9 +1986,41 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 27 unmodified lines
2008 uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM);1986 uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM);
2009 1987
2010 if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) {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 return 1;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 */
2001int32_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 *ppCtx = NULL;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#ifdef ENABLE_FRAME_DUMP3617#ifdef ENABLE_FRAME_DUMP
3608 DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - 1].sRecFileName[0], pSvcParam->iSpatialLayerNum - 1, pCtx->bRecFlag, pCtx->pCurDqLayer); // pDecPic: final reconstruction output3618 DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - 1].sRecFileName[0],
3619 pSvcParam->iSpatialLayerNum - 1, pCtx->bRecFlag, pCtx->pCurDqLayer); // pDecPic: final reconstruction output
3609 pCtx->bRecFlag = true;3620 pCtx->bRecFlag = true;
3610 3621
3611#endif//ENABLE_FRAME_DUMP3622#endif//ENABLE_FRAME_DUMP
@@ -3629,6 +3640,9 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 17 unmodified lines
3629 int32_t iReturn = ENC_RETURN_SUCCESS;3640 int32_t iReturn = ENC_RETURN_SUCCESS;
3630 int8_t iIndexD = 0;3641 int8_t iIndexD = 0;
3631 bool bNeedReset = false;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 if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1;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 iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam);3650 iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam);
3637 if (iReturn != ENC_RETURN_SUCCESS) return iReturn;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 pOldParam = (*ppCtx)->pSvcParam;3661 pOldParam = (*ppCtx)->pSvcParam;
3640 3662
3641 /* Decide whether need reset for IDR frame based on adjusting prarameters changed */3663 /* Decide whether need reset for IDR frame based on adjusting prarameters changed */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t