sei.h
上传用户:hjq518
上传日期:2021-12-09
资源大小:5084k
文件大小:10k
源码类别:

Audio

开发平台:

Visual C++

  1. /*!
  2.  ************************************************************************
  3.  *  file
  4.  *     sei.h
  5.  *  brief
  6.  *     definitions for Supplemental Enhanced Information
  7.  *  author(s)
  8.  *      - Dong Tian                             <tian@cs.tut.fi>
  9.  *      - TBD
  10.  *
  11.  * ************************************************************************
  12.  */
  13. #ifndef SEI_H
  14. #define SEI_H
  15. #define MAX_LAYER_NUMBER 2
  16. #define MAX_DEPENDENT_SUBSEQ 5
  17. //! definition of SEI payload type
  18. typedef enum {
  19.   SEI_BUFFERING_PERIOD = 0,
  20.   SEI_PIC_TIMING,
  21.   SEI_PAN_SCAN_RECT,
  22.   SEI_FILLER_PAYLOAD,
  23.   SEI_USER_DATA_REGISTERED_ITU_T_T35,
  24.   SEI_USER_DATA_UNREGISTERED,
  25.   SEI_RECOVERY_POINT,
  26.   SEI_DEC_REF_PIC_MARKING_REPETITION,
  27.   SEI_SPARE_PIC,
  28.   SEI_SCENE_INFO,
  29.   SEI_SUB_SEQ_INFO,
  30.   SEI_SUB_SEQ_LAYER_CHARACTERISTICS,
  31.   SEI_SUB_SEQ_CHARACTERISTICS,
  32.   SEI_FULL_FRAME_FREEZE,
  33.   SEI_FULL_FRAME_FREEZE_RELEASE,
  34.   SEI_FULL_FRAME_SNAPSHOT,
  35.   SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START,
  36.   SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END,
  37.   SEI_MOTION_CONSTRAINED_SLICE_GROUP_SET,
  38.   SEI_FILM_GRAIN_CHARACTERISTICS,
  39.   SEI_DEBLOCKING_FILTER_DISPLAY_PREFERENCE,
  40.   SEI_STEREO_VIDEO_INFO,
  41.   SEI_POST_FILTER_HINTS,
  42.   SEI_TONE_MAPPING,
  43.   SEI_MAX_ELEMENTS  //!< number of maximum syntax elements
  44. } SEI_type;
  45. #define MAX_FN 256
  46. #define AGGREGATION_PACKET_TYPE 4
  47. #define SEI_PACKET_TYPE 5  // Tian Dong: See VCEG-N72, it need updates
  48. #define NORMAL_SEI 0
  49. #define AGGREGATION_SEI 1
  50. //! SEI structure
  51. typedef struct
  52. {
  53.   Boolean available;
  54.   int payloadSize;
  55.   unsigned char subPacketType;
  56.   byte* data;
  57. } sei_struct;
  58. //!< sei_message[0]: this struct is to store the sei message packtized independently
  59. //!< sei_message[1]: this struct is to store the sei message packtized together with slice data
  60. extern sei_struct sei_message[2];
  61. void InitSEIMessages(void);
  62. void CloseSEIMessages(void);
  63. Boolean HaveAggregationSEI(void);
  64. void write_sei_message(int id, byte* payload, int payload_size, int payload_type);
  65. void finalize_sei_message(int id);
  66. void clear_sei_message(int id);
  67. void AppendTmpbits2Buf( Bitstream* dest, Bitstream* source );
  68. void PrepareAggregationSEIMessage(void);
  69. //! Spare Picture
  70. typedef struct
  71. {
  72.   int target_frame_num;
  73.   int num_spare_pics;
  74.   int payloadSize;
  75.   Bitstream* data;
  76. } spare_picture_struct;
  77. extern Boolean seiHasSparePicture;
  78. //extern Boolean sei_has_sp;
  79. extern spare_picture_struct seiSparePicturePayload;
  80. void InitSparePicture();
  81. void CloseSparePicture();
  82. void CalculateSparePicture();
  83. void ComposeSparePictureMessage(int delta_spare_frame_num, int ref_area_indicator, Bitstream *tmpBitstream);
  84. Boolean CompressSpareMBMap(unsigned char **map_sp, Bitstream *bitstream);
  85. void FinalizeSpareMBMap();
  86. //! Subseq Information
  87. typedef struct
  88. {
  89.   int subseq_layer_num;
  90.   int subseq_id;
  91.   unsigned int last_picture_flag;
  92.   unsigned int stored_frame_cnt;
  93.   int payloadSize;
  94.   Bitstream* data;
  95. } subseq_information_struct;
  96. extern Boolean seiHasSubseqInfo;
  97. extern subseq_information_struct seiSubseqInfo[MAX_LAYER_NUMBER];
  98. void InitSubseqInfo(int currLayer);
  99. void UpdateSubseqInfo(int currLayer);
  100. void FinalizeSubseqInfo(int currLayer);
  101. void ClearSubseqInfoPayload(int currLayer);
  102. void CloseSubseqInfo(int currLayer);
  103. //! Subseq Layer Information
  104. typedef struct
  105. {
  106.   unsigned short bit_rate[MAX_LAYER_NUMBER];
  107.   unsigned short frame_rate[MAX_LAYER_NUMBER];
  108.   byte data[4*MAX_LAYER_NUMBER];
  109.   int layer_number;
  110.   int payloadSize;
  111. } subseq_layer_information_struct;
  112. extern Boolean seiHasSubseqLayerInfo;
  113. extern subseq_layer_information_struct seiSubseqLayerInfo;
  114. void InitSubseqLayerInfo();
  115. void CloseSubseqLayerInfo();
  116. void FinalizeSubseqLayerInfo();
  117. //! Subseq Characteristics
  118. typedef struct
  119. {
  120.   int subseq_layer_num;
  121.   int subseq_id;
  122.   int duration_flag;
  123.   unsigned int subseq_duration;
  124.   unsigned int average_rate_flag;
  125.   unsigned int average_bit_rate;
  126.   unsigned int average_frame_rate;
  127.   int num_referenced_subseqs;
  128.   int ref_subseq_layer_num[MAX_DEPENDENT_SUBSEQ];
  129.   int ref_subseq_id[MAX_DEPENDENT_SUBSEQ];
  130.   Bitstream* data;
  131.   int payloadSize;
  132. } subseq_char_information_struct;
  133. extern Boolean seiHasSubseqChar;
  134. extern subseq_char_information_struct seiSubseqChar;
  135. void InitSubseqChar();
  136. void ClearSubseqCharPayload();
  137. void UpdateSubseqChar();
  138. void FinalizeSubseqChar();
  139. void CloseSubseqChar();
  140. typedef struct
  141. {
  142.   int scene_id;
  143.   int scene_transition_type;
  144.   int second_scene_id;
  145.   Bitstream* data;
  146.   int payloadSize;
  147. } scene_information_struct;
  148. extern Boolean seiHasSceneInformation;
  149. extern scene_information_struct seiSceneInformation;
  150. void InitSceneInformation();
  151. void CloseSceneInformation();
  152. void UpdateSceneInformation(Boolean HasSceneInformation, int sceneID, int sceneTransType, int secondSceneID);
  153. void FinalizeSceneInformation();
  154. //! PanScanRect Information
  155. typedef struct
  156. {
  157.   int pan_scan_rect_id;
  158.   int pan_scan_rect_left_offset;
  159.   int pan_scan_rect_right_offset;
  160.   int pan_scan_rect_top_offset;
  161.   int pan_scan_rect_bottom_offset;
  162.   Bitstream *data;
  163.   int payloadSize;
  164. } panscanrect_information_struct;
  165. extern Boolean seiHasPanScanRectInfo;
  166. extern panscanrect_information_struct seiPanScanRectInfo;
  167. void InitPanScanRectInfo();
  168. void ClearPanScanRectInfoPayload();
  169. void UpdatePanScanRectInfo();
  170. void FinalizePanScanRectInfo();
  171. void ClosePanScanRectInfo();
  172. //! User_data_unregistered Information
  173. typedef struct
  174. {
  175.   char *byte;
  176.   int total_byte;
  177.   Bitstream *data;
  178.   int payloadSize;
  179. } user_data_unregistered_information_struct;
  180. extern Boolean seiHasUser_data_unregistered_info;
  181. extern user_data_unregistered_information_struct seiUser_data_unregistered;
  182. void InitUser_data_unregistered();
  183. void ClearUser_data_unregistered();
  184. void UpdateUser_data_unregistered();
  185. void FinalizeUser_data_unregistered();
  186. void CloseUser_data_unregistered();
  187. //! User_data_registered_itu_t_t35 Information
  188. typedef struct
  189. {
  190.   char *byte;
  191.   int total_byte;
  192.   int itu_t_t35_country_code;
  193.   int itu_t_t35_country_code_extension_byte;
  194.   Bitstream *data;
  195.   int payloadSize;
  196. } user_data_registered_itu_t_t35_information_struct;
  197. extern Boolean seiHasUser_data_registered_itu_t_t35_info;
  198. extern user_data_registered_itu_t_t35_information_struct seiUser_data_registered_itu_t_t35;
  199. void InitUser_data_registered_itu_t_t35();
  200. void ClearUser_data_registered_itu_t_t35();
  201. void UpdateUser_data_registered_itu_t_t35();
  202. void FinalizeUser_data_registered_itu_t_t35();
  203. void CloseUser_data_registered_itu_t_t35();
  204. //! Recovery Point Information
  205. typedef struct
  206. {
  207.   unsigned int  recovery_frame_cnt;
  208.   unsigned char exact_match_flag;
  209.   unsigned char broken_link_flag;
  210.   unsigned char changing_slice_group_idc;
  211.   Bitstream *data;
  212.   int payloadSize;
  213. } recovery_point_information_struct;
  214. extern Boolean seiHasRecoveryPoint_info;
  215. extern recovery_point_information_struct seiRecoveryPoint;
  216. void InitRandomAccess();
  217. void ClearRandomAccess();
  218. void UpdateRandomAccess();
  219. void FinalizeRandomAccess();
  220. void CloseRandomAccess();
  221. // tone mapping information
  222. #define MAX_CODED_BIT_DEPTH 12
  223. #define MAX_SEI_BIT_DEPTH 12
  224. #define MAX_NUM_PIVOTS (1<<MAX_CODED_BIT_DEPTH)
  225. typedef struct
  226. {
  227.   unsigned int  tone_map_id;
  228.   unsigned char tone_map_cancel_flag;
  229.   unsigned int  tone_map_repetition_period;
  230.   unsigned char coded_data_bit_depth;
  231.   unsigned char sei_bit_depth;
  232.   unsigned int  model_id;
  233.   // variables for model 0
  234.   int  min_value;
  235.   int  max_value;
  236.   // variables for model 1
  237.   int  sigmoid_midpoint;
  238.   int  sigmoid_width;
  239.   // variables for model 2
  240.   int start_of_coded_interval[1<<MAX_SEI_BIT_DEPTH];
  241.   // variables for model 3
  242.   int num_pivots;
  243.   int coded_pivot_value[MAX_NUM_PIVOTS];
  244.   int sei_pivot_value[MAX_NUM_PIVOTS];
  245.   Bitstream *data;
  246.   int payloadSize;
  247. } tone_mapping_struct;
  248. extern Boolean seiHasTone_mapping;
  249. extern tone_mapping_struct seiToneMapping;
  250. void InitToneMapping();
  251. void FinalizeToneMapping();
  252. void ClearToneMapping();
  253. void UpdateToneMapping();
  254. void CloseToneMapping();
  255. //! Post Filter Hints Information
  256. typedef struct
  257. {
  258.   unsigned int  filter_hint_size_y;
  259.   unsigned int  filter_hint_size_x;
  260.   unsigned int  filter_hint_type;
  261.   int           ***filter_hint;
  262.   unsigned int  additional_extension_flag;
  263.   Bitstream *data;
  264.   int payloadSize;
  265. } post_filter_information_struct;
  266. extern Boolean seiHasPostFilterHints_info;
  267. extern post_filter_information_struct seiPostFilterHints;
  268. void InitPostFilterHints();
  269. void ClearPostFilterHints();
  270. void UpdatePostFilterHints();
  271. void FinalizePostFilterHints();
  272. void ClosePostFilterHints();
  273. int Write_SEI_NALU(int len);
  274. // This is only temp
  275. //! Buffering Period Information
  276. #define MAX_CPB_CNT_MINUS1 31
  277. #define MAX_PIC_STRUCT_VALUE 16
  278. typedef struct
  279. {
  280.   int seq_parameter_set_id;
  281.   int nal_initial_cpb_removal_delay[MAX_CPB_CNT_MINUS1+1];
  282.   int nal_initial_cpb_removal_delay_offset[MAX_CPB_CNT_MINUS1+1];
  283.   int vcl_initial_cpb_removal_delay[MAX_CPB_CNT_MINUS1+1];
  284.   int vcl_initial_cpb_removal_delay_offset[MAX_CPB_CNT_MINUS1+1];
  285.   Bitstream *data;
  286.   int payloadSize;
  287. } bufferingperiod_information_struct;
  288. extern Boolean seiHasBuffering_period;
  289. bufferingperiod_information_struct seiBufferingPeriod;
  290. void InitBufferingPeriod();
  291. void ClearBufferingPeriod();
  292. void CloseBufferingPeriod();
  293. void UpdateBufferingPeriod();
  294. void FinalizeBufferingPeriod();
  295. //! Picture timing Information
  296. typedef struct
  297. {
  298.   int cpb_removal_delay;
  299.   int dpb_output_delay;
  300.   int pic_struct;
  301.   Boolean clock_timestamp_flag[MAX_PIC_STRUCT_VALUE];
  302.   int ct_type;
  303.   Boolean nuit_field_based_flag;
  304.   int counting_type;
  305.   Boolean full_timestamp_flag;
  306.   Boolean discontinuity_flag;
  307.   Boolean cnt_dropped_flag;
  308.   int n_frames;
  309.   int seconds_value;
  310.   int minutes_value;
  311.   int hours_value;
  312.   Boolean seconds_flag;
  313.   Boolean minutes_flag;
  314.   Boolean hours_flag;
  315.   int time_offset;
  316.   Bitstream *data;
  317.   int payloadSize;
  318. } pictiming_information_struct;
  319. extern Boolean seiHasPicTiming_info;
  320. pictiming_information_struct seiPicTiming;
  321. void InitPicTiming();
  322. void ClearPicTiming();
  323. void ClosePicTiming();
  324. void UpdatePicTiming();
  325. void FinalizePicTiming();
  326. // end of temp additions
  327. #endif