/src/libavc/encoder/ih264e_sei.c
Line | Count | Source (jump to first uncovered line) |
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 |
24 | | * ih264e_sei.c |
25 | | * |
26 | | * @brief |
27 | | * This file contains function definitions related to SEI NAL's header encoding |
28 | | * |
29 | | * @author |
30 | | * ittiam |
31 | | * |
32 | | * @par List of Functions: |
33 | | * - ih264e_put_sei_mdcv_params |
34 | | * - ih264e_put_sei_cll_params |
35 | | * - ih264e_put_sei_ave_params |
36 | | * - ih264e_put_sei_ccv_params |
37 | | * - ih264e_put_sei_msg |
38 | | * - ih264e_put_sei_sii_params |
39 | | * |
40 | | * @remarks |
41 | | * None |
42 | | * |
43 | | ******************************************************************************* |
44 | | */ |
45 | | |
46 | | /*****************************************************************************/ |
47 | | /* File Includes */ |
48 | | /*****************************************************************************/ |
49 | | |
50 | | /* System include files */ |
51 | | #include <stdio.h> |
52 | | #include <stddef.h> |
53 | | #include <stdlib.h> |
54 | | #include <string.h> |
55 | | #include <assert.h> |
56 | | |
57 | | /* User include files */ |
58 | | #include "ih264_typedefs.h" |
59 | | #include "iv2.h" |
60 | | #include "ive2.h" |
61 | | #include "ih264_macros.h" |
62 | | #include "ih264_platform_macros.h" |
63 | | #include "ih264e_trace.h" |
64 | | #include "ih264e_error.h" |
65 | | #include "ih264e_bitstream.h" |
66 | | #include "ih264_defs.h" |
67 | | #include "ih264_structs.h" |
68 | | #include "ih264_cabac_tables.h" |
69 | | #include "ih264e_cabac_structs.h" |
70 | | #include "irc_cntrl_param.h" |
71 | | #include "ime_distortion_metrics.h" |
72 | | #include "ime_defs.h" |
73 | | #include "ime_structs.h" |
74 | | #include "ih264e_defs.h" |
75 | | #include "irc_cntrl_param.h" |
76 | | #include "irc_frame_info_collector.h" |
77 | | #include "ih264_trans_quant_itrans_iquant.h" |
78 | | #include "ih264_inter_pred_filters.h" |
79 | | #include "ih264_deblk_edge_filters.h" |
80 | | #include "ih264e_structs.h" |
81 | | #include "ih264e_encode_header.h" |
82 | | #include "ih264e_sei.h" |
83 | | |
84 | | /*****************************************************************************/ |
85 | | /* Function Definitions */ |
86 | | /*****************************************************************************/ |
87 | | |
88 | | /** |
89 | | ****************************************************************************** |
90 | | * |
91 | | * @brief Generates Mastering Display Color Volume (Supplemental Enhancement Information ) |
92 | | * |
93 | | * @par Description |
94 | | * Parse Supplemental Enhancement Information |
95 | | * |
96 | | * @param[in] ps_bitstrm |
97 | | * pointer to bitstream context (handle) |
98 | | * |
99 | | * @param[in] ps_sei_mdcv |
100 | | * pointer to structure containing mdcv SEI data |
101 | | * |
102 | | * @return success or failure error code |
103 | | * |
104 | | ****************************************************************************** |
105 | | */ |
106 | | IH264E_ERROR_T ih264e_put_sei_mdcv_params(sei_mdcv_params_t *ps_sei_mdcv, |
107 | | bitstrm_t *ps_bitstrm) |
108 | 3.81k | { |
109 | 3.81k | WORD32 return_status = IH264E_SUCCESS; |
110 | 3.81k | UWORD8 u1_payload_size = 0; |
111 | 3.81k | UWORD32 u4_count; |
112 | | |
113 | 3.81k | if(ps_sei_mdcv == NULL) |
114 | 0 | { |
115 | 0 | return IH264E_FAIL; |
116 | 0 | } |
117 | | |
118 | 3.81k | u1_payload_size += (NUM_SEI_MDCV_PRIMARIES * 2); /* display primaries x */ |
119 | 3.81k | u1_payload_size += (NUM_SEI_MDCV_PRIMARIES * 2); /* display primaries y */ |
120 | 3.81k | u1_payload_size += 2; /* white point x */ |
121 | 3.81k | u1_payload_size += 2; /* white point y */ |
122 | 3.81k | u1_payload_size += 4; /* max display mastering luminance */ |
123 | 3.81k | u1_payload_size += 4; /* min display mastering luminance */ |
124 | | |
125 | | /************************************************************************/ |
126 | | /* PayloadSize : This is the size of the payload in bytes */ |
127 | | /************************************************************************/ |
128 | 3.81k | PUT_BITS(ps_bitstrm, u1_payload_size, 8, return_status, "u1_payload_size"); |
129 | | |
130 | | /*******************************************************************************/ |
131 | | /* Put the mastering display color volume SEI parameters into the bitstream. */ |
132 | | /*******************************************************************************/ |
133 | | |
134 | | /* display primaries x */ |
135 | 15.2k | for(u4_count = 0; u4_count < NUM_SEI_MDCV_PRIMARIES; u4_count++) |
136 | 11.4k | { |
137 | 11.4k | PUT_BITS(ps_bitstrm, ps_sei_mdcv->au2_display_primaries_x[u4_count], 16, |
138 | 11.4k | return_status, "u2_display_primaries_x"); |
139 | | |
140 | 11.4k | PUT_BITS(ps_bitstrm, ps_sei_mdcv->au2_display_primaries_y[u4_count], 16, |
141 | 11.4k | return_status, "u2_display_primaries_y"); |
142 | 11.4k | } |
143 | | |
144 | | /* white point x */ |
145 | 3.81k | PUT_BITS(ps_bitstrm, ps_sei_mdcv->u2_white_point_x, 16, return_status, "u2_white point x"); |
146 | | |
147 | | /* white point y */ |
148 | 3.81k | PUT_BITS(ps_bitstrm, ps_sei_mdcv->u2_white_point_y, 16, return_status, "u2_white point y"); |
149 | | |
150 | | /* max display mastering luminance */ |
151 | 3.81k | PUT_BITS(ps_bitstrm, ps_sei_mdcv->u4_max_display_mastering_luminance, 32, |
152 | 3.81k | return_status, "u4_max_display_mastering_luminance"); |
153 | | |
154 | | /* min display mastering luminance */ |
155 | 3.81k | PUT_BITS(ps_bitstrm, ps_sei_mdcv->u4_min_display_mastering_luminance, 32, |
156 | 3.81k | return_status, "u4_max_display_mastering_luminance"); |
157 | | |
158 | 3.81k | return (return_status); |
159 | 3.81k | } |
160 | | |
161 | | /** |
162 | | ****************************************************************************** |
163 | | * |
164 | | * @brief Stores content light level info in bitstream |
165 | | * |
166 | | * @par Description |
167 | | * Parse Supplemental Enhancement Information |
168 | | * |
169 | | * @param[in] ps_bitstrm |
170 | | * pointer to bitstream context (handle) |
171 | | * |
172 | | * @param[in] ps_sei_cll |
173 | | * Pinter to structure containing cll sei params |
174 | | * |
175 | | * @return success or failure error code |
176 | | * |
177 | | ****************************************************************************** |
178 | | */ |
179 | | IH264E_ERROR_T ih264e_put_sei_cll_params(sei_cll_params_t *ps_sei_cll, |
180 | | bitstrm_t *ps_bitstrm) |
181 | 3.41k | { |
182 | 3.41k | WORD32 return_status = IH264E_SUCCESS; |
183 | 3.41k | UWORD8 u1_payload_size = 0; |
184 | | |
185 | 3.41k | if(ps_sei_cll == NULL) |
186 | 0 | { |
187 | 0 | return IH264E_FAIL; |
188 | 0 | } |
189 | | |
190 | 3.41k | u1_payload_size += 2; /* max pic average light level */ |
191 | 3.41k | u1_payload_size += 2; /* max content light level */ |
192 | | |
193 | | /************************************************************************/ |
194 | | /* PayloadSize : This is the size of the payload in bytes */ |
195 | | /************************************************************************/ |
196 | 3.41k | PUT_BITS(ps_bitstrm, u1_payload_size, 8, return_status, "u1_payload_size"); |
197 | | |
198 | 3.41k | PUT_BITS(ps_bitstrm, ps_sei_cll->u2_max_content_light_level, 16, |
199 | 3.41k | return_status, "u2_max_content_light_level"); |
200 | 3.41k | PUT_BITS(ps_bitstrm, ps_sei_cll->u2_max_pic_average_light_level, 16, |
201 | 3.41k | return_status, "u2_max_pic_average_light_level"); |
202 | | |
203 | 3.41k | return (return_status); |
204 | 3.41k | } |
205 | | |
206 | | /** |
207 | | ****************************************************************************** |
208 | | * |
209 | | * @brief Stores ambient viewing environment info in bitstream |
210 | | * |
211 | | * @par Description |
212 | | * Parse Supplemental Enhancement Information |
213 | | * |
214 | | * @param[in] ps_bitstrm |
215 | | * pointer to bitstream context (handle) |
216 | | * |
217 | | * @param[in] ps_sei_ave |
218 | | * pointer to ambient viewing environment info |
219 | | * |
220 | | * @return success or failure error code |
221 | | * |
222 | | ****************************************************************************** |
223 | | */ |
224 | | IH264E_ERROR_T ih264e_put_sei_ave_params(sei_ave_params_t *ps_sei_ave, |
225 | | bitstrm_t *ps_bitstrm) |
226 | 3.98k | { |
227 | 3.98k | WORD32 return_status = IH264E_SUCCESS; |
228 | 3.98k | UWORD8 u1_payload_size = 0; |
229 | | |
230 | 3.98k | if(ps_sei_ave == NULL) |
231 | 0 | { |
232 | 0 | return IH264E_FAIL; |
233 | 0 | } |
234 | | |
235 | 3.98k | u1_payload_size += 4; /* ambient illuminance */ |
236 | 3.98k | u1_payload_size += 2; /* ambient light x */ |
237 | 3.98k | u1_payload_size += 2; /* ambient light y */ |
238 | | |
239 | | /************************************************************************/ |
240 | | /* PayloadSize : This is the size of the payload in bytes */ |
241 | | /************************************************************************/ |
242 | 3.98k | PUT_BITS(ps_bitstrm, u1_payload_size, 8, return_status, "u1_payload_size"); |
243 | | |
244 | 3.98k | PUT_BITS(ps_bitstrm, ps_sei_ave->u4_ambient_illuminance, 32, |
245 | 3.98k | return_status, "u4_ambient_illuminance"); |
246 | 3.98k | PUT_BITS(ps_bitstrm, ps_sei_ave->u2_ambient_light_x, 16, |
247 | 3.98k | return_status, "u2_ambient_light_x"); |
248 | 3.98k | PUT_BITS(ps_bitstrm, ps_sei_ave->u2_ambient_light_y, 16, |
249 | 3.98k | return_status, "u2_ambient_light_y"); |
250 | | |
251 | 3.98k | return (return_status); |
252 | 3.98k | } |
253 | | |
254 | | /** |
255 | | ****************************************************************************** |
256 | | * |
257 | | * @brief Generates Content Color Volume info (Supplemental Enhancement Information ) |
258 | | * |
259 | | * @par Description |
260 | | * Parse Supplemental Enhancement Information |
261 | | * |
262 | | * @param[in] ps_bitstrm |
263 | | * pointer to bitstream context (handle) |
264 | | * |
265 | | * @param[in] ps_sei_ccv |
266 | | * pointer to structure containing CCV SEI data |
267 | | * |
268 | | * @return success or failure error code |
269 | | * |
270 | | ****************************************************************************** |
271 | | */ |
272 | | IH264E_ERROR_T ih264e_put_sei_ccv_params(sei_ccv_params_t *ps_sei_ccv, |
273 | | bitstrm_t *ps_bitstrm) |
274 | 0 | { |
275 | 0 | WORD32 return_status = IH264E_SUCCESS; |
276 | 0 | UWORD16 u2_payload_bits = 0; |
277 | 0 | UWORD8 u1_payload_bytes = 0; |
278 | 0 | UWORD32 u4_count; |
279 | |
|
280 | 0 | if(ps_sei_ccv == NULL) |
281 | 0 | { |
282 | 0 | return IH264E_FAIL; |
283 | 0 | } |
284 | | |
285 | 0 | u2_payload_bits += 1; /* ccv cancel flag */ |
286 | 0 | if(0 == (UWORD32)ps_sei_ccv->u1_ccv_cancel_flag) |
287 | 0 | { |
288 | 0 | u2_payload_bits += 1; /* ccv persistence flag */ |
289 | 0 | u2_payload_bits += 1; /* ccv primaries present flag */ |
290 | 0 | u2_payload_bits += 1; /* ccv min luminance value present flag */ |
291 | 0 | u2_payload_bits += 1; /* ccv max luminance value present flag */ |
292 | 0 | u2_payload_bits += 1; /* ccv avg luminance value present flag */ |
293 | 0 | u2_payload_bits += 2; /* ccv reserved zero 2bits */ |
294 | 0 | if(1 == ps_sei_ccv->u1_ccv_primaries_present_flag) |
295 | 0 | { |
296 | 0 | u2_payload_bits += (NUM_SEI_CCV_PRIMARIES * 32); /* ccv primaries x[ c ] */ |
297 | 0 | u2_payload_bits += (NUM_SEI_CCV_PRIMARIES * 32); /* ccv primaries y[ c ] */ |
298 | 0 | } |
299 | 0 | if(1 == ps_sei_ccv->u1_ccv_min_luminance_value_present_flag) |
300 | 0 | { |
301 | 0 | u2_payload_bits += 32; /* ccv min luminance value */ |
302 | 0 | } |
303 | 0 | if(1 == ps_sei_ccv->u1_ccv_max_luminance_value_present_flag) |
304 | 0 | { |
305 | 0 | u2_payload_bits += 32; /* ccv max luminance value */ |
306 | 0 | } |
307 | 0 | if(1 == ps_sei_ccv->u1_ccv_avg_luminance_value_present_flag) |
308 | 0 | { |
309 | 0 | u2_payload_bits += 32; /* ccv avg luminance value */ |
310 | 0 | } |
311 | 0 | } |
312 | |
|
313 | 0 | u1_payload_bytes = (UWORD8)((u2_payload_bits + 7) >> 3); |
314 | | /************************************************************************/ |
315 | | /* PayloadSize : This is the size of the payload in bytes */ |
316 | | /************************************************************************/ |
317 | 0 | PUT_BITS(ps_bitstrm, u1_payload_bytes, 8, return_status, "u1_payload_bytes"); |
318 | | |
319 | | /*******************************************************************************/ |
320 | | /* Put the Content Color Volume SEI parameters into the bitstream. */ |
321 | | /*******************************************************************************/ |
322 | |
|
323 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u1_ccv_cancel_flag, 1, |
324 | 0 | return_status, "u1_ccv_cancel_flag"); |
325 | |
|
326 | 0 | if(0 == ps_sei_ccv->u1_ccv_cancel_flag) |
327 | 0 | { |
328 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u1_ccv_persistence_flag, 1, |
329 | 0 | return_status, "u1_ccv_persistence_flag"); |
330 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u1_ccv_primaries_present_flag, 1, |
331 | 0 | return_status, "u1_ccv_primaries_present_flag"); |
332 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u1_ccv_min_luminance_value_present_flag, 1, |
333 | 0 | return_status, "u1_ccv_min_luminance_value_present_flag"); |
334 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u1_ccv_max_luminance_value_present_flag, 1, |
335 | 0 | return_status, "u1_ccv_max_luminance_value_present_flag"); |
336 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u1_ccv_avg_luminance_value_present_flag, 1, |
337 | 0 | return_status, "u1_ccv_avg_luminance_value_present_flag"); |
338 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u1_ccv_reserved_zero_2bits, 2, |
339 | 0 | return_status, "u1_ccv_reserved_zero_2bits"); |
340 | | |
341 | | /* ccv primaries */ |
342 | 0 | if(1 == ps_sei_ccv->u1_ccv_primaries_present_flag) |
343 | 0 | { |
344 | 0 | for(u4_count = 0; u4_count < NUM_SEI_CCV_PRIMARIES; u4_count++) |
345 | 0 | { |
346 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->ai4_ccv_primaries_x[u4_count], 32, |
347 | 0 | return_status, "i4_ccv_primaries_x"); |
348 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->ai4_ccv_primaries_y[u4_count], 32, |
349 | 0 | return_status, "i4_ccv_primaries_y"); |
350 | 0 | } |
351 | 0 | } |
352 | | |
353 | 0 | if(1 == ps_sei_ccv->u1_ccv_min_luminance_value_present_flag) |
354 | 0 | { |
355 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u4_ccv_min_luminance_value, 32, |
356 | 0 | return_status, "u4_ccv_min_luminance_value"); |
357 | 0 | } |
358 | 0 | if(1 == ps_sei_ccv->u1_ccv_max_luminance_value_present_flag) |
359 | 0 | { |
360 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u4_ccv_max_luminance_value, 32, |
361 | 0 | return_status, "u4_ccv_max_luminance_value"); |
362 | 0 | } |
363 | 0 | if(1 == ps_sei_ccv->u1_ccv_avg_luminance_value_present_flag) |
364 | 0 | { |
365 | 0 | PUT_BITS(ps_bitstrm, ps_sei_ccv->u4_ccv_avg_luminance_value, 32, |
366 | 0 | return_status, "u4_ccv_avg_luminance_value"); |
367 | 0 | } |
368 | 0 | } |
369 | | |
370 | 0 | return (return_status); |
371 | 0 | } |
372 | | |
373 | | /** |
374 | | ****************************************************************************** |
375 | | * |
376 | | * @brief Signal shutter interval info in the bitstream |
377 | | * |
378 | | * @par Description |
379 | | * Parse Supplemental Enhancement Information |
380 | | * |
381 | | * @param[in] ps_bitstrm |
382 | | * pointer to bitstream context (handle) |
383 | | * |
384 | | * @param[in] ps_sei_sii |
385 | | * pointer to shutter interval info |
386 | | * |
387 | | * @return success or failure error code |
388 | | * |
389 | | ****************************************************************************** |
390 | | */ |
391 | | IH264E_ERROR_T ih264e_put_sei_sii_params(sei_sii_params_t *ps_sei_sii, bitstrm_t *ps_bitstrm) |
392 | 0 | { |
393 | 0 | WORD32 return_status = IH264E_SUCCESS; |
394 | 0 | UWORD16 u2_payload_bits = 0; |
395 | 0 | UWORD8 u1_payload_bytes = 0; |
396 | |
|
397 | 0 | if(ps_sei_sii == NULL) |
398 | 0 | { |
399 | 0 | return IH264E_FAIL; |
400 | 0 | } |
401 | | |
402 | 0 | if(0 == ps_sei_sii->u4_sii_sub_layer_idx) |
403 | 0 | { |
404 | 0 | u2_payload_bits += 1; /* shutter interval info present flag */ |
405 | |
|
406 | 0 | if(1 == ps_sei_sii->u1_shutter_interval_info_present_flag) |
407 | 0 | { |
408 | 0 | u2_payload_bits += 32; /* sii time scale */ |
409 | 0 | u2_payload_bits += 1; /* fixed shutter interval within cvs flag */ |
410 | |
|
411 | 0 | if(1 == ps_sei_sii->u1_fixed_shutter_interval_within_cvs_flag) |
412 | 0 | { |
413 | 0 | u2_payload_bits += 32; /* sii num units in shutter interval */ |
414 | 0 | } |
415 | 0 | else |
416 | 0 | { |
417 | 0 | int sizeofSubLayer; |
418 | 0 | u2_payload_bits += 3; /* sii max sub layers minus1 */ |
419 | 0 | sizeofSubLayer = |
420 | 0 | sizeof(ps_sei_sii->au4_sub_layer_num_units_in_shutter_interval) / |
421 | 0 | sizeof(ps_sei_sii->au4_sub_layer_num_units_in_shutter_interval[0]); |
422 | 0 | u2_payload_bits += |
423 | 0 | 32 * sizeofSubLayer; /* sii sub layer num units in shutter interval */ |
424 | 0 | } |
425 | 0 | } |
426 | 0 | } |
427 | |
|
428 | 0 | u1_payload_bytes = (UWORD8) ((u2_payload_bits + 7) >> 3); |
429 | | /************************************************************************/ |
430 | | /* PayloadSize : This is the size of the payload in bytes */ |
431 | | /************************************************************************/ |
432 | 0 | PUT_BITS(ps_bitstrm, u1_payload_bytes, 8, return_status, "u1_payload_bytes"); |
433 | | |
434 | | /*******************************************************************************/ |
435 | | /* Put the Shutter Interval Info SEI parameters into the bitstream. */ |
436 | | /*******************************************************************************/ |
437 | |
|
438 | 0 | PUT_BITS_UEV(ps_bitstrm, ps_sei_sii->u4_sii_sub_layer_idx, return_status, |
439 | 0 | "u4_sii_sub_layer_idx"); |
440 | |
|
441 | 0 | if(0 == ps_sei_sii->u4_sii_sub_layer_idx) |
442 | 0 | { |
443 | 0 | PUT_BITS(ps_bitstrm, ps_sei_sii->u1_shutter_interval_info_present_flag, 1, return_status, |
444 | 0 | "u1_shutter_interval_info_present_flag"); |
445 | |
|
446 | 0 | if(1 == ps_sei_sii->u1_shutter_interval_info_present_flag) |
447 | 0 | { |
448 | 0 | PUT_BITS(ps_bitstrm, ps_sei_sii->u4_sii_time_scale, 32, return_status, |
449 | 0 | "u4_sii_time_scale"); |
450 | 0 | PUT_BITS(ps_bitstrm, ps_sei_sii->u1_fixed_shutter_interval_within_cvs_flag, 1, |
451 | 0 | return_status, "u1_fixed_shutter_interval_within_cvs_flag"); |
452 | |
|
453 | 0 | if(1 == ps_sei_sii->u1_fixed_shutter_interval_within_cvs_flag) |
454 | 0 | { |
455 | 0 | PUT_BITS(ps_bitstrm, ps_sei_sii->u4_sii_num_units_in_shutter_interval, 32, |
456 | 0 | return_status, "u4_sii_num_units_in_shutter_interval"); |
457 | 0 | } |
458 | 0 | else |
459 | 0 | { |
460 | 0 | int i; |
461 | 0 | PUT_BITS(ps_bitstrm, ps_sei_sii->u1_sii_max_sub_layers_minus1, 3, return_status, |
462 | 0 | "u1_sii_max_sub_layers_minus1"); |
463 | |
|
464 | 0 | for(i = 0; i <= ps_sei_sii->u1_sii_max_sub_layers_minus1; i++) |
465 | 0 | { |
466 | 0 | PUT_BITS(ps_bitstrm, ps_sei_sii->au4_sub_layer_num_units_in_shutter_interval[i], |
467 | 0 | 32, return_status, "au4_sub_layer_num_units_in_shutter_interval[i]"); |
468 | 0 | } |
469 | 0 | } |
470 | 0 | } |
471 | 0 | } |
472 | 0 | return (return_status); |
473 | 0 | } |
474 | | |
475 | | /** |
476 | | ****************************************************************************** |
477 | | * |
478 | | * @brief Generates SEI (Supplemental Enhancement Information ) |
479 | | * |
480 | | * @par Description |
481 | | * Parse Supplemental Enhancement Information |
482 | | * |
483 | | * @param[in] e_payload_type |
484 | | * Determines the type of SEI msg |
485 | | * |
486 | | * @param[in] ps_bitstrm |
487 | | * pointer to bitstream context (handle) |
488 | | * |
489 | | * @param[in] ps_sei_params |
490 | | * pointer to structure containing SEI data |
491 | | * buffer period, recovery point, picture timing |
492 | | * |
493 | | * @return success or failure error code |
494 | | * |
495 | | ****************************************************************************** |
496 | | */ |
497 | | IH264E_ERROR_T ih264e_put_sei_msg(IH264_SEI_TYPE e_payload_type, |
498 | | sei_params_t *ps_sei_params, |
499 | | bitstrm_t *ps_bitstrm) |
500 | 11.2k | { |
501 | 11.2k | WORD32 return_status = IH264E_SUCCESS; |
502 | | |
503 | | /************************************************************************/ |
504 | | /* PayloadType : Send in the SEI type in the stream */ |
505 | | /************************************************************************/ |
506 | | |
507 | 11.2k | UWORD32 u4_payload_type = e_payload_type; |
508 | | |
509 | 11.2k | while(u4_payload_type > 0xFF) |
510 | 0 | { |
511 | 0 | PUT_BITS(ps_bitstrm, 0xFF, 8, return_status, "payload"); |
512 | 0 | u4_payload_type -= 0xFF; |
513 | 0 | } |
514 | | |
515 | 11.2k | PUT_BITS(ps_bitstrm, (UWORD32)u4_payload_type, 8, return_status, "e_payload_type"); |
516 | | |
517 | 11.2k | switch(e_payload_type) |
518 | 11.2k | { |
519 | 3.81k | case IH264_SEI_MASTERING_DISP_COL_VOL : |
520 | 3.81k | return_status = ih264e_put_sei_mdcv_params(&(ps_sei_params->s_sei_mdcv_params), |
521 | 3.81k | ps_bitstrm); |
522 | 3.81k | break; |
523 | | |
524 | 3.41k | case IH264_SEI_CONTENT_LIGHT_LEVEL_DATA : |
525 | 3.41k | return_status = ih264e_put_sei_cll_params(&(ps_sei_params->s_sei_cll_params), |
526 | 3.41k | ps_bitstrm); |
527 | 3.41k | break; |
528 | | |
529 | 3.98k | case IH264_SEI_AMBIENT_VIEWING_ENVIRONMENT : |
530 | 3.98k | return_status = ih264e_put_sei_ave_params(&(ps_sei_params->s_sei_ave_params), |
531 | 3.98k | ps_bitstrm); |
532 | 3.98k | break; |
533 | | |
534 | 0 | case IH264_SEI_CONTENT_COLOR_VOLUME : |
535 | 0 | return_status = ih264e_put_sei_ccv_params(&(ps_sei_params->s_sei_ccv_params), |
536 | 0 | ps_bitstrm); |
537 | 0 | break; |
538 | | |
539 | 0 | case IH264_SEI_SHUTTER_INTERVAL_INFO: |
540 | 0 | return_status = ih264e_put_sei_sii_params(&(ps_sei_params->s_sei_sii_params), ps_bitstrm); |
541 | |
|
542 | 0 | break; |
543 | | |
544 | 0 | default : |
545 | 0 | return_status = IH264E_FAIL; |
546 | 11.2k | } |
547 | | |
548 | | /* rbsp trailing bits */ |
549 | 11.2k | if((IH264E_SUCCESS == return_status) && (ps_bitstrm->i4_bits_left_in_cw & 0x7)) |
550 | 0 | return_status = ih264e_put_rbsp_trailing_bits(ps_bitstrm); |
551 | | |
552 | 11.2k | return(return_status); |
553 | 11.2k | } |
554 | | |
555 | | |