ref: f42cbaca324d1b41e8ed68a21217a043ef501c13
parent: cd1991a0e39a6429af387394056420f2a7d48608
author: sijchen@cisco.com <sijchen@cisco.com>
date: Thu Jan 18 05:12:49 EST 2018
adjust output order in log for readability add UT and log
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -641,8 +641,8 @@
WelsLog (pLogCtx, WELS_LOG_WARNING, "layerId(%d) Profile is baseline, Change CABAC to CAVLC", i);
}
} else if (pLayerInfo->uiProfileIdc == PRO_UNKNOWN) {
- if ((i==0) || pCodingParam->bSimulcastAVC) {
- pLayerInfo->uiProfileIdc = (pCodingParam->iEntropyCodingModeFlag)?PRO_HIGH:PRO_BASELINE;
+ if ((i == 0) || pCodingParam->bSimulcastAVC) {
+ pLayerInfo->uiProfileIdc = (pCodingParam->iEntropyCodingModeFlag) ? PRO_HIGH : PRO_BASELINE;
} else {
pLayerInfo->uiProfileIdc = PRO_SCALABLE_BASELINE;
}
@@ -4188,17 +4188,23 @@
if (bNeedReset) {
WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO,
"WelsEncoderParamAdjust(),bSimulcastAVC(%d,%d),iSpatialLayerNum(%d,%d),iPicWidth(%d,%d),iPicHeight(%d,%d),Rect.iWidth(%d,%d),Rect.iHeight(%d,%d)",
- pOldParam->bSimulcastAVC, pNewParam->bSimulcastAVC, pOldParam->iSpatialLayerNum, pNewParam->iSpatialLayerNum,
- pOldParam->iPicWidth, pNewParam->iPicWidth, pOldParam->iPicHeight, pNewParam->iPicHeight,
- pOldParam->SUsedPicRect.iWidth, pNewParam->SUsedPicRect.iWidth, pOldParam->SUsedPicRect.iHeight,
- pNewParam->SUsedPicRect.iHeight);
+ pOldParam->bSimulcastAVC, pNewParam->bSimulcastAVC,
+ pOldParam->iSpatialLayerNum, pNewParam->iSpatialLayerNum,
+ pOldParam->iPicWidth, pNewParam->iPicWidth,
+ pOldParam->iPicHeight, pNewParam->iPicHeight,
+ pOldParam->SUsedPicRect.iWidth, pNewParam->SUsedPicRect.iWidth,
+ pOldParam->SUsedPicRect.iHeight, pNewParam->SUsedPicRect.iHeight);
WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO,
- "WelsEncoderParamAdjust(),bEnableLongTermReference(%d,%d),iLTRRefNum(%d,%d),iMultipleThreadIdc(%d,%d),bEnableBackgroundDetection(%d,%d),bEnableAdaptiveQuant(%d,%d),eSpsPpsIdStrategy(%d,%d),iMaxNumRefFrame(%d,%d)",
- pOldParam->bEnableLongTermReference, pNewParam->bEnableLongTermReference, pOldParam->iLTRRefNum, pNewParam->iLTRRefNum,
- pOldParam->iMultipleThreadIdc, pNewParam->iMultipleThreadIdc, pOldParam->bEnableBackgroundDetection,
- pNewParam->bEnableBackgroundDetection, pOldParam->bEnableAdaptiveQuant, pNewParam->bEnableAdaptiveQuant,
- pOldParam->eSpsPpsIdStrategy, pNewParam->eSpsPpsIdStrategy, pNewParam->iMaxNumRefFrame, pOldParam->iMaxNumRefFrame);
+ "WelsEncoderParamAdjust(),bEnableLongTermReference(%d,%d),iLTRRefNum(%d,%d),iMultipleThreadIdc(%d,%d),bEnableBackgroundDetection(%d,%d),bEnableAdaptiveQuant(%d,%d),eSpsPpsIdStrategy(%d,%d),iMaxNumRefFrame(%d,%d),iTemporalLayerNum(%d,%d)",
+ pOldParam->bEnableLongTermReference, pNewParam->bEnableLongTermReference,
+ pOldParam->iLTRRefNum, pNewParam->iLTRRefNum,
+ pOldParam->iMultipleThreadIdc, pNewParam->iMultipleThreadIdc,
+ pOldParam->bEnableBackgroundDetection, pNewParam->bEnableBackgroundDetection,
+ pOldParam->bEnableAdaptiveQuant, pNewParam->bEnableAdaptiveQuant,
+ pOldParam->eSpsPpsIdStrategy, pNewParam->eSpsPpsIdStrategy,
+ pOldParam->iMaxNumRefFrame, pNewParam->iMaxNumRefFrame,
+ pOldParam->iTemporalLayerNum, pNewParam->iTemporalLayerNum);
}
if (!bNeedReset) { // Check its picture resolutions/quality settings respectively in each dependency layer
iIndexD = 0;
@@ -4218,8 +4224,9 @@
WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO,
"WelsEncoderParamAdjust(),iIndexD = %d,sSpatialLayers.wxh_old(%d,%d),sSpatialLayers.wxh_new(%d,%d),iActualwxh_old(%d,%d),iActualwxh_new(%d,%d)",
iIndexD, pOldParam->sSpatialLayers[iIndexD].iVideoWidth, pOldParam->sSpatialLayers[iIndexD].iVideoHeight,
- pNewParam->sSpatialLayers[iIndexD].iVideoWidth, pNewParam->sSpatialLayers[iIndexD].iVideoHeight, kpOldDlp->iActualWidth,
- kpOldDlp->iActualHeight, kpNewDlp->iActualWidth, kpNewDlp->iActualHeight);
+ pNewParam->sSpatialLayers[iIndexD].iVideoWidth, pNewParam->sSpatialLayers[iIndexD].iVideoHeight,
+ kpOldDlp->iActualWidth, kpOldDlp->iActualHeight,
+ kpNewDlp->iActualWidth, kpNewDlp->iActualHeight);
break;
}
@@ -4251,7 +4258,8 @@
bNeedReset = true;
WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO,
"WelsEncoderParamAdjust() iIndexD = %d,fInputFrameRate(%f,%f),fOutputFrameRate(%f,%f),fMaxFrameRate(%f,%f)", iIndexD,
- kpOldDlp->fInputFrameRate, kpNewDlp->fInputFrameRate, kpOldDlp->fOutputFrameRate, kpNewDlp->fOutputFrameRate,
+ kpOldDlp->fInputFrameRate, kpNewDlp->fInputFrameRate,
+ kpOldDlp->fOutputFrameRate, kpNewDlp->fOutputFrameRate,
pOldParam->fMaxFrameRate, pNewParam->fMaxFrameRate);
break;
}
--- a/test/api/encode_options_test.cpp
+++ b/test/api/encode_options_test.cpp
@@ -1957,8 +1957,8 @@
sParam.iEntropyCodingModeFlag = rand() % 2;
sParam.sSpatialLayers[0].iSpatialBitrate = sParam.iTargetBitrate = 3000;
- int TraceLevel = WELS_LOG_DEBUG;
- encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel);
+// int TraceLevel = WELS_LOG_DEBUG;
+// encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel);
//decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &TraceLevel);
iEncProfileIdc = profileList[rand() % 11];
iEncLevelIdc = levelList[rand() % 18];
@@ -1980,7 +1980,7 @@
}
ASSERT_TRUE (iDecProfileIdc == iEncProfileIdc) << "enc_profile = " << iEncProfileIdc << " dec_profile = " <<
- iDecProfileIdc;
+ iDecProfileIdc;
//check whether the level is changed according to level limitation
ELevelIdc uiLevel = LEVEL_UNKNOWN;
@@ -2213,8 +2213,8 @@
prepareParamDefault (1, iSliceNum, iWidth, iHeight, fFrameRate, &sParam);
sParam.iTemporalLayerNum = 2;
- //int TraceLevel = WELS_LOG_DEBUG;
- //encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel);
+// int TraceLevel = WELS_LOG_DEBUG;
+// encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel);
iRet = encoder_->InitializeExt (&sParam);
ASSERT_TRUE (iRet == cmResultSuccess) << "InitializeExt: iRet = " << iRet << " at " << sParam.iPicWidth << "x" <<
sParam.iPicHeight;
@@ -2261,3 +2261,74 @@
ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet;
}
+
+TEST_F (EncodeDecodeTestAPI, TemporalLayerChangeDuringEncoding_Specific) {
+ int iWidth = 320;
+ int iHeight = 192;
+ float fFrameRate = 15;
+ int iSliceNum = 1;
+ int iRet = 0;
+ int iTotalFrame = (rand() % 20) + 3;
+ int iFrameNum = 0;
+ SEncParamExt sParam;
+ encoder_->GetDefaultParams (&sParam);
+ prepareParamDefault (1, iSliceNum, iWidth, iHeight, fFrameRate, &sParam);
+
+ int originalTemporalLayerNum = 1;
+ int originalBR = 500000;
+ float originalFR = 7.5;
+ int iSteps[3] = {2, 1, 3};
+ int iStepIdx = 0;
+ bool bSetOption = false;
+
+ sParam.iTemporalLayerNum = originalTemporalLayerNum;
+ sParam.iNumRefFrame = 1;
+
+ int TraceLevel = WELS_LOG_INFO;
+ encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel);
+ iRet = encoder_->InitializeExt (&sParam);
+ ASSERT_TRUE (iRet == cmResultSuccess) << "InitializeExt: iRet = " << iRet << " at " << sParam.iPicWidth << "x" <<
+ sParam.iPicHeight;
+
+ ASSERT_TRUE (InitialEncDec (iWidth, iHeight));
+
+ int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2;
+ do {
+ FileInputStream fileStream;
+ ASSERT_TRUE (fileStream.Open ("res/CiscoVT2people_320x192_12fps.yuv"));
+
+ while (fileStream.read (buf_.data(), frameSize) == frameSize) {
+
+ if ( (iStepIdx < 3) && (iFrameNum == ((iTotalFrame / 3) * (iStepIdx + 1)))) {
+ sParam.iTemporalLayerNum = originalTemporalLayerNum * iSteps[iStepIdx];
+ sParam.iTargetBitrate = sParam.sSpatialLayers[0].iSpatialBitrate = originalBR * iSteps[iStepIdx];
+ sParam.fMaxFrameRate = sParam.sSpatialLayers[0].fFrameRate = originalFR * pow (2, iSteps[iStepIdx]);
+ encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam);
+
+ bSetOption = true;
+ iStepIdx += 1;
+ }
+
+ iRet = encoder_->EncodeFrame (&EncPic, &info);
+ EXPECT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet;
+
+ if (bSetOption) {
+ if ((iStepIdx == 1) || (iStepIdx == 3)) {
+ EXPECT_TRUE (info.eFrameType == videoFrameTypeIDR) << "iStepIdx=" << iStepIdx << "iFrameNum=" << iFrameNum << "iTotalFrame=" << iTotalFrame;
+ } else {
+ EXPECT_TRUE (info.eFrameType != videoFrameTypeIDR) << "iStepIdx=" << iStepIdx << "iFrameNum=" << iFrameNum << "iTotalFrame=" << iTotalFrame;
+ }
+
+ bSetOption = false;
+ }
+
+
+ }
+ iFrameNum++;
+ } while (iFrameNum < iTotalFrame);
+
+ iRet = encoder_->Uninitialize();
+ ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet;
+
+}
+