History

add checking of frame rate and temporal layer setting for encoder input param Reviewed at https://rbcommons.com/s/OpenH264/r/836/

Sijia Chen committed 12 years ago

Commit 68fed531 parent 007fb473 files · +33 −32Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+9−18
@@ -75,7 +75,6 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 74 unmodified lines
75 * \return successful - 0; otherwise none 0 for failed75 * \return successful - 0; otherwise none 0 for failed
76 */76 */
77int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) {77int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) {
78 float fMaxFrameRate = 0.0f;
79 const float fEpsn = 0.000001f;78 const float fEpsn = 0.000001f;
80 int32_t i = 0;79 int32_t i = 0;
81 80
@@ -128,25 +127,13 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { · 46 unmodified lines
128 return ENC_RETURN_INVALIDINPUT;127 return ENC_RETURN_INVALIDINPUT;
129 }128 }
130 if (UINT_MAX == GetLogFactor (fDlp->fOutputFrameRate, fDlp->fInputFrameRate)) {129 if (UINT_MAX == GetLogFactor (fDlp->fOutputFrameRate, fDlp->fInputFrameRate)) {
131 WelsLog (pLogCtx, WELS_LOG_ERROR,130 WelsLog (pLogCtx, WELS_LOG_WARNING,
132 "Invalid settings in input frame rate(%.6f) and output frame rate(%.6f) of layer #%d config file: iResult of output frame rate divided by input frame rate should be power of 2(i.e,in/pOut=2^n)..",131 "AUTO CORRECT: Invalid settings in input frame rate(%.6f) and output frame rate(%.6f) of layer #%d config file: iResult of output frame rate divided by input frame rate should be power of 2(i.e,in/pOut=2^n). \n Auto correcting Output Framerate to Input Framerate %f!\n",
133 fDlp->fInputFrameRate, fDlp->fOutputFrameRate, i);132 fDlp->fInputFrameRate, fDlp->fOutputFrameRate, i, fDlp->fInputFrameRate);
134 return ENC_RETURN_INVALIDINPUT;133 fDlp->fOutputFrameRate = fDlp->fInputFrameRate;
135 }134 }
136 }135 }
137 136
138 for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
139 SSpatialLayerInternal* fDlp = &pCfg->sDependencyLayers[i];
140 if (fDlp->fInputFrameRate > fMaxFrameRate)
141 fMaxFrameRate = fDlp->fInputFrameRate;
142 }
143
144 if (fMaxFrameRate > fEpsn && (fMaxFrameRate - pCfg->fMaxFrameRate > fEpsn
145 || fMaxFrameRate - pCfg->fMaxFrameRate < -fEpsn)) {
146 pCfg->fMaxFrameRate = fMaxFrameRate;
147 }
148
149
150 if ((pCfg->iRCMode != RC_OFF_MODE) && (pCfg->iRCMode != RC_QUALITY_MODE) && (pCfg->iRCMode != RC_BUFFERBASED_MODE)137 if ((pCfg->iRCMode != RC_OFF_MODE) && (pCfg->iRCMode != RC_QUALITY_MODE) && (pCfg->iRCMode != RC_BUFFERBASED_MODE)
151 && (pCfg->iRCMode != RC_BITRATE_MODE)) {138 && (pCfg->iRCMode != RC_BITRATE_MODE)) {
152 WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidation(),Invalid iRCMode = %d", pCfg->iRCMode);139 WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidation(),Invalid iRCMode = %d", pCfg->iRCMode);
@@ -2026,6 +2013,11 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 1873 unmodified lines
2026 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet);2013 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet);
2027 return iRet;2014 return iRet;
2028 }2015 }
2016 iRet = pCodingParam->DetermineTemporalSettings();
2017 if (iRet != ENC_RETURN_SUCCESS) {
2018 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting!)", iRet);
2019 return iRet;
2020 }
2029 iRet = GetMultipleThreadIdc (pLogCtx, pCodingParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags);2021 iRet = GetMultipleThreadIdc (pLogCtx, pCodingParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags);
2030 if (iRet != 0) {2022 if (iRet != 0) {
2031 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), GetMultipleThreadIdc failed return %d.", iRet);2023 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), GetMultipleThreadIdc failed return %d.", iRet);
@@ -2045,7 +2037,6 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 13 unmodified lines
2045 pCtx->pMemAlign = new CMemoryAlign (iCacheLineSize);2037 pCtx->pMemAlign = new CMemoryAlign (iCacheLineSize);
2046 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pCtx->pMemAlign), FreeMemorySvc (&pCtx))2038 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pCtx->pMemAlign), FreeMemorySvc (&pCtx))
2047 2039
2048 pCodingParam->DetermineTemporalSettings();
2049 iRet = AllocCodingParam (&pCtx->pSvcParam, pCtx->pMemAlign);2040 iRet = AllocCodingParam (&pCtx->pSvcParam, pCtx->pMemAlign);
2050 if (iRet != 0) {2041 if (iRet != 0) {
2051 FreeMemorySvc (&pCtx);2042 FreeMemorySvc (&pCtx);

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