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
7575 * \return successful - 0; otherwise none 0 for failed
7676 */
7777 int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) {
78− float fMaxFrameRate = 0.0f;
7978 const float fEpsn = 0.000001f;
8079 int32_t i = 0;
8180
@@ -128,25 +127,13 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { · 46 unmodified lines
128127 return ENC_RETURN_INVALIDINPUT;
129128 }
130129 if (UINT_MAX == GetLogFactor (fDlp->fOutputFrameRate, fDlp->fInputFrameRate)) {
131− WelsLog (pLogCtx, WELS_LOG_ERROR,
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)..",
133− fDlp->fInputFrameRate, fDlp->fOutputFrameRate, i);
134− return ENC_RETURN_INVALIDINPUT;
130+ WelsLog (pLogCtx, WELS_LOG_WARNING,
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",
132+ fDlp->fInputFrameRate, fDlp->fOutputFrameRate, i, fDlp->fInputFrameRate);
133+ fDlp->fOutputFrameRate = fDlp->fInputFrameRate;
135134 }
136135 }
137136
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−
150137 if ((pCfg->iRCMode != RC_OFF_MODE) && (pCfg->iRCMode != RC_QUALITY_MODE) && (pCfg->iRCMode != RC_BUFFERBASED_MODE)
151138 && (pCfg->iRCMode != RC_BITRATE_MODE)) {
152139 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
20262013 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet);
20272014 return iRet;
20282015 }
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+ }
20292021 iRet = GetMultipleThreadIdc (pLogCtx, pCodingParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags);
20302022 if (iRet != 0) {
20312023 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
20452037 pCtx->pMemAlign = new CMemoryAlign (iCacheLineSize);
20462038 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pCtx->pMemAlign), FreeMemorySvc (&pCtx))
20472039
2048− pCodingParam->DetermineTemporalSettings();
20492040 iRet = AllocCodingParam (&pCtx->pSvcParam, pCtx->pMemAlign);
20502041 if (iRet != 0) {
20512042 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