Merge pull request #362 from mstorsjo/encoder-default-params
Add a new public method for initializing SEncParamExt to default values
This commit is contained in:
commit
9319f879e4
@ -59,6 +59,8 @@ class ISVCEncoder {
|
|||||||
virtual int EXTAPI Initialize (const SEncParamBase* pParam) = 0;
|
virtual int EXTAPI Initialize (const SEncParamBase* pParam) = 0;
|
||||||
virtual int EXTAPI InitializeExt (const SEncParamExt* pParam) = 0;
|
virtual int EXTAPI InitializeExt (const SEncParamExt* pParam) = 0;
|
||||||
|
|
||||||
|
virtual int EXTAPI GetDefaultParams (SEncParamExt* pParam) = 0;
|
||||||
|
|
||||||
virtual int EXTAPI Uninitialize() = 0;
|
virtual int EXTAPI Uninitialize() = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -142,6 +144,8 @@ struct ISVCEncoderVtbl {
|
|||||||
int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam);
|
int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam);
|
||||||
int (*InitializeExt) (ISVCEncoder*, const SEncParamExt* pParam);
|
int (*InitializeExt) (ISVCEncoder*, const SEncParamExt* pParam);
|
||||||
|
|
||||||
|
int (*GetDefaultParams) (ISVCEncoder*, SEncParamExt* pParam);
|
||||||
|
|
||||||
int (*Uninitialize) (ISVCEncoder*);
|
int (*Uninitialize) (ISVCEncoder*);
|
||||||
|
|
||||||
int (*EncodeFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
|
int (*EncodeFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
|
||||||
|
@ -137,13 +137,67 @@ TagWelsSvcCodingParam (const bool kbEnableRc = true) {
|
|||||||
}
|
}
|
||||||
~TagWelsSvcCodingParam() {}
|
~TagWelsSvcCodingParam() {}
|
||||||
|
|
||||||
void FillDefault (const bool kbEnableRc) {
|
static void FillDefault (SEncParamExt& param, const bool kbEnableRc) {
|
||||||
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
|
memset(¶m, 0, sizeof(param));
|
||||||
uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
|
param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
|
||||||
iNumRefFrame = MIN_REF_PIC_COUNT; // number of reference frame used
|
param.iNumRefFrame = MIN_REF_PIC_COUNT; // number of reference frame used
|
||||||
|
|
||||||
|
param.iPicWidth = 0; // actual input picture width
|
||||||
|
param.iPicHeight = 0; // actual input picture height
|
||||||
|
|
||||||
|
param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
|
||||||
|
param.iInputCsp = videoFormatI420; // input sequence color space in default
|
||||||
|
param.uiFrameToBeCoded = (uint32_t) - 1; // frame to be encoded (at input frame rate)
|
||||||
|
|
||||||
|
param.iTargetBitrate = 0; // overall target bitrate introduced in RC module
|
||||||
|
#ifdef MT_ENABLED
|
||||||
|
param.iMultipleThreadIdc = 0; // auto to detect cpu cores inside
|
||||||
|
#else
|
||||||
|
param.iMultipleThreadIdc =
|
||||||
|
1; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
|
||||||
|
#endif//MT_ENABLED
|
||||||
|
param.iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
|
||||||
|
|
||||||
|
param.iLTRRefNum = 0;
|
||||||
|
param.iLtrMarkPeriod = 30; //the min distance of two int32_t references
|
||||||
|
|
||||||
|
param.bEnableSSEI = true;
|
||||||
|
param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application
|
||||||
|
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
|
||||||
|
|
||||||
|
/* Deblocking loop filter */
|
||||||
|
param.iLoopFilterDisableIdc = 1; // 0: on, 1: off, 2: on except for slice boundaries
|
||||||
|
param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0
|
||||||
|
param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0
|
||||||
|
param.iInterLayerLoopFilterDisableIdc = 1; // Employed based upon inter-layer, same comment as above
|
||||||
|
param.iInterLayerLoopFilterAlphaC0Offset = 0; // InterLayerLoopFilterAlphaC0Offset
|
||||||
|
param.iInterLayerLoopFilterBetaOffset = 0; // InterLayerLoopFilterBetaOffset
|
||||||
|
|
||||||
|
/* Rate Control */
|
||||||
|
param.bEnableRc = kbEnableRc;
|
||||||
|
param.iRCMode = 0;
|
||||||
|
param.iPaddingFlag = 0;
|
||||||
|
|
||||||
|
param.bEnableDenoise = false; // denoise control
|
||||||
|
param.bEnableSceneChangeDetect = true; // scene change detection control
|
||||||
|
param.bEnableBackgroundDetection = true; // background detection control
|
||||||
|
param.bEnableAdaptiveQuant = true; // adaptive quantization control
|
||||||
|
param.bEnableFrameSkip = true; // frame skipping
|
||||||
|
param.bEnableLongTermReference = false; // long term reference control
|
||||||
|
param.bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
|
||||||
|
param.bPrefixNalAddingCtrl = true; // prefix NAL adding control
|
||||||
|
param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
|
||||||
|
param.iTemporalLayerNum = 1; // number of temporal layer specified
|
||||||
|
|
||||||
|
param.iMaxQp = 51;
|
||||||
|
param.iMinQp = 0;
|
||||||
|
param.iUsageType = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FillDefault (const bool kbEnableRc) {
|
||||||
|
FillDefault(*this, kbEnableRc);
|
||||||
|
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
|
||||||
|
|
||||||
iPicWidth = 0; // actual input picture width
|
|
||||||
iPicHeight = 0; // actual input picture height
|
|
||||||
SUsedPicRect.iLeft =
|
SUsedPicRect.iLeft =
|
||||||
SUsedPicRect.iTop =
|
SUsedPicRect.iTop =
|
||||||
SUsedPicRect.iWidth =
|
SUsedPicRect.iWidth =
|
||||||
@ -151,57 +205,12 @@ void FillDefault (const bool kbEnableRc) {
|
|||||||
|
|
||||||
pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/
|
pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/
|
||||||
|
|
||||||
fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
|
|
||||||
iInputCsp = videoFormatI420; // input sequence color space in default
|
|
||||||
uiFrameToBeCoded = (uint32_t) - 1; // frame to be encoded (at input frame rate)
|
|
||||||
|
|
||||||
iTargetBitrate = 0; // overall target bitrate introduced in RC module
|
|
||||||
bDeblockingParallelFlag = false; // deblocking filter parallelization control flag
|
bDeblockingParallelFlag = false; // deblocking filter parallelization control flag
|
||||||
#ifdef MT_ENABLED
|
|
||||||
iMultipleThreadIdc = 0; // auto to detect cpu cores inside
|
|
||||||
#else
|
|
||||||
iMultipleThreadIdc =
|
|
||||||
1; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
|
|
||||||
#endif//MT_ENABLED
|
|
||||||
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
|
|
||||||
|
|
||||||
iLTRRefNum = 0;
|
|
||||||
iLtrMarkPeriod = 30; //the min distance of two int32_t references
|
|
||||||
|
|
||||||
bMgsT0OnlyStrategy =
|
bMgsT0OnlyStrategy =
|
||||||
true; // Strategy of have MGS only at T0 frames (0: do not use this strategy; 1: use this strategy)
|
true; // Strategy of have MGS only at T0 frames (0: do not use this strategy; 1: use this strategy)
|
||||||
bEnableSSEI = true;
|
|
||||||
bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application
|
|
||||||
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
|
|
||||||
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
|
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
|
||||||
|
|
||||||
/* Deblocking loop filter */
|
|
||||||
iLoopFilterDisableIdc = 1; // 0: on, 1: off, 2: on except for slice boundaries
|
|
||||||
iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0
|
|
||||||
iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0
|
|
||||||
iInterLayerLoopFilterDisableIdc = 1; // Employed based upon inter-layer, same comment as above
|
|
||||||
iInterLayerLoopFilterAlphaC0Offset = 0; // InterLayerLoopFilterAlphaC0Offset
|
|
||||||
iInterLayerLoopFilterBetaOffset = 0; // InterLayerLoopFilterBetaOffset
|
|
||||||
|
|
||||||
/* Rate Control */
|
|
||||||
bEnableRc = kbEnableRc;
|
|
||||||
iRCMode = 0;
|
|
||||||
iPaddingFlag = 0;
|
|
||||||
|
|
||||||
bEnableDenoise = false; // denoise control
|
|
||||||
bEnableSceneChangeDetect = true; // scene change detection control
|
|
||||||
bEnableBackgroundDetection = true; // background detection control
|
|
||||||
bEnableAdaptiveQuant = true; // adaptive quantization control
|
|
||||||
bEnableFrameSkip = true; // frame skipping
|
|
||||||
bEnableLongTermReference = false; // long term reference control
|
|
||||||
bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
|
|
||||||
bPrefixNalAddingCtrl = true; // prefix NAL adding control
|
|
||||||
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);
|
memset(sDependencyLayers,0,sizeof(SDLayerParam)*MAX_DEPENDENCY_LAYER);
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,6 +69,8 @@ class CWelsH264SVCEncoder : public ISVCEncoder {
|
|||||||
virtual int EXTAPI Initialize (const SEncParamBase* argv);
|
virtual int EXTAPI Initialize (const SEncParamBase* argv);
|
||||||
virtual int EXTAPI InitializeExt (const SEncParamExt* argv);
|
virtual int EXTAPI InitializeExt (const SEncParamExt* argv);
|
||||||
|
|
||||||
|
virtual int EXTAPI GetDefaultParams (SEncParamExt* argv);
|
||||||
|
|
||||||
virtual int EXTAPI Uninitialize();
|
virtual int EXTAPI Uninitialize();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -197,6 +197,11 @@ void CWelsH264SVCEncoder::InitEncoder (void) {
|
|||||||
|
|
||||||
/* Interfaces override from ISVCEncoder */
|
/* Interfaces override from ISVCEncoder */
|
||||||
|
|
||||||
|
int CWelsH264SVCEncoder::GetDefaultParams (SEncParamExt* argv) {
|
||||||
|
SWelsSvcCodingParam::FillDefault(*argv, true);
|
||||||
|
return cmResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SVC Encoder Initialization
|
* SVC Encoder Initialization
|
||||||
*/
|
*/
|
||||||
|
@ -12,13 +12,14 @@ typedef void(*CheckFunc)(int, int, const char*);
|
|||||||
void CheckEncoderInterface(ISVCEncoder* p, CheckFunc check) {
|
void CheckEncoderInterface(ISVCEncoder* p, CheckFunc check) {
|
||||||
CHECK(1, p, Initialize);
|
CHECK(1, p, Initialize);
|
||||||
CHECK(2, p, InitializeExt);
|
CHECK(2, p, InitializeExt);
|
||||||
CHECK(3, p, Uninitialize);
|
CHECK(3, p, GetDefaultParams);
|
||||||
CHECK(4, p, EncodeFrame);
|
CHECK(4, p, Uninitialize);
|
||||||
CHECK(5, p, EncodeParameterSets);
|
CHECK(5, p, EncodeFrame);
|
||||||
CHECK(6, p, PauseFrame);
|
CHECK(6, p, EncodeParameterSets);
|
||||||
CHECK(7, p, ForceIntraFrame);
|
CHECK(7, p, PauseFrame);
|
||||||
CHECK(8, p, SetOption);
|
CHECK(8, p, ForceIntraFrame);
|
||||||
CHECK(9, p, GetOption);
|
CHECK(9, p, SetOption);
|
||||||
|
CHECK(10, p, GetOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckDecoderInterface(ISVCDecoder* p, CheckFunc check) {
|
void CheckDecoderInterface(ISVCDecoder* p, CheckFunc check) {
|
||||||
|
@ -30,35 +30,39 @@ struct SVCEncoderImpl : public ISVCEncoder {
|
|||||||
EXPECT_TRUE(gThis == this);
|
EXPECT_TRUE(gThis == this);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
virtual int EXTAPI Uninitialize() {
|
virtual int EXTAPI GetDefaultParams(SEncParamExt* pParam) {
|
||||||
EXPECT_TRUE(gThis == this);
|
EXPECT_TRUE(gThis == this);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
virtual int EXTAPI Uninitialize() {
|
||||||
|
EXPECT_TRUE(gThis == this);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
virtual int EXTAPI EncodeFrame(const SSourcePicture* kpSrcPic,
|
virtual int EXTAPI EncodeFrame(const SSourcePicture* kpSrcPic,
|
||||||
SFrameBSInfo* pBsInfo) {
|
SFrameBSInfo* pBsInfo) {
|
||||||
EXPECT_TRUE(gThis == this);
|
EXPECT_TRUE(gThis == this);
|
||||||
return 4;
|
return 5;
|
||||||
}
|
}
|
||||||
virtual int EXTAPI EncodeParameterSets(SFrameBSInfo* pBsInfo) {
|
virtual int EXTAPI EncodeParameterSets(SFrameBSInfo* pBsInfo) {
|
||||||
EXPECT_TRUE(gThis == this);
|
EXPECT_TRUE(gThis == this);
|
||||||
return 5;
|
return 6;
|
||||||
}
|
}
|
||||||
virtual int EXTAPI PauseFrame(const SSourcePicture* kpSrcPic,
|
virtual int EXTAPI PauseFrame(const SSourcePicture* kpSrcPic,
|
||||||
SFrameBSInfo* pBsInfo) {
|
SFrameBSInfo* pBsInfo) {
|
||||||
EXPECT_TRUE(gThis == this);
|
EXPECT_TRUE(gThis == this);
|
||||||
return 6;
|
return 7;
|
||||||
}
|
}
|
||||||
virtual int EXTAPI ForceIntraFrame(bool bIDR) {
|
virtual int EXTAPI ForceIntraFrame(bool bIDR) {
|
||||||
EXPECT_TRUE(gThis == this);
|
EXPECT_TRUE(gThis == this);
|
||||||
return 7;
|
return 8;
|
||||||
}
|
}
|
||||||
virtual int EXTAPI SetOption(ENCODER_OPTION eOptionId, void* pOption) {
|
virtual int EXTAPI SetOption(ENCODER_OPTION eOptionId, void* pOption) {
|
||||||
EXPECT_TRUE(gThis == this);
|
EXPECT_TRUE(gThis == this);
|
||||||
return 8;
|
return 9;
|
||||||
}
|
}
|
||||||
virtual int EXTAPI GetOption(ENCODER_OPTION eOptionId, void* pOption) {
|
virtual int EXTAPI GetOption(ENCODER_OPTION eOptionId, void* pOption) {
|
||||||
EXPECT_TRUE(gThis == this);
|
EXPECT_TRUE(gThis == this);
|
||||||
return 9;
|
return 10;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user