FFmpeg
cbs_av1.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVCODEC_CBS_AV1_H
20 #define AVCODEC_CBS_AV1_H
21 
22 #include <stddef.h>
23 #include <stdint.h>
24 
25 #include "av1.h"
26 #include "cbs.h"
27 
28 
29 typedef struct AV1RawOBUHeader {
35 
40 
41 typedef struct AV1RawColorConfig {
45 
50 
57 
58 typedef struct AV1RawTimingInfo {
60  uint32_t time_scale;
61 
65 
66 typedef struct AV1RawDecoderModelInfo {
72 
73 typedef struct AV1RawSequenceHeader {
77 
82 
85 
86  uint16_t operating_point_idc[AV1_MAX_OPERATING_POINTS];
89  uint8_t decoder_model_present_for_this_op[AV1_MAX_OPERATING_POINTS];
90  uint32_t decoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
91  uint32_t encoder_buffer_delay[AV1_MAX_OPERATING_POINTS];
92  uint8_t low_delay_mode_flag[AV1_MAX_OPERATING_POINTS];
93  uint8_t initial_display_delay_present_for_this_op[AV1_MAX_OPERATING_POINTS];
94  uint8_t initial_display_delay_minus_1[AV1_MAX_OPERATING_POINTS];
95 
100 
104 
112 
116 
121 
123 
127 
129 
132 
133 typedef struct AV1RawFrameHeader {
138 
142 
147 
151 
153  uint32_t buffer_removal_time[AV1_MAX_OPERATING_POINTS];
154 
163 
165 
168  uint8_t ref_order_hint[AV1_NUM_REF_FRAMES];
172  int8_t ref_frame_idx[AV1_REFS_PER_FRAME];
173  uint32_t delta_frame_id_minus1[AV1_REFS_PER_FRAME];
174 
180 
182 
186  uint8_t width_in_sbs_minus_1[AV1_MAX_TILE_COLS];
187  uint8_t height_in_sbs_minus_1[AV1_MAX_TILE_ROWS];
190 
191  // These are derived values, but it's very unhelpful to have to
192  // recalculate them all the time so we store them here.
193  uint16_t tile_cols;
194  uint16_t tile_rows;
195 
197  int8_t delta_q_y_dc;
199  int8_t delta_q_u_dc;
200  int8_t delta_q_u_ac;
201  int8_t delta_q_v_dc;
202  int8_t delta_q_v_ac;
207 
213  int16_t feature_value[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
214 
220 
221  uint8_t loop_filter_level[4];
226  int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME];
227  uint8_t update_mode_delta[2];
228  int8_t loop_filter_mode_deltas[2];
229 
232  uint8_t cdef_y_pri_strength[8];
233  uint8_t cdef_y_sec_strength[8];
234  uint8_t cdef_uv_pri_strength[8];
235  uint8_t cdef_uv_sec_strength[8];
236 
237  uint8_t lr_type[3];
240 
244 
247 
251  //AV1RawSubexp gm_params[AV1_TOTAL_REFS_PER_FRAME][6];
252  uint32_t gm_params[AV1_TOTAL_REFS_PER_FRAME][6];
253 
255  uint16_t grain_seed;
259  uint8_t point_y_value[16];
260  uint8_t point_y_scaling[16];
263  uint8_t point_cb_value[16];
264  uint8_t point_cb_scaling[16];
266  uint8_t point_cr_value[16];
267  uint8_t point_cr_scaling[16];
270  uint8_t ar_coeffs_y_plus_128[24];
271  uint8_t ar_coeffs_cb_plus_128[24];
272  uint8_t ar_coeffs_cr_plus_128[24];
277  uint16_t cb_offset;
280  uint16_t cr_offset;
284 
285 typedef struct AV1RawTileData {
287  size_t data_size;
290 
291 typedef struct AV1RawTileGroup {
293  uint16_t tg_start;
294  uint16_t tg_end;
295 
298 
299 typedef struct AV1RawFrame {
302 } AV1RawFrame;
303 
304 typedef struct AV1RawTileList {
308 
311 
312 typedef struct AV1RawMetadataHDRCLL {
313  uint16_t max_cll;
314  uint16_t max_fall;
316 
317 typedef struct AV1RawMetadataHDRMDCV {
318  uint16_t primary_chromaticity_x[3];
319  uint16_t primary_chromaticity_y[3];
322  uint32_t luminance_max;
323  uint32_t luminance_min;
325 
333  uint16_t spatial_layer_max_width[4];
334  uint16_t spatial_layer_max_height[4];
335  uint8_t spatial_layer_ref_id[4];
337  uint8_t temporal_group_temporal_id[255];
338  uint8_t temporal_group_temporal_switching_up_point_flag[255];
339  uint8_t temporal_group_spatial_switching_up_point_flag[255];
340  uint8_t temporal_group_ref_cnt[255];
341  uint8_t temporal_group_ref_pic_diff[255][7];
343 
344 typedef struct AV1RawMetadataITUTT35 {
347 
349  size_t payload_size;
352 
353 typedef struct AV1RawMetadataTimecode {
358  uint16_t n_frames;
368 
369 typedef struct AV1RawMetadata {
370  uint64_t metadata_type;
371  union {
377  } metadata;
379 
380 typedef struct AV1RawPadding {
382  size_t payload_size;
384 } AV1RawPadding;
385 
386 
387 typedef struct AV1RawOBU {
389 
390  size_t obu_size;
391 
392  union {
400  } obu;
401 } AV1RawOBU;
402 
403 typedef struct AV1ReferenceFrameState {
404  int valid; // RefValid
405  int frame_id; // RefFrameId
406  int upscaled_width; // RefUpscaledWidth
407  int frame_width; // RefFrameWidth
408  int frame_height; // RefFrameHeight
409  int render_width; // RefRenderWidth
410  int render_height; // RefRenderHeight
411  int frame_type; // RefFrameType
412  int subsampling_x; // RefSubsamplingX
413  int subsampling_y; // RefSubsamplingY
414  int bit_depth; // RefBitDepth
415  int order_hint; // RefOrderHint
417 
418 typedef struct CodedBitstreamAV1Context {
421 
426 
430 
437 
443 
445 
446  // Write buffer.
450 
451 
452 #endif /* AVCODEC_CBS_AV1_H */
AV1RawMetadata metadata
Definition: cbs_av1.h:398
uint8_t use_ref_frame_mvs
Definition: cbs_av1.h:179
uint8_t tx_mode
Definition: cbs_av1.h:241
uint32_t display_frame_id
Definition: cbs_av1.h:137
uint8_t full_timestamp_flag
Definition: cbs_av1.h:355
size_t obu_size
Definition: cbs_av1.h:390
uint8_t frame_width_bits_minus_1
Definition: cbs_av1.h:96
AV1RawTileList tile_list
Definition: cbs_av1.h:397
uint8_t loop_filter_sharpness
Definition: cbs_av1.h:222
uint8_t enable_superres
Definition: cbs_av1.h:124
uint8_t film_grain_params_ref_idx
Definition: cbs_av1.h:257
uint8_t cnt_dropped_flag
Definition: cbs_av1.h:357
uint32_t time_scale
Definition: cbs_av1.h:60
uint8_t refresh_frame_flags
Definition: cbs_av1.h:166
uint8_t disable_cdf_update
Definition: cbs_av1.h:144
uint8_t mono_chrome
Definition: cbs_av1.h:44
uint8_t seq_choose_integer_mv
Definition: cbs_av1.h:119
uint8_t allow_screen_content_tools
Definition: cbs_av1.h:145
AVBufferRef * payload_ref
Definition: cbs_av1.h:350
uint8_t num_y_points
Definition: cbs_av1.h:258
AVBufferRef * sequence_header_ref
Definition: cbs_av1.h:420
uint8_t additional_frame_id_length_minus_1
Definition: cbs_av1.h:103
uint8_t grain_scaling_minus_8
Definition: cbs_av1.h:268
uint16_t white_point_chromaticity_x
Definition: cbs_av1.h:320
uint8_t primary_ref_frame
Definition: cbs_av1.h:155
uint8_t allow_high_precision_mv
Definition: cbs_av1.h:175
uint8_t order_hint_bits_minus_1
Definition: cbs_av1.h:122
uint8_t enable_jnt_comp
Definition: cbs_av1.h:114
uint8_t cr_mult
Definition: cbs_av1.h:278
uint8_t timing_info_present_flag
Definition: cbs_av1.h:78
uint32_t num_units_in_display_tick
Definition: cbs_av1.h:59
uint8_t showable_frame
Definition: cbs_av1.h:141
uint8_t tile_cols_log2
Definition: cbs_av1.h:184
uint8_t color_range
Definition: cbs_av1.h:51
uint8_t lr_unit_shift
Definition: cbs_av1.h:238
uint16_t frame_width_minus_1
Definition: cbs_av1.h:156
uint8_t operating_points_cnt_minus_1
Definition: cbs_av1.h:81
uint8_t chroma_scaling_from_luma
Definition: cbs_av1.h:261
uint8_t seq_profile
Definition: cbs_av1.h:74
uint8_t interpolation_filter
Definition: cbs_av1.h:177
uint8_t cb_luma_mult
Definition: cbs_av1.h:276
uint8_t lr_uv_shift
Definition: cbs_av1.h:239
uint8_t reduced_still_picture_header
Definition: cbs_av1.h:76
uint8_t seq_choose_screen_content_tools
Definition: cbs_av1.h:117
uint8_t delta_lf_res
Definition: cbs_av1.h:218
uint8_t buffer_removal_time_present_flag
Definition: cbs_av1.h:152
uint16_t tile_rows
Definition: cbs_av1.h:194
AV1RawTileData tile_data
Definition: cbs_av1.h:309
uint8_t matrix_coefficients
Definition: cbs_av1.h:49
uint8_t enable_intra_edge_filter
Definition: cbs_av1.h:107
uint8_t clip_to_restricted_range
Definition: cbs_av1.h:282
uint8_t order_hint
Definition: cbs_av1.h:150
uint8_t discontinuity_flag
Definition: cbs_av1.h:356
uint8_t
uint8_t film_grain_params_present
Definition: cbs_av1.h:130
uint8_t enable_masked_compound
Definition: cbs_av1.h:109
uint8_t * data
Definition: cbs_av1.h:286
uint16_t max_frame_width_minus_1
Definition: cbs_av1.h:98
uint8_t * write_buffer
Definition: cbs_av1.h:447
uint16_t context_update_tile_id
Definition: cbs_av1.h:188
uint8_t cr_luma_mult
Definition: cbs_av1.h:279
uint8_t allow_intrabc
Definition: cbs_av1.h:167
uint8_t delta_lf_multi
Definition: cbs_av1.h:219
uint8_t qm_v
Definition: cbs_av1.h:206
uint8_t output_frame_width_in_tiles_minus_1
Definition: cbs_av1.h:305
AV1RawMetadataHDRMDCV hdr_mdcv
Definition: cbs_av1.h:373
uint8_t high_bitdepth
Definition: cbs_av1.h:42
uint8_t enable_warped_motion
Definition: cbs_av1.h:110
size_t payload_size
Definition: cbs_av1.h:382
uint8_t itu_t_t35_country_code
Definition: cbs_av1.h:345
uint8_t allow_warped_motion
Definition: cbs_av1.h:245
uint8_t extension_header_reserved_3bits
Definition: cbs_av1.h:38
uint16_t tile_count_minus_1
Definition: cbs_av1.h:307
uint8_t render_height_minus_1
Definition: cbs_av1.h:162
uint8_t enable_ref_frame_mvs
Definition: cbs_av1.h:115
uint8_t frame_presentation_time_length_minus_1
Definition: cbs_av1.h:70
uint8_t cdef_bits
Definition: cbs_av1.h:231
int8_t delta_q_v_dc
Definition: cbs_av1.h:201
uint8_t tile_start_and_end_present_flag
Definition: cbs_av1.h:292
uint8_t * frame_header
Definition: cbs_av1.h:424
uint8_t enable_filter_intra
Definition: cbs_av1.h:106
uint8_t seq_force_integer_mv
Definition: cbs_av1.h:120
uint8_t use_superres
Definition: cbs_av1.h:158
uint8_t separate_uv_delta_q
Definition: cbs_av1.h:55
AV1RawTileData tile_data
Definition: cbs_av1.h:296
uint8_t temporal_id
Definition: cbs_av1.h:36
AVBufferRef * frame_header_ref
Definition: cbs_av1.h:423
uint16_t frame_height_minus_1
Definition: cbs_av1.h:157
uint8_t twelve_bit
Definition: cbs_av1.h:43
AV1RawMetadataTimecode timecode
Definition: cbs_av1.h:376
AV1RawFrame frame
Definition: cbs_av1.h:395
uint8_t force_integer_mv
Definition: cbs_av1.h:146
uint8_t buffer_delay_length_minus_1
Definition: cbs_av1.h:67
uint8_t spatial_layer_description_present_flag
Definition: cbs_av1.h:330
uint8_t temporal_group_description_present_flag
Definition: cbs_av1.h:331
uint8_t still_picture
Definition: cbs_av1.h:75
uint8_t apply_grain
Definition: cbs_av1.h:254
AV1RawColorConfig color_config
Definition: cbs_av1.h:128
uint16_t tg_start
Definition: cbs_av1.h:293
uint8_t obu_extension_flag
Definition: cbs_av1.h:32
uint8_t qm_u
Definition: cbs_av1.h:205
AVBufferRef * payload_ref
Definition: cbs_av1.h:383
uint8_t spatial_layer_dimensions_present_flag
Definition: cbs_av1.h:329
uint32_t frame_presentation_time
Definition: cbs_av1.h:136
uint16_t max_cll
Definition: cbs_av1.h:313
uint32_t luminance_min
Definition: cbs_av1.h:323
uint8_t reference_select
Definition: cbs_av1.h:242
uint8_t use_128x128_superblock
Definition: cbs_av1.h:105
uint8_t frame_type
Definition: cbs_av1.h:139
uint8_t obu_reserved_1bit
Definition: cbs_av1.h:34
uint8_t enable_restoration
Definition: cbs_av1.h:126
AV1RawOBUHeader header
Definition: cbs_av1.h:388
AV1RawMetadataScalability scalability
Definition: cbs_av1.h:374
uint8_t enable_cdef
Definition: cbs_av1.h:125
uint32_t time_offset_value
Definition: cbs_av1.h:366
uint8_t ar_coeff_lag
Definition: cbs_av1.h:269
uint8_t color_primaries
Definition: cbs_av1.h:47
uint16_t cr_offset
Definition: cbs_av1.h:280
size_t data_size
Definition: cbs_av1.h:287
uint16_t white_point_chromaticity_y
Definition: cbs_av1.h:321
uint8_t scalability_mode_idc
Definition: cbs_av1.h:327
uint8_t cb_mult
Definition: cbs_av1.h:275
uint8_t subsampling_y
Definition: cbs_av1.h:53
uint8_t decoder_model_info_present_flag
Definition: cbs_av1.h:79
uint16_t max_frame_height_minus_1
Definition: cbs_av1.h:99
uint8_t using_qmatrix
Definition: cbs_av1.h:203
uint8_t diff_uv_delta
Definition: cbs_av1.h:198
uint8_t delta_frame_id_length_minus_2
Definition: cbs_av1.h:102
uint8_t loop_filter_delta_update
Definition: cbs_av1.h:224
int8_t delta_q_u_dc
Definition: cbs_av1.h:199
uint8_t subsampling_x
Definition: cbs_av1.h:52
uint8_t error_resilient_mode
Definition: cbs_av1.h:143
uint16_t max_fall
Definition: cbs_av1.h:314
uint8_t enable_order_hint
Definition: cbs_av1.h:113
uint8_t segmentation_temporal_update
Definition: cbs_av1.h:210
uint32_t current_frame_id
Definition: cbs_av1.h:148
AV1 common definitions.
uint8_t delta_q_res
Definition: cbs_av1.h:216
uint8_t loop_filter_delta_enabled
Definition: cbs_av1.h:223
uint8_t is_filter_switchable
Definition: cbs_av1.h:176
uint16_t cb_offset
Definition: cbs_av1.h:277
uint8_t show_existing_frame
Definition: cbs_av1.h:134
AV1RawTileGroup tile_group
Definition: cbs_av1.h:301
uint8_t color_description_present_flag
Definition: cbs_av1.h:46
uint8_t spatial_layers_cnt_minus_1
Definition: cbs_av1.h:328
uint32_t luminance_max
Definition: cbs_av1.h:322
uint8_t obu_type
Definition: cbs_av1.h:31
AV1RawDecoderModelInfo decoder_model_info
Definition: cbs_av1.h:84
uint8_t scalability_structure_reserved_3bits
Definition: cbs_av1.h:332
int8_t delta_q_u_ac
Definition: cbs_av1.h:200
uint8_t last_frame_idx
Definition: cbs_av1.h:170
uint8_t base_q_idx
Definition: cbs_av1.h:196
AV1RawSequenceHeader * sequence_header
Definition: cbs_av1.h:419
uint8_t spatial_id
Definition: cbs_av1.h:37
uint32_t num_ticks_per_picture_minus_1
Definition: cbs_av1.h:63
AV1RawSequenceHeader sequence_header
Definition: cbs_av1.h:393
uint8_t equal_picture_interval
Definition: cbs_av1.h:62
uint8_t tile_size_bytes_minus1
Definition: cbs_av1.h:189
uint8_t segmentation_enabled
Definition: cbs_av1.h:208
uint8_t qm_y
Definition: cbs_av1.h:204
AV1RawMetadataHDRCLL hdr_cll
Definition: cbs_av1.h:372
uint16_t tile_cols
Definition: cbs_av1.h:193
uint8_t disable_frame_end_update_cdf
Definition: cbs_av1.h:181
AVBufferRef * data_ref
Definition: cbs_av1.h:288
uint8_t segmentation_update_map
Definition: cbs_av1.h:209
uint8_t frame_id_numbers_present_flag
Definition: cbs_av1.h:101
A reference to a data buffer.
Definition: buffer.h:81
uint8_t coded_denom
Definition: cbs_av1.h:159
uint8_t frame_height_bits_minus_1
Definition: cbs_av1.h:97
AV1RawMetadataITUTT35 itut_t35
Definition: cbs_av1.h:375
uint8_t * payload
Definition: cbs_av1.h:381
AV1RawPadding padding
Definition: cbs_av1.h:399
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
uint8_t buffer_removal_time_length_minus_1
Definition: cbs_av1.h:69
uint8_t cdef_damping_minus_3
Definition: cbs_av1.h:230
uint8_t ar_coeff_shift_minus_6
Definition: cbs_av1.h:273
uint8_t frame_size_override_flag
Definition: cbs_av1.h:149
uint8_t overlap_flag
Definition: cbs_av1.h:281
uint8_t time_offset_length
Definition: cbs_av1.h:365
uint8_t delta_q_present
Definition: cbs_av1.h:215
uint8_t uniform_tile_spacing_flag
Definition: cbs_av1.h:183
int8_t delta_q_v_ac
Definition: cbs_av1.h:202
uint8_t num_cb_points
Definition: cbs_av1.h:262
uint64_t metadata_type
Definition: cbs_av1.h:370
uint8_t * payload
Definition: cbs_av1.h:348
int8_t delta_q_y_dc
Definition: cbs_av1.h:197
uint16_t tg_end
Definition: cbs_av1.h:294
uint8_t is_motion_mode_switchable
Definition: cbs_av1.h:178
uint8_t skip_mode_present
Definition: cbs_av1.h:243
uint8_t initial_display_delay_present_flag
Definition: cbs_av1.h:80
uint8_t tile_rows_log2
Definition: cbs_av1.h:185
uint8_t obu_has_size_field
Definition: cbs_av1.h:33
uint8_t update_grain
Definition: cbs_av1.h:256
uint8_t chroma_sample_position
Definition: cbs_av1.h:54
uint8_t delta_lf_present
Definition: cbs_av1.h:217
uint8_t golden_frame_idx
Definition: cbs_av1.h:171
AV1RawTileGroup tile_group
Definition: cbs_av1.h:396
AV1RawFrameHeader frame_header
Definition: cbs_av1.h:394
uint8_t frame_refs_short_signaling
Definition: cbs_av1.h:169
uint8_t itu_t_t35_country_code_extension_byte
Definition: cbs_av1.h:346
uint32_t num_units_in_decoding_tick
Definition: cbs_av1.h:68
uint8_t output_frame_height_in_tiles_minus_1
Definition: cbs_av1.h:306
AV1RawTimingInfo timing_info
Definition: cbs_av1.h:83
uint8_t show_frame
Definition: cbs_av1.h:140
uint8_t frame_to_show_map_idx
Definition: cbs_av1.h:135
uint8_t num_cr_points
Definition: cbs_av1.h:265
AV1RawFrameHeader header
Definition: cbs_av1.h:300
uint8_t enable_intraintra_compound
Definition: cbs_av1.h:108
uint8_t segmentation_update_data
Definition: cbs_av1.h:211
uint8_t seq_force_screen_content_tools
Definition: cbs_av1.h:118
uint8_t render_width_minus_1
Definition: cbs_av1.h:161
uint8_t grain_scale_shift
Definition: cbs_av1.h:274
uint8_t enable_dual_filter
Definition: cbs_av1.h:111
uint16_t grain_seed
Definition: cbs_av1.h:255
uint8_t transfer_characteristics
Definition: cbs_av1.h:48
uint8_t reduced_tx_set
Definition: cbs_av1.h:246
uint8_t obu_forbidden_bit
Definition: cbs_av1.h:30
uint8_t render_and_frame_size_different
Definition: cbs_av1.h:160