1 /* ///////////////////////////////////////////////////////////////////////
2 //
3 //               INTEL CORPORATION PROPRIETARY INFORMATION
4 //  This software is supplied under the terms of a license agreement or
5 //  nondisclosure agreement with Intel Corporation and may not be copied
6 //  or disclosed except in accordance with the terms of that agreement.
7 //        Copyright (c) 2001-2006 Intel Corporation. All Rights Reserved.
8 //
9 //  Description:    MPEG-4 header.
10 //
11 */
12 
13 
14 #ifndef _H264_SEI_H_
15 #define _H264_SEI_H_
16 
17 #include "h264.h"
18 
19 
20 //defines for SEI
21 #define MAX_CPB_CNT					32
22 #define MAX_NUM_CLOCK_TS			3
23 #define MAX_PAN_SCAN_CNT			3
24 #define MAX_NUM_SPARE_PICS			16
25 #define MAX_SUB_SEQ_LAYERS   		256
26 #define MAX_SLICE_GRPS				1    // for high profile
27 #define NUM_SPS						32
28 #define MAX_NUM_REF_SUBSEQS			256
29 
30 
31 #define SEI_SCAN_FORMAT_INTERLACED      0x1
32 #define SEI_SCAN_FORMAT_PROGRESSIVE     0x3
33 #define SEI_SCAN_FORMAT_VALID(r)        (r&0x1)
34 #define SEI_SCAN_FORMAT(r)              ((r&0x2)>>1)
35 
36 typedef enum
37 {
38 	SEI_BUF_PERIOD = 0,
39 	SEI_PIC_TIMING,
40 	SEI_PAN_SCAN,
41 	SEI_FILLER_PAYLOAD,
42 	SEI_REG_USERDATA,
43 	SEI_UNREG_USERDATA,
44 	SEI_RECOVERY_POINT,
45 	SEI_DEC_REF_PIC_MARKING_REP,
46 	SEI_SPARE_PIC,
47 	SEI_SCENE_INFO,
48 	SEI_SUB_SEQ_INFO,
49 	SEI_SUB_SEQ_LAYER,
50 	SEI_SUB_SEQ,
51 	SEI_FULL_FRAME_FREEZE,
52 	SEI_FULL_FRAME_FREEZE_RELEASE,
53 	SEI_FULL_FRAME_SNAPSHOT,
54 	SEI_PROGRESSIVE_SEGMENT_START,
55 	SEI_PROGRESSIVE_SEGMENT_END,
56 	SEI_MOTION_CONSTRAINED_SLICE_GRP_SET,
57 	SEI_FILM_GRAIN_CHARACTERISTICS,
58 	SEI_DEBLK_FILTER_DISPLAY_PREFERENCE,
59 	SEI_STEREO_VIDEO_INFO,
60 	SEI_RESERVED,
61 }h264_sei_payloadtype;
62 
63 
64 
65 typedef struct _h264_SEI_buffering_period
66 {
67   	int32_t seq_param_set_id;
68    int32_t initial_cpb_removal_delay_nal;
69    int32_t initial_cpb_removal_delay_offset_nal;
70    int32_t initial_cpb_removal_delay_vcl;
71    int32_t initial_cpb_removal_delay_offset_vcl;
72 
73 }h264_SEI_buffering_period_t;
74 
75 typedef struct _h264_SEI_pic_timing
76 {
77 	int32_t cpb_removal_delay;
78 	int32_t dpb_output_delay;
79 	int32_t pic_struct;
80 }h264_SEI_pic_timing_t;
81 
82 #if 0
83 int32_t clock_timestamp_flag[MAX_NUM_CLOCK_TS];
84 int32_t ct_type[MAX_NUM_CLOCK_TS];
85 int32_t nuit_field_based_flag[MAX_NUM_CLOCK_TS];
86 int32_t counting_type[MAX_NUM_CLOCK_TS];
87 int32_t full_timestamp_flag[MAX_NUM_CLOCK_TS];
88 int32_t discontinuity_flag[MAX_NUM_CLOCK_TS];
89 int32_t cnt_dropped_flag[MAX_NUM_CLOCK_TS];
90 int32_t n_frames[MAX_NUM_CLOCK_TS];
91 int32_t seconds_value[MAX_NUM_CLOCK_TS];
92 int32_t minutes_value[MAX_NUM_CLOCK_TS];
93 int32_t hours_value[MAX_NUM_CLOCK_TS];
94 int32_t seconds_flag[MAX_NUM_CLOCK_TS];
95 int32_t minutes_flag[MAX_NUM_CLOCK_TS];
96 int32_t hours_flag[MAX_NUM_CLOCK_TS];
97 int32_t time_offset[MAX_NUM_CLOCK_TS];
98 
99 #endif
100 
101 typedef struct _h264_SEI_pan_scan_rectangle
102 {
103 	int32_t pan_scan_rect_id;
104 	int32_t pan_scan_rect_cancel_flag;
105 	int32_t pan_scan_cnt_minus1;
106 	int32_t pan_scan_rect_left_offset[MAX_PAN_SCAN_CNT];
107 	int32_t pan_scan_rect_right_offset[MAX_PAN_SCAN_CNT];
108 	int32_t pan_scan_rect_top_offset[MAX_PAN_SCAN_CNT];
109 	int32_t pan_scan_rect_bottom_offset[MAX_PAN_SCAN_CNT];
110 	int32_t pan_scan_rect_repetition_period;
111 }h264_SEI_pan_scan_rectangle_t;
112 
113 typedef struct _h264_SEI_filler_payload
114 {
115 	int32_t ff_byte;
116 }h264_SEI_filler_payload_t;
117 
118 typedef struct _h264_SEI_userdata_registered
119 {
120 	int32_t itu_t_t35_country_code;
121 	int32_t itu_t_t35_country_code_extension_byte;
122 	int32_t itu_t_t35_payload_byte;
123 }h264_SEI_userdata_registered_t;
124 
125 typedef struct _h264_SEI_userdata_unregistered
126 {
127 	int32_t uuid_iso_iec_11578[4];
128 	int32_t user_data_payload_byte;
129 }h264_SEI_userdata_unregistered_t;
130 
131 typedef struct _h264_SEI_recovery_point
132 {
133 	int32_t recovery_frame_cnt;
134 	int32_t exact_match_flag;
135 	int32_t broken_link_flag;
136 	int32_t changing_slice_group_idc;
137 }h264_SEI_recovery_point_t;
138 
139 typedef struct _h264_SEI_decoded_ref_pic_marking_repetition
140 {
141 	int32_t original_idr_flag;
142 	int32_t original_frame_num;
143 	int32_t orignal_field_pic_flag;
144 	int32_t original_bottom_field_pic_flag;
145 	int32_t no_output_of_prior_pics_flag;
146 	int32_t long_term_reference_flag;
147 	int32_t adaptive_ref_pic_marking_mode_flag;
148 	int32_t memory_management_control_operation;				//UE
149 	int32_t difference_of_pics_num_minus1;						//UE
150 	int32_t long_term_pic_num;									//UE
151 	int32_t long_term_frame_idx;								//UE
152 	int32_t max_long_term_frame_idx_plus1;						//UE
153 }h264_SEI_decoded_ref_pic_marking_repetition_t;
154 
155 typedef struct _h264_SEI_spare_picture
156 {
157 	int32_t target_frame_num;
158 	int32_t spare_field_flag;
159 	int32_t target_bottom_field_flag;
160 	int32_t num_spare_pics_minus1;
161 	int32_t delta_spare_frame_num[MAX_NUM_SPARE_PICS];
162 	int32_t spare_bottom_field_flag[MAX_NUM_SPARE_PICS];
163 	int32_t spare_area_idc[MAX_NUM_SPARE_PICS];				// not complete
164 }h264_SEI_spare_picture_t;
165 
166 typedef struct _h264_SEI_scene_info
167 {
168 	int32_t scene_info_present_flag;
169 	int32_t scene_id;
170 	int32_t scene_transitioning_type;
171 	int32_t second_scene_id;
172 }h264_SEI_scene_info_t;
173 
174 typedef struct _h264_SEI_sub_sequence_info
175 {
176 	int32_t sub_seq_layer_num;
177 	int32_t sub_seq_id;
178 	int32_t first_ref_pic_flag;
179 	int32_t leading_non_ref_pic_flag;
180 	int32_t last_pic_flag;
181 	int32_t sub_seq_frame_num_flag;
182 	int32_t sub_seq_frame_num;
183 }h264_SEI_sub_sequence_info_t;
184 
185 typedef struct _h264_SEI_sub_sequence_layer
186 {
187 	int32_t num_sub_seq_layers_minus1;
188 	int32_t accurate_statistics_flag[MAX_SUB_SEQ_LAYERS];
189 	int32_t average_bit_rate[MAX_SUB_SEQ_LAYERS];
190 	int32_t average_frame_rate[MAX_SUB_SEQ_LAYERS];
191 }h264_SEI_sub_sequence_layer_t;
192 
193 typedef struct _h264_SEI_sub_sequence
194 {
195 	int32_t sub_seq_layer_num;
196 	int32_t sub_seq_id;
197 	int32_t duration_flag;
198 	int32_t sub_seq_duration;
199 	int32_t average_rate_flag;
200 	int32_t average_statistics_flag;
201 	int32_t average_bit_rate;
202 	int32_t average_frame_rate;
203 	int32_t num_referenced_subseqs;
204 	int32_t ref_sub_seq_layer_num;
205 	int32_t ref_sub_seq_id;
206 	int32_t ref_sub_seq_direction;
207 }h264_SEI_sub_sequence_t;
208 
209 typedef struct _h264_SEI_full_frame_freeze
210 {
211 	int32_t full_frame_freeze_repetition_period;
212 }h264_SEI_full_frame_freeze_t;
213 
214 typedef struct _h264_SEI_full_frame_snapshot
215 {
216 	int32_t snapshot_id;
217 }h264_SEI_full_frame_snapshot_t;
218 
219 typedef struct _h264_SEI_progressive_segment_start
220 {
221 	int32_t progressive_refinement_id;
222 	int32_t num_refinement_steps_minus1;
223 }h264_SEI_progressive_segment_start_t;
224 
225 typedef struct _h264_SEI_progressive_segment_end
226 {
227 	int32_t progressive_refinement_id;
228 }h264_SEI_progressive_segment_end_t;
229 
230 typedef struct _h264_SEI_motion_constrained_slice_group
231 {
232 	int32_t num_slice_groups_in_set_minus1;
233 	int32_t slice_group_id[MAX_SLICE_GRPS];
234 	int32_t exact_sample_value_match_flag;
235 	int32_t pan_scan_rect_flag;
236 	int32_t pan_scan_rect_id;
237 }h264_SEI_motion_constrained_slice_group_t;
238 
239 typedef struct _h264_SEI_deblocking_filter_display_pref
240 {
241 	int32_t devlocking_display_preference_cancel_flag;
242 	int32_t display_prior_to_deblocking_preferred_flag;
243 	int32_t dec_frame_buffering_constraint_flag;
244 	int32_t deblocking_display_preference_repetition_period;
245 }h264_SEI_deblocking_filter_display_pref_t;
246 
247 typedef struct _h264_SEI_stereo_video_info
248 {
249 	int32_t field_views_flag;
250 	int32_t top_field_is_left_view_flag;
251 	int32_t curent_frame_is_left_view_flag;
252 	int32_t next_frame_is_second_view_flag;
253 	int32_t left_view_self_contained_flag;
254 	int32_t right_view_self_contained_flag;
255 }h264_SEI_stereo_video_info_t;
256 
257 typedef struct _h264_SEI_reserved
258 {
259 	int32_t reserved_sei_message_payload_byte;
260 }h264_SEI_reserved_t;
261 
262 
263 ////////////////////////////
264 // SEI Info
265 /////////////////////////////
266 
267 typedef struct sei_info
268 {
269 	int32_t recovery_point;
270 	int32_t recovery_frame_num;
271 
272 	int32_t capture_POC;
273 	int32_t freeze_POC;
274 	int32_t release_POC;        // The POC which when reached will allow display update to re-commence
275 	int32_t disp_frozen;        // Indicates display is currently frozen
276 	int32_t freeze_rep_period;
277 	int32_t recovery_frame_cnt;
278 	int32_t capture_fn;
279 	int32_t recovery_fn;
280 	int32_t broken_link;
281 	int32_t scan_format;
282 	int32_t broken_link_pic;
283 }sei_info, *sei_info_ptr;
284 
285 /*typedef struct _h264_SEI
286 {
287 	h264_SEI_buffering_period_t buf_period;
288 	h264_SEI_pic_timing_t pic_timing;
289 	h264_SEI_pan_scan_rectangle_t pan_scan_timing;
290 	h264_SEI_filler_payload_t filler_payload;
291 	h264_SEI_userdata_registered_t userdata_reg;
292 	h264_SEI_userdata_unregistered_t userdata_unreg;
293 	h264_SEI_recovery_point_t recovery_point;
294 	h264_SEI_decoded_ref_pic_marking_repetition_t dec_ref_pic_marking_rep;
295 	h264_SEI_spare_picture_t spare_pic;
296 	h264_SEI_scene_info_t scene_info;
297 	h264_SEI_sub_sequence_info_t sub_sequence_info;
298 	h264_SEI_sub_sequence_layer_t sub_sequence_layer;
299 	h264_SEI_sub_sequence_t sub_sequence;
300 	h264_SEI_full_frame_snapshot_t full_frame_snapshot;
301 	h264_SEI_full_frame_t full_frame;
302 	h264_SEI_progressive_segment_start_t progressive_segment_start;
303 	h264_SEI_progressive_segment_end_t progressive_segment_end;
304 	h264_SEI_motion_constrained_slice_group_t motion_constrained_slice_grp;
305 	h264_SEI_deblocking_filter_display_pref_t deblk_filter_display_pref;
306 	h264_SEI_stereo_video_info_t stereo_video_info;
307 	h264_SEI_reserved_t reserved;
308 }h264_SEI_t;
309 */
310 
311 
312 #endif  //_H264_SEI_H_
313 
314 
315