ref: c6f078dd5ab0b356696ee1d85df7929e9b72b4ab
parent: c36b0a6c1240650283631905151231022265b336
parent: 4ee0534f7f87467b49450411160d3e2fb6e6810a
author: ruil2 <ruil2@cisco.com>
date: Tue Jan 30 04:53:36 EST 2018
Merge pull request #2906 from sijchen/param [Encoder] add a param adjustment for encoder param validation
--- a/codec/encoder/core/inc/param_svc.h
+++ b/codec/encoder/core/inc/param_svc.h
@@ -417,6 +417,21 @@
pSpatialLayer->iMaxSpatialBitrate =
pCodingParam.sSpatialLayers[iIdxSpatial].iMaxSpatialBitrate;
+ if ((iSpatialLayerNum==1) && (iIdxSpatial==0)) {
+ if (pSpatialLayer->iVideoWidth == 0) {
+ pSpatialLayer->iVideoWidth = iPicWidth;
+ }
+ if (pSpatialLayer->iVideoHeight == 0) {
+ pSpatialLayer->iVideoHeight = iPicHeight;
+ }
+ if (pSpatialLayer->iSpatialBitrate == 0) {
+ pSpatialLayer->iSpatialBitrate = iTargetBitrate;
+ }
+ if (pSpatialLayer->iMaxSpatialBitrate == 0) {
+ pSpatialLayer->iMaxSpatialBitrate = iMaxBitrate;
+ }
+ }
+
//multi slice
pSpatialLayer->sSliceArgument = pCodingParam.sSpatialLayers[iIdxSpatial].sSliceArgument;
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -488,13 +488,24 @@
for (i = 0; i < pCodingParam->iSpatialLayerNum; ++ i) {
SSpatialLayerConfig* pSpatialLayer = &pCodingParam->sSpatialLayers[i];
- const int32_t kiPicWidth = pSpatialLayer->iVideoWidth;
- const int32_t kiPicHeight = pSpatialLayer->iVideoHeight;
+ int32_t kiPicWidth = pSpatialLayer->iVideoWidth;
+ int32_t kiPicHeight = pSpatialLayer->iVideoHeight;
uint32_t iMbWidth = 0;
uint32_t iMbHeight = 0;
int32_t iMbNumInFrame = 0;
uint32_t iMaxSliceNum = MAX_SLICES_NUM;
int32_t iReturn = 0;
+
+ if ((pCodingParam->iPicWidth > 0) && (pCodingParam->iPicHeight > 0)
+ && (kiPicWidth == 0) && (kiPicHeight == 0)
+ && (pCodingParam->iSpatialLayerNum == 1)) {
+ kiPicWidth = pSpatialLayer->iVideoWidth = pCodingParam->iPicWidth;
+ kiPicHeight = pSpatialLayer->iVideoHeight = pCodingParam->iPicHeight;
+ WelsLog (pLogCtx, WELS_LOG_DEBUG,
+ "ParamValidationExt(), layer resolution is not set, set to general resolution %d x %d",
+ pSpatialLayer->iVideoWidth, pSpatialLayer->iVideoHeight);
+ }
+
if ((kiPicWidth <= 0) || (kiPicHeight <= 0) || (kiPicWidth * kiPicHeight > (MAX_MBS_PER_FRAME << 8))) {
WelsLog (pLogCtx, WELS_LOG_ERROR,
"ParamValidationExt(), width > 0, height > 0, width * height <= %d, invalid %d x %d in dependency layer settings!",