cleanup interface parameters

This commit is contained in:
ruil2 2014-06-16 17:17:24 +08:00
parent 91cd93e5d0
commit 7acf0e5b02
11 changed files with 273 additions and 261 deletions

View File

@ -98,25 +98,28 @@ int32_t WelsWritePpsSyntax (SWelsPPS* pPps, SBitStringAux* pBitStringAux, SParaS
/*!
* \brief initialize pSps based on configurable parameters in svc
* \param pSps SWelsSPS*
* \param layer_param SDLayerParam*, dependency layer parameter
* \param pLayerParam SSpatialLayerConfig dependency layer parameter
* \param pLayerParamInternal SSpatialLayerInternal*, internal dependency layer parameter
* \param iSpsId SPS Id
* \return 0 - successful
* 1 - failed
*/
int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
const int32_t kiNumRefFrame,
int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialLayerInternal* pLayerParamInternal,
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
const uint32_t kiSpsId, const bool kbEnableFrameCropping, bool bEnableRc);
/*!
* \brief initialize subset pSps based on configurable parameters in svc
* \param pSubsetSps SSubsetSps*
* \param layer_param SDLayerParam*, dependency layer parameter
* \param pLayerParam SSpatialLayerConfig dependency layer parameter
* \param pLayerParamInternal SSpatialLayerInternal*, internal dependency layer parameter
* \param kiSpsId SPS Id
* \return 0 - successful
* 1 - failed
*/
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
const int32_t kiNumRefFrame,
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SSpatialLayerConfig* pLayerParam,
SSpatialLayerInternal* pLayerParamInternal,
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
const uint32_t kiSpsId, const bool kbEnableFrameCropping, bool bEnableRc);
/*!

View File

@ -86,7 +86,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType);
EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum);
int32_t GetTemporalLevel (SDLayerParam* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize);
int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize);
/*!
* \brief Dump reconstruction for dependency layer
*/

View File

@ -80,37 +80,24 @@ static inline uint32_t GetLogFactor (float base, float upper) {
typedef struct TagDLayerParam {
int32_t iActualWidth; // input source picture actual width
int32_t iActualHeight; // input source picture actual height
int32_t iFrameWidth; // frame width
int32_t iFrameHeight; // frame height
int32_t iSpatialBitrate;
/* temporal settings related */
int32_t iTemporalResolution;
int32_t iDecompositionStages;
uint8_t uiCodingIdx2TemporalId[ (1 << MAX_TEMPORAL_LEVEL) + 1];
uint8_t uiProfileIdc; // value of profile IDC (0 for auto-detection)
uint8_t uiLevelIdc;
int8_t iHighestTemporalId;
// uint8_t uiDependencyId;
int8_t iDLayerQp;
SSliceConfig sSliceCfg; // multiple slice options
float fInputFrameRate; // input frame rate
float fOutputFrameRate; // output frame rate
#ifdef ENABLE_FRAME_DUMP
char sRecFileName[MAX_FNAME_LEN]; // file to be constructed
#endif//ENABLE_FRAME_DUMP
} SDLayerParam;
} SSpatialLayerInternal;
/*
* Cisco OpenH264 Encoder Parameter Configuration
*/
typedef struct TagWelsSvcCodingParam: SEncParamExt {
SDLayerParam sDependencyLayers[MAX_DEPENDENCY_LAYER];
SSpatialLayerInternal sDependencyLayers[MAX_DEPENDENCY_LAYER];
/* General */
uint32_t uiGopSize; // GOP size (at maximal frame rate: 16)
@ -217,19 +204,19 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
memset (sDependencyLayers, 0, sizeof (SDLayerParam)*MAX_DEPENDENCY_LAYER);
memset (sDependencyLayers, 0, sizeof (SSpatialLayerInternal)*MAX_DEPENDENCY_LAYER);
memset (sSpatialLayers, 0 , sizeof (SSpatialLayerConfig)*MAX_SPATIAL_LAYER_NUM);
//init multi-slice
sDependencyLayers[0].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 1;
sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 1;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
sDependencyLayers[0].iDLayerQp = SVC_QUALITY_BASE_QP;
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
sSpatialLayers[0].iDLayerQp = SVC_QUALITY_BASE_QP;
}
@ -251,13 +238,13 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
iRCMode = pCodingParam.iRCMode; // rc mode
int8_t iIdxSpatial = 0;
uint8_t uiProfileIdc = PRO_BASELINE;
EProfileIdc uiProfileIdc = PRO_BASELINE;
SDLayerParam* pDlp = &sDependencyLayers[0];
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
while (iIdxSpatial < iSpatialLayerNum) {
pDlp->uiProfileIdc = uiProfileIdc;
sSpatialLayers->uiProfileIdc = uiProfileIdc;
sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate,
MIN_FRAME_RATE, MAX_FRAME_RATE);
pDlp->fInputFrameRate =
@ -267,15 +254,12 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP
pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth;
pDlp->iFrameWidth = pDlp->iActualWidth;
pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight;
pDlp->iFrameHeight = pDlp->iActualHeight;
pDlp->iSpatialBitrate =
sSpatialLayers->iSpatialBitrate =
sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer
pDlp->iDLayerQp = SVC_QUALITY_BASE_QP;
sSpatialLayers->iDLayerQp = SVC_QUALITY_BASE_QP;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
@ -390,18 +374,20 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
pCodingParam.bEnableSpsPpsIdAddition;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
//SHOULD enable this feature.
SDLayerParam* pDlp = &sDependencyLayers[0];
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
float fMaxFr = .0f;
uint8_t uiProfileIdc = PRO_BASELINE;
EProfileIdc uiProfileIdc = PRO_BASELINE;
int8_t iIdxSpatial = 0;
while (iIdxSpatial < iSpatialLayerNum) {
pDlp->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc :
pSpatialLayer->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc :
pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc;
pDlp->uiLevelIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc == LEVEL_UNKNOWN) ? LEVEL_5_0 :
pSpatialLayer->uiLevelIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc == LEVEL_UNKNOWN) ? LEVEL_5_0 :
pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc;
float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
MIN_FRAME_RATE, fParamMaxFrameRate);
pSpatialLayer->fFrameRate =
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
if (pDlp->fInputFrameRate > fMaxFr + EPSN)
@ -410,26 +396,27 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
#ifdef ENABLE_FRAME_DUMP
pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP
pDlp->iFrameWidth = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth; // frame width
pDlp->iFrameHeight = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight;// frame height
pDlp->iSpatialBitrate =
pSpatialLayer->iVideoWidth = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth; // frame width
pSpatialLayer->iVideoHeight = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight;// frame height
pSpatialLayer->iSpatialBitrate =
pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer
//multi slice
pDlp->sSliceCfg.uiSliceMode = pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.uiSliceMode;
pDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint
pSpatialLayer->sSliceCfg.uiSliceMode = pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.uiSliceMode;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint
= (uint32_t) (pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
pDlp->sSliceCfg.sSliceArgument.uiSliceNum
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum
= pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceNum;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
memcpy (pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum,
memcpy (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum,
pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage
kiLesserSliceNum * sizeof (uint32_t)) ;
pDlp->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
pSpatialLayer->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ pSpatialLayer;
++ iIdxSpatial;
}
@ -444,15 +431,14 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
void SetActualPicResolution() {
int32_t iSpatialIdx = iSpatialLayerNum - 1;
SDLayerParam* pDlayer = &sDependencyLayers[iSpatialIdx];
for (; iSpatialIdx >= 0; iSpatialIdx --) {
pDlayer = &sDependencyLayers[iSpatialIdx];
SSpatialLayerInternal* pDlayerInternal = &sDependencyLayers[iSpatialIdx];
SSpatialLayerConfig* pDlayer = &sSpatialLayers[iSpatialIdx];
pDlayer->iActualWidth = pDlayer->iFrameWidth;
pDlayer->iActualHeight = pDlayer->iFrameHeight;
pDlayer->iFrameWidth = WELS_ALIGN (pDlayer->iActualWidth, MB_WIDTH_LUMA);
pDlayer->iFrameHeight = WELS_ALIGN (pDlayer->iActualHeight, MB_HEIGHT_LUMA);
pDlayerInternal->iActualWidth = pDlayer->iVideoWidth;
pDlayerInternal->iActualHeight = pDlayer->iVideoHeight;
pDlayer->iVideoWidth = WELS_ALIGN (pDlayerInternal->iActualWidth, MB_WIDTH_LUMA);
pDlayer->iVideoHeight = WELS_ALIGN (pDlayerInternal->iActualHeight, MB_HEIGHT_LUMA);
}
}
@ -465,8 +451,9 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
const int32_t iDecStages = WELS_LOG2 (
uiGopSize); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize)
const uint8_t* pTemporalIdList = &g_kuiTemporalIdListTable[iDecStages][0];
SDLayerParam* pDlp = &sDependencyLayers[0];
uint8_t uiProfileIdc = PRO_BASELINE;
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
EProfileIdc uiProfileIdc = PRO_BASELINE;
int8_t i = 0;
while (i < iSpatialLayerNum) {
@ -476,7 +463,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
int8_t iMaxTemporalId = 0;
memset (pDlp->uiCodingIdx2TemporalId, INVALID_TEMPORAL_ID, sizeof (pDlp->uiCodingIdx2TemporalId));
pDlp->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE;
pSpatialLayer->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE;
iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1;
for (uint32_t uiFrameIdx = 0; uiFrameIdx <= uiGopSize; ++ uiFrameIdx) {
@ -495,6 +482,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ pSpatialLayer;
++ i;
}
iDecompStages = (int8_t)iDecStages;

View File

@ -356,14 +356,14 @@ static inline bool WelsGetPaddingOffset (int32_t iActualWidth, int32_t iActualHe
return (iWidth > iActualWidth) || (iHeight > iActualHeight);
}
int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
const int32_t kiNumRefFrame,
int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialLayerInternal* pLayerParamInternal,
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc) {
memset (pSps, 0, sizeof (SWelsSPS));
pSps->uiSpsId = kuiSpsId;
pSps->iMbWidth = (pLayerParam->iFrameWidth + 15) >> 4;
pSps->iMbHeight = (pLayerParam->iFrameHeight + 15) >> 4;
pSps->iMbWidth = (pLayerParam->iVideoWidth + 15) >> 4;
pSps->iMbHeight = (pLayerParam->iVideoHeight + 15) >> 4;
if (0 == kuiIntraPeriod) {
//max value of both iFrameNum and POC are 2^16-1, in our encoder, iPOC=2*iFrameNum, so max of iFrameNum should be 2^15-1.--
@ -380,8 +380,8 @@ int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t k
if (kbEnableFrameCropping) {
// TODO: get frame_crop_left_offset, frame_crop_right_offset, frame_crop_top_offset, frame_crop_bottom_offset
pSps->bFrameCroppingFlag = WelsGetPaddingOffset (pLayerParam->iActualWidth, pLayerParam->iActualHeight,
pLayerParam->iFrameWidth, pLayerParam->iFrameHeight, pSps->sFrameCrop);
pSps->bFrameCroppingFlag = WelsGetPaddingOffset (pLayerParamInternal->iActualWidth, pLayerParamInternal->iActualHeight,
pLayerParam->iVideoWidth, pLayerParam->iVideoHeight, pSps->sFrameCrop);
} else {
pSps->bFrameCroppingFlag = false;
}
@ -389,9 +389,9 @@ int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t k
pSps->uiProfileIdc = pLayerParam->uiProfileIdc ? pLayerParam->uiProfileIdc : PRO_BASELINE;
if (bEnableRc) //fixed QP condition
pSps->iLevelIdc = WelsGetLevelIdc (pSps, pLayerParam->fOutputFrameRate, pLayerParam->iSpatialBitrate);
pSps->iLevelIdc = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate, pLayerParam->iSpatialBitrate);
else
pSps->iLevelIdc = WelsGetLevelIdc (pSps, pLayerParam->fOutputFrameRate,
pSps->iLevelIdc = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate,
0); // Set tar_br = 0 to remove the bitrate constraint; a better way is to set actual tar_br as 0
//for Scalable Baseline, Scalable High, and Scalable High Intra profiles.If level_idc is equal to 9, the indicated level is level 1b.
@ -405,14 +405,16 @@ int32_t WelsInitSps (SWelsSPS* pSps, SDLayerParam* pLayerParam, const uint32_t k
}
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod,
const int32_t kiNumRefFrame,
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SSpatialLayerConfig* pLayerParam,
SSpatialLayerInternal* pLayerParamInternal,
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc) {
SWelsSPS* pSps = &pSubsetSps->pSps;
memset (pSubsetSps, 0, sizeof (SSubsetSps));
WelsInitSps (pSps, pLayerParam, kuiIntraPeriod, kiNumRefFrame, kuiSpsId, kbEnableFrameCropping, bEnableRc);
WelsInitSps (pSps, pLayerParam, pLayerParamInternal, kuiIntraPeriod, kiNumRefFrame, kuiSpsId, kbEnableFrameCropping,
bEnableRc);
pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc :
PRO_SCALABLE_BASELINE;

View File

@ -719,7 +719,7 @@ void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, co
void PerformDeblockingFilter (sWelsEncCtx* pEnc) {
const int32_t kiCurDid = pEnc->uiDependencyId;
SWelsSvcCodingParam* pSvcParam = pEnc->pSvcParam;
SDLayerParam* pDlp = &pSvcParam->sDependencyLayers[kiCurDid];
SSpatialLayerConfig* pSpatialLayer = &pSvcParam->sSpatialLayers[kiCurDid];
SDqLayer* pCurLayer = pEnc->pCurDqLayer;
if (pCurLayer->iLoopFilterDisableIdc == 0) {
@ -728,7 +728,7 @@ void PerformDeblockingFilter (sWelsEncCtx* pEnc) {
int32_t iSliceCount = 0;
int32_t iSliceIdx = 0;
if (SM_DYN_SLICE != pDlp->sSliceCfg.uiSliceMode) {
if (SM_DYN_SLICE != pSpatialLayer->sSliceCfg.uiSliceMode) {
iSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx);
do {
DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx);

View File

@ -85,7 +85,7 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) {
return ENC_RETURN_UNSUPPORTED_PARA;
}
for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
SDLayerParam* fDlp = &pCfg->sDependencyLayers[i];
SSpatialLayerInternal* fDlp = &pCfg->sDependencyLayers[i];
if (fDlp->fOutputFrameRate > fDlp->fInputFrameRate || (fDlp->fInputFrameRate >= -fEpsn
&& fDlp->fInputFrameRate <= fEpsn)
|| (fDlp->fOutputFrameRate >= -fEpsn && fDlp->fOutputFrameRate <= fEpsn)) {
@ -103,7 +103,7 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) {
}
for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
SDLayerParam* fDlp = &pCfg->sDependencyLayers[i];
SSpatialLayerInternal* fDlp = &pCfg->sDependencyLayers[i];
if (fDlp->fInputFrameRate > fMaxFrameRate)
fMaxFrameRate = fDlp->fInputFrameRate;
}
@ -117,8 +117,8 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) {
if (pCfg->iRCMode != RC_OFF_MODE) {
int32_t iTotalBitrate = 0;
for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
SDLayerParam* fDlp = &pCfg->sDependencyLayers[i];
iTotalBitrate += fDlp->iSpatialBitrate;
SSpatialLayerConfig* pSpatialLayer = &pCfg->sSpatialLayers[i];
iTotalBitrate += pSpatialLayer->iSpatialBitrate;
}
if (iTotalBitrate > pCfg->iTargetBitrate) {
WelsLog (pLogCtx, WELS_LOG_ERROR,
@ -190,9 +190,9 @@ int32_t ParamValidationExt (SLogContext* pCtx, SWelsSvcCodingParam* pCodingParam
}
for (i = 0; i < pCodingParam->iSpatialLayerNum; ++ i) {
SDLayerParam* fDlp = &pCodingParam->sDependencyLayers[i];
const int32_t kiPicWidth = fDlp->iFrameWidth;
const int32_t kiPicHeight = fDlp->iFrameHeight;
SSpatialLayerConfig* pSpatialLayer = &pCodingParam->sSpatialLayers[i];
const int32_t kiPicWidth = pSpatialLayer->iVideoWidth;
const int32_t kiPicHeight = pSpatialLayer->iVideoHeight;
uint32_t iMbWidth = 0;
uint32_t iMbHeight = 0;
int32_t iMbNumInFrame = 0;
@ -209,118 +209,119 @@ int32_t ParamValidationExt (SLogContext* pCtx, SWelsSvcCodingParam* pCodingParam
return ENC_RETURN_UNSUPPORTED_PARA;
}
if (fDlp->sSliceCfg.uiSliceMode >= SM_RESERVED) {
if (pSpatialLayer->sSliceCfg.uiSliceMode >= SM_RESERVED) {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMode (%d) settings!\n",
fDlp->sSliceCfg.uiSliceMode);
pSpatialLayer->sSliceCfg.uiSliceMode);
return ENC_RETURN_UNSUPPORTED_PARA;
}
if ((pCodingParam->uiMaxNalSize != 0) && (fDlp->sSliceCfg.uiSliceMode != SM_DYN_SLICE)) {
if ((pCodingParam->uiMaxNalSize != 0) && (pSpatialLayer->sSliceCfg.uiSliceMode != SM_DYN_SLICE)) {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMode (%d) settings!,MaxNalSize = %d\n",
fDlp->sSliceCfg.uiSliceMode, pCodingParam->uiMaxNalSize);
pSpatialLayer->sSliceCfg.uiSliceMode, pCodingParam->uiMaxNalSize);
return ENC_RETURN_UNSUPPORTED_PARA;
}
//check pSlice settings under multi-pSlice
if (kiPicWidth <= 16 && kiPicHeight <= 16) {
//only have one MB, set to single_slice
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
}
switch (fDlp->sSliceCfg.uiSliceMode) {
switch (pSpatialLayer->sSliceCfg.uiSliceMode) {
case SM_SINGLE_SLICE:
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 0;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 0;
for (iIdx = 0; iIdx < MAX_SLICES_NUM; iIdx++) {
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[iIdx] = 0;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[iIdx] = 0;
}
break;
case SM_FIXEDSLCNUM_SLICE: {
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
iMbWidth = (kiPicWidth + 15) >> 4;
iMbHeight = (kiPicHeight + 15) >> 4;
iMbNumInFrame = iMbWidth * iMbHeight;
iMaxSliceNum = MAX_SLICES_NUM;
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0
|| fDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) {
if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum <= 0
|| pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum);
return ENC_RETURN_UNSUPPORTED_PARA;
}
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) {
if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum == 1) {
WelsLog (pCtx, WELS_LOG_DEBUG,
"ParamValidationExt(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum);
pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
break;
}
if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom
//check uiSliceNum
GomValidCheckSliceNum (iMbWidth, iMbHeight, &fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
assert (fDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1);
GomValidCheckSliceNum (iMbWidth, iMbHeight, &pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum);
assert (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > 1);
//set uiSliceMbNum with current uiSliceNum
GomValidCheckSliceMbNum (iMbWidth, iMbHeight, &fDlp->sSliceCfg.sSliceArgument);
GomValidCheckSliceMbNum (iMbWidth, iMbHeight, &pSpatialLayer->sSliceCfg.sSliceArgument);
} else if (!CheckFixedSliceNumMultiSliceSetting (iMbNumInFrame,
&fDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
&pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
//check uiSliceMbNum with current uiSliceNum
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
return ENC_RETURN_UNSUPPORTED_PARA;
}
// considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting
if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) {
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1;
break;
}
}
break;
case SM_AUTO_SLICE: {
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
}
break;
case SM_RASTER_SLICE: {
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
iMbWidth = (kiPicWidth + 15) >> 4;
iMbHeight = (kiPicHeight + 15) >> 4;
iMbNumInFrame = iMbWidth * iMbHeight;
iMaxSliceNum = MAX_SLICES_NUM;
if (fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0] <= 0) {
if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0] <= 0) {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
return ENC_RETURN_UNSUPPORTED_PARA;
}
if (!CheckRasterMultiSliceSetting (iMbNumInFrame, &fDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
if (!CheckRasterMultiSliceSetting (iMbNumInFrame,
&pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
return ENC_RETURN_UNSUPPORTED_PARA;
}
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0
|| fDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) { // verify interleave mode settings
if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum <= 0
|| pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) { // verify interleave mode settings
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) in SM_RASTER_SLICE settings!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum);
return ENC_RETURN_UNSUPPORTED_PARA;
}
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) {
if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum == 1) {
WelsLog (pCtx, WELS_LOG_ERROR,
"ParamValidationExt(), pSlice setting for SM_RASTER_SLICE now turn to SM_SINGLE_SLICE!\n");
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
break;
}
if ((pCodingParam->iRCMode != RC_OFF_MODE) && fDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1) {
if ((pCodingParam->iRCMode != RC_OFF_MODE) && pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > 1) {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), WARNING: GOM based RC do not support SM_RASTER_SLICE!\n");
}
// considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting
if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) {
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1;
break;
}
}
break;
case SM_ROWMB_SLICE: {
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
iMbWidth = (kiPicWidth + 15) >> 4;
iMbHeight = (kiPicHeight + 15) >> 4;
@ -329,16 +330,17 @@ int32_t ParamValidationExt (SLogContext* pCtx, SWelsSvcCodingParam* pCodingParam
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings more than MAX!\n", iMbHeight);
return ENC_RETURN_UNSUPPORTED_PARA;
}
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight;
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0) {
if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum <= 0) {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum);
return ENC_RETURN_UNSUPPORTED_PARA;
}
if (!CheckRowMbMultiSliceSetting (iMbWidth, &fDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
if (!CheckRowMbMultiSliceSetting (iMbWidth,
&pSpatialLayer->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
return ENC_RETURN_UNSUPPORTED_PARA;
}
}
@ -346,9 +348,9 @@ int32_t ParamValidationExt (SLogContext* pCtx, SWelsSvcCodingParam* pCodingParam
case SM_DYN_SLICE: {
iMbWidth = (kiPicWidth + 15) >> 4;
iMbHeight = (kiPicHeight + 15) >> 4;
if (fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint <= 0) {
if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint <= 0) {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid iSliceSize (%d) settings!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
return ENC_RETURN_UNSUPPORTED_PARA;
}
@ -358,24 +360,25 @@ int32_t ParamValidationExt (SLogContext* pCtx, SWelsSvcCodingParam* pCodingParam
return ENC_RETURN_UNSUPPORTED_PARA;
}
if (fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint > (pCodingParam->uiMaxNalSize - NAL_HEADER_ADD_0X30BYTES)) {
if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint > (pCodingParam->uiMaxNalSize -
NAL_HEADER_ADD_0X30BYTES)) {
WelsLog (pCtx, WELS_LOG_WARNING,
"ParamValidationExt(), slice mode = SM_DYN_SLICE, uiSliceSizeConstraint = %d ,uiMaxNalsize = %d!\n",
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint, pCodingParam->uiMaxNalSize);
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = pCodingParam->uiMaxNalSize - NAL_HEADER_ADD_0X30BYTES;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint, pCodingParam->uiMaxNalSize);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = pCodingParam->uiMaxNalSize - NAL_HEADER_ADD_0X30BYTES;
}
// considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting
if (iMbWidth * iMbHeight <= MIN_NUM_MB_PER_SLICE) {
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1;
break;
}
}
break;
default: {
WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMode (%d) settings!\n",
pCodingParam->sDependencyLayers[0].sSliceCfg.uiSliceMode);
pCodingParam->sSpatialLayers[0].sSliceCfg.uiSliceMode);
return ENC_RETURN_UNSUPPORTED_PARA;
}
@ -388,7 +391,7 @@ int32_t ParamValidationExt (SLogContext* pCtx, SWelsSvcCodingParam* pCodingParam
void WelsEncoderApplyFrameRate (SWelsSvcCodingParam* pParam) {
SDLayerParam* pLayerParam;
SSpatialLayerInternal* pLayerParam;
const float kfEpsn = 0.000001f;
const int32_t kiNumLayer = pParam->iSpatialLayerNum;
int32_t i;
@ -416,7 +419,7 @@ void WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam,
//TODO (Sijia): this is a temporary solution which keep the ratio between layers
//but it is also possible to fulfill the bitrate of lower layer first
SDLayerParam* pLayerParam;
SSpatialLayerConfig* pLayerParam;
const int32_t iNumLayers = pParam->iSpatialLayerNum;
int32_t i, iOrigTotalBitrate = 0;
if (iLayer == SPATIAL_LAYER_ALL) {
@ -428,12 +431,12 @@ void WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam,
}
//read old BR
for (i = 0; i < iNumLayers; i++) {
iOrigTotalBitrate += pParam->sDependencyLayers[i].iSpatialBitrate;
iOrigTotalBitrate += pParam->sSpatialLayers[i].iSpatialBitrate;
}
//write new BR
float fRatio = 0.0;
for (i = 0; i < iNumLayers; i++) {
pLayerParam = & (pParam->sDependencyLayers[i]);
pLayerParam = & (pParam->sSpatialLayers[i]);
fRatio = pLayerParam->iSpatialBitrate / (static_cast<float> (iOrigTotalBitrate));
pLayerParam->iSpatialBitrate = static_cast<int32_t> (pParam->iTargetBitrate * fRatio);
}
@ -468,7 +471,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara
iNumDependencyLayers = pParam->iSpatialLayerNum;
do {
SDLayerParam* pDLayer = &pParam->sDependencyLayers[iDIndex];
SSpatialLayerConfig* pDLayer = &pParam->sSpatialLayers[iDIndex];
// pDLayer->ptr_cfg = pParam;
int32_t iOrgNumNals = iCountNumNals;
@ -484,8 +487,8 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara
// MAX_SLICES_NUM < MAX_LAYER_NUM_OF_FRAME ensured at svc_enc_slice_segment.h
assert (iCountNumNals - iOrgNumNals <= MAX_NAL_UNITS_IN_LAYER);
} else { /*if ( SM_SINGLE_SLICE != pDLayer->sSliceCfg.uiSliceMode )*/
const int32_t kiNumOfSlice = GetInitialSliceNum ((pDLayer->iFrameWidth + 0x0f) >> 4,
(pDLayer->iFrameHeight + 0x0f) >> 4,
const int32_t kiNumOfSlice = GetInitialSliceNum ((pDLayer->iVideoWidth + 0x0f) >> 4,
(pDLayer->iVideoHeight + 0x0f) >> 4,
&pDLayer->sSliceCfg);
// NEED check iCountNals value in case multiple slices is used
@ -616,8 +619,8 @@ int32_t InitMbListD (sWelsEncCtx** ppCtx) {
return 1;
for (i = 0; i < iNumDlayer; i++) {
iMbWidth = ((*ppCtx)->pSvcParam->sDependencyLayers[i].iFrameWidth + 15) >> 4;
iMbHeight = ((*ppCtx)->pSvcParam->sDependencyLayers[i].iFrameHeight + 15) >> 4;
iMbWidth = ((*ppCtx)->pSvcParam->sSpatialLayers[i].iVideoWidth + 15) >> 4;
iMbHeight = ((*ppCtx)->pSvcParam->sSpatialLayers[i].iVideoHeight + 15) >> 4;
iMbSize[i] = iMbWidth * iMbHeight;
iOverallMbNum += iMbSize[i];
}
@ -733,8 +736,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
while (iDlayerIndex < iDlayerCount) {
SRefList* pRefList = NULL;
uint32_t i = 0;
const int32_t kiWidth = pParam->sDependencyLayers[iDlayerIndex].iFrameWidth;
const int32_t kiHeight = pParam->sDependencyLayers[iDlayerIndex].iFrameHeight;
const int32_t kiWidth = pParam->sSpatialLayers[iDlayerIndex].iVideoWidth;
const int32_t kiHeight = pParam->sSpatialLayers[iDlayerIndex].iVideoHeight;
int32_t iPicWidth = WELS_ALIGN (kiWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with iWidth of horizon
int32_t iPicChromaWidth = iPicWidth >> 1;
@ -762,9 +765,9 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
iDlayerIndex = 0;
while (iDlayerIndex < iDlayerCount) {
SDqLayer* pDqLayer = NULL;
SDLayerParam* pDlayer = &pParam->sDependencyLayers[iDlayerIndex];
const int32_t kiMbW = (pDlayer->iFrameWidth + 0x0f) >> 4;
const int32_t kiMbH = (pDlayer->iFrameHeight + 0x0f) >> 4;
SSpatialLayerConfig* pDlayer = &pParam->sSpatialLayers[iDlayerIndex];
const int32_t kiMbW = (pDlayer->iVideoWidth + 0x0f) >> 4;
const int32_t kiMbH = (pDlayer->iVideoHeight + 0x0f) >> 4;
int32_t iMaxSliceNum = 1;
const int32_t kiSliceNum = GetInitialSliceNum (kiMbW, kiMbH, &pDlayer->sSliceCfg);
if (iMaxSliceNum < kiSliceNum)
@ -851,7 +854,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof (
SFeatureSearchPreparation), "pFeatureSearchPreparation"));
WELS_VERIFY_RETURN_PROC_IF (1, NULL == pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx));
int32_t iReturn = RequestFeatureSearchPreparation (pMa, pDlayer->iFrameWidth, pDlayer->iFrameHeight,
int32_t iReturn = RequestFeatureSearchPreparation (pMa, pDlayer->iVideoWidth, pDlayer->iVideoHeight,
kiNeedFeatureStorage,
pDqLayer->pFeatureSearchPreparation);
WELS_VERIFY_RETURN_PROC_IF (1, ENC_RETURN_SUCCESS != iReturn, FreeMemorySvc (ppCtx));
@ -882,7 +885,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
while (iDlayerIndex < iDlayerCount) {
SDqIdc* pDqIdc = & (*ppCtx)->pDqIdcMap[iDlayerIndex];
const bool bUseSubsetSps = (iDlayerIndex > BASE_DEPENDENCY_ID);
SDLayerParam* pDlayerParam = &pParam->sDependencyLayers[iDlayerIndex];
SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex];
pDqIdc->uiSpatialId = iDlayerIndex;
pPps = & (*ppCtx)->pPPSArray[iPpsId];
@ -895,8 +898,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
// Need port pSps/pPps initialization due to spatial scalability changed
if (!bUseSubsetSps) {
WelsInitSps (pSps, pDlayerParam, pParam->uiIntraPeriod, pParam->iNumRefFrame, iSpsId,
pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, pParam->iNumRefFrame,
iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
if (iDlayerCount > 1) {
pSps->bConstraintSet0Flag = true;
@ -904,8 +907,9 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
pSps->bConstraintSet2Flag = true;
}
} else {
WelsInitSubsetSps (pSubsetSps, pDlayerParam, pParam->uiIntraPeriod, pParam->iNumRefFrame, iSpsId,
pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
pParam->iNumRefFrame,
iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
}
// initialize pPps
@ -984,8 +988,8 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers
iSpatialIdx = 0;
while (iSpatialIdx < kiNumSpatialLayers) {
const int32_t kiTmpWidth = (pParam->sDependencyLayers[iSpatialIdx].iFrameWidth + 15) >> 4;
const int32_t kiTmpHeight = (pParam->sDependencyLayers[iSpatialIdx].iFrameHeight + 15) >> 4;
const int32_t kiTmpWidth = (pParam->sSpatialLayers[iSpatialIdx].iVideoWidth + 15) >> 4;
const int32_t kiTmpHeight = (pParam->sSpatialLayers[iSpatialIdx].iVideoHeight + 15) >> 4;
int32_t iNumMb = kiTmpWidth * kiTmpHeight;
sMbSizeMap[iSpatialIdx].iMbWidth = kiTmpWidth;
@ -1005,9 +1009,9 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers
iSpatialIdx = 0;
while (iSpatialIdx < kiNumSpatialLayers) {
SDLayerParam* fDlp = &pParam->sDependencyLayers[iSpatialIdx];
SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iSpatialIdx];
const int32_t kiWidthPad = WELS_ALIGN (fDlp->iFrameWidth, 16) + (PADDING_LENGTH << 1);
const int32_t kiWidthPad = WELS_ALIGN (fDlp->iVideoWidth, 16) + (PADDING_LENGTH << 1);
iLineSizeY[iSpatialIdx][kbBaseTemporalFlag] = WELS_ALIGN (kiWidthPad, 32);
iLineSizeUV[iSpatialIdx][kbBaseTemporalFlag] = WELS_ALIGN ((kiWidthPad >> 1), 16);
@ -1230,7 +1234,7 @@ void ReleaseMemoryVaaScreen (SVAAFrameInfo* pVaa, CMemoryAlign* pMa, const int3
int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam;
CMemoryAlign* pMa = (*ppCtx)->pMemAlign;
SDLayerParam* pFinalSpatial = NULL;
SSpatialLayerConfig* pFinalSpatial = NULL;
int32_t iCountBsLen = 0;
int32_t iCountNals = 0;
int32_t iMaxPicWidth = 0;
@ -1265,9 +1269,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
return 1;
}
pFinalSpatial = &pParam->sDependencyLayers[kiNumDependencyLayers - 1];
iMaxPicWidth = pFinalSpatial->iFrameWidth;
iMaxPicHeight = pFinalSpatial->iFrameHeight;
pFinalSpatial = &pParam->sSpatialLayers[kiNumDependencyLayers - 1];
iMaxPicWidth = pFinalSpatial->iVideoWidth;
iMaxPicHeight = pFinalSpatial->iVideoHeight;
iCountMaxMbNum = ((15 + iMaxPicWidth) >> 4) * ((15 + iMaxPicHeight) >> 4);
iResult = AcquireLayersNals (ppCtx, pParam, &iCountLayers, &iCountNals);
@ -1283,11 +1287,11 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
int32_t iLayerBsSize = 0;
iIndex = 0;
while (iIndex < pParam->iSpatialLayerNum) {
SDLayerParam* fDlp = &pParam->sDependencyLayers[iIndex];
SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iIndex];
fCompressRatioThr = COMPRESS_RATIO_THR;
iLayerBsSize = WELS_ROUND (((3 * fDlp->iFrameWidth * fDlp->iFrameHeight) >> 1) * fCompressRatioThr) +
iLayerBsSize = WELS_ROUND (((3 * fDlp->iVideoWidth * fDlp->iVideoHeight) >> 1) * fCompressRatioThr) +
MAX_MACROBLOCK_SIZE_IN_BYTE;
iLayerBsSize = WELS_ALIGN (iLayerBsSize, 4); // 4 bytes alinged
iVclLayersBsSizeCount += iLayerBsSize;
@ -1581,7 +1585,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
if (NULL != pCtx->ppDqLayerList && pParam != NULL) {
while (ilayer < pParam->iSpatialLayerNum) {
SDqLayer* pDq = pCtx->ppDqLayerList[ilayer];
SDLayerParam* pDlp = &pCtx->pSvcParam->sDependencyLayers[ilayer];
SSpatialLayerConfig* pDlp = &pCtx->pSvcParam->sSpatialLayers[ilayer];
const bool kbIsDynamicSlicing = (SM_DYN_SLICE == pDlp->sSliceCfg.uiSliceMode);
@ -1740,11 +1744,11 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar
uint16_t iMaxSliceCount = 0;
do {
SDLayerParam* pDlp = &pCodingParam->sDependencyLayers[iSpatialIdx];
SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[iSpatialIdx];
SSliceConfig* pMso = &pDlp->sSliceCfg;
SSliceArgument* pSlcArg = &pMso->sSliceArgument;
const int32_t kiMbWidth = (pDlp->iFrameWidth + 15) >> 4;
const int32_t kiMbHeight = (pDlp->iFrameHeight + 15) >> 4;
const int32_t kiMbWidth = (pDlp->iVideoWidth + 15) >> 4;
const int32_t kiMbHeight = (pDlp->iVideoHeight + 15) >> 4;
const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight;
int32_t iSliceNum = (SM_AUTO_SLICE == pMso->uiSliceMode) ? kiCpuCores : pSlcArg->uiSliceNum;
// NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode,
@ -2155,7 +2159,7 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
/*!
* \brief get temporal level due to configuration and coding context
*/
int32_t GetTemporalLevel (SDLayerParam* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize) {
int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize) {
const int32_t kiCodingIdx = kiFrameNum & (kiGopSize - 1);
return fDlp->uiCodingIdx2TemporalId[kiCodingIdx];
@ -2274,12 +2278,12 @@ void WelsInitCurrentDlayerMltslc (sWelsEncCtx* pCtx, int32_t iPartitionNum) {
if (pCtx->pSvcParam->iRCMode != RC_OFF_MODE) {
//RC case
uiFrmByte = (
((uint32_t) (pCtx->pSvcParam->sDependencyLayers[iCurDid].iSpatialBitrate)
((uint32_t) (pCtx->pSvcParam->sSpatialLayers[iCurDid].iSpatialBitrate)
/ (uint32_t) (pCtx->pSvcParam->sDependencyLayers[iCurDid].fInputFrameRate)) >> 3);
} else {
//fixed QP case
const int32_t iTtlMbNumInFrame = pSliceCtx->iMbNumInFrame;
int32_t iQDeltaTo26 = (26 - pCtx->pSvcParam->sDependencyLayers[iCurDid].iDLayerQp);
int32_t iQDeltaTo26 = (26 - pCtx->pSvcParam->sSpatialLayers[iCurDid].iDLayerQp);
uiFrmByte = (iTtlMbNumInFrame * byte_complexIMBat26);
if (iQDeltaTo26 > 0) {
@ -2325,7 +2329,7 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx,
SSlice* pSlice = NULL;
const uint8_t kiCurDid = pCtx->uiDependencyId;
const bool kbUseSubsetSpsFlag = (kiCurDid > BASE_DEPENDENCY_ID);
SDLayerParam* fDlp = &pParam->sDependencyLayers[kiCurDid];
SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[kiCurDid];
SNalUnitHeaderExt* pNalHdExt = &pCurDq->sLayerInfo.sNalHeaderExt;
SNalUnitHeader* pNalHd = &pNalHdExt->sNalHeader;
SDqIdc* pDqIdc = &pCtx->pDqIdcMap[kiCurDid];
@ -2962,7 +2966,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
while (iSpatialIdx < iSpatialNum) {
const int32_t iDidIdx = (pSpatialIndexMap + iSpatialIdx)->iDid; // get iDid
SDLayerParam* pParam = &pSvcParam->sDependencyLayers[iDidIdx];
SSpatialLayerConfig* pParam = &pSvcParam->sSpatialLayers[iDidIdx];
pCtx->uiDependencyId = iCurDid = (int8_t)iDidIdx;
pCtx->pVpp->AnalyzeSpatialPic (pCtx, iDidIdx);
@ -2971,8 +2975,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
pCtx->pEncPic->iPictureType = pCtx->eSliceType;
pCtx->pEncPic->iFramePoc = pCtx->iPOC;
iCurWidth = pParam->iFrameWidth;
iCurHeight = pParam->iFrameHeight;
iCurWidth = pParam->iVideoWidth;
iCurHeight = pParam->iVideoHeight;
iDidList[iSpatialIdx] = iCurDid;
@ -2982,8 +2986,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
case SM_FIXEDSLCNUM_SLICE:
case SM_AUTO_SLICE: {
if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) &&
(pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum)
(pSvcParam->sSpatialLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sSpatialLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum)
)
AdjustEnhanceLayer (pCtx, iCurDid);
break;
@ -3297,7 +3301,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
if (
(!pCtx->pCurDqLayer->bDeblockingParallelFlag) &&
#if !defined(ENABLE_FRAME_DUMP)
((eNalRefIdc != NRI_PRI_LOWEST) && (pParam->iHighestTemporalId == 0 || iCurTid < pParam->iHighestTemporalId)) &&
((eNalRefIdc != NRI_PRI_LOWEST) && (pSvcParam->sDependencyLayers[iDidIdx].iHighestTemporalId == 0
|| iCurTid < pSvcParam->sDependencyLayers[iDidIdx].iHighestTemporalId)) &&
#endif//!ENABLE_FRAME_DUMP
true
) {
@ -3478,12 +3483,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
#endif//MT_DEBUG
if (pSvcParam->iMultipleThreadIdc > 1 && iDidList[0] == BASE_DEPENDENCY_ID
&& ((pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
|| (pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_AUTO_SLICE))
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum
&& ((pSvcParam->sDependencyLayers[iDidList[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
|| (pSvcParam->sDependencyLayers[iDidList[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_AUTO_SLICE))
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iDidList[iSpatialNum -
&& ((pSvcParam->sSpatialLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
|| (pSvcParam->sSpatialLayers[0].sSliceCfg.uiSliceMode == SM_AUTO_SLICE))
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum
&& ((pSvcParam->sSpatialLayers[iDidList[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
|| (pSvcParam->sSpatialLayers[iDidList[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_AUTO_SLICE))
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sSpatialLayers[iDidList[iSpatialNum -
1]].sSliceCfg.sSliceArgument.uiSliceNum) {
AdjustBaseLayer (pCtx);
}
@ -3538,22 +3543,24 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
iIndexD = 0;
assert (pOldParam->iSpatialLayerNum == pNewParam->iSpatialLayerNum);
do {
const SDLayerParam* kpOldDlp = &pOldParam->sDependencyLayers[iIndexD];
const SDLayerParam* kpNewDlp = &pNewParam->sDependencyLayers[iIndexD];
const SSpatialLayerInternal* kpOldDlp = &pOldParam->sDependencyLayers[iIndexD];
const SSpatialLayerInternal* kpNewDlp = &pNewParam->sDependencyLayers[iIndexD];
float fT1 = .0f;
float fT2 = .0f;
// check frame size settings
if (kpOldDlp->iFrameWidth != kpNewDlp->iFrameWidth ||
kpOldDlp->iFrameHeight != kpNewDlp->iFrameHeight ||
if (pOldParam->sSpatialLayers[iIndexD].iVideoWidth != pNewParam->sSpatialLayers[iIndexD].iVideoWidth ||
pOldParam->sSpatialLayers[iIndexD].iVideoHeight != pNewParam->sSpatialLayers[iIndexD].iVideoHeight ||
kpOldDlp->iActualWidth != kpNewDlp->iActualWidth ||
kpOldDlp->iActualHeight != kpNewDlp->iActualHeight) {
bNeedReset = true;
break;
}
if (kpOldDlp->sSliceCfg.uiSliceMode != kpNewDlp->sSliceCfg.uiSliceMode ||
kpOldDlp->sSliceCfg.sSliceArgument.uiSliceNum != kpNewDlp->sSliceCfg.sSliceArgument.uiSliceNum) {
if (pOldParam->sSpatialLayers[iIndexD].sSliceCfg.uiSliceMode != pNewParam->sSpatialLayers[iIndexD].sSliceCfg.uiSliceMode
||
pOldParam->sSpatialLayers[iIndexD].sSliceCfg.sSliceArgument.uiSliceNum !=
pNewParam->sSpatialLayers[iIndexD].sSliceCfg.sSliceArgument.uiSliceNum) {
bNeedReset = true;
break;
}
@ -3653,21 +3660,24 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
// d
iIndexD = 0;
do {
SDLayerParam* pOldDlp = &pOldParam->sDependencyLayers[iIndexD];
SDLayerParam* pNewDlp = &pNewParam->sDependencyLayers[iIndexD];
SSpatialLayerInternal* pOldDlpInternal = &pOldParam->sDependencyLayers[iIndexD];
SSpatialLayerInternal* pNewDlpInternal = &pNewParam->sDependencyLayers[iIndexD];
pOldDlp->fInputFrameRate = pNewDlp->fInputFrameRate; // input frame rate
pOldDlp->fOutputFrameRate = pNewDlp->fOutputFrameRate; // output frame rate
SSpatialLayerConfig* pOldDlp = &pOldParam->sSpatialLayers[iIndexD];
SSpatialLayerConfig* pNewDlp = &pNewParam->sSpatialLayers[iIndexD];
pOldDlpInternal->fInputFrameRate = pNewDlpInternal->fInputFrameRate; // input frame rate
pOldDlpInternal->fOutputFrameRate = pNewDlpInternal->fOutputFrameRate; // output frame rate
pOldDlp->iSpatialBitrate = pNewDlp->iSpatialBitrate;
pOldDlp->uiProfileIdc = pNewDlp->uiProfileIdc; // value of profile IDC (0 for auto-detection)
/* Derived variants below */
pOldDlp->iTemporalResolution = pNewDlp->iTemporalResolution;
pOldDlp->iDecompositionStages = pNewDlp->iDecompositionStages;
pOldDlpInternal->iTemporalResolution = pNewDlpInternal->iTemporalResolution;
pOldDlpInternal->iDecompositionStages = pNewDlpInternal->iDecompositionStages;
memcpy (pOldDlp->uiCodingIdx2TemporalId, pNewDlp->uiCodingIdx2TemporalId,
sizeof (pOldDlp->uiCodingIdx2TemporalId)); // confirmed_safe_unsafe_usage
memcpy (pOldDlpInternal->uiCodingIdx2TemporalId, pNewDlpInternal->uiCodingIdx2TemporalId,
sizeof (pOldDlpInternal->uiCodingIdx2TemporalId)); // confirmed_safe_unsafe_usage
++ iIndexD;
} while (iIndexD < pOldParam->iSpatialLayerNum);

View File

@ -84,7 +84,7 @@ void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t
pBaseMem += kiGomSizeI;
pWelsSvcRc->pTemporalOverRc = (SRCTemporal*)pBaseMem;
pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc(sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC");
pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc (sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC");
}
void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) {
@ -111,7 +111,7 @@ static inline int32_t RcConvertQStep2Qp (int32_t iQpStep) {
void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = NULL;
SDLayerParam* pDLayerParam = NULL;
SSpatialLayerConfig* pDLayerParam = NULL;
int32_t j = 0;
int32_t iMbWidth = 0;
@ -125,9 +125,9 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
for (j = 0; j < pEncCtx->pSvcParam->iSpatialLayerNum; j++) {
SSliceCtx* pSliceCtx = &pEncCtx->pSliceCtxList[j];
pWelsSvcRc = &pEncCtx->pWelsSvcRc[j];
pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[j];
iMbWidth = (pDLayerParam->iFrameWidth >> 4);
pWelsSvcRc->iNumberMbFrame = iMbWidth * (pDLayerParam->iFrameHeight >> 4);
pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[j];
iMbWidth = (pDLayerParam->iVideoWidth >> 4);
pWelsSvcRc->iNumberMbFrame = iMbWidth * (pDLayerParam->iVideoHeight >> 4);
pWelsSvcRc->iSliceNum = pSliceCtx->iSliceNumInFrame;
pWelsSvcRc->iRcVaryPercentage = _BITS_RANGE; // % -- for temp
@ -173,7 +173,7 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iGomSize = (pWelsSvcRc->iNumberMbFrame + pWelsSvcRc->iNumberMbGom - 1) / pWelsSvcRc->iNumberMbGom;
RcInitLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign, 1 + pDLayerParam->iHighestTemporalId);
RcInitLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign, 1 + pEncCtx->pSvcParam->sDependencyLayers[j].iHighestTemporalId);
bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
(SM_ROWMB_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
@ -187,7 +187,7 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
void RcInitTlWeight (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
const int32_t kiDecompositionStages = pDLayerParam->iDecompositionStages;
const int32_t kiHighestTid = pDLayerParam->iHighestTemporalId;
@ -218,15 +218,17 @@ void RcInitTlWeight (sWelsEncCtx* pEncCtx) {
void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages);
const int32_t kiHighestTid = pDLayerParam->iHighestTemporalId;
int32_t input_iBitsPerFrame = WELS_ROUND(pDLayerParam->iSpatialBitrate * INT_MULTIPLY / pDLayerParam->fInputFrameRate);
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
int32_t input_iBitsPerFrame = WELS_ROUND(pDLayerParam->iSpatialBitrate * INT_MULTIPLY / pDLayerParamInternal->fInputFrameRate);
const int32_t kiGopBits = WELS_DIV_ROUND(input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
int32_t i;
pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate;
pWelsSvcRc->fFrameRate = pDLayerParam->fInputFrameRate;
pWelsSvcRc->fFrameRate = pDLayerParamInternal->fInputFrameRate;
int32_t iTargetVaryRange = FRAME_iTargetBits_VARY_RANGE * (MAX_BITS_VARY_PERCENTAGE - pWelsSvcRc->iRcVaryRatio);
int32_t iMinBitsRatio = (MAX_BITS_VARY_PERCENTAGE) * INT_MULTIPLY - iTargetVaryRange;
@ -269,8 +271,9 @@ void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) {
const int32_t kiDid = pEncCtx->uiDependencyId;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
const int32_t kiHighestTid = pDLayerParam->iHighestTemporalId;
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[kiDid];
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
int32_t i;
//I frame R-Q Model
@ -293,7 +296,7 @@ void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) {
//Backup the initial bitrate and fps
pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
pWelsSvcRc->dPreviousFps = pDLayerParam->fInputFrameRate;
pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fInputFrameRate;
memset (pWelsSvcRc->pCurrentFrameGomSad, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
@ -305,13 +308,14 @@ void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) {
bool RcJudgeBitrateFpsUpdate (sWelsEncCtx* pEncCtx) {
int32_t iCurDid = pEncCtx->uiDependencyId;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[iCurDid];
SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[iCurDid];
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[iCurDid];
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[iCurDid];
if ((pWelsSvcRc->iPreviousBitrate != pDLayerParam->iSpatialBitrate) ||
(pWelsSvcRc->dPreviousFps - pDLayerParam->fInputFrameRate) > EPSN ||
(pWelsSvcRc->dPreviousFps - pDLayerParam->fInputFrameRate) < -EPSN) {
(pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fInputFrameRate) > EPSN ||
(pWelsSvcRc->dPreviousFps - pDLayerParamInternal->fInputFrameRate) < -EPSN) {
pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
pWelsSvcRc->dPreviousFps = pDLayerParam->fInputFrameRate;
pWelsSvcRc->dPreviousFps = pDLayerParamInternal->fInputFrameRate;
return true;
} else
return false;
@ -353,7 +357,7 @@ void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) {
void RcUpdateTemporalZero (sWelsEncCtx* pEncCtx) {
const int32_t kiDid = pEncCtx->uiDependencyId;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages);
if (pWelsSvcRc->iPreviousGopSize != kiGopSize) {
@ -385,20 +389,20 @@ void RcInitIdrQp (sWelsEncCtx* pEncCtx) {
int32_t iBppIndex = 0;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
if (pDLayerParam->fOutputFrameRate > EPSN && pDLayerParam->iFrameWidth && pDLayerParam->iFrameHeight)
dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fOutputFrameRate * pDLayerParam->iFrameWidth *
pDLayerParam->iFrameHeight);
if (pDLayerParam->fFrameRate > EPSN && pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight)
dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate * pDLayerParam->iVideoWidth *
pDLayerParam->iVideoHeight);
else
dBpp = 0.1;
//Area*2
if (pDLayerParam->iFrameWidth * pDLayerParam->iFrameHeight <= 28800) // 90p video:160*90
if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 28800) // 90p video:160*90
iBppIndex = 0;
else if (pDLayerParam->iFrameWidth * pDLayerParam->iFrameHeight <= 115200) // 180p video:320*180
else if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 115200) // 180p video:320*180
iBppIndex = 1;
else if (pDLayerParam->iFrameWidth * pDLayerParam->iFrameHeight <= 460800) // 360p video:640*360
else if (pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight <= 460800) // 360p video:640*360
iBppIndex = 2;
else
iBppIndex = 3;
@ -583,20 +587,20 @@ void RcCalculateMbQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, const int32_t kiSliceId
SWelsSvcRc* RcJudgeBaseUsability (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = NULL, *pWelsSvcRc_Base = NULL;
SDLayerParam* pDlpBase = NULL, *pDLayerParam = NULL;
SSpatialLayerConfig* pDlpBase = NULL, *pDLayerParam = NULL;
SSpatialLayerInternal* pDlpBaseInternal = NULL;
if (pEncCtx->uiDependencyId <= 0)
return NULL;
pDlpBase = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId - 1];
pDlpBaseInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId - 1];
pDlpBase = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId - 1];
pWelsSvcRc_Base = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId - 1];
if (pEncCtx->uiTemporalId <= pDlpBase->iDecompositionStages) {
if (pEncCtx->uiTemporalId <= pDlpBaseInternal->iDecompositionStages) {
pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
pWelsSvcRc_Base = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId - 1];
pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
pDlpBase = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId - 1];
if ((pDLayerParam->iFrameWidth * pDLayerParam->iFrameHeight / pWelsSvcRc->iNumberMbGom) ==
(pDlpBase->iFrameWidth * pDlpBase->iFrameHeight / pWelsSvcRc_Base->iNumberMbGom))
pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
pDlpBase = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId - 1];
if ((pDLayerParam->iVideoWidth * pDLayerParam->iVideoHeight / pWelsSvcRc->iNumberMbGom) ==
(pDlpBase->iVideoWidth * pDlpBase->iVideoHeight / pWelsSvcRc_Base->iNumberMbGom))
return pWelsSvcRc_Base;
else
return NULL;
@ -925,7 +929,7 @@ void WelsRcMbInfoUpdateGom (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice*
void WelsRcPictureInitDisable (void* pCtx) {
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
const int32_t kiQp = pDLayerParam->iDLayerQp;
pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp);

View File

@ -356,7 +356,7 @@ bool WelsUpdateRefList (void* pEncCtx) {
sWelsEncCtx* pCtx = (sWelsEncCtx*)pEncCtx;
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
SDLayerParam* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame;
int32_t iRefIdx = 0;
@ -708,7 +708,7 @@ bool WelsUpdateRefListScreen (void* pEncCtx) {
sWelsEncCtx* pCtx = (sWelsEncCtx*)pEncCtx;
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
SDLayerParam* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
const uint8_t kuiTid = pCtx->uiTemporalId;
// Need update ref list in case store base layer or target dependency layer construction
if (NULL == pCtx->pCurDqLayer)
@ -763,9 +763,9 @@ bool WelsBuildRefListScreen (void* pEncCtx, const int32_t iPOC, int32_t iBestLtr
if (pCtx->eSliceType != I_SLICE) {
int iLtrRefIdx = 0;
SPicture *pRefOri = NULL;
SPicture* pRefOri = NULL;
for (int idx = 0; idx < pVaaExt->iNumOfAvailableRef; idx++) {
iLtrRefIdx = pCtx->pVpp->GetRefFrameInfo(idx,pRefOri);
iLtrRefIdx = pCtx->pVpp->GetRefFrameInfo (idx, pRefOri);
if (iLtrRefIdx >= 0 && iLtrRefIdx <= pParam->iLTRRefNum) {
SPicture* pRefPic = pRefList->pLongRefList[iLtrRefIdx];
if (pRefPic != NULL && pRefPic->bUsedAsRef && pRefPic->bIsLongRef) {

View File

@ -322,7 +322,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
iIdx = 0;
while (iIdx < iNumSpatialLayers) {
SSliceConfig* pMso = &pPara->sDependencyLayers[iIdx].sSliceCfg;
SSliceConfig* pMso = &pPara->sSpatialLayers[iIdx].sSliceCfg;
const int32_t kiSliceNum = pMso->sSliceArgument.uiSliceNum;
if (((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pMso->uiSliceMode == SM_AUTO_SLICE))
&& pPara->iMultipleThreadIdc > 1
@ -520,7 +520,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) {
SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam;
SDLayerParam* pDlp = &pCodingParam->sDependencyLayers[pCtx->uiDependencyId];
SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId];
SWelsSliceBs* pSliceBs = NULL;
const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE);
@ -717,7 +717,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
const int32_t kiCurDid = pEncPEncCtx->uiDependencyId;
const int32_t kiCurTid = pEncPEncCtx->uiTemporalId;
SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam;
SDLayerParam* pParamD = &pCodingParam->sDependencyLayers[kiCurDid];
SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid];
pCurDq = pEncPEncCtx->pCurDqLayer;
eNalType = pEncPEncCtx->eNalType;
@ -788,7 +788,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
if (pCurDq->bDeblockingParallelFlag && pSlice->sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc != 1
#if !defined(ENABLE_FRAME_DUMP)
&& (eNalRefIdc != NRI_PRI_LOWEST) &&
(pParamD->iHighestTemporalId == 0 || kiCurTid < pParamD->iHighestTemporalId)
(pCodingParam->sDependencyLayers[kiCurDid].iHighestTemporalId == 0
|| kiCurTid < pCodingParam->sDependencyLayers[kiCurDid].iHighestTemporalId)
#endif// !ENABLE_FRAME_DUMP
) {
DeblockingFilterSliceAvcbase (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);
@ -896,7 +897,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
if (pCurDq->bDeblockingParallelFlag && pSlice->sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc != 1
#if !defined(ENABLE_FRAME_DUMP)
&& (eNalRefIdc != NRI_PRI_LOWEST) &&
(pParamD->iHighestTemporalId == 0 || kiCurTid < pParamD->iHighestTemporalId)
(pCodingParam->sDependencyLayers[kiCurDid].iHighestTemporalId == 0
|| kiCurTid < pCodingParam->sDependencyLayers[kiCurDid].iHighestTemporalId)
#endif// !ENABLE_FRAME_DUMP
) {
DeblockingFilterSliceAvcbase (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);
@ -1050,8 +1052,8 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) {
// if using spatial base layer for complexity estimation
const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0)
&& (pCtx->pSvcParam->sDependencyLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
&& pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sDependencyLayers[iCurDid -
&& (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
&& pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid -
1].sSliceCfg.sSliceArgument.uiSliceNum);
if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation
@ -1115,7 +1117,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t
pPara = pCtx->pSvcParam;
while (iSpatialIdx < iSpatialNum) {
const int32_t kiDid = pDidList[iSpatialIdx];
SDLayerParam* pDlp = &pPara->sDependencyLayers[kiDid];
SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid];
SSliceConfig* pMso = &pDlp->sSliceCfg;
SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];
SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;

View File

@ -472,7 +472,7 @@ void StashPopMBStatus (SDynamicSlicingStack* pDss, SBitStringAux* pBs, SSlice* p
pBs->uiCurBits = pDss->uiBsStackCurBits;
pBs->iLeftBits = pDss->iBsStackLeftBits;
pSlice->uiLastMbQp = pDss->uiLastMbQp;
if(pMbSkipRun)
if (pMbSkipRun)
*pMbSkipRun = pDss->iMbSkipRunStack;
}
void UpdateQpForOverflow (SMB* pCurMb, uint8_t kuiChromaQpIndexOffset) {
@ -712,7 +712,7 @@ int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const
SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
SSlice* pCurSlice = &pCurLayer->sLayerInfo.pSliceInLayer[kiSliceIdx];
SBitStringAux* pBs = pCurSlice->pSliceBsa;
const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode
const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode
==
SM_DYN_SLICE);

View File

@ -127,8 +127,8 @@ int32_t CWelsPreProcess::AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCoding
// spatial pictures
iDlayerIndex = 0;
do {
const int32_t kiPicWidth = pParam->sDependencyLayers[iDlayerIndex].iFrameWidth;
const int32_t kiPicHeight = pParam->sDependencyLayers[iDlayerIndex].iFrameHeight;
const int32_t kiPicWidth = pParam->sSpatialLayers[iDlayerIndex].iVideoWidth;
const int32_t kiPicHeight = pParam->sSpatialLayers[iDlayerIndex].iVideoHeight;
const uint8_t kuiLayerInTemporal = 2 + WELS_MAX (pParam->sDependencyLayers[iDlayerIndex].iHighestTemporalId, 1);
const uint8_t kuiRefNumInTemporal = kuiLayerInTemporal + pParam->iLTRRefNum;
uint8_t i = 0;
@ -291,7 +291,8 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
SPicture* pSrcPic = NULL; // large
SPicture* pDstPic = NULL; // small
SDLayerParam* pDlayerParam = NULL;
SSpatialLayerConfig* pDlayerParam = NULL;
SSpatialLayerInternal* pDlayerParamInternal = NULL;
int32_t iSpatialNum = 0;
int32_t iSrcWidth = 0;
int32_t iSrcHeight = 0;
@ -300,10 +301,11 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
int32_t iTemporalId = 0;
int32_t iActualSpatialLayerNum = 0;
pDlayerParam = &pSvcParam->sDependencyLayers[iDependencyId];
iTargetWidth = pDlayerParam->iFrameWidth;
iTargetHeight = pDlayerParam->iFrameHeight;
iTemporalId = pDlayerParam->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)];
pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId];
pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId];
iTargetWidth = pDlayerParam->iVideoWidth;
iTargetHeight = pDlayerParam->iVideoHeight;
iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)];
iSrcWidth = pSvcParam->SUsedPicRect.iWidth;
iSrcHeight = pSvcParam->SUsedPicRect.iHeight;
@ -365,10 +367,11 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
// -- highest layer, if no downsampling, [else] block above
if (pSvcParam->iSpatialLayerNum > 1) {
while (iDependencyId >= 0) {
pDlayerParam = &pSvcParam->sDependencyLayers[iDependencyId];
iTargetWidth = pDlayerParam->iFrameWidth;
iTargetHeight = pDlayerParam->iFrameHeight;
iTemporalId = pDlayerParam->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)];
pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId];
pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId];
iTargetWidth = pDlayerParam->iVideoWidth;
iTargetHeight = pDlayerParam->iVideoHeight;
iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)];
iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1;
// NOT work for CGS, FIXME
@ -414,7 +417,7 @@ bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPic
}
for (; iSpatialIdx >= 0; iSpatialIdx --) {
SDLayerParam* pCurLayer = &pParam->sDependencyLayers[iSpatialIdx];
SSpatialLayerInternal* pCurLayer = &pParam->sDependencyLayers[iSpatialIdx];
int32_t iCurDstWidth = pCurLayer->iActualWidth;
int32_t iCurDstHeight = pCurLayer->iActualHeight;
int32_t iInputWidthXDstHeight = kiInputPicWidth * iCurDstHeight;
@ -1078,7 +1081,7 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi
return static_cast<ESceneChangeIdc> (iVaaFrameSceneChangeIdc);
}
int32_t CWelsPreProcess::GetRefFrameInfo(int32_t iRefIdx,SPicture *&pRefOri) {
int32_t CWelsPreProcess::GetRefFrameInfo (int32_t iRefIdx, SPicture*& pRefOri) {
const int32_t iTargetDid = m_pEncCtx->pSvcParam->iSpatialLayerNum - 1;
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (m_pEncCtx->pVaa);
SRefInfoParam* BestRefCandidateParam = & (pVaaExt->sVaaStrBestRefCandidate[iRefIdx]);