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_FILM_GRAIN_CHARACTERISTICS 19 68 #define SEI_MASTERING_DISP_COL_VOL 137 69 #define SEI_CONTENT_LIGHT_LEVEL_DATA 144 70 #define SEI_AMBIENT_VIEWING_ENVIRONMENT 148 71 #define SEI_CONTENT_COLOR_VOLUME 149 72 #define SEI_SHUTTER_INTERVAL_INFO 205 73 74 /* Declaration of dec_struct_t to avoid CCS compilation Error */ 75 struct _DecStruct; 76 WORD32 ih264d_parse_sei_message(struct _DecStruct *ps_dec, 77 dec_bit_stream_t *ps_bitstrm); 78 typedef struct 79 { 80 UWORD8 u1_seq_parameter_set_id; 81 UWORD32 u4_initial_cpb_removal_delay; 82 UWORD32 u4_nitial_cpb_removal_delay_offset; 83 84 } buf_period_t; 85 86 /** 87 * Structure to hold Mastering Display Color Volume SEI 88 */ 89 typedef struct 90 { 91 /** 92 * Array to store the display_primaries_x values 93 */ 94 UWORD16 au2_display_primaries_x[NUM_SEI_MDCV_PRIMARIES]; 95 96 /** 97 * Array to store the display_primaries_y values 98 */ 99 UWORD16 au2_display_primaries_y[NUM_SEI_MDCV_PRIMARIES]; 100 101 /** 102 * Variable to store the white point x value 103 */ 104 UWORD16 u2_white_point_x; 105 106 /** 107 * Variable to store the white point y value 108 */ 109 UWORD16 u2_white_point_y; 110 111 /** 112 * Variable to store the max display mastering luminance value 113 */ 114 UWORD32 u4_max_display_mastering_luminance; 115 116 /** 117 * Variable to store the min display mastering luminance value 118 */ 119 UWORD32 u4_min_display_mastering_luminance; 120 121 }sei_mdcv_params_t; 122 123 124 /** 125 * Structure for Content Light Level Info 126 * 127 */ 128 typedef struct 129 { 130 /** 131 * The maximum pixel intensity of all samples 132 */ 133 UWORD16 u2_max_content_light_level; 134 135 /** 136 * The average pixel intensity of all samples 137 */ 138 UWORD16 u2_max_pic_average_light_level; 139 140 }sei_cll_params_t; 141 142 143 /** 144 * Structure to hold Ambient viewing environment SEI 145 */ 146 typedef struct 147 { 148 149 /** 150 * specifies the environmental illuminance of the ambient viewing environment 151 */ 152 UWORD32 u4_ambient_illuminance; 153 154 /* 155 * specify the normalized x chromaticity coordinates of the 156 * environmental ambient light in the nominal viewing environment 157 */ 158 UWORD16 u2_ambient_light_x; 159 160 /* 161 * specify the normalized y chromaticity coordinates of the 162 * environmental ambient light in the nominal viewing environment 163 */ 164 UWORD16 u2_ambient_light_y; 165 166 }sei_ave_params_t; 167 168 169 /** 170 * Structure to hold Content color volume SEI 171 */ 172 typedef struct 173 { 174 /* 175 * Flag used to control persistence of CCV SEI messages 176 */ 177 UWORD8 u1_ccv_cancel_flag; 178 179 /* 180 * specifies the persistence of the CCV SEI message for the current layer 181 */ 182 UWORD8 u1_ccv_persistence_flag; 183 184 /* 185 * specifies the presence of syntax elements ccv_primaries_x and ccv_primaries_y 186 */ 187 UWORD8 u1_ccv_primaries_present_flag; 188 189 /* 190 * specifies that the syntax element ccv_min_luminance_value is present 191 */ 192 UWORD8 u1_ccv_min_luminance_value_present_flag; 193 194 /* 195 * specifies that the syntax element ccv_max_luminance_value is present 196 */ 197 UWORD8 u1_ccv_max_luminance_value_present_flag; 198 199 /* 200 * specifies that the syntax element ccv_avg_luminance_value is present 201 */ 202 UWORD8 u1_ccv_avg_luminance_value_present_flag; 203 204 /* 205 * shall be equal to 0 in bitstreams conforming to this version. Other values 206 * for reserved_zero_2bits are reserved for future use 207 */ 208 UWORD8 u1_ccv_reserved_zero_2bits; 209 210 /* 211 * specify the normalized x chromaticity coordinates of the colour 212 * primary component c of the nominal content colour volume 213 */ 214 WORD32 ai4_ccv_primaries_x[NUM_SEI_CCV_PRIMARIES]; 215 216 /* 217 * specify the normalized y chromaticity coordinates of the colour 218 * primary component c of the nominal content colour volume 219 */ 220 WORD32 ai4_ccv_primaries_y[NUM_SEI_CCV_PRIMARIES]; 221 222 /* 223 * specifies the normalized minimum luminance value 224 */ 225 UWORD32 u4_ccv_min_luminance_value; 226 227 /* 228 * specifies the normalized maximum luminance value 229 */ 230 UWORD32 u4_ccv_max_luminance_value; 231 232 /* 233 * specifies the normalized average luminance value 234 */ 235 UWORD32 u4_ccv_avg_luminance_value; 236 237 }sei_ccv_params_t; 238 239 /** 240 * Structure to hold Shutter Interval Info SEI 241 */ 242 typedef struct 243 { 244 /** 245 * specifies if the sei sii is enabled 246 */ 247 UWORD8 u1_shutter_interval_info_present_flag; 248 249 /** 250 * specifies the shutter interval temporal sub-layer index 251 * of the current picture 252 */ 253 UWORD32 u4_sii_sub_layer_idx; 254 255 /** 256 * specify the number of time units that pass in one second 257 */ 258 UWORD32 u4_sii_time_scale; 259 260 /** 261 * specifies that the indicated shutter interval is the same for all 262 * pictures in the coded video sequence 263 */ 264 UWORD8 u1_fixed_shutter_interval_within_cvs_flag; 265 266 /** 267 * specifies the the number of time units of a clock operating at the 268 * frequency sii_time_scale Hz that corresponds to the indicated shutter 269 * interval of each picture in the coded video sequence 270 */ 271 UWORD32 u4_sii_num_units_in_shutter_interval; 272 273 /** 274 * sii_max_sub_layers_minus1 plus 1 specifies the maximum number of 275 * shutter interval temporal sub-layers indexes that may be present 276 * in the coded video sequence 277 */ 278 UWORD8 u1_sii_max_sub_layers_minus1; 279 280 /** 281 * specifies the number of time units of a clock operating at the 282 * frequency sii_time_scale Hz that corresponds to the shutter 283 * interval of each picture in the coded video sequence 284 */ 285 UWORD32 au4_sub_layer_num_units_in_shutter_interval[SII_MAX_SUB_LAYERS]; 286 287 } sei_sii_params_t; 288 289 typedef struct 290 { 291 /** 292 * Flag to control the presence of FGC SEI params 293 */ 294 UWORD8 u1_film_grain_characteristics_cancel_flag; 295 296 /** 297 * Specifies the pic order count 298 */ 299 WORD32 i4_poc; 300 301 /** 302 * Specifies IDR pic ID 303 */ 304 UWORD32 u4_idr_pic_id; 305 306 /** 307 * Specifies film grain model for simulation 308 */ 309 UWORD8 u1_film_grain_model_id; 310 311 /** 312 * Specifies separate color format for decoded samples and grain 313 */ 314 UWORD8 u1_separate_colour_description_present_flag; 315 316 /** 317 * Specifies the bit depth used for the luma component 318 */ 319 UWORD8 u1_film_grain_bit_depth_luma_minus8; 320 321 /** 322 * Specifies the bit depth used for the Cb and Cr components 323 */ 324 UWORD8 u1_film_grain_bit_depth_chroma_minus8; 325 326 /** 327 * Specifies the colour space of the FGC in SEI 328 */ 329 UWORD8 u1_film_grain_full_range_flag; 330 331 /** 332 * Specifies the colour space of the FGC in SEI 333 */ 334 UWORD8 u1_film_grain_colour_primaries; 335 336 /** 337 * Specifies the colour space of the FGC in SEI 338 */ 339 UWORD8 u1_film_grain_transfer_characteristics; 340 341 /** 342 * Specifies the colour space of the FGC in SEI 343 */ 344 UWORD8 u1_film_grain_matrix_coefficients; 345 346 /** 347 * identifies the blending mode used to blend the simulated film grain with the decoded images 348 */ 349 UWORD8 u1_blending_mode_id; 350 351 /** 352 * Specifies a scale factor used in the film grain characterization equations 353 */ 354 UWORD8 u1_log2_scale_factor; 355 356 /** 357 * Indicates whether film grain is modelled or not on the colour component 358 */ 359 UWORD8 au1_comp_model_present_flag[SEI_FGC_NUM_COLOUR_COMPONENTS]; 360 361 /** 362 * Specifies the number of intensity intervals for which 363 * a specific set of model values has been estimated 364 */ 365 UWORD8 au1_num_intensity_intervals_minus1[SEI_FGC_NUM_COLOUR_COMPONENTS]; 366 367 /** 368 * Specifies the number of model values present for each intensity interval in which 369 * the film grain has been modelled 370 */ 371 UWORD8 au1_num_model_values_minus1[SEI_FGC_NUM_COLOUR_COMPONENTS]; 372 373 /** 374 * Specifies the lower bound of the interval of intensity levels for which 375 * the set of model values applies 376 */ 377 UWORD8 au1_intensity_interval_lower_bound[SEI_FGC_NUM_COLOUR_COMPONENTS] 378 [SEI_FGC_MAX_NUM_INTENSITY_INTERVALS]; 379 380 /** 381 * Specifies the upper bound of the interval of intensity levels for which 382 * the set of model values applies 383 */ 384 UWORD8 au1_intensity_interval_upper_bound[SEI_FGC_NUM_COLOUR_COMPONENTS] 385 [SEI_FGC_MAX_NUM_INTENSITY_INTERVALS]; 386 387 /** 388 * Represents each one of the model values present for 389 * the colour component and intensity interval 390 */ 391 WORD32 ai4_comp_model_value[SEI_FGC_NUM_COLOUR_COMPONENTS][SEI_FGC_MAX_NUM_INTENSITY_INTERVALS] 392 [SEI_FGC_MAX_NUM_MODEL_VALUES]; 393 394 /** 395 * Specifies the persistence of the film grain characteristics SEI message 396 */ 397 UWORD32 u4_film_grain_characteristics_repetition_period; 398 399 } sei_fgc_params_t; 400 401 struct _sei 402 { 403 UWORD8 u1_seq_param_set_id; 404 buf_period_t s_buf_period; 405 UWORD8 u1_pic_struct; 406 UWORD16 u2_recovery_frame_cnt; 407 UWORD8 u1_exact_match_flag; 408 UWORD8 u1_broken_link_flag; 409 UWORD8 u1_changing_slice_grp_idc; 410 UWORD8 u1_is_valid; 411 412 /** 413 * mastering display color volume info present flag 414 */ 415 UWORD8 u1_sei_mdcv_params_present_flag; 416 417 /* 418 * MDCV parameters 419 */ 420 sei_mdcv_params_t s_sei_mdcv_params; 421 422 /** 423 * content light level info present flag 424 */ 425 UWORD8 u1_sei_cll_params_present_flag; 426 427 /* 428 * CLL parameters 429 */ 430 sei_cll_params_t s_sei_cll_params; 431 432 /** 433 * ambient viewing environment info present flag 434 */ 435 UWORD8 u1_sei_ave_params_present_flag; 436 437 /* 438 * AVE parameters 439 */ 440 sei_ave_params_t s_sei_ave_params; 441 442 /** 443 * content color volume info present flag 444 */ 445 UWORD8 u1_sei_ccv_params_present_flag; 446 447 /* 448 * CCV parameters 449 */ 450 sei_ccv_params_t s_sei_ccv_params; 451 452 /** 453 * shutter interval info present flag 454 */ 455 UWORD8 u1_sei_sii_params_present_flag; 456 457 /* 458 * SII parameters 459 */ 460 sei_sii_params_t s_sei_sii_params; 461 462 /** 463 * film grain params info present flag 464 */ 465 UWORD8 u1_sei_fgc_params_present_flag; 466 467 /* 468 * film grain characteristics parameters 469 */ 470 sei_fgc_params_t s_sei_fgc_params; 471 }; 472 typedef struct _sei sei; 473 474 WORD32 ih264d_export_sei_mdcv_params(ivd_sei_decode_op_t *ps_sei_decode_op, 475 sei *ps_sei, sei *ps_sei_export); 476 477 WORD32 ih264d_export_sei_cll_params(ivd_sei_decode_op_t *ps_sei_decode_op, 478 sei *ps_sei, sei *ps_sei_export); 479 480 WORD32 ih264d_export_sei_ave_params(ivd_sei_decode_op_t *ps_sei_decode_op, 481 sei *ps_sei, sei *ps_sei_export); 482 483 WORD32 ih264d_export_sei_ccv_params(ivd_sei_decode_op_t *ps_sei_decode_op, 484 sei *ps_sei, sei *ps_sei_export); 485 486 WORD32 ih264d_export_sei_sii_params(ivd_sei_decode_op_t *ps_sei_decode_op, sei *ps_sei, 487 sei *ps_sei_export); 488 489 WORD32 ih264d_export_sei_fgc_params(ivd_sei_decode_op_t *ps_sei_decode_op, sei *ps_sei, 490 sei *ps_sei_export); 491 492 #endif /* _IH264D_SEI_H_ */ 493 494