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
19461946 iCacheLineSize);
19471947 }
19481948
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??
19591952 int32_t uiCpuCores =
19601953 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??
19771954 uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features
1955+
19781956 #ifdef X86_ASM
19791957 if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128)
19801958 iCacheLineSize = 128;
@@ -2008,9 +1986,41 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 27 unmodified lines
20081986 uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM);
20091987
20101988 if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) {
2011− WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), InitSliceSettings failed.");
1989+ WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed.");
20121990 return 1;
20131991 }
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+
20142024
20152025 *ppCtx = NULL;
20162026
@@ -3605,7 +3615,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 1588 unmodified lines
36053615 }
36063616
36073617 #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
36093620 pCtx->bRecFlag = true;
36103621
36113622 #endif//ENABLE_FRAME_DUMP
@@ -3629,6 +3640,9 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 17 unmodified lines
36293640 int32_t iReturn = ENC_RETURN_SUCCESS;
36303641 int8_t iIndexD = 0;
36313642 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;
36323646
36333647 if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1;
36343648
@@ -3636,6 +3650,14 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 1 unmodified line
36363650 iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam);
36373651 if (iReturn != ENC_RETURN_SUCCESS) return iReturn;
36383652
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+
36393661 pOldParam = (*ppCtx)->pSvcParam;
36403662
36413663 /* 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