1 /****************************************************************************** 2 * 3 * Copyright (C) 2018 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 * 24 * @file ihevce_encode_header_sei_vui.h 25 * 26 * @brief 27 * This file contains structures and interface prototypes for header vui/sei 28 * encoding 29 * 30 * @author 31 * ittiam 32 * 33 ****************************************************************************** 34 */ 35 36 #ifndef _IHEVCE_ENCODE_HEADER_SEI_VUI_H_ 37 #define _IHEVCE_ENCODE_HEADER_SEI_VUI_H_ 38 39 /*****************************************************************************/ 40 /* Function Macros */ 41 /*****************************************************************************/ 42 43 #ifndef DISABLE_SEI 44 /** 45 ****************************************************************************** 46 * @brief Macro to calculate the CRC for a bit index 47 ****************************************************************************** 48 */ 49 #define CALC_CRC_BIT_LEVEL(u4_crc_val, u1_cur_val, bit_idx) \ 50 { \ 51 UWORD32 u4_bit_val, u4_crc_msb; \ 52 u4_crc_msb = (u4_crc_val >> 15) & 1; \ 53 u4_bit_val = (u1_cur_val >> (7 - bit_idx)) & 1; \ 54 u4_crc_val = (((u4_crc_val << 1) + u4_bit_val) & 0xffff) ^ (u4_crc_msb * 0x1021); \ 55 } 56 57 /*****************************************************************************/ 58 /* Enums */ 59 /*****************************************************************************/ 60 typedef enum 61 { 62 /* SEI PREFIX */ 63 IHEVCE_SEI_BUF_PERIOD_T = 0, 64 IHEVCE_SEI_PIC_TIMING_T, 65 IHEVCE_SEI_PAN_SCAN_RECT_T, 66 IHEVCE_SEI_FILLER_PAYLOAD_T, 67 IHEVCE_SEI_USER_DATA_REGISTERED_ITU_T_T35_T, 68 IHEVCE_SEI_USER_DATA_UNREGISTERED_T, 69 IHEVCE_SEI_RECOVERY_POINT_T = 6, 70 IHEVCE_SEI_SCENE_INFO_T = 9, 71 IHEVCE_SEI_FULL_FRAME_SNAPSHOT_T = 15, 72 IHEVCE_SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START_T = 16, 73 IHEVCE_SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END_T = 17, 74 IHEVCE_SEI_FILM_GRAIN_CHARACTERISTICS_T = 19, 75 IHEVCE_SEI_POST_FILTER_HINT_T = 22, 76 IHEVCE_SEI_TONE_MAPPING_INFO_T = 23, 77 IHEVCE_SEI_FRAME_PACKING_ARRANGEMENT_T = 45, 78 IHEVCE_SEI_DISPLAY_ORIENTATION_T = 47, 79 IHEVCE_SEI_SOP_DESCRIPTION_T = 128, 80 IHEVCE_SEI_ACTIVE_PARAMETER_SETS_T = 129, 81 IHEVCE_SEI_DECODING_UNIT_INFO_T = 130, 82 IHEVCE_SEI_TL0_INDEX_T = 131, 83 IHEVCE_SEI_DECODED_PICTURE_HASH_T = 132, /* SEI SUFFIX */ 84 IHEVCE_SEI_SCALABLE_NESTING_T = 133, 85 IHEVCE_SEI_REGION_REFRESH_INFO_T = 134, 86 IHEVCE_SEI_MASTERING_DISP_COL_VOL_T = 137, 87 IHEVCE_SEI_CONTENT_LIGHT_LEVEL_DATA_T = 144, 88 89 /* SIE SUFFIX/PREFIX REST OF THE SEI */ 90 IHEVCE_SEI_RESERVED_SEI_MESSAGE_T 91 } IHEVCE_SEI_TYPE; 92 93 /*****************************************************************************/ 94 /* Extern Function Declarations */ 95 /*****************************************************************************/ 96 97 WORD32 ihevce_put_buf_period_sei_params( 98 buf_period_sei_params_t *ps_bp_sei, vui_t *ps_vui_params, bitstrm_t *ps_bitstrm); 99 100 WORD32 ihevce_put_active_parameter_set_sei_params( 101 active_parameter_set_sei_param_t *ps_act_sei, bitstrm_t *ps_bitstrm); 102 103 WORD32 ihevce_put_recovery_point_sei_params( 104 recovery_point_sei_params_t *ps_rp_sei, bitstrm_t *ps_bitstrm); 105 106 WORD32 ihevce_put_pic_timing_sei_params( 107 pic_timing_sei_params_t *ps_pt_sei, vui_t *ps_vui_params, bitstrm_t *ps_bitstrm); 108 109 WORD32 ihevce_put_sei_msg( 110 IHEVCE_SEI_TYPE e_payload_type, 111 sei_params_t *ps_sei_params, 112 vui_t *ps_vui_params, 113 bitstrm_t *ps_bitstrm, 114 UWORD32 i4_registered_user_data_length, 115 UWORD8 *pu1_user_data_registered); 116 117 WORD32 ihevce_generate_sei( 118 bitstrm_t *ps_bitstrm, 119 sei_params_t *ps_sei_params, 120 vui_t *ps_vui_params, 121 WORD32 insert_per_cra, 122 WORD32 nal_unit_header, 123 UWORD32 u4_num_sei_payloads, 124 sei_payload_t *ps_sei_payload); 125 126 WORD32 ihevce_populate_recovery_point_sei( 127 sei_params_t *ps_sei, ihevce_vui_sei_params_t *ps_vui_sei_prms); 128 129 WORD32 ihevce_populate_mastering_disp_col_vol_sei( 130 sei_params_t *ps_sei, ihevce_out_strm_params_t *ps_out_strm_prms); 131 132 WORD32 ihevce_populate_picture_timing_sei( 133 sei_params_t *ps_sei, 134 vui_t *ps_vui, 135 ihevce_src_params_t *ps_src_params, 136 WORD32 u4_bottom_field_flag); 137 138 WORD32 ihevce_populate_buffering_period_sei( 139 sei_params_t *ps_sei, vui_t *ps_vui, sps_t *ps_sps, ihevce_vui_sei_params_t *ps_vui_sei_prms); 140 141 WORD32 ihevce_populate_active_parameter_set_sei(sei_params_t *ps_sei, vps_t *ps_vps, sps_t *ps_sps); 142 143 WORD32 ihevce_populate_hash_sei( 144 sei_params_t *ps_sei, 145 WORD32 bit_depth, 146 void *pv_y_buf, 147 WORD32 y_wd, 148 WORD32 y_ht, 149 WORD32 y_strd, 150 void *pv_u_buf, 151 WORD32 uv_wd, 152 WORD32 uv_ht, 153 WORD32 uv_strd, 154 WORD32 i4_frame_pos_x, 155 WORD32 i4_frame_pos_y); 156 #endif 157 158 WORD32 ihevce_generate_sub_layer_hrd_params( 159 bitstrm_t *ps_bitstrm, 160 sub_lyr_hrd_params_t *ps_sub_lyr_hrd_params, 161 hrd_params_t *ps_hrd_params, 162 WORD32 cpb_cnt_minus1); 163 164 WORD32 165 ihevce_generate_hrd_params(bitstrm_t *ps_bitstrm, hrd_params_t *ps_hrd_params, sps_t *ps_sps); 166 167 WORD32 ihevce_generate_vui(bitstrm_t *ps_bitstrm, sps_t *ps_sps, vui_t s_vui); 168 169 WORD32 ihevce_populate_vui( 170 vui_t *ps_vui, 171 sps_t *ps_sps, 172 ihevce_src_params_t *ps_src_params, 173 ihevce_vui_sei_params_t *ps_vui_sei_prms, 174 WORD32 i4_resolution_id, 175 ihevce_tgt_params_t *ps_tgt_params, 176 ihevce_static_cfg_params_t *ps_stat_prms, 177 WORD32 i4_bitrate_instance_id); 178 179 #endif // _IHEVCE_ENCODE_HEADER_SEI_VUI_H_ 180