encoder interface update step1
This commit is contained in:
parent
3ff7e3d045
commit
35fa429fb0
@ -56,8 +56,8 @@ class ISVCEncoder {
|
||||
/*
|
||||
* return: CM_RETURN: 0 - success; otherwise - failed;
|
||||
*/
|
||||
virtual int EXTAPI Initialize (SVCEncodingParam* pParam, const INIT_TYPE kiInitType = INIT_TYPE_PARAMETER_BASED) = 0;
|
||||
virtual int EXTAPI Initialize2 (void* pParam, const INIT_TYPE kiInitType = INIT_TYPE_CONFIG_BASED) = 0;
|
||||
virtual int EXTAPI Initialize (SEncParamBase* pParam, const INIT_TYPE kiInitType = INIT_TYPE_PARAMETER_BASED) = 0;
|
||||
virtual int EXTAPI Initialize2 (void* pParam, const INIT_TYPE kiInitType = INIT_TYPE_PARAMETER_BASED) = 0;
|
||||
|
||||
virtual int EXTAPI Uninitialize() = 0;
|
||||
|
||||
@ -141,7 +141,7 @@ typedef struct ISVCEncoderVtbl ISVCEncoderVtbl;
|
||||
typedef const ISVCEncoderVtbl* ISVCEncoder;
|
||||
struct ISVCEncoderVtbl {
|
||||
|
||||
int (*Initialize) (ISVCEncoder*, SVCEncodingParam* pParam, const INIT_TYPE kiInitType);
|
||||
int (*Initialize) (ISVCEncoder*, SEncParamBase* pParam, const INIT_TYPE kiInitType);
|
||||
int (*Initialize2) (ISVCEncoder*, void* pParam, const INIT_TYPE kiInitType);
|
||||
|
||||
int (*Uninitialize) (ISVCEncoder*);
|
||||
|
@ -72,7 +72,8 @@ typedef enum {
|
||||
typedef enum {
|
||||
ENCODER_OPTION_DATAFORMAT = 0,
|
||||
ENCODER_OPTION_IDR_INTERVAL,
|
||||
ENCODER_OPTION_SVC_ENCODE_PARAM,
|
||||
ENCODER_OPTION_SVC_ENCODE_PARAM_BASE,
|
||||
ENCODER_OPTION_SVC_ENCODE_PARAM_EXT,
|
||||
ENCODER_OPTION_FRAME_RATE,
|
||||
ENCODER_OPTION_BITRATE,
|
||||
ENCODER_OPTION_INTER_SPATIAL_PRED,
|
||||
@ -126,7 +127,7 @@ typedef enum {
|
||||
/* SVC Encoder/Decoder Initializing Parameter Types */
|
||||
typedef enum {
|
||||
INIT_TYPE_PARAMETER_BASED = 0, // For SVC DEMO Application
|
||||
INIT_TYPE_CONFIG_BASED, // For SVC CONSOLE Application
|
||||
INIT_TYPE_PARAMETER_EXT, // For SVC CONSOLE Application
|
||||
} INIT_TYPE;
|
||||
|
||||
//enumerate the type of video bitstream which is provided to decoder
|
||||
@ -158,6 +159,13 @@ typedef struct {
|
||||
int iLTRFrameNum; //specify current decoder frame_num
|
||||
} SLTRMarkingFeedback;
|
||||
|
||||
typedef struct {
|
||||
unsigned int
|
||||
uiSliceMbNum[MAX_SLICES_NUM_TMP]; //here we use a tmp fixed value since MAX_SLICES_NUM is not defined here and its definition may be changed;
|
||||
unsigned int uiSliceNum;
|
||||
unsigned int uiSliceSizeConstraint;
|
||||
} SSliceArgument;//not all the elements in this argument will be used, how it will be used depends on uiSliceMode; see below
|
||||
|
||||
typedef struct {
|
||||
|
||||
//# 0 SM_SINGLE_SLICE | SliceNum==1
|
||||
@ -166,12 +174,7 @@ typedef struct {
|
||||
//# 3 SM_ROWMB_SLICE | according to PictureMBHeight | Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
|
||||
//# 4 SM_DYN_SLICE | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
|
||||
unsigned int uiSliceMode; //by default, uiSliceMode will be 0
|
||||
struct {
|
||||
unsigned int
|
||||
uiSliceMbNum[MAX_SLICES_NUM_TMP]; //here we use a tmp fixed value since MAX_SLICES_NUM is not defined here and its definition may be changed;
|
||||
unsigned int uiSliceNum;
|
||||
unsigned int uiSliceSizeConstraint;
|
||||
} sSliceArgument;//not all the elements in this argument will be used, how it will be used depends on uiSliceMode; see below
|
||||
SSliceArgument sSliceArgument;
|
||||
} SSliceConfig;
|
||||
|
||||
typedef struct {
|
||||
@ -183,42 +186,149 @@ typedef struct {
|
||||
int iCgsSnrRefined; // 0: SNR layers all MGS; 1: SNR layers all CGS
|
||||
int iInterSpatialLayerPredFlag; // 0: diabled [independency spatial layer coding]; 1: enabled [base spatial layer dependency coding]
|
||||
|
||||
int iQualityBitrate[MAX_QUALITY_LAYER_NUM]; // target bitrate for a quality layer
|
||||
unsigned int uiProfileIdc; // value of profile IDC (0 for auto-detection)
|
||||
int iDLayerQp;
|
||||
int iQualityBitrate[MAX_QUALITY_LAYER_NUM]; // target bitrate for a quality layer
|
||||
|
||||
SSliceConfig sSliceCfg;
|
||||
} SSpatialLayerConfig;
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* SVC Encoding Parameters */
|
||||
typedef struct {
|
||||
typedef struct TagEncParamBase{
|
||||
|
||||
int iUsageType; //enable_screen_content_signal;// 0: //camera video signal; 1: screen content signal;
|
||||
int iInputCsp; // color space of input sequence
|
||||
|
||||
int iPicWidth; // width of picture in samples
|
||||
int iPicHeight; // height of picture in samples
|
||||
int iTargetBitrate; // target bitrate desired
|
||||
int iRCMode; // RC mode
|
||||
float fMaxFrameRate; // input maximal frame rate
|
||||
|
||||
} SEncParamBase, *PEncParamBase;
|
||||
|
||||
|
||||
typedef struct TagEncParamExt:SEncParamBase
|
||||
{
|
||||
int iTemporalLayerNum; // layer number at temporal level
|
||||
int iSpatialLayerNum; // layer number at spatial level
|
||||
|
||||
float fFrameRate; // input maximal frame rate
|
||||
|
||||
int iInputCsp; // color space of input sequence
|
||||
int iKeyPicCodingMode;// mode of key picture coding
|
||||
int iIntraPeriod; // period of Intra frame
|
||||
unsigned int uiIntraPeriod; // period of Intra frame
|
||||
bool bEnableSpsPpsIdAddition;
|
||||
bool bPrefixNalAddingCtrl;
|
||||
bool bEnableDenoise; // denoise control
|
||||
bool bEnableBackgroundDetection; // background detection control //VAA_BACKGROUND_DETECTION //BGD cmd
|
||||
bool bEnableDenoise; // denoise control
|
||||
bool bEnableBackgroundDetection;// background detection control //VAA_BACKGROUND_DETECTION //BGD cmd
|
||||
bool bEnableAdaptiveQuant; // adaptive quantization control
|
||||
bool bEnableFrameSkip; // allow skipping frames to keep the bitrate within limits
|
||||
bool bEnableCropPic; // enable cropping source picture. 8/25/2010
|
||||
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
|
||||
bool bEnableLongTermReference; // 0: on, 1: off
|
||||
int iLtrMarkPeriod;
|
||||
|
||||
int iRCMode; // RC mode
|
||||
int iTemporalBitrate[MAX_TEMPORAL_LAYER_NUM]; // target bitrate specified for a temporal level
|
||||
int iPaddingFlag; // 0:disable padding;1:padding
|
||||
bool bEnableLongTermReference; // 0: on, 1: off
|
||||
int iLtrMarkPeriod;
|
||||
int iPaddingFlag; // 0:disable padding;1:padding
|
||||
int iEtropyCodingModeFlag;
|
||||
|
||||
SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM];
|
||||
int iNumRefFrame; // number of reference frame used
|
||||
unsigned int uiFrameToBeCoded; // frame to be encoded (at input frame rate)
|
||||
unsigned int uiGopSize;
|
||||
bool bEnableRc;
|
||||
short iMultipleThreadIdc; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
|
||||
short iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means;
|
||||
|
||||
} SVCEncodingParam, *PSVCEncodingParam;
|
||||
int iLTRRefNum;
|
||||
bool bEnableSSEI;
|
||||
bool bEnableFrameCroppingFlag;// enable frame cropping flag: TRUE always in application
|
||||
|
||||
/* Deblocking loop filter */
|
||||
int iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
|
||||
int iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
|
||||
|
||||
int iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
|
||||
int iInterLayerLoopFilterDisableIdc; // Employed based upon inter-layer, same comment as above
|
||||
int iInterLayerLoopFilterAlphaC0Offset; // InterLayerLoopFilterAlphaC0Offset
|
||||
int iInterLayerLoopFilterBetaOffset; // InterLayerLoopFilterBetaOffset
|
||||
bool bEnableSceneChangeDetect;
|
||||
|
||||
//added
|
||||
int iMaxQp;
|
||||
int iMinQp;
|
||||
|
||||
}SEncParamExt;
|
||||
#else
|
||||
/* SVC Encoding Parameters */
|
||||
typedef struct TagEncParamBase{
|
||||
|
||||
int iUsageType; //enable_screen_content_signal;// 0: //camera video signal; 1: screen content signal;
|
||||
int iInputCsp; // color space of input sequence
|
||||
|
||||
int iPicWidth; // width of picture in samples
|
||||
int iPicHeight; // height of picture in samples
|
||||
int iTargetBitrate; // target bitrate desired
|
||||
int iRCMode; // RC mode
|
||||
float fMaxFrameRate; // input maximal frame rate
|
||||
|
||||
} SEncParamBase, *PEncParamBase;
|
||||
|
||||
typedef struct TagEncParamExt
|
||||
{
|
||||
int iUsageType; //enable_screen_content_signal;// 0: //camera video signal; 1: screen content signal;
|
||||
int iInputCsp; // color space of input sequence
|
||||
|
||||
int iPicWidth; // width of picture in samples
|
||||
int iPicHeight; // height of picture in samples
|
||||
int iTargetBitrate; // target bitrate desired
|
||||
int iRCMode; // RC mode
|
||||
float fMaxFrameRate; // input maximal frame rate
|
||||
|
||||
int iTemporalLayerNum; // layer number at temporal level
|
||||
int iSpatialLayerNum; // layer number at spatial level
|
||||
|
||||
unsigned int uiIntraPeriod; // period of Intra frame
|
||||
bool bEnableSpsPpsIdAddition;
|
||||
bool bPrefixNalAddingCtrl;
|
||||
bool bEnableDenoise; // denoise control
|
||||
bool bEnableBackgroundDetection;// background detection control //VAA_BACKGROUND_DETECTION //BGD cmd
|
||||
bool bEnableAdaptiveQuant; // adaptive quantization control
|
||||
bool bEnableFrameSkip; // allow skipping frames to keep the bitrate within limits
|
||||
bool bEnableCropPic; // enable cropping source picture. 8/25/2010
|
||||
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
|
||||
|
||||
bool bEnableLongTermReference; // 0: on, 1: off
|
||||
int iLtrMarkPeriod;
|
||||
int iPaddingFlag; // 0:disable padding;1:padding
|
||||
int iEtropyCodingModeFlag;
|
||||
|
||||
SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM];
|
||||
int iNumRefFrame; // number of reference frame used
|
||||
unsigned int uiFrameToBeCoded; // frame to be encoded (at input frame rate)
|
||||
unsigned int uiGopSize;
|
||||
bool bEnableRc;
|
||||
short iMultipleThreadIdc; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
|
||||
short iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means;
|
||||
|
||||
int iLTRRefNum;
|
||||
bool bEnableSSEI;
|
||||
bool bEnableFrameCroppingFlag;// enable frame cropping flag: TRUE always in application
|
||||
|
||||
/* Deblocking loop filter */
|
||||
int iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
|
||||
int iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
|
||||
|
||||
int iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
|
||||
int iInterLayerLoopFilterDisableIdc; // Employed based upon inter-layer, same comment as above
|
||||
int iInterLayerLoopFilterAlphaC0Offset; // InterLayerLoopFilterAlphaC0Offset
|
||||
int iInterLayerLoopFilterBetaOffset; // InterLayerLoopFilterBetaOffset
|
||||
bool bEnableSceneChangeDetect;
|
||||
|
||||
//added
|
||||
int iMaxQp;
|
||||
int iMinQp;
|
||||
|
||||
}SEncParamExt;
|
||||
|
||||
#endif
|
||||
|
||||
//Define a new struct to show the property of video bitstream.
|
||||
typedef struct {
|
||||
|
@ -46,8 +46,6 @@
|
||||
//#define STICK_STREAM_SIZE
|
||||
|
||||
#include "measure_time.h"
|
||||
#include "param_svc.h"
|
||||
//#include "layered_pic_buffer.h"
|
||||
#include "read_config.h"
|
||||
|
||||
#include "typedefs.h"
|
||||
@ -89,7 +87,7 @@ using namespace WelsSVCEnc;
|
||||
*/
|
||||
typedef struct LayerpEncCtx_s {
|
||||
int32_t iDLayerQp;
|
||||
SMulSliceOption sMso;
|
||||
SSliceConfig sSliceCfg;
|
||||
} SLayerPEncCtx;
|
||||
|
||||
|
||||
@ -100,7 +98,7 @@ static void SigIntHandler (int a) {
|
||||
g_iCtrlC = 1;
|
||||
}
|
||||
|
||||
int ParseConfig (CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet& sFileSet) {
|
||||
int ParseConfig (CReadConfig& cRdCfg, SEncParamExt& pSvcParam, SFilesSet& sFileSet) {
|
||||
string strTag[4];
|
||||
int32_t iLeftTargetBitrate = 0;
|
||||
int32_t iLeftSpatialBitrate[MAX_DEPENDENCY_LAYER] = { 0 };
|
||||
@ -206,11 +204,11 @@ int ParseConfig (CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
} else if (strTag[0].compare ("EnableLongTermReference") == 0) {
|
||||
pSvcParam.bEnableLongTermReference = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("LtrMarkPeriod") == 0) {
|
||||
pSvcParam.uiLtrMarkPeriod = (uint32_t)atoi (strTag[1].c_str());
|
||||
pSvcParam.iLtrMarkPeriod = (uint32_t)atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("NumLayers") == 0) {
|
||||
pSvcParam.iNumDependencyLayer = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iNumDependencyLayer > MAX_DEPENDENCY_LAYER || pSvcParam.iNumDependencyLayer <= 0) {
|
||||
fprintf (stderr, "Invalid parameter in iNumDependencyLayer: %d.\n", pSvcParam.iNumDependencyLayer);
|
||||
pSvcParam.iSpatialLayerNum = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iSpatialLayerNum > MAX_DEPENDENCY_LAYER || pSvcParam.iSpatialLayerNum <= 0) {
|
||||
fprintf (stderr, "Invalid parameter in iSpatialLayerNum: %d.\n", pSvcParam.iSpatialLayerNum);
|
||||
iRet = 1;
|
||||
break;
|
||||
}
|
||||
@ -230,10 +228,10 @@ int ParseConfig (CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
}
|
||||
}
|
||||
|
||||
const int8_t kiActualLayerNum = WELS_MIN (pSvcParam.iNumDependencyLayer, iLayerCount);
|
||||
if (pSvcParam.iNumDependencyLayer >
|
||||
const int8_t kiActualLayerNum = WELS_MIN (pSvcParam.iSpatialLayerNum, iLayerCount);
|
||||
if (pSvcParam.iSpatialLayerNum >
|
||||
kiActualLayerNum) { // fixed number of dependency layer due to parameter error in settings
|
||||
pSvcParam.iNumDependencyLayer = kiActualLayerNum;
|
||||
pSvcParam.iSpatialLayerNum = kiActualLayerNum;
|
||||
}
|
||||
|
||||
assert (kiActualLayerNum <= MAX_DEPENDENCY_LAYER);
|
||||
@ -243,7 +241,7 @@ int ParseConfig (CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
int32_t iLayerArg = -2;
|
||||
int32_t iNumQualityBitrateLayerSet = 0;
|
||||
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
CReadConfig cRdLayerCfg (sFileSet.sSpatialLayers[iLayer].strLayerCfgFile);
|
||||
|
||||
memset (&sLayerCtx, 0, sizeof (SLayerPEncCtx));
|
||||
@ -260,15 +258,11 @@ int ParseConfig (CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
if (strTag[0].empty())
|
||||
continue;
|
||||
if (strTag[0].compare ("SourceWidth") == 0) {
|
||||
pDLayer->iFrameWidth = atoi (strTag[1].c_str());
|
||||
pDLayer->iActualWidth = pDLayer->iFrameWidth;
|
||||
pDLayer->iVideoWidth = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SourceHeight") == 0) {
|
||||
pDLayer->iFrameHeight = atoi (strTag[1].c_str());
|
||||
pDLayer->iActualHeight = pDLayer->iFrameHeight;
|
||||
} else if (strTag[0].compare ("FrameRateIn") == 0) {
|
||||
pDLayer->fInputFrameRate = (float)atof (strTag[1].c_str());
|
||||
pDLayer->iVideoHeight = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("FrameRateOut") == 0) {
|
||||
pDLayer->fOutputFrameRate = (float)atof (strTag[1].c_str());
|
||||
pDLayer->fFrameRate = (float)atof (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("InputFile") == 0) {
|
||||
if (strTag[1].length() > 0)
|
||||
sFileSet.sSpatialLayers[iLayer].strSeqFile = strTag[1];
|
||||
@ -299,32 +293,32 @@ int ParseConfig (CReadConfig& cRdCfg, SWelsSvcCodingParam& pSvcParam, SFilesSet&
|
||||
} else if (strTag[0].compare ("InitialQP") == 0) {
|
||||
sLayerCtx.iDLayerQp = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SliceMode") == 0) {
|
||||
sLayerCtx.sMso.uiSliceMode = (SliceMode)atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.uiSliceMode = (SliceMode)atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SliceSize") == 0) { //SM_DYN_SLICE
|
||||
sLayerCtx.sMso.sSliceArgument.uiSliceSizeConstraint = (SliceMode)atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceSizeConstraint = (SliceMode)atoi (strTag[1].c_str());
|
||||
continue;
|
||||
} else if (strTag[0].compare ("SliceNum") == 0) {
|
||||
sLayerCtx.sMso.sSliceArgument.iSliceNum = atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceNum = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare (0, kiSize, str_) == 0) {
|
||||
const char* kpString = strTag[0].c_str();
|
||||
int uiSliceIdx = atoi (&kpString[kiSize]);
|
||||
assert (uiSliceIdx < MAX_SLICES_NUM);
|
||||
sLayerCtx.sMso.sSliceArgument.uiSliceMbNum[uiSliceIdx] = atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx] = atoi (strTag[1].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
pDLayer->iDLayerQp = sLayerCtx.iDLayerQp;
|
||||
pDLayer->sMso.uiSliceMode = sLayerCtx.sMso.uiSliceMode;
|
||||
pDLayer->sSliceCfg.uiSliceMode = sLayerCtx.sSliceCfg.uiSliceMode;
|
||||
|
||||
memcpy (&pDLayer->sMso, &sLayerCtx.sMso, sizeof (SMulSliceOption)); // confirmed_safe_unsafe_usage
|
||||
memcpy (&pDLayer->sMso.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sMso.sSliceArgument.uiSliceMbNum[0],
|
||||
sizeof (sLayerCtx.sMso.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage
|
||||
memcpy (&pDLayer->sSliceCfg, &sLayerCtx.sSliceCfg, sizeof (SSliceConfig)); // confirmed_safe_unsafe_usage
|
||||
memcpy (&pDLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum[0],
|
||||
sizeof (sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
int ParseCommandLine (int argc, char** argv, SVCEncodingParam& sParam) {
|
||||
int ParseCommandLine (int argc, char** argv, SEncParamExt& sParam) {
|
||||
char* pCmd;
|
||||
int i = 0;
|
||||
|
||||
@ -338,7 +332,7 @@ int ParseCommandLine (int argc, char** argv, SVCEncodingParam& sParam) {
|
||||
sParam.iTemporalLayerNum = atoi (argv[i++]);
|
||||
|
||||
else if (!strcmp (pCmd, "-iper") && (i < argc))
|
||||
sParam.iIntraPeriod = atoi (argv[i++]);
|
||||
sParam.uiIntraPeriod = atoi (argv[i++]);
|
||||
|
||||
else if (!strcmp (pCmd, "-spsid") && (i < argc))
|
||||
sParam.bEnableSpsPpsIdAddition = atoi (argv[i++]) ? true : false;
|
||||
@ -418,7 +412,7 @@ void PrintHelp() {
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
int ParseCommandLine (int argc, char** argv, SWelsSvcCodingParam& pSvcParam, SFilesSet& sFileSet) {
|
||||
int ParseCommandLine (int argc, char** argv, SEncParamExt& pSvcParam, SFilesSet& sFileSet) {
|
||||
char* pCommand = NULL;
|
||||
SLayerPEncCtx sLayerCtx[3];
|
||||
int n = 0;
|
||||
@ -462,7 +456,7 @@ int ParseCommandLine (int argc, char** argv, SWelsSvcCodingParam& pSvcParam, SFi
|
||||
pSvcParam.bEnableLongTermReference = atoi (argv[n++]) ? true : false;
|
||||
|
||||
else if (!strcmp (pCommand, "-ltrper") && (n < argc))
|
||||
pSvcParam.uiLtrMarkPeriod = atoi (argv[n++]);
|
||||
pSvcParam.iLtrMarkPeriod = atoi (argv[n++]);
|
||||
|
||||
else if (!strcmp (pCommand, "-rc") && (n < argc))
|
||||
pSvcParam.bEnableRc = atoi (argv[n++]) ? true : false;
|
||||
@ -471,19 +465,19 @@ int ParseCommandLine (int argc, char** argv, SWelsSvcCodingParam& pSvcParam, SFi
|
||||
pSvcParam.iTargetBitrate = atoi (argv[n++]);
|
||||
|
||||
else if (!strcmp (pCommand, "-numl") && (n < argc)) {
|
||||
pSvcParam.iNumDependencyLayer = atoi (argv[n++]);
|
||||
for (int ln = 0 ; (ln < pSvcParam.iNumDependencyLayer) && (n < argc) ; ln++) {
|
||||
pSvcParam.iSpatialLayerNum = atoi (argv[n++]);
|
||||
for (int ln = 0 ; (ln < pSvcParam.iSpatialLayerNum) && (n < argc) ; ln++) {
|
||||
// pSvcParam.sDependencyLayers[ln].uiDependencyId = ln;
|
||||
sFileSet.sSpatialLayers[ln].strLayerCfgFile.assign (argv[n++]);
|
||||
}
|
||||
|
||||
for (int8_t iLayer = 0; iLayer < pSvcParam.iNumDependencyLayer; ++ iLayer) {
|
||||
for (int8_t iLayer = 0; iLayer < pSvcParam.iSpatialLayerNum; ++ iLayer) {
|
||||
SLayerPEncCtx sLayerCtx;
|
||||
string strTag[4];
|
||||
int32_t iLayerArg = -2;
|
||||
int32_t iNumQualityBitrateLayerSet = 0;
|
||||
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
CReadConfig cRdLayerCfg (sFileSet.sSpatialLayers[iLayer].strLayerCfgFile);
|
||||
|
||||
memset (&sLayerCtx, 0, sizeof (SLayerPEncCtx));
|
||||
@ -500,15 +494,11 @@ int ParseCommandLine (int argc, char** argv, SWelsSvcCodingParam& pSvcParam, SFi
|
||||
if (strTag[0].empty())
|
||||
continue;
|
||||
if (strTag[0].compare ("SourceWidth") == 0) {
|
||||
pDLayer->iFrameWidth = atoi (strTag[1].c_str());
|
||||
pDLayer->iActualWidth = pDLayer->iFrameWidth;
|
||||
pDLayer->iVideoWidth = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SourceHeight") == 0) {
|
||||
pDLayer->iFrameHeight = atoi (strTag[1].c_str());
|
||||
pDLayer->iActualHeight = pDLayer->iFrameHeight;
|
||||
} else if (strTag[0].compare ("FrameRateIn") == 0) {
|
||||
pDLayer->fInputFrameRate = (float)atof (strTag[1].c_str());
|
||||
pDLayer->iVideoHeight = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("FrameRateOut") == 0) {
|
||||
pDLayer->fOutputFrameRate = (float)atof (strTag[1].c_str());
|
||||
pDLayer->fFrameRate = (float)atof (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("InputFile") == 0) {
|
||||
if (strTag[1].length() > 0)
|
||||
sFileSet.sSpatialLayers[iLayer].strSeqFile = strTag[1];
|
||||
@ -529,24 +519,24 @@ int ParseCommandLine (int argc, char** argv, SWelsSvcCodingParam& pSvcParam, SFi
|
||||
} else if (strTag[0].compare ("InitialQP") == 0) {
|
||||
sLayerCtx.iDLayerQp = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SliceMode") == 0) {
|
||||
sLayerCtx.sMso.uiSliceMode = (SliceMode)atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.uiSliceMode = (SliceMode)atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SliceSize") == 0) { //SM_DYN_SLICE
|
||||
sLayerCtx.sMso.sSliceArgument.uiSliceSizeConstraint = (SliceMode)atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceSizeConstraint = (SliceMode)atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SliceNum") == 0) {
|
||||
sLayerCtx.sMso.sSliceArgument.iSliceNum = atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceNum = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare (0, kiSize, str_) == 0) {
|
||||
const char* kpString = strTag[0].c_str();
|
||||
int uiSliceIdx = atoi (&kpString[kiSize]);
|
||||
assert (uiSliceIdx < MAX_SLICES_NUM);
|
||||
sLayerCtx.sMso.sSliceArgument.uiSliceMbNum[uiSliceIdx] = atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx] = atoi (strTag[1].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
pDLayer->iDLayerQp = sLayerCtx.iDLayerQp;
|
||||
pDLayer->sMso.uiSliceMode = sLayerCtx.sMso.uiSliceMode;
|
||||
memcpy (&pDLayer->sMso, &sLayerCtx.sMso, sizeof (SMulSliceOption)); // confirmed_safe_unsafe_usage
|
||||
memcpy (&pDLayer->sMso.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sMso.sSliceArgument.uiSliceMbNum[0],
|
||||
sizeof (sLayerCtx.sMso.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage
|
||||
pDLayer->sSliceCfg.uiSliceMode = sLayerCtx.sSliceCfg.uiSliceMode;
|
||||
memcpy (&pDLayer->sSliceCfg, &sLayerCtx.sSliceCfg, sizeof (SSliceConfig)); // confirmed_safe_unsafe_usage
|
||||
memcpy (&pDLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum[0],
|
||||
sizeof (sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum)); // confirmed_safe_unsafe_usage
|
||||
|
||||
}
|
||||
}
|
||||
@ -569,79 +559,71 @@ int ParseCommandLine (int argc, char** argv, SWelsSvcCodingParam& pSvcParam, SFi
|
||||
|
||||
else if (!strcmp (pCommand, "-sw") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->iFrameWidth = atoi (argv[n++]);
|
||||
pDLayer->iActualWidth = pDLayer->iFrameWidth;
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iVideoWidth = atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-sh") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->iFrameHeight = atoi (argv[n++]);
|
||||
pDLayer->iActualHeight = pDLayer->iFrameHeight;
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iVideoHeight = atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-frin") && (n + 1 < argc)) {
|
||||
else if (!strcmp (pCommand, "-frout") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->fInputFrameRate = (float)atof (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-frout") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->fOutputFrameRate = (float)atof (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->fFrameRate = (float)atof (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-lqp") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iDLayerQp = sLayerCtx[iLayer].iDLayerQp = atoi (argv[n++]);
|
||||
}
|
||||
//sLayerCtx[iLayer].num_quality_layers = pDLayer->num_quality_layers = 1;
|
||||
|
||||
else if (!strcmp (pCommand, "-ltarb") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iSpatialBitrate = 1000 * atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-slcmd") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
|
||||
switch (atoi (argv[n++])) {
|
||||
case 0:
|
||||
pDLayer->sMso.uiSliceMode = SM_SINGLE_SLICE;
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
break;
|
||||
case 1:
|
||||
pDLayer->sMso.uiSliceMode = SM_FIXEDSLCNUM_SLICE;
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_FIXEDSLCNUM_SLICE;
|
||||
break;
|
||||
case 2:
|
||||
pDLayer->sMso.uiSliceMode = SM_RASTER_SLICE;
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_RASTER_SLICE;
|
||||
break;
|
||||
case 3:
|
||||
pDLayer->sMso.uiSliceMode = SM_ROWMB_SLICE;
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_ROWMB_SLICE;
|
||||
break;
|
||||
case 4:
|
||||
pDLayer->sMso.uiSliceMode = SM_DYN_SLICE;
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_DYN_SLICE;
|
||||
break;
|
||||
default:
|
||||
pDLayer->sMso.uiSliceMode = SM_RESERVED;
|
||||
pDLayer->sSliceCfg.uiSliceMode = SM_RESERVED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-slcsize") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->sMso.sSliceArgument.uiSliceSizeConstraint = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-slcnum") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
|
||||
pDLayer->sMso.sSliceArgument.iSliceNum = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->sSliceCfg.sSliceArgument.uiSliceNum = atoi (argv[n++]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -649,9 +631,9 @@ int ParseCommandLine (int argc, char** argv, SWelsSvcCodingParam& pSvcParam, SFi
|
||||
|
||||
|
||||
|
||||
int FillSpecificParameters (SVCEncodingParam& sParam) {
|
||||
int FillSpecificParameters (SEncParamExt& sParam) {
|
||||
/* Test for temporal, spatial, SNR scalability */
|
||||
sParam.fFrameRate = 30.0f; // input frame rate
|
||||
sParam.fMaxFrameRate = 30.0f; // input frame rate
|
||||
sParam.iPicWidth = 1280; // width of picture in samples
|
||||
sParam.iPicHeight = 720; // height of picture in samples
|
||||
sParam.iTargetBitrate = 2500000; // target bitrate desired
|
||||
@ -666,8 +648,7 @@ int FillSpecificParameters (SVCEncodingParam& sParam) {
|
||||
sParam.iLtrMarkPeriod = 30;
|
||||
|
||||
sParam.iInputCsp = videoFormatI420; // color space of input sequence
|
||||
sParam.iKeyPicCodingMode = 1; // mode of key picture coding
|
||||
sParam.iIntraPeriod = 320; // period of Intra frame
|
||||
sParam.uiIntraPeriod = 320; // period of Intra frame
|
||||
sParam.bEnableSpsPpsIdAddition = 1;
|
||||
sParam.bPrefixNalAddingCtrl = 1;
|
||||
|
||||
@ -679,7 +660,6 @@ int FillSpecificParameters (SVCEncodingParam& sParam) {
|
||||
sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 64000;
|
||||
sParam.sSpatialLayers[iIndexLayer].iCgsSnrRefined = 0;
|
||||
// sParam.sSpatialLayers[iIndexLayer].iQualityBitrate[0] = 0;
|
||||
// memset(sParam.iTemporalBitrate, 0, sizeof(sParam.iTemporalBitrate));
|
||||
sParam.sSpatialLayers[iIndexLayer].iInterSpatialLayerPredFlag = 0;
|
||||
#ifdef MT_ENABLED
|
||||
sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = 0;
|
||||
@ -737,7 +717,7 @@ int FillSpecificParameters (SVCEncodingParam& sParam) {
|
||||
if (sParam.sSpatialLayers[i].fFrameRate > fMaxFr + EPSN)
|
||||
fMaxFr = sParam.sSpatialLayers[i].fFrameRate;
|
||||
}
|
||||
sParam.fFrameRate = fMaxFr;
|
||||
sParam.fMaxFrameRate = fMaxFr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -753,7 +733,7 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
FILE* pFpBs = NULL;
|
||||
FILE* pFpSrc = NULL;
|
||||
SFrameBSInfo sFbi;
|
||||
SVCEncodingParam sSvcParam;
|
||||
SEncParamExt sSvcParam;
|
||||
int64_t iStart = 0, iTotal = 0;
|
||||
int32_t ret = 0;
|
||||
|
||||
@ -777,7 +757,7 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
}
|
||||
|
||||
memset (&sFbi, 0, sizeof (SFrameBSInfo));
|
||||
memset (&sSvcParam, 0, sizeof (SVCEncodingParam));
|
||||
memset (&sSvcParam, 0, sizeof (SEncParamBase));
|
||||
|
||||
FillSpecificParameters (sSvcParam);
|
||||
|
||||
@ -898,7 +878,7 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
return 1;
|
||||
|
||||
SFrameBSInfo sFbi;
|
||||
SWelsSvcCodingParam sSvcParam;
|
||||
SEncParamExt sSvcParam;
|
||||
int64_t iStart = 0, iTotal = 0;
|
||||
|
||||
// Preparing encoding process
|
||||
@ -926,10 +906,10 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
int iParsedNum = 2;
|
||||
|
||||
memset (&sFbi, 0, sizeof (SFrameBSInfo));
|
||||
memset (&sSvcParam, 0, sizeof (SWelsSvcCodingParam));
|
||||
memset (&sSvcParam, 0, sizeof (SEncParamExt));
|
||||
|
||||
sSvcParam.iInputCsp = videoFormatI420; // I420 in default
|
||||
sSvcParam.sDependencyLayers[0].uiProfileIdc = PRO_BASELINE;
|
||||
sSvcParam.sSpatialLayers[0].uiProfileIdc = PRO_BASELINE;
|
||||
// svc_cfg->sDependencyLayers[0].frext_mode = 0;
|
||||
|
||||
// for configuration file
|
||||
@ -955,21 +935,11 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
}
|
||||
|
||||
iTotalFrameMax = (int32_t)sSvcParam.uiFrameToBeCoded;
|
||||
sSvcParam.SUsedPicRect.iLeft = 0;
|
||||
sSvcParam.SUsedPicRect.iTop = 0;
|
||||
// sSvcParam.max_pic_width =
|
||||
sSvcParam.iActualPicWidth =
|
||||
sSvcParam.SUsedPicRect.iWidth = sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iFrameWidth;
|
||||
// pSvcParam.max_pic_height =
|
||||
sSvcParam.iActualPicHeight =
|
||||
sSvcParam.SUsedPicRect.iHeight = sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iFrameHeight;
|
||||
sSvcParam.iPicWidth = sSvcParam.sSpatialLayers[sSvcParam.iSpatialLayerNum - 1].iVideoWidth;
|
||||
sSvcParam.iPicHeight = sSvcParam.sSpatialLayers[sSvcParam.iSpatialLayerNum - 1].iVideoHeight;
|
||||
|
||||
sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iFrameWidth =
|
||||
WELS_ALIGN(sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iActualWidth, MB_WIDTH_LUMA);
|
||||
sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iFrameHeight =
|
||||
WELS_ALIGN(sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iActualHeight, MB_HEIGHT_LUMA);
|
||||
|
||||
if (cmResultSuccess != pPtrEnc->Initialize2 ((void*)&sSvcParam, INIT_TYPE_CONFIG_BASED)) { // SVC encoder initialization
|
||||
if (cmResultSuccess != pPtrEnc->Initialize (&sSvcParam, INIT_TYPE_PARAMETER_EXT)) { // SVC encoder initialization
|
||||
fprintf (stderr, "SVC encoder Initialize failed\n");
|
||||
iRet = 1;
|
||||
goto INSIDE_MEM_FREE;
|
||||
@ -995,10 +965,10 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
}
|
||||
#endif
|
||||
|
||||
pSrcPicList = new SSourcePicture * [sSvcParam.iNumDependencyLayer];
|
||||
while (iDlayerIdx < sSvcParam.iNumDependencyLayer) {
|
||||
SDLayerParam* pDLayer = &sSvcParam.sDependencyLayers[iDlayerIdx];
|
||||
const int kiPicResSize = pDLayer->iActualWidth * pDLayer->iActualHeight;
|
||||
pSrcPicList = new SSourcePicture * [sSvcParam.iSpatialLayerNum];
|
||||
while (iDlayerIdx < sSvcParam.iSpatialLayerNum) {
|
||||
SSpatialLayerConfig* pDLayer = &sSvcParam.sSpatialLayers[iDlayerIdx];
|
||||
const int kiPicResSize = pDLayer->iVideoWidth * pDLayer->iVideoHeight;
|
||||
SSourcePicture* pSrcPic = new SSourcePicture;
|
||||
if (pSrcPic == NULL) {
|
||||
iRet = 1;
|
||||
@ -1013,10 +983,10 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
}
|
||||
|
||||
pSrcPic->iColorFormat = videoFormatI420;
|
||||
pSrcPic->iPicWidth = pDLayer->iActualWidth;
|
||||
pSrcPic->iPicHeight = pDLayer->iActualHeight;
|
||||
pSrcPic->iStride[0] = pDLayer->iActualWidth;
|
||||
pSrcPic->iStride[1] = pSrcPic->iStride[2] = pDLayer->iActualWidth >> 1;
|
||||
pSrcPic->iPicWidth = pDLayer->iVideoWidth;
|
||||
pSrcPic->iPicHeight = pDLayer->iVideoHeight;
|
||||
pSrcPic->iStride[0] = pDLayer->iVideoWidth;
|
||||
pSrcPic->iStride[1] = pSrcPic->iStride[2] = pDLayer->iVideoWidth >> 1;
|
||||
|
||||
pSrcPicList[iDlayerIdx] = pSrcPic;
|
||||
|
||||
@ -1052,10 +1022,10 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
|
||||
iDlayerIdx = 0;
|
||||
int nSpatialLayerNum = 0;
|
||||
while (iDlayerIdx < sSvcParam.iNumDependencyLayer) {
|
||||
SDLayerParam* pDLayer = &sSvcParam.sDependencyLayers[iDlayerIdx];
|
||||
const int kiPicResSize = ((pDLayer->iActualWidth * pDLayer->iActualHeight) * 3) >> 1;
|
||||
uint32_t uiSkipIdx = (1 << pDLayer->iTemporalResolution);
|
||||
while (iDlayerIdx < sSvcParam.iSpatialLayerNum) {
|
||||
SSpatialLayerConfig* pDLayer = &sSvcParam.sSpatialLayers[iDlayerIdx];
|
||||
const int kiPicResSize = ((pDLayer->iVideoWidth * pDLayer->iVideoHeight) * 3) >> 1;
|
||||
uint32_t uiSkipIdx = 1;//(1 << pDLayer->iTemporalResolution);
|
||||
|
||||
bool bCanBeRead = false;
|
||||
|
||||
@ -1067,15 +1037,15 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
|
||||
pSrcPicList[nSpatialLayerNum]->pData[0] = pYUV[iDlayerIdx];
|
||||
pSrcPicList[nSpatialLayerNum]->pData[1] = pSrcPicList[nSpatialLayerNum]->pData[0] +
|
||||
(pDLayer->iActualWidth * pDLayer->iActualHeight);
|
||||
(pDLayer->iVideoWidth * pDLayer->iVideoHeight);
|
||||
pSrcPicList[nSpatialLayerNum]->pData[2] = pSrcPicList[nSpatialLayerNum]->pData[1] +
|
||||
((pDLayer->iActualWidth * pDLayer->iActualHeight) >> 2);
|
||||
((pDLayer->iVideoWidth * pDLayer->iVideoHeight) >> 2);
|
||||
|
||||
pSrcPicList[nSpatialLayerNum]->iPicWidth = pDLayer->iActualWidth;
|
||||
pSrcPicList[nSpatialLayerNum]->iPicHeight = pDLayer->iActualHeight;
|
||||
pSrcPicList[nSpatialLayerNum]->iStride[0] = pDLayer->iActualWidth;
|
||||
pSrcPicList[nSpatialLayerNum]->iPicWidth = pDLayer->iVideoWidth;
|
||||
pSrcPicList[nSpatialLayerNum]->iPicHeight = pDLayer->iVideoHeight;
|
||||
pSrcPicList[nSpatialLayerNum]->iStride[0] = pDLayer->iVideoWidth;
|
||||
pSrcPicList[nSpatialLayerNum]->iStride[1] = pSrcPicList[nSpatialLayerNum]->iStride[2]
|
||||
= pDLayer->iActualWidth >> 1;
|
||||
= pDLayer->iVideoWidth >> 1;
|
||||
|
||||
++ nSpatialLayerNum;
|
||||
} else { // file end while reading
|
||||
@ -1161,7 +1131,7 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
|
||||
if (iActualFrameEncodedCount > 0) {
|
||||
double dElapsed = iTotal / 1e6;
|
||||
printf ("Width: %d\nHeight: %d\nFrames: %d\nencode time: %f sec\nFPS: %f fps\n",
|
||||
sSvcParam.iActualPicWidth, sSvcParam.iActualPicHeight,
|
||||
sSvcParam.iPicWidth, sSvcParam.iPicHeight,
|
||||
iActualFrameEncodedCount, dElapsed, (iActualFrameEncodedCount * 1.0) / dElapsed);
|
||||
}
|
||||
|
||||
@ -1186,7 +1156,7 @@ INSIDE_MEM_FREE: {
|
||||
#endif
|
||||
// Destruction memory introduced in this routine
|
||||
iDlayerIdx = 0;
|
||||
while (iDlayerIdx < sSvcParam.iNumDependencyLayer) {
|
||||
while (iDlayerIdx < sSvcParam.iSpatialLayerNum) {
|
||||
if (pFileYUV[iDlayerIdx] != NULL) {
|
||||
fclose (pFileYUV[iDlayerIdx]);
|
||||
pFileYUV[iDlayerIdx] = NULL;
|
||||
@ -1195,7 +1165,7 @@ INSIDE_MEM_FREE: {
|
||||
}
|
||||
|
||||
if (pSrcPicList) {
|
||||
for (int32_t i = 0; i < sSvcParam.iNumDependencyLayer; i++) {
|
||||
for (int32_t i = 0; i < sSvcParam.iSpatialLayerNum; i++) {
|
||||
if (pSrcPicList[i]) {
|
||||
delete pSrcPicList[i];
|
||||
pSrcPicList[i] = NULL;
|
||||
|
@ -96,7 +96,7 @@ int8_t iHighestTemporalId;
|
||||
// uint8_t uiDependencyId;
|
||||
int8_t iDLayerQp;
|
||||
|
||||
SMulSliceOption sMso; // multiple slice options
|
||||
SSliceConfig sSliceCfg; // multiple slice options
|
||||
|
||||
float fInputFrameRate; // input frame rate
|
||||
float fOutputFrameRate; // output frame rate
|
||||
@ -109,17 +109,11 @@ char sRecFileName[MAX_FNAME_LEN]; // file to be constructed
|
||||
/*
|
||||
* Cisco OpenH264 Encoder Parameter Configuration
|
||||
*/
|
||||
typedef struct TagWelsSvcCodingParam {
|
||||
typedef struct TagWelsSvcCodingParam: SEncParamExt{
|
||||
SDLayerParam sDependencyLayers[MAX_DEPENDENCY_LAYER];
|
||||
|
||||
/* General */
|
||||
uint32_t uiGopSize; // GOP size (at maximal frame rate: 16)
|
||||
uint32_t uiIntraPeriod; // intra period (multiple of GOP size as desired)
|
||||
int32_t iNumRefFrame; // number of reference frame used
|
||||
|
||||
int32_t iActualPicWidth; // actual input picture width
|
||||
int32_t iActualPicHeight; // actual input picture height
|
||||
|
||||
struct {
|
||||
int32_t iLeft;
|
||||
int32_t iTop;
|
||||
@ -129,60 +123,14 @@ struct {
|
||||
|
||||
char* pCurPath; // record current lib path such as:/pData/pData/com.wels.enc/lib/
|
||||
|
||||
float fMaxFrameRate; // maximal frame rate [Hz / fps]
|
||||
int32_t iInputCsp; // color space of input sequence
|
||||
uint32_t uiFrameToBeCoded; // frame to be encoded (at input frame rate)
|
||||
|
||||
int32_t iTargetBitrate; // overall target bitrate introduced in RC module
|
||||
int16_t iMultipleThreadIdc; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
|
||||
int16_t iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means;
|
||||
|
||||
int32_t iLTRRefNum;
|
||||
uint32_t uiLtrMarkPeriod; //the min distance of two int32_t references
|
||||
|
||||
bool bDeblockingParallelFlag; // deblocking filter parallelization control flag
|
||||
bool bMgsT0OnlyStrategy; //MGS_T0_only_strategy
|
||||
bool bEnableSSEI;
|
||||
bool bEnableFrameCroppingFlag; // enable frame cropping flag: true alwayse in application
|
||||
|
||||
bool bEnableCropPic; // enable cropping source picture. , 8/25/2010
|
||||
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
|
||||
// FALSE: Streaming Video Sharing; TRUE: Video Conferencing Meeting;
|
||||
|
||||
int8_t iDecompStages; // GOP size dependency
|
||||
|
||||
/* Deblocking loop filter */
|
||||
int8_t iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
|
||||
int8_t iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
|
||||
|
||||
int8_t iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
|
||||
int8_t iInterLayerLoopFilterDisableIdc; // Employed based upon inter-layer, same comment as above
|
||||
int8_t iInterLayerLoopFilterAlphaC0Offset; // InterLayerLoopFilterAlphaC0Offset
|
||||
int8_t iInterLayerLoopFilterBetaOffset; // InterLayerLoopFilterBetaOffset
|
||||
|
||||
/* Rate Control */
|
||||
bool bEnableRc;
|
||||
int8_t iRCMode;
|
||||
int8_t iPaddingFlag;
|
||||
/* denoise control */
|
||||
bool bEnableDenoise;
|
||||
|
||||
/* scene change detection control */
|
||||
bool bEnableSceneChangeDetect;
|
||||
// background detection control
|
||||
bool bEnableBackgroundDetection;
|
||||
/* adaptive quantization control */
|
||||
bool bEnableAdaptiveQuant;
|
||||
/* frame skipping */
|
||||
bool bEnableFrameSkip;
|
||||
/* long term reference control */
|
||||
bool bEnableLongTermReference;
|
||||
|
||||
/* pSps pPps id addition control */
|
||||
bool bEnableSpsPpsIdAddition;
|
||||
/* Layer definition */
|
||||
bool bPrefixNalAddingCtrl;
|
||||
int8_t iNumDependencyLayer; // number of dependency(Spatial/CGS) layers used to be encoded
|
||||
int8_t iNumTemporalLayer; // number of temporal layer specified
|
||||
|
||||
|
||||
|
||||
public:
|
||||
@ -196,8 +144,8 @@ void FillDefault (const bool kbEnableRc) {
|
||||
uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
|
||||
iNumRefFrame = MIN_REF_PIC_COUNT; // number of reference frame used
|
||||
|
||||
iActualPicWidth = 0; // actual input picture width
|
||||
iActualPicHeight = 0; // actual input picture height
|
||||
iPicWidth = 0; // actual input picture width
|
||||
iPicHeight = 0; // actual input picture height
|
||||
SUsedPicRect.iLeft =
|
||||
SUsedPicRect.iTop =
|
||||
SUsedPicRect.iWidth =
|
||||
@ -220,7 +168,7 @@ void FillDefault (const bool kbEnableRc) {
|
||||
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
|
||||
|
||||
iLTRRefNum = 0;
|
||||
uiLtrMarkPeriod = 30; //the min distance of two int32_t references
|
||||
iLtrMarkPeriod = 30; //the min distance of two int32_t references
|
||||
|
||||
bMgsT0OnlyStrategy =
|
||||
true; // Strategy of have MGS only at T0 frames (0: do not use this strategy; 1: use this strategy)
|
||||
@ -251,25 +199,99 @@ void FillDefault (const bool kbEnableRc) {
|
||||
bEnableLongTermReference = false; // long term reference control
|
||||
bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
|
||||
bPrefixNalAddingCtrl = true; // prefix NAL adding control
|
||||
iNumDependencyLayer = 0; // number of dependency(Spatial/CGS) layers used to be encoded
|
||||
iNumTemporalLayer = 0; // number of temporal layer specified
|
||||
iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
|
||||
iTemporalLayerNum = 1; // number of temporal layer specified
|
||||
|
||||
iMaxQp = 51;
|
||||
iMinQp = 0;
|
||||
iUsageType = 0;
|
||||
memset(sDependencyLayers,0,sizeof(SDLayerParam)*MAX_DEPENDENCY_LAYER);
|
||||
|
||||
|
||||
|
||||
//init multi-slice
|
||||
sDependencyLayers[0].sSliceCfg.uiSliceMode = 0;
|
||||
sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
|
||||
sDependencyLayers[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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int32_t ParamTranscode (SVCEncodingParam& pCodingParam, const bool kbEnableRc = true) {
|
||||
pCodingParam.fFrameRate = WELS_CLIP3 (pCodingParam.fFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
|
||||
int32_t ParamBaseTranscode (SEncParamBase& pCodingParam, const bool kbEnableRc = true) {
|
||||
|
||||
pCodingParam.fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
|
||||
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
|
||||
|
||||
iPicWidth = pCodingParam.iPicWidth;
|
||||
iPicHeight = pCodingParam.iPicHeight;
|
||||
|
||||
SUsedPicRect.iLeft = 0;
|
||||
SUsedPicRect.iTop = 0;
|
||||
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
|
||||
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
|
||||
|
||||
bEnableRc = kbEnableRc;
|
||||
if (pCodingParam.iRCMode != RC_MODE0 && pCodingParam.iRCMode != RC_MODE1)
|
||||
iRCMode = RC_MODE1;
|
||||
else
|
||||
iRCMode = pCodingParam.iRCMode; // rc mode
|
||||
|
||||
|
||||
|
||||
int8_t iIdxSpatial = 0;
|
||||
uint8_t uiProfileIdc = PRO_BASELINE;
|
||||
SDLayerParam* pDlp = &sDependencyLayers[0];
|
||||
|
||||
while (iIdxSpatial < iSpatialLayerNum) {
|
||||
|
||||
pDlp->uiProfileIdc = uiProfileIdc;
|
||||
sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate,
|
||||
MIN_FRAME_RATE, pCodingParam.fMaxFrameRate);
|
||||
pDlp->fInputFrameRate =
|
||||
pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE,
|
||||
MAX_FRAME_RATE);
|
||||
#ifdef ENABLE_FRAME_DUMP
|
||||
pDlp->sRecFileName[0] = '\0'; // file to be constructed
|
||||
#endif//ENABLE_FRAME_DUMP
|
||||
pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth;
|
||||
pDlp->iFrameWidth = WELS_ALIGN(pDlp->iActualWidth, MB_WIDTH_LUMA);
|
||||
|
||||
pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight;
|
||||
pDlp->iFrameHeight = WELS_ALIGN(pDlp->iActualHeight, MB_HEIGHT_LUMA);
|
||||
|
||||
pDlp->iSpatialBitrate =
|
||||
sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer
|
||||
|
||||
|
||||
pDlp->iDLayerQp = SVC_QUALITY_BASE_QP;
|
||||
|
||||
uiProfileIdc = PRO_SCALABLE_BASELINE;
|
||||
++ pDlp;
|
||||
++ iIdxSpatial;
|
||||
}
|
||||
SetActualPicResolution();
|
||||
|
||||
return 0;
|
||||
}
|
||||
int32_t ParamTranscode (SEncParamExt& pCodingParam, const bool kbEnableRc = true) {
|
||||
pCodingParam.fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
|
||||
|
||||
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
|
||||
uiFrameToBeCoded = (uint32_t) -
|
||||
1; // frame to be encoded (at input frame rate), -1 dependents on length of input sequence
|
||||
|
||||
iActualPicWidth = pCodingParam.iPicWidth;
|
||||
iActualPicHeight = pCodingParam.iPicHeight;
|
||||
iPicWidth = pCodingParam.iPicWidth;
|
||||
iPicHeight = pCodingParam.iPicHeight;
|
||||
|
||||
SUsedPicRect.iLeft = 0;
|
||||
SUsedPicRect.iTop = 0;
|
||||
SUsedPicRect.iWidth = ((iActualPicWidth >> 1) << 1);
|
||||
SUsedPicRect.iHeight = ((iActualPicHeight >> 1) << 1);
|
||||
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
|
||||
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
|
||||
|
||||
/* Deblocking loop filter */
|
||||
#ifdef MT_ENABLED
|
||||
@ -315,22 +337,22 @@ int32_t ParamTranscode (SVCEncodingParam& pCodingParam, const bool kbEnableRc =
|
||||
|
||||
/* Enable int32_t term reference */
|
||||
bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false;
|
||||
uiLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
|
||||
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
|
||||
|
||||
/* For ssei information */
|
||||
bEnableSSEI = true;
|
||||
|
||||
/* Layer definition */
|
||||
iNumDependencyLayer = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
|
||||
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
|
||||
MAX_DEPENDENCY_LAYER); // number of dependency(Spatial/CGS) layers used to be encoded
|
||||
pCodingParam.iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1,
|
||||
MAX_TEMPORAL_LEVEL); // safe valid iTemporalLayerNum
|
||||
iNumTemporalLayer = (int8_t)
|
||||
iTemporalLayerNum = (int8_t)
|
||||
pCodingParam.iTemporalLayerNum;//(int8_t)WELS_CLIP3(pCodingParam.iTemporalLayerNum, 1, MAX_TEMPORAL_LEVEL);// number of temporal layer specified
|
||||
|
||||
uiGopSize = 1 << (iNumTemporalLayer - 1); // Override GOP size based temporal layer
|
||||
iDecompStages = iNumTemporalLayer - 1; // WELS_LOG2( uiGopSize );// GOP size dependency
|
||||
uiIntraPeriod = pCodingParam.iIntraPeriod;// intra period (multiple of GOP size as desired)
|
||||
uiGopSize = 1 << (iTemporalLayerNum - 1); // Override GOP size based temporal layer
|
||||
iDecompStages = iTemporalLayerNum - 1; // WELS_LOG2( uiGopSize );// GOP size dependency
|
||||
uiIntraPeriod = pCodingParam.uiIntraPeriod;// intra period (multiple of GOP size as desired)
|
||||
if (uiIntraPeriod == (uint32_t) (-1))
|
||||
uiIntraPeriod = 0;
|
||||
else if (uiIntraPeriod & uiGopSize) // none multiple of GOP size
|
||||
@ -340,7 +362,7 @@ int32_t ParamTranscode (SVCEncodingParam& pCodingParam, const bool kbEnableRc =
|
||||
iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum);
|
||||
iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
|
||||
|
||||
uiLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
|
||||
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
|
||||
|
||||
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
|
||||
|
||||
@ -352,11 +374,11 @@ int32_t ParamTranscode (SVCEncodingParam& pCodingParam, const bool kbEnableRc =
|
||||
float fMaxFr = .0f;
|
||||
uint8_t uiProfileIdc = PRO_BASELINE;
|
||||
int8_t iIdxSpatial = 0;
|
||||
while (iIdxSpatial < iNumDependencyLayer) {
|
||||
while (iIdxSpatial < iSpatialLayerNum) {
|
||||
pDlp->uiProfileIdc = uiProfileIdc;
|
||||
|
||||
pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
|
||||
MIN_FRAME_RATE, pCodingParam.fFrameRate);
|
||||
MIN_FRAME_RATE, pCodingParam.fMaxFrameRate);
|
||||
pDlp->fInputFrameRate =
|
||||
pDlp->fOutputFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE,
|
||||
MAX_FRAME_RATE);
|
||||
@ -373,13 +395,13 @@ int32_t ParamTranscode (SVCEncodingParam& pCodingParam, const bool kbEnableRc =
|
||||
|
||||
|
||||
//multi slice
|
||||
pDlp->sMso.uiSliceMode = (SliceMode)pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.uiSliceMode;
|
||||
pDlp->sMso.sSliceArgument.uiSliceSizeConstraint
|
||||
pDlp->sSliceCfg.uiSliceMode = (SliceMode)pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.uiSliceMode;
|
||||
pDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint
|
||||
= (uint32_t) (pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
|
||||
pDlp->sMso.sSliceArgument.iSliceNum
|
||||
pDlp->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->sMso.sSliceArgument.uiSliceMbNum,
|
||||
memcpy (pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum,
|
||||
pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage
|
||||
kiLesserSliceNum * sizeof (uint32_t)) ;
|
||||
|
||||
@ -400,7 +422,7 @@ int32_t ParamTranscode (SVCEncodingParam& pCodingParam, const bool kbEnableRc =
|
||||
// assuming that the width/height ratio of all spatial layers are the same
|
||||
|
||||
void SetActualPicResolution() {
|
||||
int32_t iSpatialIdx = iNumDependencyLayer - 1;
|
||||
int32_t iSpatialIdx = iSpatialLayerNum - 1;
|
||||
SDLayerParam* pDlayer = &sDependencyLayers[iSpatialIdx];
|
||||
|
||||
for (; iSpatialIdx >= 0; iSpatialIdx --) {
|
||||
@ -426,7 +448,7 @@ void DetermineTemporalSettings() {
|
||||
uint8_t uiProfileIdc = PRO_BASELINE;
|
||||
int8_t i = 0;
|
||||
|
||||
while (i < iNumDependencyLayer) {
|
||||
while (i < iSpatialLayerNum) {
|
||||
const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate);
|
||||
const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate);
|
||||
int32_t iNotCodedMask = 0;
|
||||
|
@ -80,18 +80,6 @@ SM_RESERVED = 5
|
||||
#define JUMPPACKETSIZE_JUDGE(len,mb_idx,max_byte) ( (len) > JUMPPACKETSIZE_CONSTRAINT(max_byte) ) //( (mb_idx+1)%40/*16slice for compare*/ == 0 ) //
|
||||
//cur_mb_idx is for early tests, can be omit in optimization
|
||||
|
||||
typedef struct TagSliceArgument {
|
||||
uint32_t uiSliceMbNum[MAX_SLICES_NUM]; //will perform check on this array to decide specific slicing, see note
|
||||
uint32_t uiSliceSizeConstraint;
|
||||
int16_t iSliceNum;
|
||||
} SSliceArgument;
|
||||
|
||||
typedef struct TagMulSliceOption { //interfaces about slicing from application layer
|
||||
SSliceArgument
|
||||
sSliceArgument; //according to uiSliceMode, decide which elements of this structure will actually takes effect
|
||||
SliceMode uiSliceMode;
|
||||
} SMulSliceOption;
|
||||
|
||||
/*!
|
||||
* \brief SSlice context
|
||||
*/
|
||||
@ -139,7 +127,7 @@ int32_t InitSlicePEncCtx (SSliceCtx* pSliceCtx,
|
||||
bool bFmoUseFlag,
|
||||
int32_t iMbWidth,
|
||||
int32_t iMbHeight,
|
||||
SMulSliceOption* pMulSliceOption,
|
||||
SSliceConfig* pMulSliceOption,
|
||||
void* pPpsArg);
|
||||
|
||||
|
||||
@ -206,7 +194,7 @@ int32_t WelsGetNumMbInSlice (SSliceCtx* pSliceCtx, const int32_t kiSliceIdc);
|
||||
* Get slice count for multiple slice segment
|
||||
*
|
||||
*/
|
||||
int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SMulSliceOption* pMso);
|
||||
int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceConfig* pMso);
|
||||
int32_t GetCurrentSliceNum (const SSliceCtx* kpSliceCtx);
|
||||
|
||||
//checking valid para
|
||||
|
@ -734,7 +734,7 @@ void PerformDeblockingFilter (sWelsEncCtx* pEnc) {
|
||||
int32_t iSliceCount = 0;
|
||||
int32_t iSliceIdx = 0;
|
||||
|
||||
if (SM_DYN_SLICE != pDlp->sMso.uiSliceMode) {
|
||||
if (SM_DYN_SLICE != pDlp->sSliceCfg.uiSliceMode) {
|
||||
iSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx);
|
||||
do {
|
||||
DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx);
|
||||
|
@ -287,15 +287,15 @@ EFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum) {
|
||||
|
||||
// perform scene change detection
|
||||
if ((!pSvcParam->bEnableSceneChangeDetect) || pEncCtx->pVaa->bIdrPeriodFlag ||
|
||||
(kiSpatialNum < pSvcParam->iNumDependencyLayer)
|
||||
(kiSpatialNum < pSvcParam->iSpatialLayerNum)
|
||||
|| (pEncCtx->uiFrameIdxRc < (VGOP_SIZE << 1))) { // avoid too frequent I frame coding, rc control
|
||||
bSceneChangeFlag = false;
|
||||
} else {
|
||||
bSceneChangeFlag = pEncCtx->pVaa->bSceneChangeFlag;
|
||||
}
|
||||
|
||||
//scene_changed_flag: RC enable && iSpatialNum == pSvcParam->iNumDependencyLayer
|
||||
//bIdrPeriodFlag: RC disable || iSpatialNum != pSvcParam->iNumDependencyLayer
|
||||
//scene_changed_flag: RC enable && iSpatialNum == pSvcParam->iSpatialLayerNum
|
||||
//bIdrPeriodFlag: RC disable || iSpatialNum != pSvcParam->iSpatialLayerNum
|
||||
//pEncCtx->bEncCurFrmAsIdrFlag: 1. first frame should be IDR; 2. idr pause; 3. idr request
|
||||
iFrameType = (pEncCtx->pVaa->bIdrPeriodFlag || bSceneChangeFlag
|
||||
|| pEncCtx->bEncCurFrmAsIdrFlag) ? WELS_FRAME_TYPE_IDR : WELS_FRAME_TYPE_P;
|
||||
|
@ -88,7 +88,7 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) {
|
||||
|
||||
assert (pCfg != NULL);
|
||||
|
||||
for (i = 0; i < pCfg->iNumDependencyLayer; ++ i) {
|
||||
for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
|
||||
SDLayerParam* fDlp = &pCfg->sDependencyLayers[i];
|
||||
if (fDlp->fOutputFrameRate > fDlp->fInputFrameRate || (fDlp->fInputFrameRate >= -fEpsn
|
||||
&& fDlp->fInputFrameRate <= fEpsn)
|
||||
@ -109,7 +109,7 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) {
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < pCfg->iNumDependencyLayer; ++ i) {
|
||||
for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
|
||||
SDLayerParam* fDlp = &pCfg->sDependencyLayers[i];
|
||||
if (fDlp->fInputFrameRate > fMaxFrameRate)
|
||||
fMaxFrameRate = fDlp->fInputFrameRate;
|
||||
@ -120,7 +120,7 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) {
|
||||
pCfg->fMaxFrameRate = fMaxFrameRate;
|
||||
}
|
||||
|
||||
for (i = 0; i < pCfg->iNumDependencyLayer; ++ i) {
|
||||
for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
|
||||
SDLayerParam* fDlp = &pCfg->sDependencyLayers[i];
|
||||
|
||||
pLastSpatialParam = fDlp;
|
||||
@ -142,19 +142,19 @@ int32_t ParamValidationExt (void* pParam) {
|
||||
if (NULL == pCodingParam)
|
||||
return 1;
|
||||
|
||||
if (pCodingParam->iNumDependencyLayer < 1 || pCodingParam->iNumDependencyLayer > MAX_DEPENDENCY_LAYER) {
|
||||
if (pCodingParam->iSpatialLayerNum < 1 || pCodingParam->iSpatialLayerNum > MAX_DEPENDENCY_LAYER) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), monitor invalid pCodingParam->iNumDependencyLayer: %d!\n",
|
||||
pCodingParam->iNumDependencyLayer);
|
||||
fprintf (stderr, "ParamValidationExt(), monitor invalid pCodingParam->iSpatialLayerNum: %d!\n",
|
||||
pCodingParam->iSpatialLayerNum);
|
||||
#endif//#if _DEBUG
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pCodingParam->iNumTemporalLayer < 1 || pCodingParam->iNumTemporalLayer > MAX_TEMPORAL_LEVEL) {
|
||||
if (pCodingParam->iTemporalLayerNum < 1 || pCodingParam->iTemporalLayerNum > MAX_TEMPORAL_LEVEL) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), monitor invalid pCodingParam->iNumTemporalLayer: %d!\n",
|
||||
pCodingParam->iNumTemporalLayer);
|
||||
fprintf (stderr, "ParamValidationExt(), monitor invalid pCodingParam->iTemporalLayerNum: %d!\n",
|
||||
pCodingParam->iTemporalLayerNum);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
@ -201,7 +201,7 @@ int32_t ParamValidationExt (void* pParam) {
|
||||
pCodingParam->bDeblockingParallelFlag = false;
|
||||
#endif//MT_ENABLED
|
||||
|
||||
for (i = 0; i < pCodingParam->iNumDependencyLayer; ++ i) {
|
||||
for (i = 0; i < pCodingParam->iSpatialLayerNum; ++ i) {
|
||||
SDLayerParam* fDlp = &pCodingParam->sDependencyLayers[i];
|
||||
const int32_t kiPicWidth = fDlp->iFrameWidth;
|
||||
const int32_t kiPicHeight = fDlp->iFrameHeight;
|
||||
@ -224,9 +224,9 @@ int32_t ParamValidationExt (void* pParam) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fDlp->sMso.uiSliceMode >= SM_RESERVED) {
|
||||
if (fDlp->sSliceCfg.uiSliceMode >= SM_RESERVED) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceMode (%d) settings!\n", fDlp->sMso.uiSliceMode);
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceMode (%d) settings!\n", fDlp->sSliceCfg.uiSliceMode);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
@ -234,102 +234,102 @@ int32_t ParamValidationExt (void* pParam) {
|
||||
//check pSlice settings under multi-pSlice
|
||||
if (kiPicWidth <= 16 && kiPicHeight <= 16) {
|
||||
//only have one MB, set to single_slice
|
||||
fDlp->sMso.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
}
|
||||
switch (fDlp->sMso.uiSliceMode) {
|
||||
switch (fDlp->sSliceCfg.uiSliceMode) {
|
||||
case SM_SINGLE_SLICE:
|
||||
fDlp->sMso.sSliceArgument.iSliceNum = 1;
|
||||
fDlp->sMso.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
fDlp->sMso.sSliceArgument.iSliceNum = 0;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 0;
|
||||
for (iIdx = 0; iIdx < MAX_SLICES_NUM; iIdx++) {
|
||||
fDlp->sMso.sSliceArgument.uiSliceMbNum[iIdx] = 0;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[iIdx] = 0;
|
||||
}
|
||||
break;
|
||||
case SM_FIXEDSLCNUM_SLICE: {
|
||||
fDlp->sMso.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
|
||||
iMbWidth = (kiPicWidth + 15) >> 4;
|
||||
iMbHeight = (kiPicHeight + 15) >> 4;
|
||||
iMbNumInFrame = iMbWidth * iMbHeight;
|
||||
iMaxSliceNum = MAX_SLICES_NUM;
|
||||
if (fDlp->sMso.sSliceArgument.iSliceNum <= 0
|
||||
|| fDlp->sMso.sSliceArgument.iSliceNum > iMaxSliceNum) {
|
||||
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0
|
||||
|| fDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", fDlp->sMso.sSliceArgument.iSliceNum);
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
if (fDlp->sMso.sSliceArgument.iSliceNum == 1) {
|
||||
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr,
|
||||
"ParamValidationExt(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type!\n",
|
||||
fDlp->sMso.sSliceArgument.iSliceNum);
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
#endif//#if _DEBUG
|
||||
fDlp->sMso.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
break;
|
||||
}
|
||||
if (pCodingParam->bEnableRc) { // multiple slices verify with gom
|
||||
//check uiSliceNum
|
||||
GomValidCheckSliceNum (iMbWidth, iMbHeight, (int32_t*)&fDlp->sMso.sSliceArgument.iSliceNum);
|
||||
assert (fDlp->sMso.sSliceArgument.iSliceNum > 1);
|
||||
GomValidCheckSliceNum (iMbWidth, iMbHeight, (int32_t*)&fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
assert (fDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1);
|
||||
//set uiSliceMbNum with current uiSliceNum
|
||||
GomValidCheckSliceMbNum (iMbWidth, iMbHeight, &fDlp->sMso.sSliceArgument);
|
||||
GomValidCheckSliceMbNum (iMbWidth, iMbHeight, &fDlp->sSliceCfg.sSliceArgument);
|
||||
} else if (!CheckFixedSliceNumMultiSliceSetting (iMbNumInFrame,
|
||||
&fDlp->sMso.sSliceArgument)) { // verify interleave mode settings
|
||||
&fDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
|
||||
//check uiSliceMbNum with current uiSliceNum
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n",
|
||||
fDlp->sMso.sSliceArgument.uiSliceMbNum[0]);
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
// 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->sMso.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sMso.sSliceArgument.iSliceNum = 1;
|
||||
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SM_RASTER_SLICE: {
|
||||
fDlp->sMso.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
|
||||
iMbWidth = (kiPicWidth + 15) >> 4;
|
||||
iMbHeight = (kiPicHeight + 15) >> 4;
|
||||
iMbNumInFrame = iMbWidth * iMbHeight;
|
||||
iMaxSliceNum = MAX_SLICES_NUM;
|
||||
if (fDlp->sMso.sSliceArgument.uiSliceMbNum[0] <= 0) {
|
||||
if (fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0] <= 0) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n",
|
||||
fDlp->sMso.sSliceArgument.uiSliceMbNum[0]);
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!CheckRasterMultiSliceSetting (iMbNumInFrame, &fDlp->sMso.sSliceArgument)) { // verify interleave mode settings
|
||||
if (!CheckRasterMultiSliceSetting (iMbNumInFrame, &fDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n",
|
||||
fDlp->sMso.sSliceArgument.uiSliceMbNum[0]);
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
if (fDlp->sMso.sSliceArgument.iSliceNum <= 0
|
||||
|| fDlp->sMso.sSliceArgument.iSliceNum > iMaxSliceNum) { // verify interleave mode settings
|
||||
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0
|
||||
|| fDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) { // verify interleave mode settings
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceNum (%d) in SM_RASTER_SLICE settings!\n",
|
||||
fDlp->sMso.sSliceArgument.iSliceNum);
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
if (fDlp->sMso.sSliceArgument.iSliceNum == 1) {
|
||||
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), pSlice setting for SM_RASTER_SLICE now turn to SM_SINGLE_SLICE!\n");
|
||||
#endif//#if _DEBUG
|
||||
fDlp->sMso.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
break;
|
||||
}
|
||||
#ifdef MT_ENABLED
|
||||
if (pCodingParam->bEnableRc && fDlp->sMso.sSliceArgument.iSliceNum > 1) {
|
||||
if (pCodingParam->bEnableRc && fDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), WARNING: GOM based RC do not support SM_RASTER_SLICE!\n");
|
||||
#endif//#if _DEBUG
|
||||
@ -337,14 +337,14 @@ int32_t ParamValidationExt (void* pParam) {
|
||||
#endif
|
||||
// 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->sMso.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sMso.sSliceArgument.iSliceNum = 1;
|
||||
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SM_ROWMB_SLICE: {
|
||||
fDlp->sMso.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0;
|
||||
|
||||
iMbWidth = (kiPicWidth + 15) >> 4;
|
||||
iMbHeight = (kiPicHeight + 15) >> 4;
|
||||
@ -355,18 +355,18 @@ int32_t ParamValidationExt (void* pParam) {
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
fDlp->sMso.sSliceArgument.iSliceNum = iMbHeight;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight;
|
||||
|
||||
if (fDlp->sMso.sSliceArgument.iSliceNum <= 0) {
|
||||
if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", fDlp->sMso.sSliceArgument.iSliceNum);
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", fDlp->sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
if (!CheckRowMbMultiSliceSetting (iMbWidth, &fDlp->sMso.sSliceArgument)) { // verify interleave mode settings
|
||||
if (!CheckRowMbMultiSliceSetting (iMbWidth, &fDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n",
|
||||
fDlp->sMso.sSliceArgument.uiSliceMbNum[0]);
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
@ -375,17 +375,17 @@ int32_t ParamValidationExt (void* pParam) {
|
||||
case SM_DYN_SLICE: {
|
||||
iMbWidth = (kiPicWidth + 15) >> 4;
|
||||
iMbHeight = (kiPicHeight + 15) >> 4;
|
||||
if (fDlp->sMso.sSliceArgument.uiSliceSizeConstraint <= 0) {
|
||||
if (fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint <= 0) {
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid iSliceSize (%d) settings!\n",
|
||||
fDlp->sMso.sSliceArgument.uiSliceSizeConstraint);
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
}
|
||||
// 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->sMso.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sMso.sSliceArgument.iSliceNum = 1;
|
||||
fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
fDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -394,7 +394,7 @@ int32_t ParamValidationExt (void* pParam) {
|
||||
|
||||
#if defined (_DEBUG)
|
||||
fprintf (stderr, "ParamValidationExt(), invalid uiSliceMode (%d) settings!\n",
|
||||
pCodingParam->sDependencyLayers[0].sMso.uiSliceMode);
|
||||
pCodingParam->sDependencyLayers[0].sSliceCfg.uiSliceMode);
|
||||
#endif//#if _DEBUG
|
||||
return 1;
|
||||
|
||||
@ -411,7 +411,7 @@ void WelsEncoderApplyFrameRate(SWelsSvcCodingParam* pParam)
|
||||
{
|
||||
SDLayerParam* pLayerParam;
|
||||
const float kfEpsn = 0.000001f;
|
||||
const int32_t kiNumLayer = pParam->iNumDependencyLayer;
|
||||
const int32_t kiNumLayer = pParam->iSpatialLayerNum;
|
||||
int32_t i;
|
||||
const float kfMaxFrameRate = pParam->fMaxFrameRate;
|
||||
float fRatio;
|
||||
@ -439,7 +439,7 @@ void WelsEncoderApplyBitRate(SWelsSvcCodingParam* pParam)
|
||||
//but it is also possible to fulfill the bitrate of lower layer first
|
||||
|
||||
SDLayerParam* pLayerParam;
|
||||
const int32_t iNumLayers = pParam->iNumDependencyLayer;
|
||||
const int32_t iNumLayers = pParam->iSpatialLayerNum;
|
||||
int32_t i, iOrigTotalBitrate=0;
|
||||
//read old BR
|
||||
for (i=0;i<iNumLayers;i++) {
|
||||
@ -474,7 +474,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara
|
||||
if (NULL == pParam || NULL == ppCtx || NULL == *ppCtx)
|
||||
return 1;
|
||||
|
||||
iNumDependencyLayers = pParam->iNumDependencyLayer;
|
||||
iNumDependencyLayers = pParam->iSpatialLayerNum;
|
||||
|
||||
do {
|
||||
SDLayerParam* pDLayer = &pParam->sDependencyLayers[iDIndex];
|
||||
@ -485,7 +485,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara
|
||||
//Review this part and suggest no change, since the memory over-use
|
||||
//(1) counts little to the overall performance
|
||||
//(2) should not be critial even under mobile case
|
||||
if (SM_DYN_SLICE == pDLayer->sMso.uiSliceMode) {
|
||||
if (SM_DYN_SLICE == pDLayer->sSliceCfg.uiSliceMode) {
|
||||
iCountNumNals += MAX_SLICES_NUM;
|
||||
// plus prefix NALs
|
||||
if (iDIndex == 0)
|
||||
@ -497,10 +497,10 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara
|
||||
#else//!MT_ENABLED || !PACKING_ONE_SLICE_PER_LAYER
|
||||
assert (iCountNumNals - iOrgNumNals <= MAX_NAL_UNITS_IN_LAYER);
|
||||
#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER
|
||||
} else { /*if ( SM_SINGLE_SLICE != pDLayer->sMso.uiSliceMode )*/
|
||||
} else { /*if ( SM_SINGLE_SLICE != pDLayer->sSliceCfg.uiSliceMode )*/
|
||||
const int32_t kiNumOfSlice = GetInitialSliceNum ((pDLayer->iFrameWidth + 0x0f) >> 4,
|
||||
(pDLayer->iFrameHeight + 0x0f) >> 4,
|
||||
&pDLayer->sMso);
|
||||
&pDLayer->sSliceCfg);
|
||||
|
||||
// NEED check iCountNals value in case multiple slices is used
|
||||
iCountNumNals += kiNumOfSlice; // for pSlice VCL NALs
|
||||
@ -575,7 +575,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara
|
||||
*/
|
||||
int32_t AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam) {
|
||||
CMemoryAlign* pMa = pCtx->pMemAlign;
|
||||
const int32_t kiDlayerCount = pParam->iNumDependencyLayer;
|
||||
const int32_t kiDlayerCount = pParam->iSpatialLayerNum;
|
||||
int32_t iDlayerIndex = 0;
|
||||
|
||||
// spatial pictures
|
||||
@ -605,7 +605,7 @@ int32_t AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam) {
|
||||
void FreeSpatialPictures (sWelsEncCtx* pCtx) {
|
||||
CMemoryAlign* pMa = pCtx->pMemAlign;
|
||||
int32_t j = 0;
|
||||
while (j < pCtx->pSvcParam->iNumDependencyLayer) {
|
||||
while (j < pCtx->pSvcParam->iSpatialLayerNum) {
|
||||
uint8_t i = 0;
|
||||
uint8_t uiRefNumInTemporal = pCtx->uiSpatialPicNum[j];
|
||||
|
||||
@ -695,7 +695,7 @@ static void InitMbInfo (sWelsEncCtx* pEnc, SMB* pList, SDqLayer* pLayer, con
|
||||
|
||||
|
||||
int32_t InitMbListD (sWelsEncCtx** ppCtx) {
|
||||
int32_t iNumDlayer = (*ppCtx)->pSvcParam->iNumDependencyLayer;
|
||||
int32_t iNumDlayer = (*ppCtx)->pSvcParam->iSpatialLayerNum;
|
||||
int32_t iMbSize[MAX_DEPENDENCY_LAYER] = { 0 };
|
||||
int32_t iOverallMbNum = 0;
|
||||
int32_t iMbWidth = 0;
|
||||
@ -811,7 +811,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
|
||||
|
||||
pMa = (*ppCtx)->pMemAlign;
|
||||
pParam = (*ppCtx)->pSvcParam;
|
||||
iDlayerCount = pParam->iNumDependencyLayer;
|
||||
iDlayerCount = pParam->iSpatialLayerNum;
|
||||
iNumRef = pParam->iNumRefFrame;
|
||||
// highest_layers_in_temporal = 1 + WELS_MAX(pParam->iDecompStages, 1);
|
||||
pStrideTab = (*ppCtx)->pStrideTab;
|
||||
@ -859,7 +859,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
|
||||
const int32_t kiMbW = (pDlayer->iFrameWidth + 0x0f) >> 4;
|
||||
const int32_t kiMbH = (pDlayer->iFrameHeight + 0x0f) >> 4;
|
||||
int32_t iMaxSliceNum = 1;
|
||||
const int32_t kiSliceNum = GetInitialSliceNum (kiMbW, kiMbH, &pDlayer->sMso);
|
||||
const int32_t kiSliceNum = GetInitialSliceNum (kiMbW, kiMbH, &pDlayer->sSliceCfg);
|
||||
if (iMaxSliceNum < kiSliceNum)
|
||||
iMaxSliceNum = kiSliceNum;
|
||||
|
||||
@ -868,7 +868,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer), FreeMemorySvc (ppCtx))
|
||||
|
||||
// for dynamic slicing mode
|
||||
if (SM_DYN_SLICE == pDlayer->sMso.uiSliceMode) {
|
||||
if (SM_DYN_SLICE == pDlayer->sSliceCfg.uiSliceMode) {
|
||||
const int32_t iSize = pParam->iCountThreadsNum * sizeof (int32_t);
|
||||
|
||||
pDqLayer->pNumSliceCodedOfPartition = (int32_t*)pMa->WelsMallocz (iSize, "pNumSliceCodedOfPartition");
|
||||
@ -885,7 +885,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
|
||||
pDqLayer->iMbWidth = kiMbW;
|
||||
pDqLayer->iMbHeight = kiMbH;
|
||||
#ifndef MT_ENABLED
|
||||
if (SM_DYN_SLICE == pDlayer->sMso.uiSliceMode) { //wmalloc pSliceInLayer
|
||||
if (SM_DYN_SLICE == pDlayer->sSliceCfg.uiSliceMode) { //wmalloc pSliceInLayer
|
||||
SSlice* pSlice = NULL;
|
||||
int32_t iSliceIdx = 0;
|
||||
//wmalloc AVERSLICENUM_CONSTANT of pDqLayer->sLayerInfo.pSliceInLayer,
|
||||
@ -958,7 +958,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
|
||||
pDqLayer->bDeblockingParallelFlag = pParam->bDeblockingParallelFlag;
|
||||
|
||||
//deblocking parameter adjustment
|
||||
if (SM_SINGLE_SLICE == pDlayer->sMso.uiSliceMode) {
|
||||
if (SM_SINGLE_SLICE == pDlayer->sSliceCfg.uiSliceMode) {
|
||||
//iLoopFilterDisableIdc: will be 0 or 1 under single_slice
|
||||
if (2 == pParam->iLoopFilterDisableIdc) {
|
||||
pDqLayer->iLoopFilterDisableIdc = 0;
|
||||
@ -1037,7 +1037,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) {
|
||||
false,
|
||||
pSps->iMbWidth,
|
||||
pSps->iMbHeight,
|
||||
& (pDlayerParam->sMso),
|
||||
& (pDlayerParam->sSliceCfg),
|
||||
pPps);
|
||||
if (iResult) {
|
||||
WelsLog (*ppCtx, WELS_LOG_WARNING, "InitDqLayers(), InitSlicePEncCtx failed(%d)!", iResult);
|
||||
@ -1099,7 +1099,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers
|
||||
return 1;
|
||||
(*ppCtx)->pStrideTab = pPtr;
|
||||
|
||||
iCntTid = pParam->iNumTemporalLayer > 1 ? 2 : 1;
|
||||
iCntTid = pParam->iTemporalLayerNum > 1 ? 2 : 1;
|
||||
|
||||
iSpatialIdx = 0;
|
||||
while (iSpatialIdx < kiNumSpatialLayers) {
|
||||
@ -1335,7 +1335,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
|
||||
int32_t iCountLayers = 0;
|
||||
int32_t iResult = 0;
|
||||
float fCompressRatioThr = .5f;
|
||||
const int32_t kiNumDependencyLayers = pParam->iNumDependencyLayer;
|
||||
const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum;
|
||||
const uint32_t kuiMvdInterTableSize = (kiNumDependencyLayers == 1 ? (1 + (648 << 1)) : (1 + (972 << 1)));
|
||||
const uint32_t kuiMvdCacheAlginedSize = kuiMvdInterTableSize * sizeof (uint16_t);
|
||||
int32_t iVclLayersBsSizeCount = 0;
|
||||
@ -1371,12 +1371,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
iNonVclLayersBsSizeCount = SSEI_BUFFER_SIZE + pParam->iNumDependencyLayer * SPS_BUFFER_SIZE +
|
||||
(1 + pParam->iNumDependencyLayer) * PPS_BUFFER_SIZE;
|
||||
iNonVclLayersBsSizeCount = SSEI_BUFFER_SIZE + pParam->iSpatialLayerNum * SPS_BUFFER_SIZE +
|
||||
(1 + pParam->iSpatialLayerNum) * PPS_BUFFER_SIZE;
|
||||
|
||||
int32_t iLayerBsSize = 0;
|
||||
iIndex = 0;
|
||||
while (iIndex < pParam->iNumDependencyLayer) {
|
||||
while (iIndex < pParam->iSpatialLayerNum) {
|
||||
SDLayerParam* fDlp = &pParam->sDependencyLayers[iIndex];
|
||||
|
||||
fCompressRatioThr = COMPRESS_RATIO_DECIDED_BY_RESOLUTION (fDlp->iFrameWidth, fDlp->iFrameHeight);
|
||||
@ -1664,16 +1664,17 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
|
||||
// pDq layers list
|
||||
ilayer = 0;
|
||||
if (NULL != pCtx->ppDqLayerList && pParam != NULL) {
|
||||
while (ilayer < pParam->iNumDependencyLayer) {
|
||||
while (ilayer < pParam->iSpatialLayerNum) {
|
||||
SDqLayer* pDq = pCtx->ppDqLayerList[ilayer];
|
||||
SDLayerParam* pDlp = &pCtx->pSvcParam->sDependencyLayers[ilayer];
|
||||
const bool kbIsDynamicSlicing = (SM_DYN_SLICE == pDlp->sMso.uiSliceMode);
|
||||
|
||||
const bool kbIsDynamicSlicing = (SM_DYN_SLICE == pDlp->sSliceCfg.uiSliceMode);
|
||||
|
||||
// pDq layers
|
||||
if (NULL != pDq) {
|
||||
if (NULL != pDq->sLayerInfo.pSliceInLayer) {
|
||||
int32_t iSliceIdx = 0;
|
||||
int32_t iSliceNum = GetInitialSliceNum (pDq->iMbWidth, pDq->iMbHeight, &pDlp->sMso);
|
||||
int32_t iSliceNum = GetInitialSliceNum (pDq->iMbWidth, pDq->iMbHeight, &pDlp->sSliceCfg);
|
||||
if (iSliceNum < 1)
|
||||
iSliceNum = 1;
|
||||
while (iSliceIdx < iSliceNum) {
|
||||
@ -1707,7 +1708,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
|
||||
// reference picture list extension
|
||||
if (NULL != pCtx->ppRefPicListExt && pParam != NULL) {
|
||||
ilayer = 0;
|
||||
while (ilayer < pParam->iNumDependencyLayer) {
|
||||
while (ilayer < pParam->iSpatialLayerNum) {
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[ilayer];
|
||||
if (NULL != pRefList) {
|
||||
int32_t iRef = 0;
|
||||
@ -1731,7 +1732,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
|
||||
// pSlice context list
|
||||
if (NULL != pCtx->pSliceCtxList && pParam != NULL) {
|
||||
ilayer = 0;
|
||||
while (ilayer < pParam->iNumDependencyLayer) {
|
||||
while (ilayer < pParam->iSpatialLayerNum) {
|
||||
SSliceCtx* pSliceCtx = &pCtx->pSliceCtxList[ilayer];
|
||||
if (NULL != pSliceCtx)
|
||||
UninitSlicePEncCtx (pSliceCtx, pMa);
|
||||
@ -1817,12 +1818,12 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
|
||||
}
|
||||
|
||||
int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCpuCores, int16_t* pMaxSliceCount) {
|
||||
int32_t iSpatialIdx = 0, iSpatialNum = pCodingParam->iNumDependencyLayer;
|
||||
int32_t iSpatialIdx = 0, iSpatialNum = pCodingParam->iSpatialLayerNum;
|
||||
int16_t iMaxSliceCount = 0;
|
||||
|
||||
do {
|
||||
SDLayerParam* pDlp = &pCodingParam->sDependencyLayers[iSpatialIdx];
|
||||
SMulSliceOption* pMso = &pDlp->sMso;
|
||||
SSliceConfig* pMso = &pDlp->sSliceCfg;
|
||||
SSliceArgument* pSlcArg = &pMso->sSliceArgument;
|
||||
const int32_t kiMbWidth = (pDlp->iFrameWidth + 15) >> 4;
|
||||
const int32_t kiMbHeight = (pDlp->iFrameHeight + 15) >> 4;
|
||||
@ -1831,7 +1832,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp
|
||||
#if defined(DYNAMIC_SLICE_ASSIGN)
|
||||
int32_t iSliceNum = (SM_FIXEDSLCNUM_SLICE == pMso->uiSliceMode
|
||||
|| SM_DYN_SLICE == pMso->uiSliceMode) ? kiCpuCores :
|
||||
pSlcArg->iSliceNum; // uiSliceNum per input has been validated at ParamValidationExt()
|
||||
pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt()
|
||||
#else//!DYNAMIC_SLICE_ASSIGN
|
||||
int32_t iSliceNum = (SM_DYN_SLICE == pMso->uiSliceMode) ? kiCpuCores :
|
||||
pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt()
|
||||
@ -1843,7 +1844,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp
|
||||
// NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode,
|
||||
// uiSliceNum of current spatial layer settings equals to uiCpuCores number; SM_DYN_SLICE mode,
|
||||
// uiSliceNum intials as uiCpuCores also, stay tuned dynamically slicing in future
|
||||
pSlcArg->iSliceNum = iSliceNum; // used fixed one
|
||||
pSlcArg->uiSliceNum = iSliceNum; // used fixed one
|
||||
|
||||
switch (pMso->uiSliceMode) {
|
||||
case SM_DYN_SLICE:
|
||||
@ -2093,7 +2094,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
|
||||
#endif//ENABLE_TRACE_FILE
|
||||
|
||||
pCodingParam->DetermineTemporalSettings();
|
||||
iRet = AllocCodingParam (&pCtx->pSvcParam, pCtx->pMemAlign, pCodingParam->iNumDependencyLayer);
|
||||
iRet = AllocCodingParam (&pCtx->pSvcParam, pCtx->pMemAlign, pCodingParam->iSpatialLayerNum);
|
||||
if (iRet != 0) {
|
||||
FreeMemorySvc (&pCtx);
|
||||
return iRet;
|
||||
@ -2151,7 +2152,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
|
||||
void StatOverallEncodingExt (sWelsEncCtx* pCtx) {
|
||||
int8_t i = 0;
|
||||
int8_t j = 0;
|
||||
for (i = 0; i < pCtx->pSvcParam->iNumDependencyLayer; i++) {
|
||||
for (i = 0; i < pCtx->pSvcParam->iSpatialLayerNum; i++) {
|
||||
fprintf (stdout, "\nDependency layer : %d\n", i);
|
||||
fprintf (stdout, "Quality layer : %d\n", j);
|
||||
{
|
||||
@ -2563,8 +2564,8 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx,
|
||||
|
||||
pCurDq->pDecPic = pDecPic;
|
||||
|
||||
if (fDlp->sMso.uiSliceMode == SM_DYN_SLICE) // need get extra slices for update
|
||||
iSliceCount = GetInitialSliceNum (pCurDq->iMbWidth, pCurDq->iMbHeight, &fDlp->sMso);
|
||||
if (fDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE) // need get extra slices for update
|
||||
iSliceCount = GetInitialSliceNum (pCurDq->iMbWidth, pCurDq->iMbHeight, &fDlp->sSliceCfg);
|
||||
else
|
||||
iSliceCount = GetCurrentSliceNum (pCurDq->pSliceEncCtx);
|
||||
assert (iSliceCount > 0);
|
||||
@ -2644,7 +2645,7 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) {
|
||||
|
||||
if (P_SLICE == pCtx->eSliceType) {
|
||||
if (kbBaseAvail) {
|
||||
if (pCtx->pSvcParam->iNumDependencyLayer == (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1)) { //
|
||||
if (pCtx->pSvcParam->iSpatialLayerNum == (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1)) { //
|
||||
pCtx->pFuncList->pfMotionSearch = WelsMotionEstimateSearchSad;
|
||||
pCtx->pFuncList->pfFirstIntraMode = WelsMdFirstIntraMode;
|
||||
pCtx->pFuncList->pfIntraFineMd = WelsMdIntraFinePartitionVaa;
|
||||
@ -2667,7 +2668,7 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) {
|
||||
pCtx->pFuncList->sSampleDealingFuncs.pfMeCost = pCtx->pFuncList->sSampleDealingFuncs.pfSampleSatd;
|
||||
} else {
|
||||
//case 3: pBase layer MD + encoding
|
||||
if (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1 == pCtx->pSvcParam->iNumDependencyLayer) {
|
||||
if (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1 == pCtx->pSvcParam->iSpatialLayerNum) {
|
||||
pCtx->pFuncList->pfMotionSearch = WelsMotionEstimateSearchSad;
|
||||
pCtx->pFuncList->pfFirstIntraMode = WelsMdFirstIntraMode;
|
||||
pCtx->pFuncList->pfIntraFineMd = WelsMdIntraFinePartitionVaa;
|
||||
@ -2690,7 +2691,7 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) {
|
||||
pCtx->pFuncList->sSampleDealingFuncs.pfMeCost = pCtx->pFuncList->sSampleDealingFuncs.pfSampleSatd;
|
||||
}
|
||||
} else if (I_SLICE == pCtx->eSliceType) {
|
||||
if (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1 == pCtx->pSvcParam->iNumDependencyLayer) {
|
||||
if (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1 == pCtx->pSvcParam->iSpatialLayerNum) {
|
||||
pCtx->pFuncList->sSampleDealingFuncs.pfMdCost = pCtx->pFuncList->sSampleDealingFuncs.pfSampleSad;
|
||||
pCtx->pFuncList->sSampleDealingFuncs.pfIntra16x16Combined3 =
|
||||
pCtx->pFuncList->sSampleDealingFuncs.pfIntra16x16Combined3Sad;
|
||||
@ -3199,12 +3200,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
|
||||
// Encoding this picture might mulitiple sQualityStat layers potentially be encoded as followed
|
||||
|
||||
switch (param_d->sMso.uiSliceMode) {
|
||||
switch (param_d->sSliceCfg.uiSliceMode) {
|
||||
case SM_FIXEDSLCNUM_SLICE: {
|
||||
#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN)
|
||||
if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) &&
|
||||
(pSvcParam->sDependencyLayers[iCurDid].sMso.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sMso.sSliceArgument.iSliceNum)
|
||||
(pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum)
|
||||
)
|
||||
AdjustEnhanceLayer (pCtx, iCurDid);
|
||||
#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN
|
||||
@ -3235,7 +3236,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
bAvcBased = (iCurDid == BASE_DEPENDENCY_ID);
|
||||
pCtx->bNeedPrefixNalFlag = (bAvcBased &&
|
||||
(pSvcParam->bPrefixNalAddingCtrl ||
|
||||
(pSvcParam->iNumDependencyLayer > 1)));
|
||||
(pSvcParam->iSpatialLayerNum > 1)));
|
||||
|
||||
if (eFrameType == WELS_FRAME_TYPE_P) {
|
||||
eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE : NAL_UNIT_CODED_SLICE_EXT;
|
||||
@ -3281,7 +3282,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
PreprocessSliceCoding (pCtx); // MUST be called after pfWelsRcPictureInit() and WelsInitCurrentLayer()
|
||||
|
||||
iLayerSize = 0;
|
||||
if (SM_SINGLE_SLICE == param_d->sMso.uiSliceMode) { // only one slice within a sQualityStat layer
|
||||
if (SM_SINGLE_SLICE == param_d->sSliceCfg.uiSliceMode) { // only one slice within a sQualityStat layer
|
||||
int32_t iSliceSize = 0;
|
||||
|
||||
if (pCtx->bNeedPrefixNalFlag) {
|
||||
@ -3310,9 +3311,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
}
|
||||
// for dynamic slicing single threading..
|
||||
#ifndef MT_ENABLED
|
||||
else if (SM_DYN_SLICE == param_d->sMso.uiSliceMode)
|
||||
else if (SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode)
|
||||
#else // MT_ENABLED
|
||||
else if ((SM_DYN_SLICE == param_d->sMso.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1))
|
||||
else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1))
|
||||
#endif//MT_ENABLED
|
||||
{
|
||||
const int32_t kiLastMbInFrame = pCtx->pCurDqLayer->pSliceEncCtx->iMbNumInFrame;
|
||||
@ -3322,7 +3323,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
#if defined(MT_ENABLED)
|
||||
int err = 0;
|
||||
// THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE
|
||||
if ((SM_DYN_SLICE != param_d->sMso.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
|
||||
if ((SM_DYN_SLICE != param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
|
||||
iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
|
||||
if (iLayerNum +
|
||||
#if defined(PACKING_ONE_SLICE_PER_LAYER)
|
||||
@ -3333,7 +3334,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
>= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed
|
||||
WelsLog (pCtx, WELS_LOG_ERROR,
|
||||
"WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d) at iDid= %d uiSliceMode= %d, iSliceCount= %d!",
|
||||
iLayerNum, MAX_LAYER_NUM_OF_FRAME, iCurDid, param_d->sMso.uiSliceMode, iSliceCount);
|
||||
iLayerNum, MAX_LAYER_NUM_OF_FRAME, iCurDid, param_d->sSliceCfg.uiSliceMode, iSliceCount);
|
||||
return -1;
|
||||
}
|
||||
if (iSliceCount <= 1) {
|
||||
@ -3363,7 +3364,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
if (err) {
|
||||
WelsLog (pCtx, WELS_LOG_ERROR,
|
||||
"[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",
|
||||
err, pSvcParam->iCountThreadsNum, iSliceCount, param_d->sMso.uiSliceMode, pSvcParam->iMultipleThreadIdc);
|
||||
err, pSvcParam->iCountThreadsNum, iSliceCount, param_d->sSliceCfg.uiSliceMode, pSvcParam->iMultipleThreadIdc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3422,7 +3423,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
if (err) {
|
||||
WelsLog (pCtx, WELS_LOG_ERROR,
|
||||
"[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",
|
||||
err, pSvcParam->iCountThreadsNum, iSliceCount, param_d->sMso.uiSliceMode, pSvcParam->iMultipleThreadIdc);
|
||||
err, pSvcParam->iCountThreadsNum, iSliceCount, param_d->sSliceCfg.uiSliceMode, pSvcParam->iMultipleThreadIdc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3499,7 +3500,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
}
|
||||
}
|
||||
// THREAD_FULLY_FIRE_MODE && SM_DYN_SLICE
|
||||
else if ((SM_DYN_SLICE == param_d->sMso.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
|
||||
else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
|
||||
const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum;
|
||||
#if defined(PACKING_ONE_SLICE_PER_LAYER)
|
||||
ResetCountBsSizeInPartitions (pCtx->pSliceThreading->pCountBsSizeInPartition, kiPartitionCnt);
|
||||
@ -3514,7 +3515,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
if (err) {
|
||||
WelsLog (pCtx, WELS_LOG_ERROR,
|
||||
"[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!\n",
|
||||
err, pSvcParam->iCountThreadsNum, iSliceCount, param_d->sMso.uiSliceMode, pSvcParam->iMultipleThreadIdc);
|
||||
err, pSvcParam->iCountThreadsNum, iSliceCount, param_d->sSliceCfg.uiSliceMode, pSvcParam->iMultipleThreadIdc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3604,7 +3605,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
|
||||
#ifdef ENABLE_FRAME_DUMP
|
||||
// Dump reconstruction picture for each sQualityStat layer
|
||||
if (iCurDid + 1 < pSvcParam->iNumDependencyLayer)
|
||||
if (iCurDid + 1 < pSvcParam->iSpatialLayerNum)
|
||||
DumpDependencyRec (fsnr, ¶m_d->sRecFileName[0], iCurDid);
|
||||
#endif//ENABLE_FRAME_DUMP
|
||||
|
||||
@ -3686,7 +3687,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
#endif//STAT_OUTPUT
|
||||
|
||||
#if defined(MT_ENABLED) && defined(PACKING_ONE_SLICE_PER_LAYER)
|
||||
if (pSvcParam->iMultipleThreadIdc <= 1 || SM_SINGLE_SLICE == param_d->sMso.uiSliceMode) // sigle thread actually used
|
||||
if (pSvcParam->iMultipleThreadIdc <= 1 || SM_SINGLE_SLICE == param_d->sSliceCfg.uiSliceMode) // sigle thread actually used
|
||||
#else
|
||||
if (1)
|
||||
#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER
|
||||
@ -3725,8 +3726,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
}
|
||||
|
||||
#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
|
||||
if (param_d->sMso.uiSliceMode == SM_FIXEDSLCNUM_SLICE && pSvcParam->iMultipleThreadIdc > 1 &&
|
||||
pSvcParam->iMultipleThreadIdc >= param_d->sMso.sSliceArgument.iSliceNum) {
|
||||
if (param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE && pSvcParam->iMultipleThreadIdc > 1 &&
|
||||
pSvcParam->iMultipleThreadIdc >= param_d->sSliceCfg.sSliceArgument.uiSliceNum) {
|
||||
CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx,
|
||||
pCtx->pSliceThreading->pSliceConsumeTime[iCurDid]);
|
||||
#if defined(MT_DEBUG)
|
||||
@ -3737,7 +3738,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
|
||||
++ iSpatialIdx;
|
||||
|
||||
if (iCurDid + 1 < pSvcParam->iNumDependencyLayer) {
|
||||
if (iCurDid + 1 < pSvcParam->iSpatialLayerNum) {
|
||||
WelsSwapDqLayers (pCtx);
|
||||
}
|
||||
|
||||
@ -3777,17 +3778,17 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur
|
||||
|
||||
#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN)
|
||||
if (pSvcParam->iMultipleThreadIdc > 1 && did_list[0] == BASE_DEPENDENCY_ID
|
||||
&& pSvcParam->sDependencyLayers[0].sMso.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sMso.sSliceArgument.iSliceNum
|
||||
&& pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sMso.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum
|
||||
&& pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[did_list[iSpatialNum -
|
||||
1]].sMso.sSliceArgument.iSliceNum) {
|
||||
1]].sSliceCfg.sSliceArgument.uiSliceNum) {
|
||||
AdjustBaseLayer (pCtx);
|
||||
}
|
||||
#endif//DYNAMIC_SLICE_ASSIGN
|
||||
|
||||
#ifdef ENABLE_FRAME_DUMP
|
||||
DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iNumDependencyLayer -
|
||||
DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum -
|
||||
1].sRecFileName[0]); // pDecPic: final reconstruction output
|
||||
#endif//ENABLE_FRAME_DUMP
|
||||
|
||||
@ -3823,18 +3824,18 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
|
||||
/* Decide whether need reset for IDR frame based on adjusting prarameters changed */
|
||||
/* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */
|
||||
bNeedReset = (pOldParam == NULL) ||
|
||||
(pOldParam->iNumTemporalLayer != pNewParam->iNumTemporalLayer) ||
|
||||
(pOldParam->iTemporalLayerNum != pNewParam->iTemporalLayerNum) ||
|
||||
(pOldParam->uiGopSize != pNewParam->uiGopSize) ||
|
||||
(pOldParam->iNumDependencyLayer != pNewParam->iNumDependencyLayer) ||
|
||||
(pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) ||
|
||||
(pOldParam->iDecompStages != pNewParam->iDecompStages) ||
|
||||
(pOldParam->iActualPicWidth != pNewParam->iActualPicWidth
|
||||
|| pOldParam->iActualPicHeight != pNewParam->iActualPicHeight) ||
|
||||
(pOldParam->iPicWidth != pNewParam->iPicWidth
|
||||
|| pOldParam->iPicHeight != pNewParam->iPicHeight) ||
|
||||
(pOldParam->SUsedPicRect.iWidth != pNewParam->SUsedPicRect.iWidth
|
||||
|| pOldParam->SUsedPicRect.iHeight != pNewParam->SUsedPicRect.iHeight) ||
|
||||
(pOldParam->bEnableLongTermReference != pNewParam->bEnableLongTermReference);
|
||||
if (!bNeedReset) { // Check its picture resolutions/quality settings respectively in each dependency layer
|
||||
iIndexD = 0;
|
||||
assert (pOldParam->iNumDependencyLayer == pNewParam->iNumDependencyLayer);
|
||||
assert (pOldParam->iSpatialLayerNum == pNewParam->iSpatialLayerNum);
|
||||
do {
|
||||
const SDLayerParam* kpOldDlp = &pOldParam->sDependencyLayers[iIndexD];
|
||||
const SDLayerParam* kpNewDlp = &pNewParam->sDependencyLayers[iIndexD];
|
||||
@ -3850,8 +3851,8 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
|
||||
break;
|
||||
}
|
||||
|
||||
if (kpOldDlp->sMso.uiSliceMode != kpNewDlp->sMso.uiSliceMode ||
|
||||
kpOldDlp->sMso.sSliceArgument.iSliceNum != kpNewDlp->sMso.sSliceArgument.iSliceNum) {
|
||||
if (kpOldDlp->sSliceCfg.uiSliceMode != kpNewDlp->sSliceCfg.uiSliceMode ||
|
||||
kpOldDlp->sSliceCfg.sSliceArgument.uiSliceNum != kpNewDlp->sSliceCfg.sSliceArgument.uiSliceNum) {
|
||||
bNeedReset = true;
|
||||
break;
|
||||
}
|
||||
@ -3874,7 +3875,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
|
||||
}
|
||||
|
||||
++ iIndexD;
|
||||
} while (iIndexD < pOldParam->iNumDependencyLayer);
|
||||
} while (iIndexD < pOldParam->iSpatialLayerNum);
|
||||
}
|
||||
|
||||
if (bNeedReset) {
|
||||
@ -3929,7 +3930,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
|
||||
|
||||
/* int32_t term reference control */
|
||||
pOldParam->bEnableLongTermReference = pNewParam->bEnableLongTermReference;
|
||||
pOldParam->uiLtrMarkPeriod = pNewParam->uiLtrMarkPeriod;
|
||||
pOldParam->iLtrMarkPeriod = pNewParam->iLtrMarkPeriod;
|
||||
|
||||
// keep below values unchanged as before
|
||||
pOldParam->bEnableSSEI = pNewParam->bEnableSSEI;
|
||||
@ -3977,7 +3978,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
|
||||
sizeof (pOldDlp->uiCodingIdx2TemporalId)); // confirmed_safe_unsafe_usage
|
||||
|
||||
++ iIndexD;
|
||||
} while (iIndexD < pOldParam->iNumDependencyLayer);
|
||||
} while (iIndexD < pOldParam->iSpatialLayerNum);
|
||||
}
|
||||
|
||||
/* Any else initialization/reset for rate control here? */
|
||||
|
@ -114,7 +114,7 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
|
||||
fp_test_rc = fopen ("testRC.dat", "w");
|
||||
fp_vgop = fopen ("vgop.dat", "w");
|
||||
#endif
|
||||
for (j = 0; j < pEncCtx->pSvcParam->iNumDependencyLayer; j++) {
|
||||
for (j = 0; j < pEncCtx->pSvcParam->iSpatialLayerNum; j++) {
|
||||
SSliceCtx* pSliceCtx = &pEncCtx->pSliceCtxList[j];
|
||||
pWelsSvcRc = &pEncCtx->pWelsSvcRc[j];
|
||||
pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[j];
|
||||
@ -167,9 +167,9 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
|
||||
|
||||
RcInitLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign, 1 + pDLayerParam->iHighestTemporalId);
|
||||
|
||||
bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sMso.uiSliceMode) ||
|
||||
(SM_ROWMB_SLICE == pDLayerParam->sMso.uiSliceMode) ||
|
||||
(SM_DYN_SLICE == pDLayerParam->sMso.uiSliceMode));
|
||||
bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
|
||||
(SM_ROWMB_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
|
||||
(SM_DYN_SLICE == pDLayerParam->sSliceCfg.uiSliceMode));
|
||||
if (bMultiSliceMode)
|
||||
pWelsSvcRc->iNumberMbGom = pWelsSvcRc->iNumberMbFrame;
|
||||
}
|
||||
@ -810,7 +810,7 @@ void WelsRcPictureInfoUpdateGom (void* pCtx, int32_t layer_size) {
|
||||
|
||||
|
||||
if (pEncCtx->pSvcParam->bEnableFrameSkip &&
|
||||
pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iNumDependencyLayer - 1) {
|
||||
pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iSpatialLayerNum - 1) {
|
||||
RcVBufferCalculationSkip (pEncCtx);
|
||||
}
|
||||
|
||||
@ -939,7 +939,7 @@ void WelsRcFreeMemory (void* pCtx) {
|
||||
fclose (fp_vgop);
|
||||
fp_vgop = NULL;
|
||||
#endif
|
||||
for (i = 0; i < pEncCtx->pSvcParam->iNumDependencyLayer; i++) {
|
||||
for (i = 0; i < pEncCtx->pSvcParam->iSpatialLayerNum; i++) {
|
||||
pWelsSvcRc = &pEncCtx->pWelsSvcRc[i];
|
||||
RcFreeLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign);
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ void WelsMarkPic (sWelsEncCtx* pCtx) {
|
||||
int32_t iSliceIdx = 0;
|
||||
|
||||
if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bLTRMarkEnable && pCtx->uiTemporalId == 0) {
|
||||
if (!pLtr->bReceivedT0LostFlag && pLtr->uiLtrMarkInterval > pCtx->pSvcParam->uiLtrMarkPeriod
|
||||
if (!pLtr->bReceivedT0LostFlag && pLtr->uiLtrMarkInterval > pCtx->pSvcParam->iLtrMarkPeriod
|
||||
&& CheckCurMarkFrameNumUsed (pCtx)) {
|
||||
pLtr->bLTRMarkingFlag = true;
|
||||
pLtr->bLTRMarkEnable = false;
|
||||
|
@ -353,7 +353,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
|
||||
pMa = (*ppCtx)->pMemAlign;
|
||||
pPara = pCodingParam;
|
||||
iNumSpatialLayers = pPara->iNumDependencyLayer;
|
||||
iNumSpatialLayers = pPara->iSpatialLayerNum;
|
||||
iThreadNum = pPara->iCountThreadsNum;
|
||||
iMaxSliceNum = (*ppCtx)->iMaxSliceCount;
|
||||
|
||||
@ -399,8 +399,8 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
|
||||
iIdx = 0;
|
||||
while (iIdx < iNumSpatialLayers) {
|
||||
SMulSliceOption* pMso = &pPara->sDependencyLayers[iIdx].sMso;
|
||||
const int32_t kiSliceNum = pMso->sSliceArgument.iSliceNum;
|
||||
SSliceConfig* pMso = &pPara->sDependencyLayers[iIdx].sSliceCfg;
|
||||
const int32_t kiSliceNum = pMso->sSliceArgument.uiSliceNum;
|
||||
if (pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE && pPara->iMultipleThreadIdc > 1
|
||||
&& pPara->iMultipleThreadIdc >= kiSliceNum) {
|
||||
pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]");
|
||||
@ -638,7 +638,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
|
||||
}
|
||||
#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
|
||||
iIdx = 0;
|
||||
while (iIdx < pCodingParam->iNumDependencyLayer) {
|
||||
while (iIdx < pCodingParam->iSpatialLayerNum) {
|
||||
if (pSmt->pSliceConsumeTime[iIdx]) {
|
||||
pMa->WelsFree (pSmt->pSliceConsumeTime[iIdx], "pSliceConsumeTime[]");
|
||||
pSmt->pSliceConsumeTime[iIdx] = NULL;
|
||||
@ -688,7 +688,8 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
|
||||
SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam;
|
||||
SDLayerParam* pDlp = &pCodingParam->sDependencyLayers[pCtx->uiDependencyId];
|
||||
SWelsSliceBs* pSliceBs = NULL;
|
||||
const bool kbIsDynamicSlicingMode = (pDlp->sMso.uiSliceMode == SM_DYN_SLICE);
|
||||
const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE);
|
||||
|
||||
int32_t iLayerSize = 0;
|
||||
int32_t iNalIdxBase = pLbi->iNalCount;
|
||||
int32_t iSliceIdx = 0;
|
||||
@ -944,7 +945,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
eNalRefIdc = pEncPEncCtx->eNalPriority;
|
||||
bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag;
|
||||
|
||||
if (pParamD->sMso.uiSliceMode != SM_DYN_SLICE) {
|
||||
if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) {
|
||||
int64_t iSliceStart = 0;
|
||||
bool bDsaFlag = false;
|
||||
iSliceIdx = pPrivateData->iSliceIndex;
|
||||
@ -952,9 +953,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
|
||||
|
||||
#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
|
||||
bDsaFlag = (pParamD->sMso.uiSliceMode == SM_FIXEDSLCNUM_SLICE &&
|
||||
bDsaFlag = (pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE &&
|
||||
pCodingParam->iMultipleThreadIdc > 1 &&
|
||||
pCodingParam->iMultipleThreadIdc >= pParamD->sMso.sSliceArgument.iSliceNum);
|
||||
pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
if (bDsaFlag)
|
||||
iSliceStart = WelsTime();
|
||||
#endif//DYNAMIC_SLICE_ASSIGN || MT_DEBUG
|
||||
@ -1376,10 +1377,11 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) {
|
||||
int32_t iNeedAdj = 1;
|
||||
// uiSliceMode of referencing spatial should be SM_FIXEDSLCNUM_SLICE
|
||||
// if using spatial base layer for complexity estimation
|
||||
|
||||
const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0)
|
||||
&& (pCtx->pSvcParam->sDependencyLayers[iCurDid - 1].sMso.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& (pCtx->pSvcParam->sDependencyLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sDependencyLayers[iCurDid -
|
||||
1].sMso.sSliceArgument.iSliceNum);
|
||||
1].sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
|
||||
if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation
|
||||
#ifdef TRY_SLICING_BALANCE
|
||||
@ -1457,7 +1459,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t
|
||||
while (iSpatialIdx < iSpatialNum) {
|
||||
const int32_t kiDid = pDidList[iSpatialIdx];
|
||||
SDLayerParam* pDlp = &pPara->sDependencyLayers[kiDid];
|
||||
SMulSliceOption* pMso = &pDlp->sMso;
|
||||
SMulSliceOption* pMso = &pDlp->sSliceCfg;
|
||||
SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];
|
||||
SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
|
||||
const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;
|
||||
|
@ -66,7 +66,7 @@ int32_t AssignMbMapSingleSlice (void* pMbMap, const int32_t kiCountMbNum, const
|
||||
*
|
||||
* \return 0 - successful; none 0 - failed
|
||||
*/
|
||||
int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SMulSliceOption* kpMso) {
|
||||
int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpMso) {
|
||||
if (NULL == pSliceSeg || SM_SINGLE_SLICE == pSliceSeg->uiSliceMode)
|
||||
return 1;
|
||||
|
||||
@ -123,7 +123,7 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SMulSliceOption*
|
||||
//slice parameter check for SM_FIXEDSLCNUM_SLICE
|
||||
bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* pSliceArg) {
|
||||
int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]);
|
||||
const uint32_t kuiSliceNum = pSliceArg->iSliceNum;
|
||||
const uint32_t kuiSliceNum = pSliceArg->uiSliceNum;
|
||||
uint32_t uiSliceIdx = 0;
|
||||
const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum;
|
||||
int32_t iNumMbLeft = kiMbNumInFrame;
|
||||
@ -143,7 +143,7 @@ bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceAr
|
||||
//slice parameter check for SM_ROWMB_SLICE
|
||||
bool CheckRowMbMultiSliceSetting (const int32_t kiMbWidth, SSliceArgument* pSliceArg) {
|
||||
int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]);
|
||||
const uint32_t kuiSliceNum = pSliceArg->iSliceNum;
|
||||
const uint32_t kuiSliceNum = pSliceArg->uiSliceNum;
|
||||
uint32_t uiSliceIdx = 0;
|
||||
|
||||
if (NULL == pSlicesAssignList)
|
||||
@ -202,7 +202,7 @@ bool CheckRasterMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument*
|
||||
return false;
|
||||
}
|
||||
|
||||
pSliceArg->iSliceNum = iActualSliceCount;
|
||||
pSliceArg->uiSliceNum = iActualSliceCount;
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -247,7 +247,7 @@ void GomValidCheckSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, i
|
||||
// GOM based RC related for uiSliceMbNum decision, only used at SM_FIXEDSLCNUM_SLICE
|
||||
void GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceArgument* pSliceArg) {
|
||||
uint32_t* pSlicesAssignList = & (pSliceArg->uiSliceMbNum[0]);
|
||||
const uint32_t kuiSliceNum = pSliceArg->iSliceNum;
|
||||
const uint32_t kuiSliceNum = pSliceArg->uiSliceNum;
|
||||
const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight;
|
||||
const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum;
|
||||
int32_t iNumMbLeft = kiMbNumInFrame;
|
||||
@ -300,7 +300,7 @@ void GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight,
|
||||
* Get slice count for multiple slice segment
|
||||
*
|
||||
*/
|
||||
int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SMulSliceOption* pMso) {
|
||||
int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceConfig* pMso) {
|
||||
if (NULL == pMso)
|
||||
return -1;
|
||||
|
||||
@ -309,7 +309,7 @@ int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, S
|
||||
case SM_FIXEDSLCNUM_SLICE:
|
||||
case SM_RASTER_SLICE:
|
||||
case SM_ROWMB_SLICE: {
|
||||
return pMso->sSliceArgument.iSliceNum;
|
||||
return pMso->sSliceArgument.uiSliceNum;
|
||||
}
|
||||
case SM_DYN_SLICE: {
|
||||
return AVERSLICENUM_CONSTRAINT;//at the beginning of dynamic slicing, set the uiSliceNum to be 1
|
||||
@ -336,7 +336,7 @@ int32_t GetInitialSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, S
|
||||
*/
|
||||
int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
|
||||
CMemoryAlign* pMa,
|
||||
SMulSliceOption* pMso,
|
||||
SSliceConfig* pMso,
|
||||
const int32_t kiMbWidth,
|
||||
const int32_t kiMbHeight) {
|
||||
const int32_t kiCountMbNum = kiMbWidth * kiMbHeight;
|
||||
@ -497,7 +497,7 @@ int32_t InitSlicePEncCtx (SSliceCtx* pSliceCtx,
|
||||
bool bFmoUseFlag,
|
||||
int32_t iMbWidth,
|
||||
int32_t iMbHeight,
|
||||
SMulSliceOption* pMso,
|
||||
SSliceConfig* pMso,
|
||||
void* pPpsArg) {
|
||||
if (NULL == pSliceCtx)
|
||||
return 1;
|
||||
|
@ -631,8 +631,9 @@ void WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kb
|
||||
void WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
|
||||
//pSlice-level init should be outside and before this function
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
|
||||
const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag;
|
||||
const bool kbHighestSpatial = pEncCtx->pSvcParam->iNumDependencyLayer ==
|
||||
const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum ==
|
||||
(pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1);
|
||||
|
||||
//MD switch
|
||||
@ -649,8 +650,9 @@ void WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
|
||||
void WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
|
||||
//pSlice-level init should be outside and before this function
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
|
||||
const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag;
|
||||
const bool kbHighestSpatial = pEncCtx->pSvcParam->iNumDependencyLayer ==
|
||||
const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum ==
|
||||
(pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1);
|
||||
|
||||
//MD switch
|
||||
@ -681,7 +683,7 @@ void WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int
|
||||
SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
|
||||
SSlice* pCurSlice = &pCurLayer->sLayerInfo.pSliceInLayer[kiSliceIdx];
|
||||
SBitStringAux* pBs = pCurSlice->pSliceBsa;
|
||||
const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId].sMso.uiSliceMode ==
|
||||
const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode ==
|
||||
SM_DYN_SLICE);
|
||||
|
||||
assert (kiSliceIdx == pCurSlice->uiSliceIdx);
|
||||
@ -916,7 +918,7 @@ void WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, con
|
||||
int32_t iCurMbIdx = -1;
|
||||
int32_t iMbSkipRun = 0;
|
||||
const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
|
||||
const int32_t kiMvdInterTableSize = (pEncCtx->pSvcParam->iNumDependencyLayer == 1 ? 648 : 972);
|
||||
const int32_t kiMvdInterTableSize = (pEncCtx->pSvcParam->iSpatialLayerNum == 1 ? 648 : 972);
|
||||
const int32_t kiMvdInterTableStride = 1 + (kiMvdInterTableSize << 1);
|
||||
uint16_t* pMvdCostTableInter = &pEncCtx->pMvdCostTableInter[kiMvdInterTableSize];
|
||||
const int32_t kiSliceIdx = pSlice->uiSliceIdx;
|
||||
@ -999,7 +1001,7 @@ void WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, vo
|
||||
int32_t iNextMbIdx = kiSliceFirstMbXY;
|
||||
int32_t iCurMbIdx = -1;
|
||||
int32_t iMbSkipRun = 0;
|
||||
const int32_t kiMvdInterTableSize = (pEncCtx->pSvcParam->iNumDependencyLayer == 1 ? 648 : 972);
|
||||
const int32_t kiMvdInterTableSize = (pEncCtx->pSvcParam->iSpatialLayerNum == 1 ? 648 : 972);
|
||||
const int32_t kiMvdInterTableStride = 1 + (kiMvdInterTableSize << 1);
|
||||
uint16_t* pMvdCostTableInter = &pEncCtx->pMvdCostTableInter[kiMvdInterTableSize];
|
||||
const int32_t kiSliceIdx = pSlice->uiSliceIdx;
|
||||
|
@ -263,7 +263,7 @@ int32_t CWelsPreProcess::WelsPreprocessReset (sWelsEncCtx* pCtx) {
|
||||
int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePicture** kppSrcPicList,
|
||||
const int32_t kiConfiguredLayerNum) {
|
||||
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
||||
int32_t iNumDependencyLayer = (int32_t)pSvcParam->iNumDependencyLayer;
|
||||
int32_t iNumDependencyLayer = (int32_t)pSvcParam->iSpatialLayerNum;
|
||||
int32_t iSpatialNum = 0;
|
||||
|
||||
if (!m_bInitDone) {
|
||||
@ -359,7 +359,7 @@ int32_t CWelsPreProcess::AnalyzeSpatialPic (sWelsEncCtx* pCtx, const int32_t kiD
|
||||
int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSourcePicture* kpSrc,
|
||||
Scaled_Picture* pScaledPicture) {
|
||||
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
||||
int8_t iDependencyId = pSvcParam->iNumDependencyLayer - 1;
|
||||
int8_t iDependencyId = pSvcParam->iSpatialLayerNum - 1;
|
||||
int32_t iPicturePos = pCtx->uiSpatialLayersInTemporal[iDependencyId] - 1;
|
||||
|
||||
SPicture* pSrcPic = NULL; // large
|
||||
@ -410,7 +410,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
pCtx->pVaa->bSceneChangeFlag = DetectSceneChange (pDstPic, pRefPic);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < pSvcParam->iNumDependencyLayer; i++) {
|
||||
for (int32_t i = 0; i < pSvcParam->iSpatialLayerNum; i++) {
|
||||
if (pSvcParam->sDependencyLayers[i].uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)]
|
||||
!= INVALID_TEMPORAL_ID) {
|
||||
++ iActualSpatialLayerNum;
|
||||
@ -430,7 +430,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
// pSrc is
|
||||
// -- padded input pic, if downsample should be applied to generate highest layer, [if] block above
|
||||
// -- highest layer, if no downsampling, [else] block above
|
||||
if (pSvcParam->iNumDependencyLayer > 1) {
|
||||
if (pSvcParam->iSpatialLayerNum > 1) {
|
||||
while (iDependencyId >= 0) {
|
||||
pDlayerParam = &pSvcParam->sDependencyLayers[iDependencyId];
|
||||
iTargetWidth = pDlayerParam->iFrameWidth;
|
||||
@ -468,7 +468,7 @@ int32_t CWelsPreProcess::MultiLayerPreprocess (sWelsEncCtx* pCtx, const SSourceP
|
||||
const SSourcePicture* pSrc = NULL;
|
||||
SPicture* pDstPic = NULL;
|
||||
const int32_t iSpatialLayersCfgCount =
|
||||
pSvcParam->iNumDependencyLayer; // count number of spatial layers to be encoded in cfg
|
||||
pSvcParam->iSpatialLayerNum; // count number of spatial layers to be encoded in cfg
|
||||
int32_t i = 0;
|
||||
int32_t j = -1;
|
||||
|
||||
@ -498,7 +498,7 @@ int32_t CWelsPreProcess::MultiLayerPreprocess (sWelsEncCtx* pCtx, const SSourceP
|
||||
++ i;
|
||||
} while (i < kiSpatialNum);
|
||||
|
||||
if (pSvcParam->bEnableSceneChangeDetect && (kiSpatialNum == pSvcParam->iNumDependencyLayer)
|
||||
if (pSvcParam->bEnableSceneChangeDetect && (kiSpatialNum == pSvcParam->iSpatialLayerNum)
|
||||
&& !pCtx->pVaa->bIdrPeriodFlag && !pCtx->bEncCurFrmAsIdrFlag) {
|
||||
SPicture* pRef = pCtx->pLtr[0].bReceivedT0LostFlag ?
|
||||
pCtx->pSpatialPic[0][pCtx->uiSpatialLayersInTemporal[0] + pCtx->pVaa->uiValidLongTermPicIdx] :
|
||||
@ -516,11 +516,11 @@ int32_t CWelsPreProcess::MultiLayerPreprocess (sWelsEncCtx* pCtx, const SSourceP
|
||||
bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPicture) {
|
||||
const int32_t kiInputPicWidth = pParam->SUsedPicRect.iWidth;
|
||||
const int32_t kiInputPicHeight = pParam->SUsedPicRect.iHeight;
|
||||
const int32_t kiDstPicWidth = pParam->sDependencyLayers[pParam->iNumDependencyLayer - 1].iActualWidth;
|
||||
const int32_t kiDstPicHeight = pParam->sDependencyLayers[pParam->iNumDependencyLayer - 1].iActualHeight;
|
||||
const int32_t kiDstPicWidth = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualWidth;
|
||||
const int32_t kiDstPicHeight = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualHeight;
|
||||
bool bNeedDownsampling = true;
|
||||
|
||||
int32_t iSpatialIdx = pParam->iNumDependencyLayer - 1;
|
||||
int32_t iSpatialIdx = pParam->iSpatialLayerNum - 1;
|
||||
|
||||
if (kiDstPicWidth >= kiInputPicWidth && kiDstPicHeight >= kiInputPicHeight) {
|
||||
iSpatialIdx --; // highest D layer do not need downsampling
|
||||
@ -566,7 +566,7 @@ void FreeScaledPic (Scaled_Picture* pScaledPicture, CMemoryAlign* pMemoryAlign
|
||||
|
||||
int32_t CWelsPreProcess::InitLastSpatialPictures (sWelsEncCtx* pCtx) {
|
||||
SWelsSvcCodingParam* pParam = pCtx->pSvcParam;
|
||||
const int32_t kiDlayerCount = pParam->iNumDependencyLayer;
|
||||
const int32_t kiDlayerCount = pParam->iSpatialLayerNum;
|
||||
int32_t iDlayerIndex = 0;
|
||||
|
||||
for (; iDlayerIndex < kiDlayerCount; iDlayerIndex++) {
|
||||
|
@ -66,7 +66,7 @@ class CWelsH264SVCEncoder : public ISVCEncoder {
|
||||
/*
|
||||
* return: CM_RETURN: 0 - success; otherwise - failed;
|
||||
*/
|
||||
virtual int EXTAPI Initialize (SVCEncodingParam* argv, const INIT_TYPE init_type);
|
||||
virtual int EXTAPI Initialize (SEncParamBase* argv, const INIT_TYPE init_type);
|
||||
virtual int EXTAPI Initialize2 (void* argv, const INIT_TYPE init_type);
|
||||
|
||||
virtual int EXTAPI Uninitialize();
|
||||
|
@ -206,29 +206,49 @@ void CWelsH264SVCEncoder::InitEncoder (void) {
|
||||
/*
|
||||
* SVC Encoder Initialization
|
||||
*/
|
||||
int CWelsH264SVCEncoder::Initialize (SVCEncodingParam* argv, const INIT_TYPE iInitType) {
|
||||
if (INIT_TYPE_PARAMETER_BASED != iInitType || NULL == argv) {
|
||||
int CWelsH264SVCEncoder::Initialize (SEncParamBase* argv, const INIT_TYPE iInitType) {
|
||||
|
||||
|
||||
if ((INIT_TYPE_PARAMETER_BASED != iInitType && INIT_TYPE_PARAMETER_EXT != iInitType)|| NULL == argv) {
|
||||
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid iInitType= %d, argv= 0x%p\n",
|
||||
iInitType, (void*)argv);
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
||||
if (m_bInitialFlag) {
|
||||
if (m_bInitialFlag) {
|
||||
WelsLog (m_pEncContext, WELS_LOG_WARNING, "CWelsH264SVCEncoder::Initialize(), reinitialize, m_bInitialFlag= %d\n",
|
||||
m_bInitialFlag);
|
||||
Uninitialize();
|
||||
}
|
||||
|
||||
SVCEncodingParam sEncodingParam;
|
||||
SWelsSvcCodingParam sConfig (true);
|
||||
if(iInitType == INIT_TYPE_PARAMETER_BASED)
|
||||
{
|
||||
SEncParamBase sEncodingParam;
|
||||
memcpy (&sEncodingParam, argv, sizeof (SEncParamBase)); // confirmed_safe_unsafe_usage
|
||||
|
||||
memcpy (&sEncodingParam, argv, sizeof (SVCEncodingParam)); // confirmed_safe_unsafe_usage
|
||||
|
||||
// Convert SEncParamBase into WelsSVCParamConfig here..
|
||||
if (sConfig.ParamBaseTranscode (sEncodingParam, true)) {
|
||||
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n");
|
||||
Uninitialize();
|
||||
return cmInitParaError;
|
||||
}
|
||||
}
|
||||
else if(iInitType == INIT_TYPE_PARAMETER_EXT)
|
||||
{
|
||||
SEncParamExt sEncodingParam;
|
||||
memcpy (&sEncodingParam, argv, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage
|
||||
// Convert SEncParamBase into WelsSVCParamConfig here..
|
||||
if (sConfig.ParamTranscode (sEncodingParam, true)) {
|
||||
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n");
|
||||
Uninitialize();
|
||||
return cmInitParaError;
|
||||
}
|
||||
}
|
||||
#ifdef REC_FRAME_COUNT
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO, "CWelsH264SVCEncoder::Initialize, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
|
||||
m_uiCountFrameNum, m_iCspInternal);
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO,
|
||||
"coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->iKeyPicCodingMode= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableFrameSkip= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
|
||||
"coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableFrameSkip= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
|
||||
sEncodingParam.iPicWidth,
|
||||
sEncodingParam.iPicHeight,
|
||||
sEncodingParam.iTargetBitrate,
|
||||
@ -237,7 +257,6 @@ int CWelsH264SVCEncoder::Initialize (SVCEncodingParam* argv, const INIT_TYPE iIn
|
||||
sEncodingParam.iSpatialLayerNum,
|
||||
sEncodingParam.fFrameRate,
|
||||
sEncodingParam.iInputCsp,
|
||||
sEncodingParam.iKeyPicCodingMode,
|
||||
sEncodingParam.iIntraPeriod,
|
||||
sEncodingParam.bEnableSpsPpsIdAddition,
|
||||
sEncodingParam.bPrefixNalAddingCtrl,
|
||||
@ -267,21 +286,13 @@ int CWelsH264SVCEncoder::Initialize (SVCEncodingParam* argv, const INIT_TYPE iIn
|
||||
++ i;
|
||||
}
|
||||
#endif//REC_FRAME_COUNT
|
||||
|
||||
// Convert SVCEncodingParam into WelsSVCParamConfig here..
|
||||
if (sConfig.ParamTranscode (sEncodingParam, true)) {
|
||||
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n");
|
||||
Uninitialize();
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
||||
m_iSrcListSize = 1;
|
||||
|
||||
return Initialize2 ((void*)&sConfig, INIT_TYPE_CONFIG_BASED);
|
||||
return Initialize2 ((void*)&sConfig, INIT_TYPE_PARAMETER_BASED);
|
||||
}
|
||||
|
||||
int CWelsH264SVCEncoder::Initialize2 (void* argv, const INIT_TYPE iInitType) {
|
||||
if (INIT_TYPE_CONFIG_BASED != iInitType || NULL == argv) {
|
||||
if (INIT_TYPE_PARAMETER_BASED != iInitType || NULL == argv) {
|
||||
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), invalid iInitType= %d, argv= 0x%p.\n",
|
||||
iInitType, (void*)argv);
|
||||
return cmInitParaError;
|
||||
@ -303,20 +314,20 @@ int CWelsH264SVCEncoder::Initialize2 (void* argv, const INIT_TYPE iInitType) {
|
||||
}
|
||||
|
||||
// Check valid parameters
|
||||
const int32_t iNumOfLayers = pCfg->iNumDependencyLayer;
|
||||
const int32_t iNumOfLayers = pCfg->iSpatialLayerNum;
|
||||
if (iNumOfLayers < 1 || iNumOfLayers > MAX_DEPENDENCY_LAYER) {
|
||||
WelsLog (m_pEncContext, WELS_LOG_ERROR,
|
||||
"CWelsH264SVCEncoder::Initialize(), invalid iNumDependencyLayer= %d, valid at range of [1, %d].\n", iNumOfLayers,
|
||||
"CWelsH264SVCEncoder::Initialize(), invalid iSpatialLayerNum= %d, valid at range of [1, %d].\n", iNumOfLayers,
|
||||
MAX_DEPENDENCY_LAYER);
|
||||
Uninitialize();
|
||||
return cmInitParaError;
|
||||
}
|
||||
if (pCfg->iNumTemporalLayer < 1)
|
||||
pCfg->iNumTemporalLayer = 1;
|
||||
if (pCfg->iNumTemporalLayer > MAX_TEMPORAL_LEVEL) {
|
||||
if (pCfg->iTemporalLayerNum < 1)
|
||||
pCfg->iTemporalLayerNum = 1;
|
||||
if (pCfg->iTemporalLayerNum > MAX_TEMPORAL_LEVEL) {
|
||||
WelsLog (m_pEncContext, WELS_LOG_ERROR,
|
||||
"CWelsH264SVCEncoder::Initialize(), invalid iNumTemporalLayer= %d, valid at range of [1, %d].\n",
|
||||
pCfg->iNumTemporalLayer, MAX_TEMPORAL_LEVEL);
|
||||
"CWelsH264SVCEncoder::Initialize(), invalid iTemporalLayerNum= %d, valid at range of [1, %d].\n",
|
||||
pCfg->iTemporalLayerNum, MAX_TEMPORAL_LEVEL);
|
||||
Uninitialize();
|
||||
return cmInitParaError;
|
||||
}
|
||||
@ -366,17 +377,17 @@ int CWelsH264SVCEncoder::Initialize2 (void* argv, const INIT_TYPE iInitType) {
|
||||
|
||||
pCfg->iNumRefFrame = WELS_CLIP3 (pCfg->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
|
||||
|
||||
if (pCfg->uiLtrMarkPeriod == 0) {
|
||||
pCfg->uiLtrMarkPeriod = 30;
|
||||
if (pCfg->iLtrMarkPeriod == 0) {
|
||||
pCfg->iLtrMarkPeriod = 30;
|
||||
}
|
||||
|
||||
const int32_t kiDecStages = WELS_LOG2 (pCfg->uiGopSize);
|
||||
pCfg->iInputCsp = iColorspace;
|
||||
pCfg->iNumTemporalLayer = (int8_t) (1 + kiDecStages);
|
||||
pCfg->iTemporalLayerNum = (int8_t) (1 + kiDecStages);
|
||||
pCfg->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pCfg->iLoopFilterAlphaC0Offset, -6, 6);
|
||||
pCfg->iLoopFilterBetaOffset = WELS_CLIP3 (pCfg->iLoopFilterBetaOffset, -6, 6);
|
||||
|
||||
// m_pSrcPicList = (SSourcePicture **)WelsMalloc( pCfg->iNumDependencyLayer * sizeof(SSourcePicture *), "m_pSrcPicList" );
|
||||
// m_pSrcPicList = (SSourcePicture **)WelsMalloc( pCfg->iSpatialLayerNum * sizeof(SSourcePicture *), "m_pSrcPicList" );
|
||||
// prefer use new/delete pair due encoder intialization stage not start yet for CacheLineSize not detection here (16 or 64 not matched)
|
||||
m_pSrcPicList = new SSourcePicture* [iNumOfLayers];
|
||||
|
||||
@ -388,8 +399,8 @@ int CWelsH264SVCEncoder::Initialize2 (void* argv, const INIT_TYPE iInitType) {
|
||||
}
|
||||
|
||||
// decide property list size between INIT_TYPE_PARAMETER_BASED/INIT_TYPE_CONFIG_BASED
|
||||
m_iMaxPicWidth = pCfg->iActualPicWidth;
|
||||
m_iMaxPicHeight = pCfg->iActualPicHeight;
|
||||
m_iMaxPicWidth = pCfg->iPicWidth;
|
||||
m_iMaxPicHeight = pCfg->iPicHeight;
|
||||
m_iSrcListSize = iNumOfLayers;
|
||||
|
||||
for (int32_t i = 0; i < m_iSrcListSize; ++ i) {
|
||||
@ -580,10 +591,10 @@ int CWelsH264SVCEncoder::EncodeFrame2 (const SSourcePicture** pSrcPicList, int
|
||||
}
|
||||
char strStreamFileName[128] = {0};
|
||||
int32_t iLen = WelsSnprintf (strStreamFileName, 128, "adj%d_w%d.264", m_iSwitchTimes,
|
||||
m_pEncContext->pSvcParam->iActualPicWidth);
|
||||
m_pEncContext->pSvcParam->iPicWidth);
|
||||
m_pFileBs = WelsFopen (strStreamFileName, "wb");
|
||||
WelsSnprintf (strStreamFileName, 128, "adj%d_w%d_size.iLen", m_iSwitchTimes,
|
||||
m_pEncContext->pSvcParam->iActualPicWidth);
|
||||
m_pEncContext->pSvcParam->iPicWidth);
|
||||
m_pFileBsSize = WelsFopen (strStreamFileName, "wb");
|
||||
|
||||
|
||||
@ -729,18 +740,18 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
m_pEncContext->pSvcParam->uiIntraPeriod = (uint32_t)iValue;
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_SVC_ENCODE_PARAM: { // SVC Encoding Parameter
|
||||
SVCEncodingParam sEncodingParam;
|
||||
case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter
|
||||
SEncParamExt sEncodingParam;
|
||||
SWelsSvcCodingParam sConfig (true);
|
||||
int32_t iInputColorspace = 0;
|
||||
int32_t iTargetWidth = 0;
|
||||
int32_t iTargetHeight = 0;
|
||||
|
||||
memcpy (&sEncodingParam, pOption, sizeof (SVCEncodingParam)); // confirmed_safe_unsafe_usage
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO, "ENCODER_OPTION_SVC_ENCODE_PARAM, sEncodingParam.iInputCsp= 0x%x\n",
|
||||
memcpy (&sEncodingParam, pOption, sizeof (SEncParamBase)); // confirmed_safe_unsafe_usage
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO, "ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, sEncodingParam.iInputCsp= 0x%x\n",
|
||||
sEncodingParam.iInputCsp);
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO,
|
||||
"coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iPaddingFlag= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->iKeyPicCodingMode= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
|
||||
"coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iPaddingFlag= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
|
||||
sEncodingParam.iPicWidth,
|
||||
sEncodingParam.iPicHeight,
|
||||
sEncodingParam.iTargetBitrate,
|
||||
@ -748,10 +759,9 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
sEncodingParam.iPaddingFlag,
|
||||
sEncodingParam.iTemporalLayerNum,
|
||||
sEncodingParam.iSpatialLayerNum,
|
||||
sEncodingParam.fFrameRate,
|
||||
sEncodingParam.fMaxFrameRate,
|
||||
sEncodingParam.iInputCsp,
|
||||
sEncodingParam.iKeyPicCodingMode,
|
||||
sEncodingParam.iIntraPeriod,
|
||||
sEncodingParam.uiIntraPeriod,
|
||||
sEncodingParam.bEnableSpsPpsIdAddition,
|
||||
sEncodingParam.bPrefixNalAddingCtrl,
|
||||
sEncodingParam.bEnableDenoise,
|
||||
@ -781,7 +791,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
}
|
||||
#ifdef OUTPUT_BIT_STREAM
|
||||
if (sEncodingParam.sSpatialLayers[sEncodingParam.iSpatialLayerNum - 1].iVideoWidth !=
|
||||
m_pEncContext->pSvcParam->sDependencyLayers[m_pEncContext->pSvcParam->iNumDependencyLayer - 1].iFrameWidth) {
|
||||
m_pEncContext->pSvcParam->sDependencyLayers[m_pEncContext->pSvcParam->iSpatialLayerNum - 1].iFrameWidth) {
|
||||
++ m_iSwitchTimes;
|
||||
m_bSwitch = true;
|
||||
}
|
||||
@ -795,11 +805,11 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
if (sConfig.ParamTranscode (sEncodingParam, true)) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
if (sConfig.iNumDependencyLayer < 1) {
|
||||
if (sConfig.iSpatialLayerNum < 1) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
iTargetWidth = sConfig.iActualPicWidth;
|
||||
iTargetHeight = sConfig.iActualPicHeight;
|
||||
iTargetWidth = sConfig.iPicWidth;
|
||||
iTargetHeight = sConfig.iPicHeight;
|
||||
if (m_pSrcPicList[0] == NULL) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
@ -812,7 +822,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
}
|
||||
#ifdef REC_FRAME_COUNT
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
|
||||
m_uiCountFrameNum, m_iCspInternal);
|
||||
#endif//REC_FRAME_COUNT
|
||||
|
||||
@ -876,7 +886,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
break;
|
||||
case ENCOCER_LTR_MARKING_PERIOD: {
|
||||
uint32_t iValue = * ((uint32_t*) (pOption));
|
||||
m_pEncContext->pSvcParam->uiLtrMarkPeriod = iValue;
|
||||
m_pEncContext->pSvcParam->iLtrMarkPeriod = iValue;
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_LTR: {
|
||||
@ -954,15 +964,25 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
* ((int32_t*)pOption) = m_pEncContext->pSvcParam->uiIntraPeriod;
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_SVC_ENCODE_PARAM: { // SVC Encoding Parameter
|
||||
case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter
|
||||
#ifdef REC_FRAME_COUNT
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
|
||||
"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
|
||||
m_uiCountFrameNum, m_iCspInternal);
|
||||
#endif//REC_FRAME_COUNT
|
||||
memcpy (pOption, m_pEncContext->pSvcParam, sizeof (SWelsSvcCodingParam)); // confirmed_safe_unsafe_usage
|
||||
memcpy (pOption, m_pEncContext->pSvcParam, sizeof (SEncParamExt)); // confirmed_safe_unsafe_usage
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter
|
||||
#ifdef REC_FRAME_COUNT
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
|
||||
m_uiCountFrameNum, m_iCspInternal);
|
||||
#endif//REC_FRAME_COUNT
|
||||
memcpy (pOption, m_pEncContext->pSvcParam, sizeof (SEncParamBase)); // confirmed_safe_unsafe_usage
|
||||
}
|
||||
break;
|
||||
|
||||
case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate
|
||||
#ifdef REC_FRAME_COUNT
|
||||
WelsLog (m_pEncContext, WELS_LOG_INFO,
|
||||
|
@ -7,32 +7,14 @@
|
||||
|
||||
static int InitWithParam(ISVCEncoder* encoder, int width,
|
||||
int height, float frameRate) {
|
||||
SVCEncodingParam param;
|
||||
memset (¶m, 0, sizeof(SVCEncodingParam));
|
||||
SEncParamBase param;
|
||||
memset (¶m, 0, sizeof(SEncParamBase));
|
||||
|
||||
param.sSpatialLayers[0].iVideoWidth = width;
|
||||
param.sSpatialLayers[0].iVideoHeight = height;
|
||||
param.sSpatialLayers[0].fFrameRate = frameRate;
|
||||
param.sSpatialLayers[0].iQualityLayerNum = 1;
|
||||
param.sSpatialLayers[0].iSpatialBitrate = 600000;
|
||||
|
||||
SSliceConfig* sliceCfg = ¶m.sSpatialLayers[0].sSliceCfg;
|
||||
sliceCfg->sSliceArgument.uiSliceNum = 1;
|
||||
sliceCfg->sSliceArgument.uiSliceSizeConstraint = 1500;
|
||||
sliceCfg->sSliceArgument.uiSliceMbNum[0] = 960;
|
||||
|
||||
param.fFrameRate = param.sSpatialLayers[0].fFrameRate;
|
||||
param.iPicWidth = param.sSpatialLayers[0].iVideoWidth;
|
||||
param.iPicHeight = param.sSpatialLayers[0].iVideoHeight;
|
||||
param.fMaxFrameRate = frameRate;
|
||||
param.iPicWidth = width;
|
||||
param.iPicHeight = height;
|
||||
param.iTargetBitrate = 5000000;
|
||||
param.iTemporalLayerNum = 3;
|
||||
param.iSpatialLayerNum = 1;
|
||||
param.bEnableBackgroundDetection = true;
|
||||
param.bEnableLongTermReference = true;
|
||||
param.iLtrMarkPeriod = 30;
|
||||
param.iInputCsp = videoFormatI420;
|
||||
param.bEnableSpsPpsIdAddition = true;
|
||||
|
||||
return encoder->Initialize(¶m, INIT_TYPE_PARAMETER_BASED);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ static void* gThis;
|
||||
*/
|
||||
struct SVCEncoderImpl : public ISVCEncoder {
|
||||
virtual ~SVCEncoderImpl() {}
|
||||
virtual int EXTAPI Initialize(SVCEncodingParam* pParam,
|
||||
virtual int EXTAPI Initialize(SEncParamBase* pParam,
|
||||
const INIT_TYPE kiInitType) {
|
||||
EXPECT_TRUE(gThis == this);
|
||||
return 1;
|
||||
|
@ -104,8 +104,8 @@ TEST_P(DecodeEncodeTest, CompareOutput) {
|
||||
}
|
||||
|
||||
static const DecodeEncodeFileParam kFileParamArray[] = {
|
||||
{"res/test_vd_1d.264", "41c672107cfe9e8e8a67b5d08cbd701f6c982ccd", 320, 192, 12.0f},
|
||||
{"res/test_vd_rc.264", "d546ea7c671b42503f8a46ba50bef2a3eaca4c5a", 320, 192, 12.0f},
|
||||
{"res/test_vd_1d.264", "c04a5978eb715837c29463e79b6598a05136829f", 320, 192, 12.0f},
|
||||
{"res/test_vd_rc.264", "40d8eb5a54d358c663f836c689a158c326de4b1c", 320, 192, 12.0f},
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(DecodeEncodeFile, DecodeEncodeTest,
|
||||
|
@ -65,15 +65,15 @@ TEST_P(EncoderOutputTest, CompareOutput) {
|
||||
static const EncodeFileParam kFileParamArray[] = {
|
||||
{
|
||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||
"4df5751a59eb02153e086ade9b3ecfcb8845c30b", 320, 192, 12.0f
|
||||
"06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f
|
||||
},
|
||||
{
|
||||
"res/CiscoVT2people_160x96_6fps.yuv",
|
||||
"6eb53b6bfdb95dfca0575bd3efe81aa58163951c", 160, 96, 6.0f
|
||||
"4f3759fc44125b27a179ebff158dbba9e431bd0b", 160, 96, 6.0f
|
||||
},
|
||||
{
|
||||
"res/Static_152_100.yuv",
|
||||
"c5af55647a5ead570bd5d96651e05ea699762b8e", 152, 100, 6.0f
|
||||
"a004c7410a78bfe00af65ae7071ce1c485cf036e", 152, 100, 6.0f
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user