aarch64: Add assembly support for -fsanitize=hwaddress tagged globals.
[libav.git] / libavcodec / hevc_ps.h
blob6e2b5277736666d85da9ef5a58a4881dbd16ad76
1 /*
2 * HEVC parameter set parsing
4 * This file is part of Libav.
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVCODEC_HEVC_PS_H
22 #define AVCODEC_HEVC_PS_H
24 #include <stdint.h>
26 #include "libavutil/buffer.h"
27 #include "libavutil/pixfmt.h"
28 #include "libavutil/rational.h"
30 #include "avcodec.h"
31 #include "get_bits.h"
32 #include "hevc.h"
34 typedef struct ShortTermRPS {
35 unsigned int num_negative_pics;
36 int num_delta_pocs;
37 int rps_idx_num_delta_pocs;
38 int32_t delta_poc[32];
39 uint8_t used[32];
40 } ShortTermRPS;
42 typedef struct HEVCWindow {
43 unsigned int left_offset;
44 unsigned int right_offset;
45 unsigned int top_offset;
46 unsigned int bottom_offset;
47 } HEVCWindow;
49 typedef struct VUI {
50 AVRational sar;
52 int overscan_info_present_flag;
53 int overscan_appropriate_flag;
55 int video_signal_type_present_flag;
56 int video_format;
57 int video_full_range_flag;
58 int colour_description_present_flag;
59 uint8_t colour_primaries;
60 uint8_t transfer_characteristic;
61 uint8_t matrix_coeffs;
63 int chroma_loc_info_present_flag;
64 int chroma_sample_loc_type_top_field;
65 int chroma_sample_loc_type_bottom_field;
66 int neutra_chroma_indication_flag;
68 int field_seq_flag;
69 int frame_field_info_present_flag;
71 int default_display_window_flag;
72 HEVCWindow def_disp_win;
74 int vui_timing_info_present_flag;
75 uint32_t vui_num_units_in_tick;
76 uint32_t vui_time_scale;
77 int vui_poc_proportional_to_timing_flag;
78 int vui_num_ticks_poc_diff_one_minus1;
79 int vui_hrd_parameters_present_flag;
81 int bitstream_restriction_flag;
82 int tiles_fixed_structure_flag;
83 int motion_vectors_over_pic_boundaries_flag;
84 int restricted_ref_pic_lists_flag;
85 int min_spatial_segmentation_idc;
86 int max_bytes_per_pic_denom;
87 int max_bits_per_min_cu_denom;
88 int log2_max_mv_length_horizontal;
89 int log2_max_mv_length_vertical;
90 } VUI;
92 typedef struct PTLCommon {
93 uint8_t profile_space;
94 uint8_t tier_flag;
95 uint8_t profile_idc;
96 uint8_t profile_compatibility_flag[32];
97 uint8_t level_idc;
98 uint8_t progressive_source_flag;
99 uint8_t interlaced_source_flag;
100 uint8_t non_packed_constraint_flag;
101 uint8_t frame_only_constraint_flag;
102 } PTLCommon;
104 typedef struct PTL {
105 PTLCommon general_ptl;
106 PTLCommon sub_layer_ptl[HEVC_MAX_SUB_LAYERS];
108 uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
109 uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
110 } PTL;
112 typedef struct HEVCVPS {
113 uint8_t vps_temporal_id_nesting_flag;
114 int vps_max_layers;
115 int vps_max_sub_layers; ///< vps_max_temporal_layers_minus1 + 1
117 PTL ptl;
118 int vps_sub_layer_ordering_info_present_flag;
119 unsigned int vps_max_dec_pic_buffering[HEVC_MAX_SUB_LAYERS];
120 unsigned int vps_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
121 unsigned int vps_max_latency_increase[HEVC_MAX_SUB_LAYERS];
122 int vps_max_layer_id;
123 int vps_num_layer_sets; ///< vps_num_layer_sets_minus1 + 1
124 uint8_t vps_timing_info_present_flag;
125 uint32_t vps_num_units_in_tick;
126 uint32_t vps_time_scale;
127 uint8_t vps_poc_proportional_to_timing_flag;
128 int vps_num_ticks_poc_diff_one; ///< vps_num_ticks_poc_diff_one_minus1 + 1
129 int vps_num_hrd_parameters;
130 } HEVCVPS;
132 typedef struct ScalingList {
133 /* This is a little wasteful, since sizeID 0 only needs 8 coeffs,
134 * and size ID 3 only has 2 arrays, not 6. */
135 uint8_t sl[4][6][64];
136 uint8_t sl_dc[2][6];
137 } ScalingList;
139 typedef struct HEVCSPS {
140 int vps_id;
141 int chroma_format_idc;
142 uint8_t separate_colour_plane_flag;
144 HEVCWindow output_window;
146 HEVCWindow pic_conf_win;
148 int bit_depth;
149 int pixel_shift;
150 enum AVPixelFormat pix_fmt;
152 unsigned int log2_max_poc_lsb;
153 int pcm_enabled_flag;
155 int max_sub_layers;
156 struct {
157 int max_dec_pic_buffering;
158 int num_reorder_pics;
159 int max_latency_increase;
160 } temporal_layer[HEVC_MAX_SUB_LAYERS];
162 VUI vui;
163 PTL ptl;
165 uint8_t scaling_list_enable_flag;
166 ScalingList scaling_list;
168 unsigned int nb_st_rps;
169 ShortTermRPS st_rps[HEVC_MAX_SHORT_TERM_REF_PIC_SETS];
171 uint8_t amp_enabled_flag;
172 uint8_t sao_enabled;
174 uint8_t long_term_ref_pics_present_flag;
175 uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS];
176 uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS];
177 uint8_t num_long_term_ref_pics_sps;
179 struct {
180 uint8_t bit_depth;
181 uint8_t bit_depth_chroma;
182 unsigned int log2_min_pcm_cb_size;
183 unsigned int log2_max_pcm_cb_size;
184 uint8_t loop_filter_disable_flag;
185 } pcm;
186 uint8_t sps_temporal_mvp_enabled_flag;
187 uint8_t sps_strong_intra_smoothing_enable_flag;
189 unsigned int log2_min_cb_size;
190 unsigned int log2_diff_max_min_coding_block_size;
191 unsigned int log2_min_tb_size;
192 unsigned int log2_max_trafo_size;
193 unsigned int log2_ctb_size;
194 unsigned int log2_min_pu_size;
196 int max_transform_hierarchy_depth_inter;
197 int max_transform_hierarchy_depth_intra;
199 ///< coded frame dimension in various units
200 int width;
201 int height;
202 int ctb_width;
203 int ctb_height;
204 int ctb_size;
205 int min_cb_width;
206 int min_cb_height;
207 int min_tb_width;
208 int min_tb_height;
209 int min_pu_width;
210 int min_pu_height;
212 int hshift[3];
213 int vshift[3];
215 int qp_bd_offset;
216 } HEVCSPS;
218 typedef struct HEVCPPS {
219 unsigned int sps_id; ///< seq_parameter_set_id
221 uint8_t sign_data_hiding_flag;
223 uint8_t cabac_init_present_flag;
225 int num_ref_idx_l0_default_active; ///< num_ref_idx_l0_default_active_minus1 + 1
226 int num_ref_idx_l1_default_active; ///< num_ref_idx_l1_default_active_minus1 + 1
227 int pic_init_qp_minus26;
229 uint8_t constrained_intra_pred_flag;
230 uint8_t transform_skip_enabled_flag;
232 uint8_t cu_qp_delta_enabled_flag;
233 int diff_cu_qp_delta_depth;
235 int cb_qp_offset;
236 int cr_qp_offset;
237 uint8_t pic_slice_level_chroma_qp_offsets_present_flag;
238 uint8_t weighted_pred_flag;
239 uint8_t weighted_bipred_flag;
240 uint8_t output_flag_present_flag;
241 uint8_t transquant_bypass_enable_flag;
243 uint8_t dependent_slice_segments_enabled_flag;
244 uint8_t tiles_enabled_flag;
245 uint8_t entropy_coding_sync_enabled_flag;
247 int num_tile_columns; ///< num_tile_columns_minus1 + 1
248 int num_tile_rows; ///< num_tile_rows_minus1 + 1
249 uint8_t uniform_spacing_flag;
250 uint8_t loop_filter_across_tiles_enabled_flag;
252 uint8_t seq_loop_filter_across_slices_enabled_flag;
254 uint8_t deblocking_filter_control_present_flag;
255 uint8_t deblocking_filter_override_enabled_flag;
256 uint8_t disable_dbf;
257 int beta_offset; ///< beta_offset_div2 * 2
258 int tc_offset; ///< tc_offset_div2 * 2
260 uint8_t scaling_list_data_present_flag;
261 ScalingList scaling_list;
263 uint8_t lists_modification_present_flag;
264 int log2_parallel_merge_level; ///< log2_parallel_merge_level_minus2 + 2
265 int num_extra_slice_header_bits;
266 uint8_t slice_header_extension_present_flag;
268 // Inferred parameters
269 unsigned int *column_width; ///< ColumnWidth
270 unsigned int *row_height; ///< RowHeight
271 unsigned int *col_bd; ///< ColBd
272 unsigned int *row_bd; ///< RowBd
273 int *col_idxX;
275 int *ctb_addr_rs_to_ts; ///< CtbAddrRSToTS
276 int *ctb_addr_ts_to_rs; ///< CtbAddrTSToRS
277 int *tile_id; ///< TileId
278 int *tile_pos_rs; ///< TilePosRS
279 int *min_tb_addr_zs; ///< MinTbAddrZS
280 } HEVCPPS;
282 typedef struct HEVCParamSets {
283 AVBufferRef *vps_list[HEVC_MAX_VPS_COUNT];
284 AVBufferRef *sps_list[HEVC_MAX_SPS_COUNT];
285 AVBufferRef *pps_list[HEVC_MAX_PPS_COUNT];
287 /* currently active parameter sets */
288 const HEVCVPS *vps;
289 const HEVCSPS *sps;
290 const HEVCPPS *pps;
291 } HEVCParamSets;
294 * Parse the SPS from the bitstream into the provided HEVCSPS struct.
296 * @param sps_id the SPS id will be written here
297 * @param apply_defdispwin if set 1, the default display window from the VUI
298 * will be applied to the video dimensions
299 * @param vps_list if non-NULL, this function will validate that the SPS refers
300 * to an existing VPS
302 int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
303 int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx);
305 int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx,
306 HEVCParamSets *ps);
307 int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx,
308 HEVCParamSets *ps, int apply_defdispwin);
309 int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
310 HEVCParamSets *ps);
312 int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
313 ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header);
315 int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int id,
316 uint8_t *buf, int buf_size);
318 #endif /* AVCODEC_HEVC_PS_H */