00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SEI_H
00016 #define SEI_H
00017
00018 #define MAX_LAYER_NUMBER 2
00019 #define MAX_DEPENDENT_SUBSEQ 5
00020
00021 #define MAX_CODED_BIT_DEPTH 12
00022 #define MAX_SEI_BIT_DEPTH 12
00023 #define MAX_NUM_PIVOTS (1<<MAX_CODED_BIT_DEPTH)
00024
00025
00026 #define MAX_CPB_CNT_MINUS1 31
00027 #define MAX_PIC_STRUCT_VALUE 16
00028 #define MAX_FN 256
00029
00030 #define AGGREGATION_PACKET_TYPE 4
00031 #define SEI_PACKET_TYPE 5 // Tian Dong: See VCEG-N72, it need updates
00032
00033 #define NORMAL_SEI 0
00034 #define AGGREGATION_SEI 1
00035
00036
00037
00038 typedef enum {
00039 SEI_BUFFERING_PERIOD = 0,
00040 SEI_PIC_TIMING,
00041 SEI_PAN_SCAN_RECT,
00042 SEI_FILLER_PAYLOAD,
00043 SEI_USER_DATA_REGISTERED_ITU_T_T35,
00044 SEI_USER_DATA_UNREGISTERED,
00045 SEI_RECOVERY_POINT,
00046 SEI_DEC_REF_PIC_MARKING_REPETITION,
00047 SEI_SPARE_PIC,
00048 SEI_SCENE_INFO,
00049 SEI_SUB_SEQ_INFO,
00050 SEI_SUB_SEQ_LAYER_CHARACTERISTICS,
00051 SEI_SUB_SEQ_CHARACTERISTICS,
00052 SEI_FULL_FRAME_FREEZE,
00053 SEI_FULL_FRAME_FREEZE_RELEASE,
00054 SEI_FULL_FRAME_SNAPSHOT,
00055 SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START,
00056 SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END,
00057 SEI_MOTION_CONSTRAINED_SLICE_GROUP_SET,
00058 SEI_FILM_GRAIN_CHARACTERISTICS,
00059 SEI_DEBLOCKING_FILTER_DISPLAY_PREFERENCE,
00060 SEI_STEREO_VIDEO_INFO,
00061 SEI_POST_FILTER_HINTS,
00062 SEI_TONE_MAPPING,
00063
00064 SEI_MAX_ELEMENTS
00065 } SEI_type;
00066
00067 typedef struct
00068 {
00069 int seq_parameter_set_id;
00070 int nal_initial_cpb_removal_delay[MAX_CPB_CNT_MINUS1+1];
00071 int nal_initial_cpb_removal_delay_offset[MAX_CPB_CNT_MINUS1+1];
00072 int vcl_initial_cpb_removal_delay[MAX_CPB_CNT_MINUS1+1];
00073 int vcl_initial_cpb_removal_delay_offset[MAX_CPB_CNT_MINUS1+1];
00074
00075 Bitstream *data;
00076 int payloadSize;
00077 } bufferingperiod_information_struct;
00078
00079
00080 typedef struct
00081 {
00082 Boolean available;
00083 int payloadSize;
00084 unsigned char subPacketType;
00085 byte* data;
00086 } sei_struct;
00087
00088
00089 typedef struct
00090 {
00091 int target_frame_num;
00092 int num_spare_pics;
00093 int payloadSize;
00094 Bitstream* data;
00095 } spare_picture_struct;
00096
00097
00098 typedef struct
00099 {
00100 int subseq_layer_num;
00101 int subseq_id;
00102 unsigned int last_picture_flag;
00103 unsigned int stored_frame_cnt;
00104
00105 int payloadSize;
00106 Bitstream* data;
00107 } subseq_information_struct;
00108
00109
00110 typedef struct
00111 {
00112 uint16 bit_rate[MAX_LAYER_NUMBER];
00113 uint16 frame_rate[MAX_LAYER_NUMBER];
00114 byte data[4*MAX_LAYER_NUMBER];
00115 int layer_number;
00116 int payloadSize;
00117 } subseq_layer_information_struct;
00118
00119
00120 typedef struct
00121 {
00122 int subseq_layer_num;
00123 int subseq_id;
00124 int duration_flag;
00125 unsigned int subseq_duration;
00126 unsigned int average_rate_flag;
00127 unsigned int average_bit_rate;
00128 unsigned int average_frame_rate;
00129 int num_referenced_subseqs;
00130 int ref_subseq_layer_num[MAX_DEPENDENT_SUBSEQ];
00131 int ref_subseq_id[MAX_DEPENDENT_SUBSEQ];
00132
00133 Bitstream* data;
00134 int payloadSize;
00135 } subseq_char_information_struct;
00136
00137 typedef struct
00138 {
00139 int scene_id;
00140 int scene_transition_type;
00141 int second_scene_id;
00142
00143 Bitstream* data;
00144 int payloadSize;
00145 } scene_information_struct;
00146
00147
00148 typedef struct
00149 {
00150 int pan_scan_rect_id;
00151 int pan_scan_rect_left_offset;
00152 int pan_scan_rect_right_offset;
00153 int pan_scan_rect_top_offset;
00154 int pan_scan_rect_bottom_offset;
00155
00156 Bitstream *data;
00157 int payloadSize;
00158 } panscanrect_information_struct;
00159
00160 typedef struct
00161 {
00162 char *byte;
00163 int total_byte;
00164 Bitstream *data;
00165 int payloadSize;
00166 } user_data_unregistered_information_struct;
00167
00168
00169 typedef struct
00170 {
00171 char *byte;
00172 int total_byte;
00173 int itu_t_t35_country_code;
00174 int itu_t_t35_country_code_extension_byte;
00175 Bitstream *data;
00176 int payloadSize;
00177 } user_data_registered_itu_t_t35_information_struct;
00178
00179
00180 typedef struct
00181 {
00182 unsigned int recovery_frame_cnt;
00183 unsigned char exact_match_flag;
00184 unsigned char broken_link_flag;
00185 unsigned char changing_slice_group_idc;
00186
00187 Bitstream *data;
00188 int payloadSize;
00189 } recovery_point_information_struct;
00190
00191
00192 typedef struct
00193 {
00194 int cpb_removal_delay;
00195 int dpb_output_delay;
00196 int pic_struct;
00197 Boolean clock_timestamp_flag[MAX_PIC_STRUCT_VALUE];
00198 int ct_type;
00199 Boolean nuit_field_based_flag;
00200 int counting_type;
00201 Boolean full_timestamp_flag;
00202 Boolean discontinuity_flag;
00203 Boolean cnt_dropped_flag;
00204 int n_frames;
00205 int seconds_value;
00206 int minutes_value;
00207 int hours_value;
00208 Boolean seconds_flag;
00209 Boolean minutes_flag;
00210 Boolean hours_flag;
00211 int time_offset;
00212
00213 Bitstream *data;
00214 int payloadSize;
00215 } pictiming_information_struct;
00216
00217
00218
00219 typedef struct
00220 {
00221 Boolean original_idr_flag;
00222 int original_frame_num;
00223 Boolean original_field_pic_flag;
00224 Boolean original_bottom_field_flag;
00225 DecRefPicMarking_t *dec_ref_pic_marking_buffer_saved;
00226
00227 Bitstream *data;
00228 int payloadSize;
00229 } drpm_repetition_information_struct;
00230
00231
00232
00233 typedef struct
00234 {
00235 unsigned int filter_hint_size_y;
00236 unsigned int filter_hint_size_x;
00237 unsigned int filter_hint_type;
00238 int ***filter_hint;
00239 unsigned int additional_extension_flag;
00240
00241 Bitstream *data;
00242 int payloadSize;
00243 } post_filter_information_struct;
00244
00245 typedef struct
00246 {
00247 unsigned int tone_map_id;
00248 unsigned char tone_map_cancel_flag;
00249 unsigned int tone_map_repetition_period;
00250 unsigned char coded_data_bit_depth;
00251 unsigned char sei_bit_depth;
00252 unsigned int model_id;
00253
00254 int min_value;
00255 int max_value;
00256
00257 int sigmoid_midpoint;
00258 int sigmoid_width;
00259
00260 int start_of_coded_interval[1<<MAX_SEI_BIT_DEPTH];
00261
00262 int num_pivots;
00263 int coded_pivot_value[MAX_NUM_PIVOTS];
00264 int sei_pivot_value[MAX_NUM_PIVOTS];
00265
00266 Bitstream *data;
00267 int payloadSize;
00268 } ToneMappingSEI;
00269
00270
00271 struct sei_params {
00272 Boolean seiHasDRPMRepetition_info;
00273 drpm_repetition_information_struct seiDRPMRepetition;
00274
00275
00276
00277 sei_struct sei_message[2];
00278 Boolean seiHasSparePicture;
00279
00280 spare_picture_struct seiSparePicturePayload;
00281 Boolean seiHasSubseqInfo;
00282 subseq_information_struct seiSubseqInfo[MAX_LAYER_NUMBER];
00283 Boolean seiHasSubseqLayerInfo;
00284 subseq_layer_information_struct seiSubseqLayerInfo;
00285 Boolean seiHasSubseqChar;
00286 subseq_char_information_struct seiSubseqChar;
00287 Boolean seiHasSceneInformation;
00288 scene_information_struct seiSceneInformation;
00289 Boolean seiHasPanScanRectInfo;
00290 panscanrect_information_struct seiPanScanRectInfo;
00291 Boolean seiHasUser_data_unregistered_info;
00292 user_data_unregistered_information_struct seiUser_data_unregistered;
00293 Boolean seiHasUser_data_registered_itu_t_t35_info;
00294 user_data_registered_itu_t_t35_information_struct seiUser_data_registered_itu_t_t35;
00295 Boolean seiHasRecoveryPoint_info;
00296 recovery_point_information_struct seiRecoveryPoint;
00297 Boolean seiHasBuffering_period;
00298 bufferingperiod_information_struct seiBufferingPeriod;
00299 Boolean seiHasPicTiming_info;
00300 pictiming_information_struct seiPicTiming;
00301
00302 Boolean seiHasTone_mapping;
00303 ToneMappingSEI seiToneMapping;
00304 Boolean seiHasPostFilterHints_info;
00305 post_filter_information_struct seiPostFilterHints;
00306
00307 Boolean seiHasTemporal_reference;
00308 Boolean seiHasClock_timestamp;
00309 Boolean seiHasPanscan_rect;
00310 Boolean seiHasHrd_picture;
00311 Boolean seiHasFiller_payload;
00312 Boolean seiHasUser_data_registered_itu_t_t35;
00313 Boolean seiHasUser_data_unregistered;
00314 Boolean seiHasRef_pic_buffer_management_repetition;
00315 Boolean seiHasSpare_picture;
00316 Boolean seiHasSubseq_information;
00317 Boolean seiHasSubseq_layer_characteristics;
00318 Boolean seiHasSubseq_characteristics;
00319
00320 };
00321
00322 typedef struct sei_params SEIParameters;
00323
00324
00325 extern void InitSEIMessages (ImageParameters *p_Img, InputParameters *p_Inp);
00326 extern void CloseSEIMessages (ImageParameters *p_Img, InputParameters *p_Inp);
00327 extern Boolean HaveAggregationSEI(ImageParameters *p_Img);
00328
00329 extern void clear_sei_message (SEIParameters *p_SEI, int id);
00330 extern void AppendTmpbits2Buf ( Bitstream* dest, Bitstream* source );
00331 extern void PrepareAggregationSEIMessage(ImageParameters *p_Img);
00332 extern void CalculateSparePicture();
00333 extern Boolean CompressSpareMBMap(ImageParameters *p_Img, unsigned char **map_sp, Bitstream *bitstream);
00334 extern void InitSubseqInfo(SEIParameters *p_SEI, int currLayer);
00335 extern void UpdateSubseqInfo (ImageParameters *p_Img, InputParameters *p_Inp, int currLayer);
00336 extern void CloseSubseqInfo (SEIParameters *p_SEI, int currLayer);
00337 void CloseSubseqLayerInfo();
00338 extern void UpdateSubseqChar(ImageParameters *p_Img);
00339
00340 extern void InitSceneInformation (SEIParameters *p_SEI);
00341 extern void CloseSceneInformation (SEIParameters *p_SEI);
00342 extern void UpdateSceneInformation (SEIParameters *p_SEI, Boolean HasSceneInformation, int sceneID, int sceneTransType, int secondSceneID);
00343 extern void FinalizeSceneInformation (SEIParameters *p_SEI);
00344 extern void UpdatePanScanRectInfo(SEIParameters *p_SEI);
00345
00346 extern void UpdateUser_data_unregistered(SEIParameters *p_SEI);
00347 extern void UpdateUser_data_registered_itu_t_t35(SEIParameters *p_SEI);
00348
00349 extern void ClearRandomAccess(SEIParameters *p_SEI);
00350 extern void UpdateRandomAccess(ImageParameters *p_Img);
00351
00352 extern void UpdateToneMapping(SEIParameters *p_SEI);
00353
00354 extern void init_sei(SEIParameters *p_SEI);
00355 extern int Write_SEI_NALU(ImageParameters *p_Img, int len);
00356 extern void InitBufferingPeriod (ImageParameters *p_Img);
00357 extern void ClearBufferingPeriod (SEIParameters *p_SEI, seq_parameter_set_rbsp_t *active_sps);
00358 extern void UpdateBufferingPeriod (ImageParameters *p_Img, InputParameters *p_Inp);
00359 extern void ClearPicTiming(SEIParameters *p_SEI);
00360 extern void UpdatePicTiming(ImageParameters *p_Img, InputParameters *p_Inp);
00361 extern void ClearDRPMRepetition(SEIParameters *p_SEI);
00362 extern void UpdateDRPMRepetition(SEIParameters *p_SEI);
00363 extern void free_drpm_buffer( DecRefPicMarking_t *pDRPM );
00364 extern void UpdatePostFilterHints(SEIParameters *p_SEI);
00365 extern void ComposeSparePictureMessage (SEIParameters *p_SEI, int delta_spare_frame_num, int ref_area_indicator, Bitstream *tmpBitstream);
00366
00367
00368
00369
00370 #endif