ref: 5fe3b6e36200c556ef200e70d7816378350dba00
parent: 600a79bea6f5c704975efa4c62fbcb52516e012c
parent: 287f3538d4d19d2333a200b69b030e2ccb5ceedb
author: volvet <[email protected]>
date: Tue Feb 18 09:00:42 EST 2014
update to the last commit: interface change
--- a/codec/api/svc/codec_api.h
+++ b/codec/api/svc/codec_api.h
@@ -56,8 +56,8 @@
/*
* 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 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*);
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -72,7 +72,8 @@
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,
@@ -97,13 +98,10 @@
DECODER_OPTION_END_OF_STREAM, /* Indicate bitstream of the final frame to be decoded */
DECODER_OPTION_VCL_NAL, //feedback whether or not have VCL NAL in current AU for application layer
DECODER_OPTION_TEMPORAL_ID, //feedback temporal id for application layer
- DECODER_OPTION_MODE, // indicates the decoding mode
- DECODER_OPTION_OUTPUT_PROPERTY,
DECODER_OPTION_FRAME_NUM, //feedback current decoded frame number
DECODER_OPTION_IDR_PIC_ID, // feedback current frame belong to which IDR period
DECODER_OPTION_LTR_MARKING_FLAG, // feedback wether current frame mark a LTR
DECODER_OPTION_LTR_MARKED_FRAME_NUM, // feedback frame num marked by current Frame
- DECODER_OPTION_DEVICE_INFO,
} DECODER_OPTION;
typedef enum { //feedback that whether or not have VCL NAL in current AU
@@ -111,14 +109,6 @@
FEEDBACK_VCL_NAL,
FEEDBACK_UNKNOWN_NAL
} FEEDBACK_VCL_NAL_IN_AU;
-typedef enum { //feedback the iTemporalId in current AU if have VCL NAL
- FEEDBACK_TEMPORAL_ID_0 = 0,
- FEEDBACK_TEMPORAL_ID_1,
- FEEDBACK_TEMPORAL_ID_2,
- FEEDBACK_TEMPORAL_ID_3,
- FEEDBACK_TEMPORAL_ID_4,
- FEEDBACK_UNKNOWN_TEMPORAL_ID
-} FEEDBACK_TEMPORAL_ID;
/* Type of layer being encoded */
typedef enum {
@@ -129,7 +119,7 @@
/* 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
@@ -162,7 +152,14 @@
} 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
//# 1 SM_FIXEDSLCNUM_SLICE | according to SliceNum | Enabled dynamic slicing for multi-thread
//# 2 SM_RASTER_SLICE | according to SlicesAssign | Need input of MB numbers each slice. In addition, if other constraint in SSliceArgument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
@@ -169,12 +166,7 @@
//# 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 {
@@ -186,42 +178,149 @@
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 iLtrMarkPeriod;
+ int iPaddingFlag; // 0:disable padding;1:padding
+ int iEtropyCodingModeFlag;
- int iRCMode; // RC mode
- int iTemporalBitrate[MAX_TEMPORAL_LAYER_NUM]; // target bitrate specified for a temporal level
- int iPaddingFlag; // 0:disable padding;1:padding
-
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 {
--- a/codec/api/svc/codec_def.h
+++ b/codec/api/svc/codec_def.h
@@ -160,32 +160,6 @@
int iSkipFrameStep; //how many frames to skip
} SRateThresholds, *PRateThresholds;
-/*new interface*/
-typedef struct WelsDeviceInfo {
- int bSupport; /* a logic flag provided by decoder which indicates whether GPU decoder can work based on the following device info. */
- char Vendor[128]; // vendor name
- char Device[128]; // device name
- char Driver[128]; // driver version
- char DriverDate[128]; // driver release date
-} Device_Info;
-
-typedef enum TagBufferProperty {
- BUFFER_HOST = 0, // host memory
- BUFFER_DEVICE = 1, // device memory including surface and shared handle
- // for DXVA: shared handle
- // for VDA : iosurface
-
- //SURFACE_DEVICE , // surface
- //SHARED_HANDLE // shared handle
-} EBufferProperty;
-
-typedef enum TagDecodeMode {
- AUTO_MODE = 0, // decided by decoder itself, dynamic mode switch, delayed switch
- SW_MODE = 1, // decoded by CPU, instant switch
- GPU_MODE = 2, // decoded by GPU, instant switch
- SWITCH_MODE = 3 // switch to the other mode, forced mode switch, delayed switch
-} EDecodeMode;
-
typedef struct TagSysMemBuffer {
int iWidth; //width of decoded pic for display
int iHeight; //height of decoded pic for display
@@ -193,24 +167,10 @@
int iStride[2]; //stride of 2 component
} SSysMEMBuffer;
-typedef struct TagVideoMemBuffer {
- int iSurfaceWidth; // used for surface create
- int iSurfaceHeight;
- int D3Dformat; //type is "D3DFORMAT"
- int D3DPool; // type is "D3DPOOL";
- int iLeftTopX;
- int iLeftTopY;
- int iRightBottomX;
- int iRightBottomY;
-} SVideoMemBuffer;
-
typedef struct TagBufferInfo {
- EBufferProperty eBufferProperty; //0: host memory; 1: device memory;
int iBufferStatus; // 0: one frame data is not ready; 1: one frame data is ready
- EDecodeMode eWorkMode; //indicate what the real working mode in decoder
union {
SSysMEMBuffer sSystemBuffer;
- SVideoMemBuffer sVideoBuffer;
} UsrData;
} SBufferInfo;
--- a/codec/console/dec/src/d3d9_utils.cpp
+++ b/codec/console/dec/src/d3d9_utils.cpp
@@ -57,7 +57,6 @@
#define SAFE_RELEASE(p) if(p) { (p)->Release(); (p) = NULL; }
#define SAFE_FREE(p) if(p) { free (p); (p) = NULL; }
-HRESULT Dump2YUV (void* pDst[3], void* pSurface, int iWidth, int iHeight, int iStride[2]);
HRESULT Dump2Surface (void* pDst[3], void* pSurface, int iWidth, int iHeight, int iStride[2]);
HRESULT InitWindow (HWND* hWnd);
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
@@ -122,7 +121,7 @@
return hResult;
BOOL bWindowed = pFp ? FALSE : TRUE;
- BOOL bNeedD3D9 = ! (!bWindowed && pInfo->eBufferProperty == BUFFER_HOST);
+ BOOL bNeedD3D9 = ! (!bWindowed);
if (!m_bInitDone)
m_bInitDone = !bNeedD3D9;
@@ -147,14 +146,11 @@
HRESULT CD3D9Utils::Render (void* pDst[3], SBufferInfo* pInfo) {
HRESULT hResult = E_FAIL;
- EBufferProperty eBufferProperty = pInfo->eBufferProperty;
- if (eBufferProperty == BUFFER_HOST) {
hResult = InitResource (NULL, pInfo);
if (SUCCEEDED (hResult))
hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
- }
if (SUCCEEDED (hResult)) {
IDirect3DSurface9* pBackBuffer = NULL;
@@ -168,7 +164,6 @@
HRESULT CD3D9Utils::Dump (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
HRESULT hResult = E_FAIL;
- EBufferProperty eBufferProperty = pInfo->eBufferProperty;
int iStride[2];
int iWidth;
int iHeight;
@@ -223,12 +218,10 @@
m_d3dpp.hDeviceWindow = m_hWnd;
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
hResult = m_lpD3D9->CreateDevice (uiAdapter, D3DDevType, NULL, dwBehaviorFlags, &m_d3dpp, &m_lpD3D9Device);
- if (pInfo->eBufferProperty == BUFFER_HOST) {
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
D3Dformat = (D3DFORMAT)NV12_FORMAT;
D3Dpool = (D3DPOOL)D3DPOOL_DEFAULT;
- }
hResult = m_lpD3D9Device->CreateOffscreenPlainSurface (iWidth, iHeight, (D3DFORMAT)D3Dformat, (D3DPOOL)D3Dpool,
&m_lpD3D9RawSurfaceShare, NULL);
@@ -297,7 +290,7 @@
return hResult;
BOOL bWindowed = pFp ? FALSE : TRUE;
- BOOL bNeedD3D9 = ! (!bWindowed && pInfo->eBufferProperty == BUFFER_HOST);
+ BOOL bNeedD3D9 = ! (!bWindowed);
if (!m_bInitDone)
m_bInitDone = !bNeedD3D9;
@@ -322,17 +315,11 @@
HRESULT CD3D9ExUtils::Render (void* pDst[3], SBufferInfo* pInfo) {
HRESULT hResult = E_FAIL;
- EBufferProperty eBufferProperty = pInfo->eBufferProperty;
- if (eBufferProperty == BUFFER_HOST) {
hResult = InitResource (NULL, pInfo);
if (SUCCEEDED (hResult))
hResult = Dump2Surface (pDst, m_lpD3D9RawSurfaceShare, pInfo->UsrData.sSystemBuffer.iWidth,
pInfo->UsrData.sSystemBuffer.iHeight, pInfo->UsrData.sSystemBuffer.iStride);
- } else if (eBufferProperty == BUFFER_DEVICE) {
- VOID* pSharedHandle = pDst[0];
- hResult = InitResource (pSharedHandle, pInfo);
- }
if (SUCCEEDED (hResult)) {
IDirect3DSurface9* pBackBuffer = NULL;
@@ -346,34 +333,14 @@
HRESULT CD3D9ExUtils::Dump (void* pDst[3], SBufferInfo* pInfo, FILE* pFp) {
HRESULT hResult = E_FAIL;
- EBufferProperty eBufferProperty = pInfo->eBufferProperty;
int iStride[2];
int iWidth;
int iHeight;
- if (eBufferProperty != BUFFER_HOST) {
- iWidth = pInfo->UsrData.sVideoBuffer.iSurfaceWidth;
- iHeight = pInfo->UsrData.sVideoBuffer.iSurfaceHeight;
- iStride[0] = iWidth;
- iStride[1] = iWidth / 2;
-
- if (m_pDumpYUV == NULL) {
- m_pDumpYUV = (unsigned char*)malloc (iWidth * iHeight * 3 / 2 * sizeof (unsigned char));
- }
-
- if (m_pDumpYUV) {
- void* pSurface = pDst[1];
- pDst[0] = m_pDumpYUV;
- pDst[1] = m_pDumpYUV + iHeight * iStride[0] * sizeof (unsigned char);
- pDst[2] = m_pDumpYUV + iHeight * iStride[0] * 5 / 4 * sizeof (unsigned char);
- hResult = Dump2YUV (pDst, pSurface, iWidth, iHeight, iStride);
- }
- } else {
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
iStride[0] = pInfo->UsrData.sSystemBuffer.iStride[0];
iStride[1] = pInfo->UsrData.sSystemBuffer.iStride[1];
- }
if (pDst[0] && pDst[1] && pDst[2])
Write2File (pFp, (unsigned char**)pDst, iStride, iWidth, iHeight);
@@ -419,17 +386,10 @@
m_d3dpp.hDeviceWindow = m_hWnd;
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
hResult = m_lpD3D9->CreateDeviceEx (uiAdapter, D3DDevType, NULL, dwBehaviorFlags, &m_d3dpp, NULL, &m_lpD3D9Device);
- if (pInfo->eBufferProperty == BUFFER_HOST) {
iWidth = pInfo->UsrData.sSystemBuffer.iWidth;
iHeight = pInfo->UsrData.sSystemBuffer.iHeight;
D3Dformat = (D3DFORMAT)NV12_FORMAT;
D3Dpool = (D3DPOOL)D3DPOOL_DEFAULT;
- } else {
- iWidth = pInfo->UsrData.sVideoBuffer.iSurfaceWidth;
- iHeight = pInfo->UsrData.sVideoBuffer.iSurfaceHeight;
- D3Dformat = (D3DFORMAT)pInfo->UsrData.sVideoBuffer.D3Dformat;
- D3Dpool = (D3DPOOL)pInfo->UsrData.sVideoBuffer.D3DPool;
- }
hResult = m_lpD3D9Device->CreateOffscreenPlainSurface (iWidth, iHeight, (D3DFORMAT)D3Dformat, (D3DPOOL)D3Dpool,
&m_lpD3D9RawSurfaceShare, &pSharedHandle);
}
@@ -440,40 +400,6 @@
return hResult;
}
-
-HRESULT Dump2YUV (void* pDst[3], void* pSurface, int iWidth, int iHeight, int iStride[2]) {
- HRESULT hResult = E_FAIL;
-
- if (!pDst[0] || !pDst[1] || !pDst[2] || !pSurface)
- return hResult;
-
- IDirect3DSurface9* pSurfaceData = (IDirect3DSurface9*)pSurface;
- D3DLOCKED_RECT sD3DLockedRect = {0};
- hResult = pSurfaceData->LockRect (&sD3DLockedRect, NULL, 0);
-
- unsigned char* pInY = (unsigned char*)sD3DLockedRect.pBits;
- unsigned char* pOutY = (unsigned char*)pDst[0];
- int iInStride = sD3DLockedRect.Pitch;
- int iOutStride = iStride[0];
-
- for (int j = 0; j < iHeight; j++)
- memcpy (pOutY + j * iOutStride, pInY + j * iInStride, iWidth); //confirmed_safe_unsafe_usage
-
- unsigned char* pOutV = (unsigned char*)pDst[1];
- unsigned char* pOutU = (unsigned char*)pDst[2];
- unsigned char* pInC = pInY + iInStride * iHeight;
- iOutStride = iStride[1];
- for (int i = 0; i < iHeight / 2; i++) {
- for (int j = 0; j < iWidth; j += 2) {
- pOutV[i * iOutStride + j / 2] = pInC[i * iInStride + j ];
- pOutU[i * iOutStride + j / 2] = pInC[i * iInStride + j + 1];
- }
- }
-
- pSurfaceData->UnlockRect();
-
- return hResult;
-}
HRESULT Dump2Surface (void* pDst[3], void* pSurface, int iWidth, int iHeight, int iStride[2]) {
HRESULT hResult = E_FAIL;
--- a/codec/console/dec/src/h264dec.cpp
+++ b/codec/console/dec/src/h264dec.cpp
@@ -81,9 +81,6 @@
int32_t iColorFormat = videoFormatInternal;
static int32_t iFrameNum = 0;
- EDecodeMode eDecoderMode = SW_MODE;
- EBufferProperty eOutputProperty = BUFFER_DEVICE;
-
CUtils cOutputModule;
double dElapsed = 0;
@@ -150,16 +147,6 @@
goto label_exit;
}
- if (pDecoder->SetOption (DECODER_OPTION_MODE, &eDecoderMode)) {
- fprintf (stderr, "SetOption() failed, opt_id : %d ..\n", DECODER_OPTION_MODE);
- goto label_exit;
- }
-
- // set the output buffer property
- if (pYuvFile) {
- pDecoder->SetOption (DECODER_OPTION_OUTPUT_PROPERTY, &eOutputProperty);
- }
-
#if defined ( STICK_STREAM_SIZE )
FILE* fpTrack = fopen ("3.len", "rb");
@@ -205,10 +192,6 @@
pDecoder->GetOption (DECODER_OPTION_VCL_NAL, &iFeedbackVclNalInAu);
int32_t iFeedbackTidInAu;
pDecoder->GetOption (DECODER_OPTION_TEMPORAL_ID, &iFeedbackTidInAu);
- int32_t iSetMode;
- pDecoder->GetOption (DECODER_OPTION_MODE, &iSetMode);
- int32_t iDeviceInfo;
- pDecoder->GetOption (DECODER_OPTION_DEVICE_INFO, &iDeviceInfo);
//~end for
iStart = WelsTime();
@@ -229,13 +212,8 @@
if (sDstBufInfo.iBufferStatus == 1) {
iFrameNum++;
cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile);
- if (sDstBufInfo.eBufferProperty == BUFFER_HOST) {
- iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
- iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
- } else {
- iWidth = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceWidth;
- iHeight = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceHeight;
- }
+ iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
+ iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
if (pOptionFile != NULL) {
if (iWidth != iLastWidth && iHeight != iLastHeight) {
@@ -268,13 +246,8 @@
if (sDstBufInfo.iBufferStatus == 1) {
cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile);
- if (sDstBufInfo.eBufferProperty == BUFFER_HOST) {
- iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
- iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
- } else {
- iWidth = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceWidth;
- iHeight = sDstBufInfo.UsrData.sVideoBuffer.iSurfaceHeight;
- }
+ iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
+ iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
if (pOptionFile != NULL) {
/* Anyway, we need write in case of final frame decoding */
--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -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 @@
*/
typedef struct LayerpEncCtx_s {
int32_t iDLayerQp;
- SMulSliceOption sMso;
+ SSliceConfig sSliceCfg;
} SLayerPEncCtx;
@@ -100,7 +98,7 @@
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 @@
} 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 @@
}
}
- 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 @@
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 @@
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 @@
} 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
} 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,33 +559,25 @@
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++]);
+ SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
+ pDLayer->fFrameRate = (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++]);
- }
-
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;
@@ -602,32 +584,32 @@
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;
}
}
@@ -634,14 +616,14 @@
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 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 @@
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 @@
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 @@
if (sParam.sSpatialLayers[i].fFrameRate > fMaxFr + EPSN)
fMaxFr = sParam.sSpatialLayers[i].fFrameRate;
}
- sParam.fFrameRate = fMaxFr;
+ sParam.fMaxFrameRate = fMaxFr;
return 0;
}
@@ -753,7 +733,7 @@
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 @@
}
memset (&sFbi, 0, sizeof (SFrameBSInfo));
- memset (&sSvcParam, 0, sizeof (SVCEncodingParam));
+ memset (&sSvcParam, 0, sizeof (SEncParamBase));
FillSpecificParameters (sSvcParam);
@@ -898,7 +878,7 @@
return 1;
SFrameBSInfo sFbi;
- SWelsSvcCodingParam sSvcParam;
+ SEncParamExt sSvcParam;
int64_t iStart = 0, iTotal = 0;
// Preparing encoding process
@@ -926,10 +906,10 @@
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 @@
}
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 @@
}
#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 @@
}
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 @@
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 @@
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 @@
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 @@
#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 @@
}
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;
--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -173,10 +173,6 @@
// Configuration
SDecodingParam* pParam;
uint32_t uiCpuFlag; // CPU compatibility detected
- int32_t iDecoderMode; // indicate decoder running mode
- int32_t iSetMode; // indicate decoder mode set from upper layer, this is read-only for decoder internal
- int32_t iDecoderOutputProperty; // indicate the output buffer property
- int32_t iModeSwitchType; // 1: optimal decision; 2: forced switch to the other mode; 0: no switch
int32_t iOutputColorFormat; // color space format to be outputed
VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection.
--- a/codec/decoder/core/inc/utils.h
+++ b/codec/decoder/core/inc/utils.h
@@ -64,8 +64,6 @@
extern void WelsLog (void* pPtr, int32_t iLevel, const char* kpFmt, ...);
#endif
-#define DECODER_MODE_NAME(a) ((a == SW_MODE)?"SW_MODE":((a == GPU_MODE)?"GPU_MODE":((a == AUTO_MODE)?"AUTO_MODE":"SWITCH_MODE")))
-#define OUTPUT_PROPERTY_NAME(a) ((a == 0)?"system_memory":"video_memory")
#define BUFFER_STATUS_NAME(a) ((a == 0)?"unvalid":"valid")
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -402,12 +402,6 @@
// open decoder
WelsOpenDecoder (pCtx);
- // decode mode setting
- pCtx->iDecoderMode = SW_MODE;
- pCtx->iSetMode = AUTO_MODE;
- pCtx->iDecoderOutputProperty = BUFFER_HOST;
- pCtx->iModeSwitchType = 0; // 0: do not do mode switch
-
return ERR_NONE;
}
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -76,9 +76,6 @@
"DecodeFrameConstruction()::::output good I frame, %d x %d, crop_left:%d, crop_right:%d, crop_top:%d, crop_bottom:%d.\n",
kiWidth, kiHeight, pCtx->sFrameCrop.iLeftOffset, pCtx->sFrameCrop.iRightOffset, pCtx->sFrameCrop.iTopOffset,
pCtx->sFrameCrop.iBottomOffset);
- WelsLog (pCtx, WELS_LOG_INFO, "After decoding, set_mode:[%s], eWorkMode:[%s], eBufferProperty:[%s]\n",
- DECODER_MODE_NAME (pCtx->iSetMode), DECODER_MODE_NAME (pCtx->iDecoderMode),
- OUTPUT_PROPERTY_NAME (pDstInfo->eBufferProperty));
}
//////output:::normal path
@@ -99,7 +96,6 @@
ppDst[0] = ppDst[0] + pCtx->sFrameCrop.iTopOffset * 2 * pPic->iLinesize[0] + pCtx->sFrameCrop.iLeftOffset * 2;
ppDst[1] = ppDst[1] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset;
ppDst[2] = ppDst[2] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset;
- pDstInfo->eBufferProperty = BUFFER_HOST;
pDstInfo->iBufferStatus = 1;
return 0;
@@ -935,7 +931,6 @@
return ERR_INFO_OUT_OF_MEMORY;
memset (pDq, 0, sizeof (SDqLayer));
- if (pCtx->iDecoderMode == SW_MODE) {
do {
const int32_t kiHshift = iPlaneIdx ? 1 : 0;
@@ -1015,7 +1010,6 @@
(NULL == pCtx->sMb.pInterPredictionDoneFlag[i])
)
)
- } // end of if(pCtx->iDecoderMode == SW_MODE)
pCtx->pDqLayersList[i] = pDq;
++ i;
@@ -1579,8 +1573,6 @@
}
}
-
- pDstInfo->eBufferProperty = (EBufferProperty)pCtx->iDecoderOutputProperty;
iErr = DecodeCurrentAccessUnit (pCtx, ppDst, iStride, &iWidth, &iHeight, pDstInfo);
--- a/codec/decoder/core/src/pic_queue.cpp
+++ b/codec/decoder/core/src/pic_queue.cpp
@@ -81,7 +81,6 @@
iLumaSize = iPicWidth * iPicHeight;
iChromaSize = iPicChromaWidth * iPicChromaHeight;
- if (pCtx->iDecoderMode == SW_MODE) {
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMalloc (iLumaSize /* luma */
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
@@ -93,7 +92,6 @@
pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH;
pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1);
pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1);
- }
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -259,32 +259,6 @@
m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
return cmResultSuccess;
- } else if (eOptID == DECODER_OPTION_MODE) {
- if (pOption == NULL)
- return cmInitParaError;
-
- iVal = * ((int*)pOption);
-
- m_pDecContext->iSetMode = iVal;
- if (iVal == SW_MODE) {
- m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;
- } else {
-#if !defined(__APPLE__)
- m_pDecContext->iDecoderOutputProperty = BUFFER_DEVICE;
-#else
- m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;//BUFFER_HOST;//BUFFER_DEVICE;
-#endif
-
- }
-
- return cmResultSuccess;
- } else if (eOptID == DECODER_OPTION_OUTPUT_PROPERTY) {
- if (pOption == NULL)
- return cmInitParaError;
-
- iVal = * ((int*)pOption);
- if (m_pDecContext->iSetMode != SW_MODE)
- m_pDecContext->iDecoderOutputProperty = iVal;
}
@@ -339,19 +313,6 @@
iVal = m_pDecContext->iFeedbackTidInAu;
* ((int*)pOption) = iVal;
return cmResultSuccess;
- } else if (DECODER_OPTION_MODE == eOptID) {
- if (pOption == NULL)
- return cmInitParaError;
-
- iVal = m_pDecContext->iSetMode;
-
- * ((int*)pOption) = iVal;
- return cmResultSuccess;
- } else if (DECODER_OPTION_DEVICE_INFO == eOptID) {
- if (pOption == NULL)
- return cmInitParaError;
-
- return cmResultSuccess;
}
return cmInitParaError;
@@ -390,7 +351,6 @@
m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize
memset (pDstInfo, 0, sizeof (SBufferInfo));
- pDstInfo->eBufferProperty = (EBufferProperty)m_pDecContext->iDecoderOutputProperty;
#ifdef LONG_TERM_REF
m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR
@@ -406,8 +366,6 @@
pDstInfo); //iErrorCode has been modified in this function
XMMREG_PROTECT_LOAD(CWelsH264Decoder);
- pDstInfo->eWorkMode = (EDecodeMode)m_pDecContext->iDecoderMode;
-
if (m_pDecContext->iErrorCode) {
ENalUnitType eNalType =
NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
@@ -447,7 +405,6 @@
DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];
DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;
DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;
- DstInfo.eBufferProperty = BUFFER_HOST;
eDecState = DecodeFrame2 (kpSrc, kiSrcLen, (void**)ppDst, &DstInfo);
if (eDecState == dsErrorFree) {
--- a/codec/encoder/core/inc/param_svc.h
+++ b/codec/encoder/core/inc/param_svc.h
@@ -96,7 +96,7 @@
// 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 @@
/*
* 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,62 +123,16 @@
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;
-int8_t iDecompStages; // GOP size dependency
+// FALSE: Streaming Video Sharing; TRUE: Video Conferencing Meeting;
-/* 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
-
+int8_t iDecompStages; // GOP size dependency
/* 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:
TagWelsSvcCodingParam (const bool kbEnableRc = true) {
FillDefault (kbEnableRc);
@@ -196,8 +144,8 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
//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 @@
// 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 @@
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;
--- a/codec/encoder/core/inc/svc_enc_slice_segment.h
+++ b/codec/encoder/core/inc/svc_enc_slice_segment.h
@@ -80,18 +80,6 @@
#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 @@
bool bFmoUseFlag,
int32_t iMbWidth,
int32_t iMbHeight,
- SMulSliceOption* pMulSliceOption,
+ SSliceConfig* pMulSliceOption,
void* pPpsArg);
@@ -206,7 +194,7 @@
* 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
--- a/codec/encoder/core/inc/wels_preprocess.h
+++ b/codec/encoder/core/inc/wels_preprocess.h
@@ -110,8 +110,8 @@
int32_t WelsPreprocessReset (sWelsEncCtx* pEncCtx);
int32_t AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam);
void FreeSpatialPictures (sWelsEncCtx* pCtx);
- int32_t WelsPreprocessStep1 (sWelsEncCtx* pEncCtx, const SSourcePicture** kppSrcPicList, const int32_t kiConfiguredLayerNum);
- int32_t WelsPreprocessStep3 (sWelsEncCtx* pEncCtx, const int32_t kiDIdx);
+ int32_t BuildSpatialPicList (sWelsEncCtx* pEncCtx, const SSourcePicture** kppSrcPicList, const int32_t kiConfiguredLayerNum);
+ int32_t AnalyzeSpatialPic (sWelsEncCtx* pEncCtx, const int32_t kiDIdx);
int32_t UpdateSpatialPictures(sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam, const int8_t iCurTid, const int32_t d_idx);
private:
--- a/codec/encoder/core/src/deblocking.cpp
+++ b/codec/encoder/core/src/deblocking.cpp
@@ -734,7 +734,7 @@
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);
--- a/codec/encoder/core/src/encoder.cpp
+++ b/codec/encoder/core/src/encoder.cpp
@@ -287,7 +287,7 @@
// 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 {
@@ -294,8 +294,8 @@
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;
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -88,7 +88,7 @@
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 @@
}
}
- 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 @@
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 @@
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 @@
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 @@
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 @@
//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 @@
#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 @@
#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 @@
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 @@
#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 @@
{
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 @@
//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 @@
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 @@
//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 @@
#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
@@ -644,7 +644,7 @@
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;
@@ -760,7 +760,7 @@
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;
@@ -802,7 +802,7 @@
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;
@@ -811,7 +811,7 @@
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");
@@ -828,7 +828,7 @@
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,
@@ -901,7 +901,7 @@
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;
@@ -980,7 +980,7 @@
false,
pSps->iMbWidth,
pSps->iMbHeight,
- & (pDlayerParam->sMso),
+ & (pDlayerParam->sSliceCfg),
pPps);
if (iResult) {
WelsLog (*ppCtx, WELS_LOG_WARNING, "InitDqLayers(), InitSlicePEncCtx failed(%d)!", iResult);
@@ -1042,7 +1042,7 @@
return 1;
(*ppCtx)->pStrideTab = pPtr;
- iCntTid = pParam->iNumTemporalLayer > 1 ? 2 : 1;
+ iCntTid = pParam->iTemporalLayerNum > 1 ? 2 : 1;
iSpatialIdx = 0;
while (iSpatialIdx < kiNumSpatialLayers) {
@@ -1278,7 +1278,7 @@
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;
@@ -1314,12 +1314,12 @@
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);
@@ -1607,16 +1607,17 @@
// 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) {
@@ -1648,7 +1649,7 @@
// 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;
@@ -1672,7 +1673,7 @@
// 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);
@@ -1758,12 +1759,12 @@
}
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;
@@ -1772,7 +1773,7 @@
#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()
@@ -1784,7 +1785,7 @@
// 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:
@@ -2034,7 +2035,7 @@
#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;
@@ -2098,7 +2099,7 @@
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);
{
@@ -2511,8 +2512,8 @@
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);
@@ -2592,7 +2593,7 @@
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;
@@ -2615,7 +2616,7 @@
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;
@@ -2638,7 +2639,7 @@
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;
@@ -3084,7 +3085,7 @@
pFbi->iLayerNum = 0; // for initialization
// perform csc/denoise/downsample/padding, generate spatial layers
- iSpatialNum = pCtx->pVpp->WelsPreprocessStep1 (pCtx, ppSrcList, iConfiguredLayerNum);
+ iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, ppSrcList, iConfiguredLayerNum);
if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate)
++ pCtx->iCodingIndex;
return WELS_FRAME_TYPE_SKIP;
@@ -3132,7 +3133,7 @@
SDLayerParam* param_d = &pSvcParam->sDependencyLayers[d_idx];
pCtx->uiDependencyId = iCurDid = (int8_t)d_idx;
- pCtx->pVpp->WelsPreprocessStep3 (pCtx, d_idx);
+ pCtx->pVpp->AnalyzeSpatialPic (pCtx, d_idx);
pCtx->pEncPic = pEncPic = (pSpatialIndexMap + iSpatialIdx)->pSrc;
pCtx->pEncPic->iPictureType = pCtx->eSliceType;
@@ -3147,12 +3148,12 @@
// 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
@@ -3183,7 +3184,7 @@
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;
@@ -3229,7 +3230,7 @@
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) {
@@ -3258,9 +3259,9 @@
}
// 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;
@@ -3270,7 +3271,7 @@
#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)
@@ -3281,7 +3282,7 @@
>= 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) {
@@ -3311,7 +3312,7 @@
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;
}
@@ -3370,7 +3371,7 @@
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;
}
@@ -3447,7 +3448,7 @@
}
}
// 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);
@@ -3462,7 +3463,7 @@
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;
}
@@ -3552,7 +3553,7 @@
#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
@@ -3634,7 +3635,7 @@
#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
@@ -3673,8 +3674,8 @@
}
#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)
@@ -3685,7 +3686,7 @@
++ iSpatialIdx;
- if (iCurDid + 1 < pSvcParam->iNumDependencyLayer) {
+ if (iCurDid + 1 < pSvcParam->iSpatialLayerNum) {
WelsSwapDqLayers (pCtx);
}
@@ -3711,17 +3712,17 @@
#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
@@ -3757,18 +3758,18 @@
/* 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];
@@ -3784,8 +3785,8 @@
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;
}
@@ -3808,7 +3809,7 @@
}
++ iIndexD;
- } while (iIndexD < pOldParam->iNumDependencyLayer);
+ } while (iIndexD < pOldParam->iSpatialLayerNum);
}
if (bNeedReset) {
@@ -3863,7 +3864,7 @@
/* 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;
@@ -3911,7 +3912,7 @@
sizeof (pOldDlp->uiCodingIdx2TemporalId)); // confirmed_safe_unsafe_usage
++ iIndexD;
- } while (iIndexD < pOldParam->iNumDependencyLayer);
+ } while (iIndexD < pOldParam->iSpatialLayerNum);
}
/* Any else initialization/reset for rate control here? */
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -114,7 +114,7 @@
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 @@
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 @@
if (pEncCtx->pSvcParam->bEnableFrameSkip &&
- pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iNumDependencyLayer - 1) {
+ pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iSpatialLayerNum - 1) {
RcVBufferCalculationSkip (pEncCtx);
}
@@ -939,7 +939,7 @@
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);
}
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -430,7 +430,7 @@
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;
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -353,7 +353,7 @@
pMa = (*ppCtx)->pMemAlign;
pPara = pCodingParam;
- iNumSpatialLayers = pPara->iNumDependencyLayer;
+ iNumSpatialLayers = pPara->iSpatialLayerNum;
iThreadNum = pPara->iCountThreadsNum;
iMaxSliceNum = (*ppCtx)->iMaxSliceCount;
@@ -399,8 +399,8 @@
#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 @@
}
#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 @@
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 @@
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 @@
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 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 @@
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;
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -66,7 +66,7 @@
*
* \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 @@
//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 @@
//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 @@
return false;
}
- pSliceArg->iSliceNum = iActualSliceCount;
+ pSliceArg->uiSliceNum = iActualSliceCount;
return true;
}
@@ -247,7 +247,7 @@
// 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 @@
* 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 @@
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 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 @@
bool bFmoUseFlag,
int32_t iMbWidth,
int32_t iMbHeight,
- SMulSliceOption* pMso,
+ SSliceConfig* pMso,
void* pPpsArg) {
if (NULL == pSliceCtx)
return 1;
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -631,8 +631,9 @@
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 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 @@
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 @@
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 @@
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;
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -265,7 +265,7 @@
int32_t CWelsPreProcess::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
@@ -295,7 +295,7 @@
void CWelsPreProcess::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 = m_uiSpatialPicNum[j];
@@ -310,10 +310,10 @@
}
}
-int32_t CWelsPreProcess::WelsPreprocessStep1 (sWelsEncCtx* pCtx, const SSourcePicture** kppSrcPicList,
+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 @@
return iSpatialNum;
}
-int32_t CWelsPreProcess::WelsPreprocessStep3 (sWelsEncCtx* pCtx, const int32_t kiDidx) {
+int32_t CWelsPreProcess::AnalyzeSpatialPic (sWelsEncCtx* pCtx, const int32_t kiDidx) {
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
bool bNeededMbAq = (pSvcParam->bEnableAdaptiveQuant && (pCtx->eSliceType == P_SLICE));
bool bCalculateBGD = (pCtx->eSliceType == P_SLICE && pSvcParam->bEnableBackgroundDetection);
@@ -430,8 +430,8 @@
int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSourcePicture* kpSrc,
Scaled_Picture* pScaledPicture) {
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
- int8_t iDependencyId = pSvcParam->iNumDependencyLayer - 1;
- int32_t iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1;
+ int8_t iDependencyId = pSvcParam->iSpatialLayerNum - 1;
+ int32_t iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1;
SPicture* pSrcPic = NULL; // large
SPicture* pDstPic = NULL; // small
@@ -481,7 +481,7 @@
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;
@@ -501,7 +501,7 @@
// 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;
@@ -539,7 +539,7 @@
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;
@@ -569,7 +569,7 @@
++ 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 ?
m_pSpatialPic[0][m_uiSpatialLayersInTemporal[0] + pCtx->pVaa->uiValidLongTermPicIdx] :
@@ -587,11 +587,11 @@
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
@@ -637,7 +637,7 @@
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++) {
--- a/codec/encoder/plus/inc/welsEncoderExt.h
+++ b/codec/encoder/plus/inc/welsEncoderExt.h
@@ -66,7 +66,7 @@
/*
* 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();
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -206,29 +206,49 @@
/*
* 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 @@
sEncodingParam.iSpatialLayerNum,
sEncodingParam.fFrameRate,
sEncodingParam.iInputCsp,
- sEncodingParam.iKeyPicCodingMode,
sEncodingParam.iIntraPeriod,
sEncodingParam.bEnableSpsPpsIdAddition,
sEncodingParam.bPrefixNalAddingCtrl,
@@ -267,21 +286,13 @@
++ 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 @@
}
// 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 @@
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 @@
}
// 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 @@
}
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 @@
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 @@
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 @@
}
#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 @@
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 @@
}
#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 @@
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 @@
* ((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,
--- a/test/BaseEncoderTest.cpp
+++ b/test/BaseEncoderTest.cpp
@@ -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);
}
--- a/test/cpp_interface_test.cpp
+++ b/test/cpp_interface_test.cpp
@@ -22,7 +22,7 @@
*/
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;
--- a/test/decode_encode_test.cpp
+++ b/test/decode_encode_test.cpp
@@ -104,8 +104,8 @@
}
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,
--- a/test/encoder_test.cpp
+++ b/test/encoder_test.cpp
@@ -65,15 +65,15 @@
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
},
};