1 /******************************************************************************
2  *
3  * Copyright (C) 2015 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 
21 /*****************************************************************************/
22 /*                                                                           */
23 /*  File Name         : ih264d_sei.h                                                */
24 /*                                                                           */
25 /*  Description       : This file contains routines to parse SEI NAL's       */
26 /*                                                                           */
27 /*  List of Functions : <List the functions defined in this file>            */
28 /*                                                                           */
29 /*  Issues / Problems : None                                                 */
30 /*                                                                           */
31 /*  Revision History  :                                                      */
32 /*                                                                           */
33 /*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
34 /*         25 05 2005   NS              Draft                                */
35 /*                                                                           */
36 /*****************************************************************************/
37 
38 #ifndef _IH264D_SEI_H_
39 #define _IH264D_SEI_H_
40 
41 #include "ih264_typedefs.h"
42 #include "ih264_macros.h"
43 #include "ih264_platform_macros.h"
44 #include "ih264d_bitstrm.h"
45 #include "ih264d_structs.h"
46 #include "ih264d.h"
47 
48 #define SEI_BUF_PERIOD      0
49 #define SEI_PIC_TIMING      1
50 #define SEI_PAN_SCAN_RECT   2
51 #define SEI_FILLER          3
52 #define SEI_UD_REG_T35      4
53 #define SEI_UD_UN_REG       5
54 #define SEI_RECOVERY_PT     6
55 #define SEI_DEC_REF_MARK    7
56 #define SEI_SPARE_PIC       8
57 #define SEI_SCENE_INFO      9
58 #define SEI_SUB_SEQN_INFO   10
59 #define SEI_SUB_SEQN_LAY_CHAR       11
60 #define SEI_SUB_SEQN_CHAR   12
61 #define SEI_FULL_FRAME_FREEZE       13
62 #define SEI_FULL_FRAME_FREEZE_REL   14
63 #define SEI_FULL_FRAME_SNAP_SHOT    15
64 #define SEI_PROG_REF_SEGMENT_START  16
65 #define SEI_PROG_REF_SEGMENT_END    17
66 #define SEI_MOT_CON_SLICE_GRP_SET   18
67 #define SEI_MASTERING_DISP_COL_VOL       137
68 #define SEI_CONTENT_LIGHT_LEVEL_DATA     144
69 #define SEI_AMBIENT_VIEWING_ENVIRONMENT  148
70 #define SEI_CONTENT_COLOR_VOLUME         149
71 
72 /* Declaration of dec_struct_t to avoid CCS compilation Error */
73 struct _DecStruct;
74 WORD32 ih264d_parse_sei_message(struct _DecStruct *ps_dec,
75                                 dec_bit_stream_t *ps_bitstrm);
76 typedef struct
77 {
78     UWORD8 u1_seq_parameter_set_id;
79     UWORD32 u4_initial_cpb_removal_delay;
80     UWORD32 u4_nitial_cpb_removal_delay_offset;
81 
82 } buf_period_t;
83 
84 /**
85  * Structure to hold Mastering Display Color Volume SEI
86  */
87 typedef struct
88 {
89     /**
90      * Array to store the display_primaries_x values
91      */
92     UWORD16 au2_display_primaries_x[NUM_SEI_MDCV_PRIMARIES];
93 
94     /**
95      * Array to store the display_primaries_y values
96      */
97     UWORD16 au2_display_primaries_y[NUM_SEI_MDCV_PRIMARIES];
98 
99     /**
100      * Variable to store the white point x value
101      */
102     UWORD16 u2_white_point_x;
103 
104     /**
105      * Variable to store the white point y value
106      */
107     UWORD16 u2_white_point_y;
108 
109     /**
110      * Variable to store the max display mastering luminance value
111      */
112     UWORD32 u4_max_display_mastering_luminance;
113 
114     /**
115      * Variable to store the min display mastering luminance value
116      */
117     UWORD32 u4_min_display_mastering_luminance;
118 
119 }sei_mdcv_params_t;
120 
121 
122 /**
123  * Structure for Content Light Level Info
124  *
125  */
126 typedef struct
127 {
128     /**
129      * The maximum pixel intensity of all samples
130      */
131     UWORD16 u2_max_content_light_level;
132 
133     /**
134      * The average pixel intensity of all samples
135      */
136     UWORD16 u2_max_pic_average_light_level;
137 
138 }sei_cll_params_t;
139 
140 
141 /**
142  * Structure to hold Ambient viewing environment SEI
143  */
144 typedef struct
145 {
146 
147     /**
148      * specifies the environmental illuminance of the ambient viewing environment
149      */
150     UWORD32 u4_ambient_illuminance;
151 
152     /*
153      * specify the normalized x chromaticity coordinates of the
154      * environmental ambient light in the nominal viewing environment
155      */
156     UWORD16 u2_ambient_light_x;
157 
158     /*
159     * specify the normalized y chromaticity coordinates of the
160     * environmental ambient light in the nominal viewing environment
161     */
162     UWORD16 u2_ambient_light_y;
163 
164 }sei_ave_params_t;
165 
166 
167 /**
168  * Structure to hold Content color volume SEI
169  */
170 typedef struct
171 {
172     /*
173      * Flag used to control persistence of CCV SEI messages
174      */
175     UWORD8 u1_ccv_cancel_flag;
176 
177     /*
178      * specifies the persistence of the CCV SEI message for the current layer
179      */
180     UWORD8 u1_ccv_persistence_flag;
181 
182     /*
183      * specifies the presence of syntax elements ccv_primaries_x and ccv_primaries_y
184      */
185     UWORD8 u1_ccv_primaries_present_flag;
186 
187     /*
188      * specifies that the syntax element ccv_min_luminance_value is present
189      */
190     UWORD8 u1_ccv_min_luminance_value_present_flag;
191 
192     /*
193      * specifies that the syntax element ccv_max_luminance_value is present
194      */
195     UWORD8 u1_ccv_max_luminance_value_present_flag;
196 
197     /*
198      * specifies that the syntax element ccv_avg_luminance_value is present
199      */
200     UWORD8 u1_ccv_avg_luminance_value_present_flag;
201 
202     /*
203      * shall be equal to 0 in bitstreams conforming to this version. Other values
204      * for reserved_zero_2bits are reserved for future use
205      */
206     UWORD8 u1_ccv_reserved_zero_2bits;
207 
208     /*
209      * specify the normalized x chromaticity coordinates of the colour
210      * primary component c of the nominal content colour volume
211      */
212     WORD32 ai4_ccv_primaries_x[NUM_SEI_CCV_PRIMARIES];
213 
214     /*
215      * specify the normalized y chromaticity coordinates of the colour
216      * primary component c of the nominal content colour volume
217      */
218     WORD32 ai4_ccv_primaries_y[NUM_SEI_CCV_PRIMARIES];
219 
220     /*
221      * specifies the normalized minimum luminance value
222      */
223     UWORD32 u4_ccv_min_luminance_value;
224 
225     /*
226      * specifies the normalized maximum luminance value
227      */
228     UWORD32 u4_ccv_max_luminance_value;
229 
230     /*
231      * specifies the normalized average luminance value
232      */
233     UWORD32 u4_ccv_avg_luminance_value;
234 
235 }sei_ccv_params_t;
236 
237 struct _sei
238 {
239     UWORD8 u1_seq_param_set_id;
240     buf_period_t s_buf_period;
241     UWORD8 u1_pic_struct;
242     UWORD16 u2_recovery_frame_cnt;
243     UWORD8 u1_exact_match_flag;
244     UWORD8 u1_broken_link_flag;
245     UWORD8 u1_changing_slice_grp_idc;
246     UWORD8 u1_is_valid;
247 
248     /**
249      *  mastering display color volume info present flag
250      */
251     UWORD8 u1_sei_mdcv_params_present_flag;
252 
253     /*
254      * MDCV parameters
255      */
256     sei_mdcv_params_t s_sei_mdcv_params;
257 
258     /**
259      * content light level info present flag
260      */
261     UWORD8 u1_sei_cll_params_present_flag;
262 
263     /*
264      * CLL parameters
265      */
266     sei_cll_params_t s_sei_cll_params;
267 
268     /**
269      * ambient viewing environment info present flag
270      */
271     UWORD8 u1_sei_ave_params_present_flag;
272 
273     /*
274      * AVE parameters
275      */
276     sei_ave_params_t s_sei_ave_params;
277 
278     /**
279      * content color volume info present flag
280      */
281     UWORD8 u1_sei_ccv_params_present_flag;
282 
283     /*
284      * CCV parameters
285      */
286     sei_ccv_params_t s_sei_ccv_params;
287 
288 };
289 typedef struct _sei sei;
290 
291 WORD32 ih264d_export_sei_mdcv_params(ivd_sei_decode_op_t *ps_sei_decode_op,
292                                      sei *ps_sei, sei *ps_sei_export);
293 
294 WORD32 ih264d_export_sei_cll_params(ivd_sei_decode_op_t *ps_sei_decode_op,
295                                     sei *ps_sei, sei *ps_sei_export);
296 
297 WORD32 ih264d_export_sei_ave_params(ivd_sei_decode_op_t *ps_sei_decode_op,
298                                     sei *ps_sei, sei *ps_sei_export);
299 
300 WORD32 ih264d_export_sei_ccv_params(ivd_sei_decode_op_t *ps_sei_decode_op,
301                                     sei *ps_sei, sei *ps_sei_export);
302 
303 #endif /* _IH264D_SEI_H_ */
304 
305