2013-12-09 13:51:09 +01:00
/*!
* \ copy
* Copyright ( c ) 2013 , Cisco Systems
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
*
* * Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
*
* * Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in
* the documentation and / or other materials provided with the
* distribution .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT
* LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT ,
* INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING ,
* BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ;
* LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT
* LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE .
*
*/
# ifndef WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__
# define WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__
////////////////Data and /or structures introduced in Cisco OpenH264 application////////////////
/* Constants */
2014-01-22 08:22:58 +01:00
# define MAX_TEMPORAL_LAYER_NUM 4
2013-12-09 13:51:09 +01:00
# define MAX_SPATIAL_LAYER_NUM 4
# define MAX_QUALITY_LAYER_NUM 4
# define MAX_LAYER_NUM_OF_FRAME 128
# define MAX_NAL_UNITS_IN_LAYER 128 // predetermined here, adjust it later if need
# define MAX_RTP_PAYLOAD_LEN 1000
# define AVERAGE_RTP_PAYLOAD_LEN 800
# define SAVED_NALUNIT_NUM_TMP ( (MAX_SPATIAL_LAYER_NUM*MAX_QUALITY_LAYER_NUM) + 1 + MAX_SPATIAL_LAYER_NUM ) //SPS/PPS + SEI/SSEI + PADDING_NAL
# define MAX_SLICES_NUM_TMP ( ( MAX_NAL_UNITS_IN_LAYER - SAVED_NALUNIT_NUM_TMP ) / 3 )
2014-04-29 07:15:28 +02:00
# define AUTO_REF_PIC_COUNT -1 // encoder selects the number of reference frame automatically
2013-12-12 23:21:12 +01:00
typedef enum {
/* Errors derived from bitstream parsing */
dsErrorFree = 0x00 , /* Bitstream error-free */
dsFramePending = 0x01 , /* Need more throughput to generate a frame output, */
dsRefLost = 0x02 , /* layer lost at reference frame with temporal id 0 */
dsBitstreamError = 0x04 , /* Error bitstreams(maybe broken internal frame) the decoder cared */
dsDepLayerLost = 0x08 , /* Dependented layer is ever lost */
dsNoParamSets = 0x10 , /* No parameter set NALs involved */
/* Errors derived from logic level */
dsInvalidArgument = 0x1000 , /* Invalid argument specified */
dsInitialOptExpected = 0x2000 , /* Initializing operation is expected */
dsOutOfMemory = 0x4000 , /* Out of memory due to new request */
/* ANY OTHERS? */
dsDstBufNeedExpand = 0x8000 /* Actual picture size exceeds size of dst pBuffer feed in decoder, so need expand its size */
} DECODING_STATE ;
2013-12-09 13:51:09 +01:00
/* Option types introduced in SVC encoder application */
2013-12-12 23:21:12 +01:00
typedef enum {
ENCODER_OPTION_DATAFORMAT = 0 ,
ENCODER_OPTION_IDR_INTERVAL ,
2014-02-18 02:32:05 +01:00
ENCODER_OPTION_SVC_ENCODE_PARAM_BASE ,
ENCODER_OPTION_SVC_ENCODE_PARAM_EXT ,
2013-12-12 23:21:12 +01:00
ENCODER_OPTION_FRAME_RATE ,
2013-12-23 03:47:13 +01:00
ENCODER_OPTION_BITRATE ,
2014-03-20 07:30:20 +01:00
ENCODER_OPTION_MAX_BITRATE ,
2013-12-12 23:21:12 +01:00
ENCODER_OPTION_INTER_SPATIAL_PRED ,
ENCODER_OPTION_RC_MODE ,
ENCODER_PADDING_PADDING ,
ENCODER_LTR_RECOVERY_REQUEST ,
ENCODER_LTR_MARKING_FEEDBACK ,
ENCOCER_LTR_MARKING_PERIOD ,
ENCODER_OPTION_LTR ,
2014-05-20 03:45:13 +02:00
ENCODER_OPTION_ENABLE_SSEI , //enable SSEI: true--enable ssei; false--disable ssei
2013-12-12 23:21:12 +01:00
ENCODER_OPTION_ENABLE_PREFIX_NAL_ADDING , //enable prefix: true--enable prefix; false--disable prefix
2014-05-20 03:45:13 +02:00
ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION , //enable pSps/pPps id addition: true--enable pSps/pPps id; false--disable pSps/pPps id addistion
2013-12-12 23:21:12 +01:00
2014-03-07 03:23:25 +01:00
ENCODER_OPTION_CURRENT_PATH ,
2014-03-10 08:22:40 +01:00
ENCODER_OPTION_DUMP_FILE ,
ENCODER_OPTION_TRACE_LEVEL
2013-12-09 13:51:09 +01:00
} ENCODER_OPTION ;
2014-01-06 06:28:55 +01:00
/* Option types introduced in decoder application */
2013-12-12 23:21:12 +01:00
typedef enum {
DECODER_OPTION_DATAFORMAT = 0 , /* Set color space of decoding output frame */
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_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
2014-04-03 11:20:56 +02:00
DECODER_OPTION_ERROR_CON_IDC , //not finished yet, indicate decoder error concealment status, in progress
2013-12-09 13:51:09 +01:00
} DECODER_OPTION ;
2014-04-03 11:20:56 +02:00
//enuerate the types of error concealment methods
typedef enum {
ERROR_CON_DISABLE = 0 ,
2014-04-16 07:25:29 +02:00
ERROR_CON_FRAME_COPY ,
2014-04-03 11:20:56 +02:00
ERROR_CON_SLICE_COPY ,
} ERROR_CON_IDC ;
2013-12-12 23:21:12 +01:00
typedef enum { //feedback that whether or not have VCL NAL in current AU
FEEDBACK_NON_VCL_NAL = 0 ,
FEEDBACK_VCL_NAL ,
FEEDBACK_UNKNOWN_NAL
2013-12-09 13:51:09 +01:00
} FEEDBACK_VCL_NAL_IN_AU ;
/* Type of layer being encoded */
2013-12-12 23:21:12 +01:00
typedef enum {
NON_VIDEO_CODING_LAYER = 0 ,
VIDEO_CODING_LAYER = 1
2013-12-09 13:51:09 +01:00
} LAYER_TYPE ;
2014-03-20 07:30:20 +01:00
typedef enum {
2014-05-06 04:30:21 +02:00
SPATIAL_LAYER_0 = 0 ,
SPATIAL_LAYER_1 = 1 ,
SPATIAL_LAYER_2 = 2 ,
SPATIAL_LAYER_3 = 3 ,
SPATIAL_LAYER_ALL = 4 ,
2014-03-20 07:30:20 +01:00
} LAYER_NUM ;
2013-12-09 13:51:09 +01:00
//enumerate the type of video bitstream which is provided to decoder
2013-12-12 23:21:12 +01:00
typedef enum {
VIDEO_BITSTREAM_AVC = 0 ,
VIDEO_BITSTREAM_SVC = 1 ,
VIDEO_BITSTREAM_DEFAULT = VIDEO_BITSTREAM_SVC ,
} VIDEO_BITSTREAM_TYPE ;
typedef enum {
NO_RECOVERY_REQUSET = 0 ,
LTR_RECOVERY_REQUEST = 1 ,
IDR_RECOVERY_REQUEST = 2 ,
NO_LTR_MARKING_FEEDBACK = 3 ,
LTR_MARKING_SUCCESS = 4 ,
LTR_MARKING_FAILED = 5 ,
} KEY_FRAME_REQUEST_TYPE ;
typedef struct {
unsigned int uiFeedbackType ; //IDR request or LTR recovery request
unsigned int uiIDRPicId ; // distinguish request from different IDR
int iLastCorrectFrameNum ;
int iCurrentFrameNum ; //specify current decoder frame_num.
} SLTRRecoverRequest ;
typedef struct {
unsigned int uiFeedbackType ; //mark failed or successful
unsigned int uiIDRPicId ; // distinguish request from different IDR
int iLTRFrameNum ; //specify current decoder frame_num
} SLTRMarkingFeedback ;
2013-12-09 13:51:09 +01:00
2014-02-18 02:32:05 +01:00
typedef struct {
2014-05-06 04:30:21 +02:00
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
2014-02-18 02:32:05 +01:00
2014-03-07 11:09:17 +01:00
typedef enum {
2014-03-07 11:13:41 +01:00
SM_SINGLE_SLICE = 0 , // | SliceNum==1
SM_FIXEDSLCNUM_SLICE = 1 , // | according to SliceNum | Enabled dynamic slicing for multi-thread
SM_RASTER_SLICE = 2 , // | 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.
SM_ROWMB_SLICE = 3 , // | according to PictureMBHeight | Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
SM_DYN_SLICE = 4 , // | according to SliceSize | Dynamic slicing (have no idea about slice_nums until encoding current frame)
2014-03-11 03:23:46 +01:00
SM_AUTO_SLICE = 5 , // | according to thread number
SM_RESERVED = 6
2014-03-07 11:09:17 +01:00
} SliceModeEnum ;
2014-03-21 08:18:17 +01:00
typedef enum {
2014-04-08 07:08:28 +02:00
RC_QUALITY_MODE = 0 , //Quality mode
RC_BITRATE_MODE = 1 , //Bitrate mode
RC_LOW_BW_MODE = 2 , //bitrate limited mode
RC_OFF_MODE = - 1 , // rate control off mode
2014-03-21 08:18:17 +01:00
} RC_MODES ;
2014-03-20 10:02:32 +01:00
typedef enum {
PRO_UNKNOWN = 0 ,
PRO_BASELINE = 66 ,
PRO_MAIN = 77 ,
PRO_EXTENDED = 88 ,
PRO_HIGH = 100 ,
PRO_HIGH10 = 110 ,
PRO_HIGH422 = 122 ,
PRO_HIGH444 = 144 ,
PRO_CAVLC444 = 244 ,
PRO_SCALABLE_BASELINE = 83 ,
PRO_SCALABLE_HIGH = 86 ,
2014-05-06 04:30:21 +02:00
} EProfileIdc ;
2014-03-20 10:02:32 +01:00
typedef enum {
LEVEL_UNKNOWN ,
LEVEL_1_0 ,
LEVEL_1_B ,
LEVEL_1_1 ,
LEVEL_1_2 ,
LEVEL_1_3 ,
LEVEL_2_0 ,
LEVEL_2_1 ,
LEVEL_2_2 ,
LEVEL_3_0 ,
LEVEL_3_1 ,
LEVEL_3_2 ,
LEVEL_4_0 ,
LEVEL_4_1 ,
LEVEL_4_2 ,
LEVEL_5_0 ,
LEVEL_5_1 ,
LEVEL_5_2
2014-05-06 04:30:21 +02:00
} ELevelIdc ;
2014-03-20 10:02:32 +01:00
2013-12-12 23:21:12 +01:00
typedef struct {
2014-03-07 11:19:16 +01:00
SliceModeEnum uiSliceMode ; //by default, uiSliceMode will be SM_SINGLE_SLICE
2014-02-18 02:32:05 +01:00
SSliceArgument sSliceArgument ;
2013-12-09 13:51:09 +01:00
} SSliceConfig ;
typedef struct {
2013-12-12 23:21:12 +01:00
int iVideoWidth ; // video size in cx specified for a layer
int iVideoHeight ; // video size in cy specified for a layer
float fFrameRate ; // frame rate specified for a layer
int iSpatialBitrate ; // target bitrate for a spatial layer
2014-03-20 07:30:20 +01:00
int iMaxSpatialBitrate ;
2014-03-20 10:02:32 +01:00
EProfileIdc uiProfileIdc ; // value of profile IDC (PRO_UNKNOWN for auto-detection)
ELevelIdc uiLevelIdc ;
2014-02-18 02:32:05 +01:00
int iDLayerQp ;
2013-12-12 23:21:12 +01:00
SSliceConfig sSliceCfg ;
2013-12-09 13:51:09 +01:00
} SSpatialLayerConfig ;
2014-03-20 10:02:32 +01:00
typedef enum {
CAMERA_VIDEO_REAL_TIME , //camera video signal
SCREEN_CONTENT_REAL_TIME , //screen content signal
2014-05-06 04:30:21 +02:00
} EUsageType ;
2014-04-08 07:08:28 +02:00
// TODO: Refine the parameters definition.
// SVC Encoding Parameters
2014-05-06 04:30:21 +02:00
typedef struct TagEncParamBase {
EUsageType
iUsageType ; //application type;// CAMERA_VIDEO_REAL_TIME: //camera video signal; SCREEN_CONTENT_REAL_TIME: screen content signal;
2014-02-18 02:32:05 +01:00
int iInputCsp ; // color space of input sequence
2013-12-12 23:21:12 +01:00
int iPicWidth ; // width of picture in samples
int iPicHeight ; // height of picture in samples
int iTargetBitrate ; // target bitrate desired
2014-03-21 08:19:30 +01:00
RC_MODES iRCMode ; // RC mode
2014-02-18 02:32:05 +01:00
float fMaxFrameRate ; // input maximal frame rate
} SEncParamBase , * PEncParamBase ;
2014-05-06 04:30:21 +02:00
typedef struct TagEncParamExt {
EUsageType
iUsageType ; //application type;// CAMERA_VIDEO_REAL_TIME: //camera video signal; SCREEN_CONTENT_REAL_TIME: screen content signal;
2014-02-18 11:12:55 +01:00
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
2014-03-21 08:19:30 +01:00
RC_MODES iRCMode ; // RC mode
2014-02-18 11:12:55 +01:00
float fMaxFrameRate ; // input maximal frame rate
2013-12-12 23:21:12 +01:00
int iTemporalLayerNum ; // layer number at temporal level
int iSpatialLayerNum ; // layer number at spatial level
2014-02-24 03:40:17 +01:00
SSpatialLayerConfig sSpatialLayers [ MAX_SPATIAL_LAYER_NUM ] ;
2013-12-12 23:21:12 +01:00
2014-02-18 02:32:05 +01:00
unsigned int uiIntraPeriod ; // period of Intra frame
2014-02-24 03:40:17 +01:00
int iNumRefFrame ; // number of reference frame used
unsigned int uiFrameToBeCoded ; // frame to be encoded (at input frame rate)
2013-12-12 23:21:12 +01:00
bool bEnableSpsPpsIdAddition ;
bool bPrefixNalAddingCtrl ;
2014-02-24 03:40:17 +01:00
bool bEnableSSEI ;
2014-02-24 03:55:15 +01:00
int iPaddingFlag ; // 0:disable padding;1:padding
2014-04-03 02:28:53 +02:00
int iEntropyCodingModeFlag ;
2014-02-24 03:40:17 +01:00
/* rc control */
2014-01-17 11:29:03 +01:00
bool bEnableFrameSkip ; // allow skipping frames to keep the bitrate within limits
2014-03-20 07:30:20 +01:00
int iMaxBitrate ; // max bitrate desired
2014-02-24 03:40:17 +01:00
int iMaxQp ;
int iMinQp ;
2014-03-21 01:59:38 +01:00
unsigned int uiMaxNalSize ;
2013-12-12 23:21:12 +01:00
2014-02-24 03:40:17 +01:00
/*LTR settings*/
2014-02-18 02:32:05 +01:00
bool bEnableLongTermReference ; // 0: on, 1: off
2014-02-24 03:40:17 +01:00
int iLTRRefNum ;
2014-03-19 09:16:08 +01:00
unsigned int iLtrMarkPeriod ;
2013-12-12 23:21:12 +01:00
2014-02-24 03:55:15 +01:00
/* multi-thread settings*/
2014-05-06 04:30:21 +02:00
unsigned short
iMultipleThreadIdc ; // 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
2014-02-18 02:32:05 +01:00
2014-05-06 04:30:21 +02:00
/* Deblocking loop filter */
2014-02-18 02:32:05 +01:00
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
2014-02-24 03:40:17 +01:00
/*pre-processing feature*/
bool bEnableDenoise ; // denoise control
bool bEnableBackgroundDetection ; // background detection control //VAA_BACKGROUND_DETECTION //BGD cmd
bool bEnableAdaptiveQuant ; // adaptive quantization control
bool bEnableFrameCroppingFlag ; // enable frame cropping flag: TRUE always in application
bool bEnableSceneChangeDetect ;
2014-05-06 04:30:21 +02:00
} SEncParamExt ;
2013-12-09 13:51:09 +01:00
//Define a new struct to show the property of video bitstream.
typedef struct {
2013-12-12 23:21:12 +01:00
unsigned int size ; //size of the struct
VIDEO_BITSTREAM_TYPE eVideoBsType ;
2013-12-09 13:51:09 +01:00
} SVideoProperty ;
/* SVC Decoding Parameters, reserved here and potential applicable in the future */
2013-12-12 23:21:12 +01:00
typedef struct TagSVCDecodingParam {
char * pFileNameRestructed ; // File name of restructed frame used for PSNR calculation based debug
int iOutputColorFormat ; // color space format to be outputed, EVideoFormatType specified in codec_def.h
unsigned int uiCpuLoad ; // CPU load
unsigned char uiTargetDqLayer ; // Setting target dq layer id
2013-12-09 13:51:09 +01:00
2013-12-12 23:21:12 +01:00
unsigned char uiEcActiveFlag ; // Whether active error concealment feature in decoder
2013-12-09 13:51:09 +01:00
2013-12-12 23:21:12 +01:00
SVideoProperty sVideoProperty ;
2013-12-09 13:51:09 +01:00
} SDecodingParam , * PDecodingParam ;
/* Bitstream inforamtion of a layer being encoded */
typedef struct {
2013-12-12 23:21:12 +01:00
unsigned char uiTemporalId ;
unsigned char uiSpatialId ;
unsigned char uiQualityId ;
2013-12-09 13:51:09 +01:00
2013-12-12 23:21:12 +01:00
unsigned char uiPriorityId ; //ignore it currently
2013-12-09 13:51:09 +01:00
2013-12-12 23:21:12 +01:00
unsigned char uiLayerType ;
2013-12-09 13:51:09 +01:00
2013-12-12 23:21:12 +01:00
int iNalCount ; // Count number of NAL coded already
2014-05-14 10:00:36 +02:00
int * pNalLengthInByte ; // Length of NAL size in byte from 0 to iNalCount-1
2013-12-12 23:21:12 +01:00
unsigned char * pBsBuf ; // Buffer of bitstream contained
2013-12-09 13:51:09 +01:00
} SLayerBSInfo , * PLayerBSInfo ;
typedef struct {
2013-12-12 23:21:12 +01:00
int iTemporalId ; // Temporal ID
unsigned char uiFrameType ;
2013-12-09 13:51:09 +01:00
2013-12-12 23:21:12 +01:00
int iLayerNum ;
SLayerBSInfo sLayerInfo [ MAX_LAYER_NUM_OF_FRAME ] ;
2013-12-09 13:51:09 +01:00
2014-02-20 07:50:04 +01:00
int eOutputFrameType ;
2014-03-03 10:05:06 +01:00
long long uiTimeStamp ;
2013-12-09 13:51:09 +01:00
} SFrameBSInfo , * PFrameBSInfo ;
2013-12-12 23:21:12 +01:00
typedef struct Source_Picture_s {
int iColorFormat ; // color space type
int iStride [ 4 ] ; // stride for each plane pData
unsigned char * pData [ 4 ] ; // plane pData
int iPicWidth ; // luma picture width in x coordinate
int iPicHeight ; // luma picture height in y coordinate
2014-03-03 10:05:06 +01:00
long long uiTimeStamp ;
2013-12-09 13:51:09 +01:00
} SSourcePicture ;
2014-05-06 04:30:21 +02:00
typedef struct Bitrate_Info_s {
2014-03-20 07:30:20 +01:00
LAYER_NUM iLayer ;
int iBitrate ; //the maximum bitrate
2014-05-06 04:30:21 +02:00
} SBitrateInfo ;
2014-03-20 07:30:20 +01:00
2014-05-06 04:30:21 +02:00
typedef struct Dump_Layer_s {
int iLayer ;
char * pFileName ;
} SDumpLayer ;
2013-12-09 13:51:09 +01:00
# endif //WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__