codec_app_def.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*!
  2. * \copy
  3. * Copyright (c) 2013, Cisco Systems
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  21. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  22. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  26. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  28. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. */
  32. #ifndef WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__
  33. #define WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__
  34. /**
  35. * @file codec_app_def.h
  36. * @brief Data and /or structures introduced in Cisco OpenH264 application
  37. */
  38. #include "codec_def.h"
  39. /* Constants */
  40. #define MAX_TEMPORAL_LAYER_NUM 4
  41. #define MAX_SPATIAL_LAYER_NUM 4
  42. #define MAX_QUALITY_LAYER_NUM 4
  43. #define MAX_LAYER_NUM_OF_FRAME 128
  44. #define MAX_NAL_UNITS_IN_LAYER 128 ///< predetermined here, adjust it later if need
  45. #define MAX_RTP_PAYLOAD_LEN 1000
  46. #define AVERAGE_RTP_PAYLOAD_LEN 800
  47. #define SAVED_NALUNIT_NUM_TMP ( (MAX_SPATIAL_LAYER_NUM*MAX_QUALITY_LAYER_NUM) + 1 + MAX_SPATIAL_LAYER_NUM ) ///< SPS/PPS + SEI/SSEI + PADDING_NAL
  48. #define MAX_SLICES_NUM_TMP ( ( MAX_NAL_UNITS_IN_LAYER - SAVED_NALUNIT_NUM_TMP ) / 3 )
  49. #define AUTO_REF_PIC_COUNT -1 ///< encoder selects the number of reference frame automatically
  50. #define UNSPECIFIED_BIT_RATE 0 ///< to do: add detail comment
  51. /**
  52. * @brief Struct of OpenH264 version
  53. */
  54. ///
  55. /// E.g. SDK version is 1.2.0.0, major version number is 1, minor version number is 2, and revision number is 0.
  56. typedef struct _tagVersion {
  57. unsigned int uMajor; ///< The major version number
  58. unsigned int uMinor; ///< The minor version number
  59. unsigned int uRevision; ///< The revision number
  60. unsigned int uReserved; ///< The reserved number, it should be 0.
  61. } OpenH264Version;
  62. /**
  63. * @brief Decoding status
  64. */
  65. typedef enum {
  66. /**
  67. * Errors derived from bitstream parsing
  68. */
  69. dsErrorFree = 0x00, ///< bit stream error-free
  70. dsFramePending = 0x01, ///< need more throughput to generate a frame output,
  71. dsRefLost = 0x02, ///< layer lost at reference frame with temporal id 0
  72. dsBitstreamError = 0x04, ///< error bitstreams(maybe broken internal frame) the decoder cared
  73. dsDepLayerLost = 0x08, ///< dependented layer is ever lost
  74. dsNoParamSets = 0x10, ///< no parameter set NALs involved
  75. dsDataErrorConcealed = 0x20, ///< current data error concealed specified
  76. /**
  77. * Errors derived from logic level
  78. */
  79. dsInvalidArgument = 0x1000, ///< invalid argument specified
  80. dsInitialOptExpected = 0x2000, ///< initializing operation is expected
  81. dsOutOfMemory = 0x4000, ///< out of memory due to new request
  82. /**
  83. * ANY OTHERS?
  84. */
  85. dsDstBufNeedExpan = 0x8000 ///< actual picture size exceeds size of dst pBuffer feed in decoder, so need expand its size
  86. } DECODING_STATE;
  87. /**
  88. * @brief Option types introduced in SVC encoder application
  89. */
  90. typedef enum {
  91. ENCODER_OPTION_DATAFORMAT = 0,
  92. ENCODER_OPTION_IDR_INTERVAL, ///< IDR period,0/-1 means no Intra period (only the first frame); lager than 0 means the desired IDR period, must be multiple of (2^temporal_layer)
  93. ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, ///< structure of Base Param
  94. ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, ///< structure of Extension Param
  95. ENCODER_OPTION_FRAME_RATE, ///< maximal input frame rate, current supported range: MAX_FRAME_RATE = 30,MIN_FRAME_RATE = 1
  96. ENCODER_OPTION_BITRATE,
  97. ENCODER_OPTION_MAX_BITRATE,
  98. ENCODER_OPTION_INTER_SPATIAL_PRED,
  99. ENCODER_OPTION_RC_MODE,
  100. ENCODER_OPTION_RC_FRAME_SKIP,
  101. ENCODER_PADDING_PADDING, ///< 0:disable padding;1:padding
  102. ENCODER_OPTION_PROFILE, ///< assgin the profile for each layer
  103. ENCODER_OPTION_LEVEL, ///< assgin the level for each layer
  104. ENCODER_OPTION_NUMBER_REF, ///< the number of refererence frame
  105. ENCODER_OPTION_DELIVERY_STATUS, ///< the delivery info which is a feedback from app level
  106. ENCODER_LTR_RECOVERY_REQUEST,
  107. ENCODER_LTR_MARKING_FEEDBACK,
  108. ENCODER_LTR_MARKING_PERIOD,
  109. ENCODER_OPTION_LTR, ///< 0:disable LTR;larger than 0 enable LTR; LTR number is fixed to be 2 in current encoder
  110. ENCODER_OPTION_COMPLEXITY,
  111. ENCODER_OPTION_ENABLE_SSEI, ///< enable SSEI: true--enable ssei; false--disable ssei
  112. ENCODER_OPTION_ENABLE_PREFIX_NAL_ADDING, ///< enable prefix: true--enable prefix; false--disable prefix
  113. ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, ///< enable pSps/pPps id addition: true--enable pSps/pPps id; false--disable pSps/pPps id addistion
  114. ENCODER_OPTION_CURRENT_PATH,
  115. ENCODER_OPTION_DUMP_FILE, ///< dump layer reconstruct frame to a specified file
  116. ENCODER_OPTION_TRACE_LEVEL, ///< trace info based on the trace level
  117. ENCODER_OPTION_TRACE_CALLBACK, ///< a void (*)(void* context, int level, const char* message) function which receives log messages
  118. ENCODER_OPTION_TRACE_CALLBACK_CONTEXT, ///< context info of trace callback
  119. ENCODER_OPTION_GET_STATISTICS, ///< read only
  120. ENCODER_OPTION_STATISTICS_LOG_INTERVAL, ///< log interval in millisecond
  121. ENCODER_OPTION_IS_LOSSLESS_LINK, ///< advanced algorithmetic settings
  122. ENCODER_OPTION_BITS_VARY_PERCENTAGE ///< bit vary percentage
  123. } ENCODER_OPTION;
  124. /**
  125. * @brief Option types introduced in decoder application
  126. */
  127. typedef enum {
  128. DECODER_OPTION_DATAFORMAT = 0, ///< color format, now supports 23 only (I420)
  129. DECODER_OPTION_END_OF_STREAM, ///< end of stream flag
  130. DECODER_OPTION_VCL_NAL, ///< feedback whether or not have VCL NAL in current AU for application layer
  131. DECODER_OPTION_TEMPORAL_ID, ///< feedback temporal id for application layer
  132. DECODER_OPTION_FRAME_NUM, ///< feedback current decoded frame number
  133. DECODER_OPTION_IDR_PIC_ID, ///< feedback current frame belong to which IDR period
  134. DECODER_OPTION_LTR_MARKING_FLAG, ///< feedback wether current frame mark a LTR
  135. DECODER_OPTION_LTR_MARKED_FRAME_NUM, ///< feedback frame num marked by current Frame
  136. DECODER_OPTION_ERROR_CON_IDC, ///< not finished yet, indicate decoder error concealment status, in progress
  137. DECODER_OPTION_TRACE_LEVEL,
  138. DECODER_OPTION_TRACE_CALLBACK, ///< a void (*)(void* context, int level, const char* message) function which receives log messages
  139. DECODER_OPTION_TRACE_CALLBACK_CONTEXT,///< context info of trace callbac
  140. DECODER_OPTION_GET_STATISTICS
  141. } DECODER_OPTION;
  142. /**
  143. * @brief Enumerate the type of error concealment methods
  144. */
  145. typedef enum {
  146. ERROR_CON_DISABLE = 0,
  147. ERROR_CON_FRAME_COPY,
  148. ERROR_CON_SLICE_COPY,
  149. ERROR_CON_FRAME_COPY_CROSS_IDR,
  150. ERROR_CON_SLICE_COPY_CROSS_IDR,
  151. ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE,
  152. ERROR_CON_SLICE_MV_COPY_CROSS_IDR,
  153. ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE
  154. } ERROR_CON_IDC;
  155. /**
  156. * @brief Feedback that whether or not have VCL NAL in current AU
  157. */
  158. typedef enum {
  159. FEEDBACK_NON_VCL_NAL = 0,
  160. FEEDBACK_VCL_NAL,
  161. FEEDBACK_UNKNOWN_NAL
  162. } FEEDBACK_VCL_NAL_IN_AU;
  163. /**
  164. * @brief Type of layer being encoded
  165. */
  166. typedef enum {
  167. NON_VIDEO_CODING_LAYER = 0,
  168. VIDEO_CODING_LAYER = 1
  169. } LAYER_TYPE;
  170. /**
  171. * @brief Spatial layer num
  172. */
  173. typedef enum {
  174. SPATIAL_LAYER_0 = 0,
  175. SPATIAL_LAYER_1 = 1,
  176. SPATIAL_LAYER_2 = 2,
  177. SPATIAL_LAYER_3 = 3,
  178. SPATIAL_LAYER_ALL = 4
  179. } LAYER_NUM;
  180. /**
  181. * @brief Enumerate the type of video bitstream which is provided to decoder
  182. */
  183. typedef enum {
  184. VIDEO_BITSTREAM_AVC = 0,
  185. VIDEO_BITSTREAM_SVC = 1,
  186. VIDEO_BITSTREAM_DEFAULT = VIDEO_BITSTREAM_SVC
  187. } VIDEO_BITSTREAM_TYPE;
  188. /**
  189. * @brief Enumerate the type of key frame request
  190. */
  191. typedef enum {
  192. NO_RECOVERY_REQUSET = 0,
  193. LTR_RECOVERY_REQUEST = 1,
  194. IDR_RECOVERY_REQUEST = 2,
  195. NO_LTR_MARKING_FEEDBACK = 3,
  196. LTR_MARKING_SUCCESS = 4,
  197. LTR_MARKING_FAILED = 5
  198. } KEY_FRAME_REQUEST_TYPE;
  199. /**
  200. * @brief Structure for LTR recover request
  201. */
  202. typedef struct {
  203. unsigned int uiFeedbackType; ///< IDR request or LTR recovery request
  204. unsigned int uiIDRPicId; ///< distinguish request from different IDR
  205. int iLastCorrectFrameNum;
  206. int iCurrentFrameNum; ///< specify current decoder frame_num.
  207. } SLTRRecoverRequest;
  208. /**
  209. * @brief Structure for LTR marking feedback
  210. */
  211. typedef struct {
  212. unsigned int uiFeedbackType; ///< mark failed or successful
  213. unsigned int uiIDRPicId; ///< distinguish request from different IDR
  214. int iLTRFrameNum; ///< specify current decoder frame_num
  215. } SLTRMarkingFeedback;
  216. /**
  217. * @brief Structure for LTR configuration
  218. */
  219. typedef struct {
  220. bool bEnableLongTermReference; ///< 1: on, 0: off
  221. int iLTRRefNum; ///< TODO: not supported to set it arbitrary yet
  222. } SLTRConfig;
  223. /**
  224. * @brief Structure for slice argument
  225. */
  226. typedef struct {
  227. unsigned int
  228. uiSliceMbNum[MAX_SLICES_NUM_TMP]; ///< only used when uiSliceMode=2;here we use a tmp fixed value since MAX_SLICES_NUM is not defined here and its definition may be changed;
  229. unsigned int uiSliceNum; ///< only used when uiSliceMode=1
  230. unsigned int uiSliceSizeConstraint; ///< only used when uiSliceMode=4
  231. } SSliceArgument; ///< not all the elements in this argument will be used, how it will be used depends on uiSliceMode; please refer to SliceModeEnum
  232. /**
  233. * @brief Enumerate the type of slice mode
  234. */
  235. typedef enum {
  236. SM_SINGLE_SLICE = 0, ///< | SliceNum==1
  237. SM_FIXEDSLCNUM_SLICE = 1, ///< | according to SliceNum | enabled dynamic slicing for multi-thread
  238. 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.
  239. SM_ROWMB_SLICE = 3, ///< | according to PictureMBHeight | typical of single row of mbs each slice + slice size constraint which including re-encoding
  240. SM_DYN_SLICE = 4, ///< | according to SliceSize | dynamic slicing (have no idea about slice_nums until encoding current frame)
  241. SM_AUTO_SLICE = 5, ///< | according to thread number
  242. SM_RESERVED = 6
  243. } SliceModeEnum;
  244. /**
  245. * @brief Enumerate the type of rate control mode
  246. */
  247. typedef enum {
  248. RC_QUALITY_MODE = 0, ///< quality mode
  249. RC_BITRATE_MODE = 1, ///< bitrate mode
  250. RC_BUFFERBASED_MODE = 2, ///< no bitrate control,only using buffer status,adjust the video quality
  251. RC_TIMESTAMP_MODE = 3, //rate control based timestamp
  252. RC_BITRATE_MODE_POST_SKIP = 4, ///< this is in-building RC MODE, WILL BE DELETED after algorithm tuning!
  253. RC_OFF_MODE = -1, ///< rate control off mode
  254. } RC_MODES;
  255. /**
  256. * @brief Enumerate the type of profile id
  257. */
  258. typedef enum {
  259. PRO_UNKNOWN = 0,
  260. PRO_BASELINE = 66,
  261. PRO_MAIN = 77,
  262. PRO_EXTENDED = 88,
  263. PRO_HIGH = 100,
  264. PRO_HIGH10 = 110,
  265. PRO_HIGH422 = 122,
  266. PRO_HIGH444 = 144,
  267. PRO_CAVLC444 = 244,
  268. PRO_SCALABLE_BASELINE = 83,
  269. PRO_SCALABLE_HIGH = 86
  270. } EProfileIdc;
  271. /**
  272. * @brief Enumerate the type of level id
  273. */
  274. typedef enum {
  275. LEVEL_UNKNOWN,
  276. LEVEL_1_0,
  277. LEVEL_1_B,
  278. LEVEL_1_1,
  279. LEVEL_1_2,
  280. LEVEL_1_3,
  281. LEVEL_2_0,
  282. LEVEL_2_1,
  283. LEVEL_2_2,
  284. LEVEL_3_0,
  285. LEVEL_3_1,
  286. LEVEL_3_2,
  287. LEVEL_4_0,
  288. LEVEL_4_1,
  289. LEVEL_4_2,
  290. LEVEL_5_0,
  291. LEVEL_5_1,
  292. LEVEL_5_2
  293. } ELevelIdc;
  294. /**
  295. * @brief Enumerate the type of wels log
  296. */
  297. enum {
  298. WELS_LOG_QUIET = 0x00, ///< quiet mode
  299. WELS_LOG_ERROR = 1 << 0, ///< error log iLevel
  300. WELS_LOG_WARNING = 1 << 1, ///< Warning log iLevel
  301. WELS_LOG_INFO = 1 << 2, ///< information log iLevel
  302. WELS_LOG_DEBUG = 1 << 3, ///< debug log, critical algo log
  303. WELS_LOG_DETAIL = 1 << 4, ///< per packet/frame log
  304. WELS_LOG_RESV = 1 << 5, ///< resversed log iLevel
  305. WELS_LOG_LEVEL_COUNT = 6,
  306. WELS_LOG_DEFAULT = WELS_LOG_WARNING ///< default log iLevel in Wels codec
  307. };
  308. /**
  309. * @brief Structure for slice configuration
  310. */
  311. typedef struct {
  312. SliceModeEnum uiSliceMode; ///< by default, uiSliceMode will be SM_SINGLE_SLICE
  313. SSliceArgument sSliceArgument;
  314. } SSliceConfig;
  315. /**
  316. * @brief Structure for spatial layer configuration
  317. */
  318. typedef struct {
  319. int iVideoWidth; ///< width of picture in luminance samples of a layer
  320. int iVideoHeight; ///< height of picture in luminance samples of a layer
  321. float fFrameRate; ///< frame rate specified for a layer
  322. int iSpatialBitrate; ///< target bitrate for a spatial layer, in unit of bps
  323. int iMaxSpatialBitrate; ///< maximum bitrate for a spatial layer, in unit of bps
  324. EProfileIdc uiProfileIdc; ///< value of profile IDC (PRO_UNKNOWN for auto-detection)
  325. ELevelIdc uiLevelIdc; ///< value of profile IDC (0 for auto-detection)
  326. int iDLayerQp; ///< value of level IDC (0 for auto-detection)
  327. SSliceConfig sSliceCfg; ///< slice configuration for a layer
  328. } SSpatialLayerConfig;
  329. /**
  330. * @brief Encoder usage type
  331. */
  332. typedef enum {
  333. CAMERA_VIDEO_REAL_TIME, ///< camera video for real-time communication
  334. SCREEN_CONTENT_REAL_TIME, ///< screen content signal
  335. CAMERA_VIDEO_NON_REAL_TIME
  336. } EUsageType;
  337. /**
  338. * @brief Enumulate the complexity mode
  339. */
  340. typedef enum {
  341. LOW_COMPLEXITY, ///< the lowest compleixty,the fastest speed,
  342. MEDIUM_COMPLEXITY, ///< medium complexity, medium speed,medium quality
  343. HIGH_COMPLEXITY ///< high complexity, lowest speed, high quality
  344. } ECOMPLEXITY_MODE;
  345. /**
  346. * @brief Enumulate for the stategy of SPS/PPS strategy
  347. */
  348. typedef enum {
  349. CONSTANT_ID = 0, ///< constant id in SPS/PPS
  350. INCREASING_ID = 0x01, ///< SPS/PPS id increases at each IDR
  351. SPS_LISTING = 0x02, ///< using SPS in the existing list if possible
  352. SPS_LISTING_AND_PPS_INCREASING = 0x03,
  353. SPS_PPS_LISTING = 0x06,
  354. } EParameterSetStrategy;
  355. // TODO: Refine the parameters definition.
  356. /**
  357. * @brief SVC Encoding Parameters
  358. */
  359. typedef struct TagEncParamBase {
  360. EUsageType
  361. iUsageType; ///< application type;1.CAMERA_VIDEO_REAL_TIME:camera video signal; 2.SCREEN_CONTENT_REAL_TIME:screen content signal;
  362. int iPicWidth; ///< width of picture in luminance samples (the maximum of all layers if multiple spatial layers presents)
  363. int iPicHeight; ///< height of picture in luminance samples((the maximum of all layers if multiple spatial layers presents)
  364. int iTargetBitrate; ///< target bitrate desired, in unit of bps
  365. RC_MODES iRCMode; ///< rate control mode
  366. float fMaxFrameRate; ///< maximal input frame rate
  367. } SEncParamBase, *PEncParamBase;
  368. /**
  369. * @brief SVC Encoding Parameters extention
  370. */
  371. typedef struct TagEncParamExt {
  372. EUsageType
  373. iUsageType; ///< application type;1.CAMERA_VIDEO_REAL_TIME:camera video signal;2.SCREEN_CONTENT_REAL_TIME:screen content signal;
  374. int iPicWidth; ///< width of picture in luminance samples (the maximum of all layers if multiple spatial layers presents)
  375. int iPicHeight; ///< height of picture in luminance samples((the maximum of all layers if multiple spatial layers presents)
  376. int iTargetBitrate; ///< target bitrate desired, in unit of bps
  377. RC_MODES iRCMode; ///< rate control mode
  378. float fMaxFrameRate; ///< maximal input frame rate
  379. int iTemporalLayerNum; ///< temporal layer number, max temporal layer = 4
  380. int iSpatialLayerNum; ///< spatial layer number,1<= iSpatialLayerNum <= MAX_SPATIAL_LAYER_NUM, MAX_SPATIAL_LAYER_NUM = 4
  381. SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM];
  382. ECOMPLEXITY_MODE iComplexityMode;
  383. unsigned int uiIntraPeriod; ///< period of Intra frame
  384. int iNumRefFrame; ///< number of reference frame used
  385. EParameterSetStrategy
  386. eSpsPpsIdStrategy; ///< different stategy in adjust ID in SPS/PPS: 0- constant ID, 1-additional ID, 6-mapping and additional
  387. bool bPrefixNalAddingCtrl; ///< false:not use Prefix NAL; true: use Prefix NAL
  388. bool bEnableSSEI; ///< false:not use SSEI; true: use SSEI -- TODO: planning to remove the interface of SSEI
  389. bool bSimulcastAVC; ///< (when encoding more than 1 spatial layer) false: use SVC syntax for higher layers; true: use Simulcast AVC -- coming soon
  390. int iPaddingFlag; ///< 0:disable padding;1:padding
  391. int iEntropyCodingModeFlag; ///< 0:CAVLC 1:CABAC.
  392. /* rc control */
  393. bool bEnableFrameSkip; ///< False: don't skip frame even if VBV buffer overflow.True: allow skipping frames to keep the bitrate within limits
  394. int iMaxBitrate; ///< the maximum bitrate, in unit of bps, set it to UNSPECIFIED_BIT_RATE if not needed
  395. int iMaxQp; ///< the maximum QP encoder supports
  396. int iMinQp; ///< the minmum QP encoder supports
  397. unsigned int uiMaxNalSize; ///< the maximum NAL size. This value should be not 0 for dynamic slice mode
  398. /*LTR settings*/
  399. bool bEnableLongTermReference; ///< 1: on, 0: off
  400. int iLTRRefNum; ///< the number of LTR(long term reference),TODO: not supported to set it arbitrary yet
  401. unsigned int iLtrMarkPeriod; ///< the LTR marked period that is used in feedback.
  402. /* multi-thread settings*/
  403. unsigned short
  404. iMultipleThreadIdc; ///< 1 # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; lager than 1: count number of threads;
  405. /* Deblocking loop filter */
  406. int iLoopFilterDisableIdc; ///< 0: on, 1: off, 2: on except for slice boundaries
  407. int iLoopFilterAlphaC0Offset; ///< AlphaOffset: valid range [-6, 6], default 0
  408. int iLoopFilterBetaOffset; ///< BetaOffset: valid range [-6, 6], default 0
  409. /*pre-processing feature*/
  410. bool bEnableDenoise; ///< denoise control
  411. bool bEnableBackgroundDetection; ///< background detection control //VAA_BACKGROUND_DETECTION //BGD cmd
  412. bool bEnableAdaptiveQuant; ///< adaptive quantization control
  413. bool bEnableFrameCroppingFlag; ///< enable frame cropping flag: TRUE always in application
  414. bool bEnableSceneChangeDetect;
  415. bool bIsLosslessLink; ///< LTR advanced setting
  416. } SEncParamExt;
  417. /**
  418. * @brief Define a new struct to show the property of video bitstream.
  419. */
  420. typedef struct {
  421. unsigned int size; ///< size of the struct
  422. VIDEO_BITSTREAM_TYPE eVideoBsType; ///< video stream type (AVC/SVC)
  423. } SVideoProperty;
  424. /**
  425. * @brief SVC Decoding Parameters, reserved here and potential applicable in the future
  426. */
  427. typedef struct TagSVCDecodingParam {
  428. char* pFileNameRestructed; ///< file name of reconstructed frame used for PSNR calculation based debug
  429. EVideoFormatType eOutputColorFormat; ///< color space format to be outputed, EVideoFormatType specified in codec_def.h
  430. unsigned int uiCpuLoad; ///< CPU load
  431. unsigned char uiTargetDqLayer; ///< setting target dq layer id
  432. ERROR_CON_IDC eEcActiveIdc; ///< whether active error concealment feature in decoder
  433. bool bParseOnly; ///< decoder for parse only, no reconstruction. When it is true, SPS/PPS size should not exceed SPS_PPS_BS_SIZE (128). Otherwise, it will return error info
  434. SVideoProperty sVideoProperty; ///< video stream property
  435. } SDecodingParam, *PDecodingParam;
  436. /**
  437. * @brief Bitstream inforamtion of a layer being encoded
  438. */
  439. typedef struct {
  440. unsigned char uiTemporalId;
  441. unsigned char uiSpatialId;
  442. unsigned char uiQualityId;
  443. unsigned char uiLayerType;
  444. int iNalCount; ///< count number of NAL coded already
  445. int* pNalLengthInByte; ///< length of NAL size in byte from 0 to iNalCount-1
  446. unsigned char* pBsBuf; ///< buffer of bitstream contained
  447. } SLayerBSInfo, *PLayerBSInfo;
  448. /**
  449. * @brief Frame bit stream info
  450. */
  451. typedef struct {
  452. int iTemporalId; ///< temporal ID
  453. /**
  454. * The sub sequence layers are ordered hierarchically based on their dependency on each other so that any picture in a layer shall not be
  455. * predicted from any picture on any higher layer.
  456. */
  457. int iSubSeqId; ///< refer to D.2.11 Sub-sequence information SEI message semantics
  458. int iLayerNum;
  459. SLayerBSInfo sLayerInfo[MAX_LAYER_NUM_OF_FRAME];
  460. EVideoFrameType eFrameType;
  461. int iFrameSizeInBytes;
  462. long long uiTimeStamp;
  463. } SFrameBSInfo, *PFrameBSInfo;
  464. /**
  465. * @brief Structure for source picture
  466. */
  467. typedef struct Source_Picture_s {
  468. int iColorFormat; ///< color space type
  469. int iStride[4]; ///< stride for each plane pData
  470. unsigned char* pData[4]; ///< plane pData
  471. int iPicWidth; ///< luma picture width in x coordinate
  472. int iPicHeight; ///< luma picture height in y coordinate
  473. long long uiTimeStamp; ///< timestamp of the source picture, unit: millisecond
  474. } SSourcePicture;
  475. /**
  476. * @brief Structure for bit rate info
  477. */
  478. typedef struct TagBitrateInfo {
  479. LAYER_NUM iLayer;
  480. int iBitrate; ///< the maximum bitrate
  481. } SBitrateInfo;
  482. /**
  483. * @brief Structure for dump layer info
  484. */
  485. typedef struct TagDumpLayer {
  486. int iLayer;
  487. char* pFileName;
  488. } SDumpLayer;
  489. /**
  490. * @brief Structure for profile info in layer
  491. *
  492. */
  493. typedef struct TagProfileInfo {
  494. int iLayer;
  495. EProfileIdc uiProfileIdc; ///< the profile info
  496. } SProfileInfo;
  497. /**
  498. * @brief Structure for level info in layer
  499. *
  500. */
  501. typedef struct TagLevelInfo {
  502. int iLayer;
  503. ELevelIdc uiLevelIdc; ///< the level info
  504. } SLevelInfo;
  505. /**
  506. * @brief Structure for dilivery status
  507. *
  508. */
  509. typedef struct TagDeliveryStatus {
  510. bool bDeliveryFlag; ///< 0: the previous frame isn't delivered,1: the previous frame is delivered
  511. int iDropFrameType; ///< the frame type that is dropped; reserved
  512. int iDropFrameSize; ///< the frame size that is dropped; reserved
  513. } SDeliveryStatus;
  514. /**
  515. * @brief The capability of decoder, for SDP negotiation
  516. */
  517. typedef struct TagDecoderCapability {
  518. int iProfileIdc; ///< profile_idc
  519. int iProfileIop; ///< profile-iop
  520. int iLevelIdc; ///< level_idc
  521. int iMaxMbps; ///< max-mbps
  522. int iMaxFs; ///< max-fs
  523. int iMaxCpb; ///< max-cpb
  524. int iMaxDpb; ///< max-dpb
  525. int iMaxBr; ///< max-br
  526. bool bRedPicCap; ///< redundant-pic-cap
  527. } SDecoderCapability;
  528. /**
  529. * @brief to do
  530. */
  531. typedef struct TagParserBsInfo {
  532. int iNalNum; ///< total NAL number in current AU
  533. int iNalLenInByte [MAX_NAL_UNITS_IN_LAYER]; ///< each nal length
  534. unsigned char* pDstBuff; ///< outputted dst buffer for parsed bitstream
  535. int iSpsWidthInPixel; ///< required SPS width info
  536. int iSpsHeightInPixel; ///< required SPS height info
  537. unsigned long long uiInBsTimeStamp; ///< input BS timestamp
  538. unsigned long long uiOutBsTimeStamp; ///< output BS timestamp
  539. } SParserBsInfo, *PParserBsInfo;
  540. /**
  541. * @brief Structure for encoder statistics
  542. */
  543. typedef struct TagVideoEncoderStatistics {
  544. unsigned int uiWidth; ///< the width of encoded frame
  545. unsigned int uiHeight; ///< the height of encoded frame
  546. //following standard, will be 16x aligned, if there are multiple spatial, this is of the highest
  547. float fAverageFrameSpeedInMs; ///< average_Encoding_Time
  548. // rate control related
  549. float fAverageFrameRate; ///< the average frame rate in, calculate since encoding starts, supposed that the input timestamp is in unit of ms
  550. float fLatestFrameRate; ///< the frame rate in, in the last second, supposed that the input timestamp is in unit of ms (? useful for checking BR, but is it easy to calculate?
  551. unsigned int uiBitRate; ///< sendrate in Bits per second, calculated within the set time-window
  552. unsigned int uiAverageFrameQP; ///< the average QP of last encoded frame
  553. unsigned int uiInputFrameCount; ///< number of frames
  554. unsigned int uiSkippedFrameCount; ///< number of frames
  555. unsigned int uiResolutionChangeTimes; ///< uiResolutionChangeTimes
  556. unsigned int uiIDRReqNum; ///< number of IDR requests
  557. unsigned int uiIDRSentNum; ///< number of actual IDRs sent
  558. unsigned int uiLTRSentNum; ///< number of LTR sent/marked
  559. long long iStatisticsTs; ///< Timestamp of updating the statistics
  560. } SEncoderStatistics; // in building, coming soon
  561. /**
  562. * @brief Structure for decoder statistics
  563. */
  564. typedef struct TagVideoDecoderStatistics {
  565. unsigned int uiWidth; ///< the width of encode/decode frame
  566. unsigned int uiHeight; ///< the height of encode/decode frame
  567. float fAverageFrameSpeedInMs; ///< average_Decoding_Time
  568. float fActualAverageFrameSpeedInMs; ///< actual average_Decoding_Time, including freezing pictures
  569. unsigned int uiDecodedFrameCount; ///< number of frames
  570. unsigned int uiResolutionChangeTimes; ///< uiResolutionChangeTimes
  571. unsigned int uiIDRCorrectNum; ///< number of correct IDR received
  572. //EC on related
  573. unsigned int
  574. uiAvgEcRatio; ///< when EC is on, the average ratio of total EC areas, can be an indicator of reconstruction quality
  575. unsigned int
  576. uiAvgEcPropRatio; ///< when EC is on, the rough average ratio of propogate EC areas, can be an indicator of reconstruction quality
  577. unsigned int uiEcIDRNum; ///< number of actual unintegrity IDR or not received but eced
  578. unsigned int uiEcFrameNum; ///<
  579. unsigned int uiIDRLostNum; ///< number of whole lost IDR
  580. unsigned int uiFreezingIDRNum; ///< number of freezing IDR with error (partly received), under resolution change
  581. unsigned int uiFreezingNonIDRNum; ///< number of freezing non-IDR with error
  582. int iAvgLumaQp; ///< average luma QP. default: -1, no correct frame outputted
  583. int iSpsReportErrorNum; ///< number of Sps Invalid report
  584. int iSubSpsReportErrorNum; ///< number of SubSps Invalid report
  585. int iPpsReportErrorNum; ///< number of Pps Invalid report
  586. int iSpsNoExistNalNum; ///< number of Sps NoExist Nal
  587. int iSubSpsNoExistNalNum; ///< number of SubSps NoExist Nal
  588. int iPpsNoExistNalNum; ///< number of Pps NoExist Nal
  589. } SDecoderStatistics; // in building, coming soon
  590. #endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__