Debian Codegraph @

va/va_enc_av1.h

raw
1 /*
2 * Copyright (c) 2021 Intel Corporation. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
26 * \file va_enc_av1.h
27 * \brief AV1 encoding API
28 *
29 * This file contains the \ref api_enc_av1 "AV1 encoding API".
30 *
31 */
32
33 #ifndef VA_ENC_AV1_H
34 #define VA_ENC_AV1_H
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #include <stdint.h>
41
42 /**
43 * \defgroup api_enc_av1 AV1 encoding API
44 *
45 * This AV1 encoding API supports 8-bit/10bit 420 format only.
46 *
47 * @{
48 */
49
50 /** \brief Attribute value for VAConfigAttribEncAV1.
51 *
52 * This attribute decribes the supported features of an AV1
53 * encoder configuration.
54 *
55 * All of the field values in this attribute are VA_FEATURE_* values,
56 * indicating support for the corresponding feature.
57 *
58 */
59 typedef union _VAConfigAttribValEncAV1 {
60 struct {
61 /**
62 * \brief Use 128x128 superblock.
63 *
64 * Allows setting use_128x128_superblock in the SPS.
65 */
66 uint32_t support_128x128_superblock : 2;
67 /**
68 * \brief Intra filter.
69 * Allows setting enable_filter_intra in the SPS.
70 */
71 uint32_t support_filter_intra : 2;
72 /**
73 * \brief Intra edge filter.
74 * Allows setting enable_intra_edge_filter in the SPS.
75 */
76 uint32_t support_intra_edge_filter : 2;
77 /**
78 * \brief Interintra compound.
79 * Allows setting enable_interintra_compound in the SPS.
80 */
81 uint32_t support_interintra_compound : 2;
82 /**
83 * \brief Masked compound.
84 * Allows setting enable_masked_compound in the SPS.
85 */
86 uint32_t support_masked_compound : 2;
87 /**
88 * \brief Warped motion.
89 * Allows setting enable_warped_motion in the SPS.
90 */
91 uint32_t support_warped_motion : 2;
92 /**
93 * \brief Palette mode.
94 * Allows setting palette_mode in the PPS.
95 */
96 uint32_t support_palette_mode : 2;
97 /**
98 * \brief Dual filter.
99 * Allows setting enable_dual_filter in the SPS.
100 */
101 uint32_t support_dual_filter : 2;
102 /**
103 * \brief Jnt compound.
104 * Allows setting enable_jnt_comp in the SPS.
105 */
106 uint32_t support_jnt_comp : 2;
107 /**
108 * \brief Refrence frame mvs.
109 * Allows setting enable_ref_frame_mvs in the SPS.
110 */
111 uint32_t support_ref_frame_mvs : 2;
112 /**
113 * \brief Super resolution.
114 * Allows setting enable_superres in the SPS.
115 */
116 uint32_t support_superres : 2;
117 /**
118 * \brief Restoration.
119 * Allows setting enable_restoration in the SPS.
120 */
121 uint32_t support_restoration : 2;
122 /**
123 * \brief Allow intraBC.
124 * Allows setting allow_intrabc in the PPS.
125 */
126 uint32_t support_allow_intrabc : 2;
127 /**
128 * \brief Cdef channel strength.
129 * Allows setting cdef_y_strengths and cdef_uv_strengths in PPS.
130 */
131 uint32_t support_cdef_channel_strength : 2;
132 /** \brief Reserved bits for future, must be zero. */
133 uint32_t reserved : 4;
134 } bits;
135 uint32_t value;
136 } VAConfigAttribValEncAV1;
137
138 /** \brief Attribute value for VAConfigAttribEncAV1Ext1. */
139 typedef union _VAConfigAttribValEncAV1Ext1 {
140 struct {
141 /**
142 * \brief Fields indicate which types of interpolation filter are supported.
143 * (interpolation_filter & 0x01) == 1: eight_tap filter is supported, 0: not.
144 * (interpolation_filter & 0x02) == 1: eight_tap_smooth filter is supported, 0: not.
145 * (interpolation_filter & 0x04) == 1: eight_sharp filter is supported, 0: not.
146 * (interpolation_filter & 0x08) == 1: bilinear filter is supported, 0: not.
147 * (interpolation_filter & 0x10) == 1: switchable filter is supported, 0: not.
148 */
149 uint32_t interpolation_filter : 5;
150 /**
151 * \brief segmentId block size accepted.
152 * Application need to send seg_id_block_size in PPS equal or larger than this value.
153 * one bit represent one block size defined as VA_SEGID_BLOCKXXXX
154 * should be (1 << VA_SEGID_BLOCKXXX | 1 << VA_SEGID_BLOCKXXX ... )
155 */
156 uint32_t min_segid_block_size_accepted : 8;
157 /**
158 * \brief Type of segment feature supported.
159 * (segment_feature_support & 0x01) == 1: SEG_LVL_ALT_Q is supported, 0: not.
160 * (segment_feature_support & 0x02) == 1: SEG_LVL_ALT_LF_Y_V is supported, 0: not.
161 * (segment_feature_support & 0x04) == 1: SEG_LVL_ALT_LF_Y_H is supported, 0: not.
162 * (segment_feature_support & 0x08) == 1: SEG_LVL_ALT_LF_U is supported, 0: not.
163 * (segment_feature_support & 0x10) == 1: SEG_LVL_ALT_LF_V is supported, 0: not.
164 * (segment_feature_support & 0x20) == 1: SEG_LVL_REF_FRAME is supported, 0: not.
165 * (segment_feature_support & 0x40) == 1: SEG_LVL_SKIP is supported, 0: not.
166 * (segment_feature_support & 0x80) == 1: SEG_LVL_GLOBALMV is supported, 0: not.
167 */
168 uint32_t segment_feature_support : 8;
169 /** \brief Reserved bits for future, must be zero. */
170 uint32_t reserved : 11;
171 } bits;
172 uint32_t value;
173 } VAConfigAttribValEncAV1Ext1;
174
175 /** \brief Attribute value for VAConfigAttribEncAV1Ext2. */
176 typedef union _VAConfigAttribValEncAV1Ext2 {
177 struct {
178 /**
179 * \brief Tile size bytes minus1.
180 * Specify the number of bytes needed to code tile size supported.
181 * This value need to be set in frame header obu.
182 */
183 uint32_t tile_size_bytes_minus1 : 2;
184 /**
185 * \brief Tile size bytes minus1.
186 * Specify the fixed number of bytes needed to code syntax obu_size.
187 */
188 uint32_t obu_size_bytes_minus1 : 2;
189 /**
190 * \brief tx_mode supported.
191 * (tx_mode_support & 0x01) == 1: ONLY_4X4 is supported, 0: not.
192 * (tx_mode_support & 0x02) == 1: TX_MODE_LARGEST is supported, 0: not.
193 * (tx_mode_support & 0x04) == 1: TX_MODE_SELECT is supported, 0: not.
194 */
195 uint32_t tx_mode_support : 3;
196 /**
197 * \brief Max tile num minus1.
198 * Specify the max number of tile supported by driver.
199 */
200 uint32_t max_tile_num_minus1 : 13;
201 /** \brief Reserved bits for future, must be zero. */
202 uint32_t reserved : 12;
203 } bits;
204 uint32_t value;
205 } VAConfigAttribValEncAV1Ext2;
206
207 /**
208 * \brief Packed header types specific to AV1 encoding.
209 *
210 * Types of packed headers generally used for AV1 encoding.
211 *
212 */
213 typedef enum {
214 /**
215 * \brief Packed Sequence Parameter Set (SPS).
216 *
217 * The corresponding packed header data buffer shall contain the
218 * complete sequence_header_obu() syntax element.
219 *
220 */
221 VAEncPackedHeaderAV1_SPS = VAEncPackedHeaderSequence,
222 /**
223 * \brief Packed Picture Parameter Set (PPS).
224 *
225 * The corresponding packed header data buffer shall contain the
226 * complete frame_header_obu() syntax element.
227 *
228 */
229 VAEncPackedHeaderAV1_PPS = VAEncPackedHeaderPicture,
230 } VAEncPackedHeaderTypeAV1;
231
232 /**
233 * \brief AV1 Encoding Sequence Parameter Buffer Structure.
234 *
235 * This structure conveys sequence level parameters.
236 *
237 */
238 typedef struct _VAEncSequenceParameterBufferAV1 {
239 /** \brief AV1 profile setting.
240 * value range [0..2].
241 */
242 uint8_t seq_profile;
243
244 /** \brief Level Setting of current operation point.
245 * value range [0..23].
246 */
247 uint8_t seq_level_idx;
248
249 /** \brief Tier Setting of current operation point.
250 * value range [0..1].
251 */
252 uint8_t seq_tier;
253
254 /** \brief Indicates whether or not the encoding is in dyadic hierarchical GOP structure.
255 * value range [0..1].
256 */
257 uint8_t hierarchical_flag;
258
259 /** \brief Period between intra_only frames. */
260 uint32_t intra_period;
261
262 /** \brief Period between I/P frames.
263 * For hierarchical structure, this is the anchor frame distance.
264 */
265 uint32_t ip_period;
266
267 /* \brief RC related fields. RC modes are set with VAConfigAttribRateControl. */
268 /* For AV1, CBR implies HRD conformance and VBR implies no HRD conformance. */
269
270 /**
271 * \brief Initial bitrate set for this sequence in CBR or VBR modes.
272 *
273 * This field represents the initial bitrate value for CBR mode or
274 * initial max bitrate value for VBR mode in this sequence.
275 * i.e. if the encoder pipeline was created with a #VAConfigAttribRateControl
276 * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
277 *
278 * The bitrate can be modified later on through
279 * #VAEncMiscParameterRateControl buffers.
280 */
281 uint32_t bits_per_second;
282
283 union {
284 struct {
285 /** \brief Still picture encoding, no inter frame referencing. */
286 uint32_t still_picture : 1;
287 /** \brief Force using 128x128 or 64x64 Supper block */
288 uint32_t use_128x128_superblock : 1;
289 /** \brief Corresponds to AV1 syntax element of the same name. */
290 uint32_t enable_filter_intra : 1;
291 /** \brief Corresponds to AV1 syntax element of the same name. */
292 uint32_t enable_intra_edge_filter : 1;
293 /** \brief Corresponds to AV1 syntax element of the same name. */
294 uint32_t enable_interintra_compound : 1;
295 /** \brief Corresponds to AV1 syntax element of the same name. */
296 uint32_t enable_masked_compound : 1;
297 /** \brief Corresponds to AV1 syntax element of the same name. */
298 uint32_t enable_warped_motion : 1;
299 /** \brief Corresponds to AV1 syntax element of the same name. */
300 uint32_t enable_dual_filter : 1;
301 /** \brief Corresponds to AV1 syntax element of the same name. */
302 uint32_t enable_order_hint : 1;
303 /** \brief Corresponds to AV1 syntax element of the same name. */
304 uint32_t enable_jnt_comp : 1;
305 /** \brief Corresponds to AV1 syntax element of the same name. */
306 uint32_t enable_ref_frame_mvs : 1;
307 /** \brief Corresponds to AV1 syntax element of the same name. */
308 uint32_t enable_superres : 1;
309 /** \brief Corresponds to AV1 syntax element of the same name. */
310 uint32_t enable_cdef : 1;
311 /** \brief Corresponds to AV1 syntax element of the same name. */
312 uint32_t enable_restoration : 1;
313 /** \brief Sepcify number of bits for every channel(Y, U or V). */
314 uint32_t bit_depth_minus8 : 3;
315 /** \brief Corresponds to AV1 syntax element of the same name. */
316 uint32_t subsampling_x : 1;
317 /** \brief Corresponds to AV1 syntax element of the same name. */
318 uint32_t subsampling_y : 1;
319 /** \brief Corresponds to AV1 syntax element of the same name. */
320 uint32_t mono_chrome : 1;
321 /** \brief Reserved bytes for future use, must be zero. */
322 uint32_t reserved_bits : 12;
323 } bits;
324 uint32_t value;
325 } seq_fields;
326
327 /** \brief Corresponds to AV1 syntax element of the same name.
328 * value range [0..7].
329 */
330 uint8_t order_hint_bits_minus_1;
331
332 /** \brief Reserved bytes for future use, must be zero */
333 uint32_t va_reserved[VA_PADDING_HIGH];
334 } VAEncSequenceParameterBufferAV1;
335
336 #define VA_AV1_MAX_SEGMENTS 8
337 #define VA_AV1_SEG_LVL_MAX 8
338
339 /**
340 * \brief Segment parameters
341 */
342 typedef struct _VAEncSegParamAV1 {
343 union {
344 struct {
345 /** \brief Indicates if segmentation is enabled in the current frame.
346 * If disabled, all the below parameters in the structure should
347 * be set to 0, and ignored by driver.
348 */
349 uint8_t segmentation_enabled : 1;
350
351 /**
352 * When segmentation_enabled equals 1 and segment_number > 0,
353 * this parameter equals 1 indicates the segmentation map may
354 * come from application, and that "Segment map data buffer"
355 * should be provided with populated segment_id. If equals 0,
356 * segmentation map should be inherited from a reference frame
357 * (specified by \c primary_ref_frame). When segmentation_enabled or
358 * segment_number equals 0, this parameter should be set to 0
359 * and ignored by driver.
360 */
361 uint8_t segmentation_update_map : 1;
362 /**
363 * When segmentation_update_map equals 1, this parameter equaling 1
364 * indicates segment id per block will be determined either from
365 * reference frame or from app. Equaling 0 means segment id per block
366 * will come from app. When segmentation_temporal_update equals 0,
367 * this parameter should be set to 0 and ignored by driver.
368 */
369 uint8_t segmentation_temporal_update : 1;
370 /** \brief Reserved bytes for future use, must be zero. */
371 uint8_t reserved : 5;
372
373 } bits;
374 uint8_t value;
375 } seg_flags;
376
377 /**
378 * If segmentation_enabled equals 1, this parameter indicates
379 * the number of segments conveyed through VAAPI. In this case,
380 * if segment_number equals 0, it will force the driver to determine
381 * how many segments would be created as well as the segmentation map
382 * to be generated. Also the driver shall write the segmentation_params()
383 * syntax in the uncompressed header at \c bit_offset_segmentation (back-annotation).
384 * In application, the rest parameters in this structure should be all
385 * set to 0 and ignored by driver. And app should NOT send the
386 * "Segment map data buffer". In packed uncompressed header
387 * bitstream, app should write syntax element segmentation_enabled
388 * as 0 and segmentation_params() should be only 1-bit-long.
389 * If segment_number > 0, and segmentation_update_map = 1, app should provide
390 * the "Segment map data buffer" and populate the rest of the
391 * current data structure. And that underline encoder would honor
392 * the segmentation parameters feature_data[0..segment_number-1][]
393 * and feature_mask[0..segment_number-1], etc.
394 * Value range [0..8].
395 */
396 uint8_t segment_number;
397
398 /** \brief segment parameters.
399 * feature_data[][] is equivalent to variable FeatureData[][] in spec,
400 * which is after clip3() operation.
401 * Clip3(x, y, z) = (z<x)? x : ((z > y)? y : z);
402 * The limit is defined in Segmentation_Feature_Max[ SEG_LVL_MAX ] = {
403 * 255, MAX_LOOP_FILTER, MAX_LOOP_FILTER, MAX_LOOP_FILTER,
404 * MAX_LOOP_FILTER, 7, 0, 0 }
405 */
406 int16_t feature_data[VA_AV1_MAX_SEGMENTS][VA_AV1_SEG_LVL_MAX];
407
408 /** \brief Bit field to indicate each feature is enabled or not per
409 * segment_id. Each bit is the feature_id.
410 */
411 uint8_t feature_mask[VA_AV1_MAX_SEGMENTS];
412
413 /** \brief Reserved bytes for future use, must be zero. */
414 uint32_t va_reserved[VA_PADDING_LOW];
415 } VAEncSegParamAV1;
416
417 /**
418 * \brief Segment map data buffer.
419 *
420 * This buffer is optional depending on the value of av1_segments.segmentation_enabled.
421 * If av1_segments.segmentation_enabled in the picture parameters equals 1,
422 * and RateControlMethod is not CQP and this surface is not provided by App,
423 * the encoder will determine the per block segmentation map. In this case,
424 * App should not provide the segmentation parameter data structure
425 * in frame header as well. If av1_segments.segmentation_enabled equals 1
426 * and the segmentation map buffer is provided, app should embed the
427 * segmentation info in frame header, populate the VAEncSegParamAV1 structure with
428 * #VAEncMacroblockMapBufferType and the driver as well as the underline encoder
429 * should honor what is given by the app.
430 */
431 typedef struct _VAEncSegMapBufferAV1 {
432 /** \brief Segment map data size. */
433 uint32_t segmentMapDataSize;
434
435 /**
436 * \brief Segment map.
437 * Size of this map is indicated by \ref segmentMapDataSize and each element
438 * in this map contains the segment id of a particular block.
439 * The element is indexed by raster scan order.
440 * The value of each entry should be in the range [0..7], inclusive.
441 */
442 uint8_t *pSegmentMap;
443 } VAEncSegMapBufferAV1;
444
445 typedef enum {
446 /** \brief Identity transformation, 0-parameter. */
447 VAAV1EncTransformationIdentity = 0,
448 /** \brief Translational motion, 2-parameter. */
449 VAAV1EncTransformationTranslation = 1,
450 /** \brief Simplified affine with rotation + zoom only, 4-parameter. */
451 VAAV1EncTransformationRotzoom = 2,
452 /** \brief Affine, 6-parameter. */
453 VAAV1EncTransformationAffine = 3,
454 /** \brief Transformation count. */
455 VAAV1EncTransformationCount
456 } VAEncTransformationTypeAV1;
457
458 typedef struct _VAEncWarpedMotionParamsAV1 {
459
460 /** \brief Specify the type of warped motion. */
461 VAEncTransformationTypeAV1 wmtype;
462
463 /** \brief Specify warp motion parameters.
464 * wm.wmmat[] corresponds to gm_params[][] in spec.
465 * Details in AV1 spec section 5.9.24 or refer to libaom code
466 * https://aomedia.googlesource.com/aom/+/refs/heads/master/av1/decoder/decodeframe.c.
467 */
468 int32_t wmmat[8];
469
470 /** \brief Valid or invalid on affine set. */
471 uint8_t invalid;
472
473 /** \brief Reserved bytes for future use, must be zero. */
474 uint32_t va_reserved[VA_PADDING_LOW];
475
476 } VAEncWarpedMotionParamsAV1;
477
478 /**
479 * \brief Reference frame control.
480 *
481 * Suggest which frame to be used as reference along with preferred search order.
482 *
483 * search_idx#: index into ref_frame_idx[] to indicate that frame will be included
484 * in the reference list if value in range [1..7]. Invalid when value is 0.
485 * The order of the search_idx# indicates the preferred search order.
486 *
487 */
488 typedef union {
489 struct {
490 /**
491 * \brief Value used as index into ref_frame_idx[] to indicate that frame
492 * will be included in the reference list.
493 * valid value range: [1..7], invalid when value is 0.
494 */
495 uint32_t search_idx0 : 3;
496 /**
497 * \brief Value used as index into ref_frame_idx[] to indicate that frame
498 * will be included in the reference list.
499 * valid value range: [1..7], invalid when value is 0.
500 */
501 uint32_t search_idx1 : 3;
502 /**
503 * \brief Value used as index into ref_frame_idx[] to indicate that frame
504 * will be included in the reference list.
505 * valid value range: [1..7], invalid when value is 0.
506 */
507 uint32_t search_idx2 : 3;
508 /**
509 * \brief Value used as index into ref_frame_idx[] to indicate that frame
510 * will be included in the reference list.
511 * valid value range: [1..7], invalid when value is 0.
512 */
513 uint32_t search_idx3 : 3;
514 /**
515 * \brief Value used as index into ref_frame_idx[] to indicate that frame
516 * will be included in the reference list.
517 * valid value range: [1..7], invalid when value is 0.
518 */
519 uint32_t search_idx4 : 3;
520 /**
521 * \brief Value used as index into ref_frame_idx[] to indicate that frame
522 * will be included in the reference list.
523 * valid value range: [1..7], invalid when value is 0.
524 */
525 uint32_t search_idx5 : 3;
526 /**
527 * \brief Value used as index into ref_frame_idx[] to indicate that frame
528 * will be included in the reference list.
529 * valid value range: [1..7], invalid when value is 0.
530 */
531 uint32_t search_idx6 : 3;
532
533 /** \brief Reserved bytes for future use, must be zero. */
534 uint32_t Reserved : 11;
535 } fields;
536 uint32_t value;
537 } VARefFrameCtrlAV1;
538
539 /**
540 * \brief AV1 Encoding Picture Parameter Buffer Structure.
541 *
542 * This structure conveys picture level parameters.
543 *
544 */
545 typedef struct _VAEncPictureParameterBufferAV1 {
546 /** \brief AV1 encoder may support SupRes and dynamic scaling function.
547 * For SupRes, underline encoder is responsible to do downscaling.
548 * For dynamic scaling, app should provide the scaled raw source.
549 */
550 /** \brief Raw source frame width in pixels. */
551 uint16_t frame_width_minus_1;
552 /** \brief Raw source frame height in pixels. */
553 uint16_t frame_height_minus_1;
554
555 /** \brief Surface to store reconstructed frame, not used for enc only case. */
556 VASurfaceID reconstructed_frame;
557
558 /** \brief Buffer to store coded data. */
559 VABufferID coded_buf;
560
561 /** \brief Reference frame buffers.
562 * Each entry of the array specifies the surface index of the picture
563 * that is referred by current picture or will be referred by any future
564 * picture. The valid entries take value from 0 to 127, inclusive.
565 * Non-valid entries, those do not point to pictures which are referred
566 * by current picture or future pictures, should take value 0xFF.
567 * Other values are not allowed.
568 *
569 * Application should update this array based on the refreshing
570 * information expected.
571 */
572 VASurfaceID reference_frames[8];
573
574 /** \brief Reference index list.
575 * Contains a list of indices into refernce_frames[].
576 * Indice with refernce frames range: [LAST_FRAME - LAST_FRAME,
577 * LAST2_FRAME - LAST_FRAME, ..., ALTREF2_FRAME - LAST_FRAME].
578 * #define LAST_FRAME 1
579 * #define LAST2_FRAME 2
580 * #define LAST3_FRAME 3
581 * #define GOLDEN_FRAME 4
582 * #define BWDREF_FRAME 5
583 * #define ALTREF_FRAME 6
584 * #define ALTREF2_FRAME 7
585 * value range [0..7].
586 */
587 uint8_t ref_frame_idx[7];
588
589 /** \brief When hierarchical_level_plus1 > 0, hierarchical_level_plus1-1 indicates
590 * the current frame's level. If VAEncMiscParameterTemporalLayerStructure
591 * is valid (number_of_layers >0), hierarchical_level_plus1 shouldn't larger than number_of_layers.
592 */
593 uint8_t hierarchical_level_plus1;
594
595 /** \brief primary reference frame.
596 * Index into reference_frames[]
597 * segment id map, context table, etc. come from the reference
598 * frame pointed by this index.
599 * value range [0..7].
600 */
601 uint8_t primary_ref_frame;
602
603 /** \brief Corresponds to AV1 syntax element of the same name. */
604 uint8_t order_hint;
605
606 /** \brief Corresponds to AV1 syntax element of the same name. */
607 uint8_t refresh_frame_flags;
608
609 /** \brief Reserved bytes for future use, must be zero. */
610 uint8_t reserved8bits1;
611
612 /** \brief Suggest which frames to be used as references.
613 * see struct #VARefFrameCtrl for details.
614 */
615 VARefFrameCtrlAV1 ref_frame_ctrl_l0;
616 VARefFrameCtrlAV1 ref_frame_ctrl_l1;
617
618 union {
619 struct {
620 /** \brief frame type.
621 * 0: key_frame.
622 * 1: inter_frame.
623 * 2: intra_only frame.
624 * 3: switch_frame (app needs to set error_resilient_mode = 1,
625 * refresh_frame_flags, etc approperately.).
626 */
627 uint32_t frame_type : 2;
628 /** \brief Corresponds to AV1 syntax element of the same name. */
629 uint32_t error_resilient_mode : 1;
630 /** \brief Corresponds to AV1 syntax element of the same name. */
631 uint32_t disable_cdf_update : 1;
632 /** \brief Corresponds to AV1 syntax element of the same name. */
633 uint32_t use_superres : 1;
634 /** \brief Corresponds to AV1 syntax element of the same name. */
635 uint32_t allow_high_precision_mv : 1;
636 /** \brief Corresponds to AV1 syntax element of the same name. */
637 uint32_t use_ref_frame_mvs : 1;
638 /** \brief Corresponds to AV1 syntax element of the same name. */
639 uint32_t disable_frame_end_update_cdf : 1;
640 /** \brief Corresponds to AV1 syntax element of the same name. */
641 uint32_t reduced_tx_set : 1;
642
643 /** \brief For single tile group, app may choose to use one frame obu
644 * to replace one frame header obu + one tile group obu.
645 * Invalid if num_tile_groups_minus1 > 0.
646 */
647 uint32_t enable_frame_obu : 1;
648
649 /** \brief Indicate the current frame will be used as a long term reference. */
650 uint32_t long_term_reference : 1;
651 /** \brief If the encoded frame will not be referred by other frames,
652 * its recon may not be generated in order to save memory bandwidth.
653 */
654 uint32_t disable_frame_recon : 1;
655 /** \brief Corresponds to AV1 syntax element of the same name. */
656 uint32_t allow_intrabc : 1;
657 /** \brief Equal to 1 indicates that intra blocks may use palette encoding.
658 * Otherwise disable palette encoding.
659 */
660 uint32_t palette_mode_enable : 1;
661 /** \brief Corresponds to AV1 syntax element of the same name. */
662 uint32_t allow_screen_content_tools : 1;
663 /** \brief Corresponds to AV1 syntax element of the same name. */
664 uint32_t force_integer_mv : 1;
665 /** \brief Reserved bytes for future use, must be zero. */
666 uint32_t reserved : 16;
667 } bits;
668 uint32_t value;
669 } picture_flags;
670
671 /** \brief Block size for each Segment ID in Segment Map.
672 * should be \c VA_SEGID_BLOCK_XXXX;
673 */
674 uint8_t seg_id_block_size;
675
676 /** \brief Number of tile groups minus 1.
677 * value range [0..255].
678 */
679 uint8_t num_tile_groups_minus1;
680
681 /** \brief Temporal id of the frame.*/
682 uint8_t temporal_id;
683
684 /** \brief Deblock filter parameters.
685 * value range [0..63].
686 */
687 uint8_t filter_level[2];
688 uint8_t filter_level_u;
689 uint8_t filter_level_v;
690
691 union {
692 struct {
693 /** \brief Sharpness level for deblock filter.
694 * value range [0..7].
695 */
696 uint8_t sharpness_level : 3;
697 uint8_t mode_ref_delta_enabled : 1;
698 uint8_t mode_ref_delta_update : 1;
699 /** \brief Reserved bytes for future use, must be zero. */
700 uint8_t reserved : 3;
701 } bits;
702 uint8_t value;
703 } loop_filter_flags;
704
705 /** \brief Super resolution scale denominator.
706 * value range [9..16].
707 */
708 uint8_t superres_scale_denominator;
709 /** \brief Corresponds to AV1 syntax element of the same name. */
710 uint8_t interpolation_filter;
711
712 /** \brief Loop filter ref deltas.
713 * value range [-63..63].
714 */
715 int8_t ref_deltas[8];
716
717 /** \brief Loop filter mode deltas.
718 * value range [-63..63].
719 */
720 int8_t mode_deltas[2];
721
722 /** \brief Quantization params. */
723 uint8_t base_qindex;
724 int8_t y_dc_delta_q;
725 int8_t u_dc_delta_q;
726 int8_t u_ac_delta_q;
727 int8_t v_dc_delta_q;
728 int8_t v_ac_delta_q;
729
730 /** \brief Min value for base q index for BRC.
731 * value range [1..255].
732 */
733 uint8_t min_base_qindex;
734
735 /** \brief Max value for base q index for BRC.
736 * value range [1..255].
737 */
738 uint8_t max_base_qindex;
739
740 /** \brief Quantization matrix. */
741 union {
742 struct {
743 /** \brief Corresponds to AV1 syntax element of the same name. */
744 uint16_t using_qmatrix : 1;
745 /** \brief Following parameters only valid when using_qmatrix == 1. */
746 uint16_t qm_y : 4;
747 /** \brief Corresponds to AV1 syntax element of the same name. */
748 uint16_t qm_u : 4;
749 /** \brief Corresponds to AV1 syntax element of the same name. */
750 uint16_t qm_v : 4;
751 /** \brief Reserved bytes for future use, must be zero. */
752 uint16_t reserved : 3;
753 } bits;
754 uint16_t value;
755 } qmatrix_flags;
756
757 /** \brief Reserved bytes for future use, must be zero. */
758 uint16_t reserved16bits1;
759
760 union {
761 struct {
762 /** \brief Specify whether quantizer index delta values are present.
763 * value range [0..1]. */
764 uint32_t delta_q_present : 1;
765 /** \brief Corresponds to AV1 syntax element of the same name.
766 * value range [0..3]. */
767 uint32_t delta_q_res : 2;
768
769 /** \brief Specify whether loop filter delta values are present.
770 * value range [0..1]. */
771 uint32_t delta_lf_present : 1;
772 /** \brief Corresponds to AV1 syntax element of the same name.
773 * value range [0..3]. */
774 uint32_t delta_lf_res : 2;
775 /** \brief Corresponds to AV1 syntax element of the same name.
776 * value range [0..1]. */
777 uint32_t delta_lf_multi : 1;
778
779 /** \brief Corresponds to AV1 syntax element of the same name.
780 * 0: ONLY_4X4;
781 * 1: TX_MODE_LARGEST;
782 * 2: TX_MODE_SELECT;
783 * 3: Invalid.
784 */
785 uint32_t tx_mode : 2;
786
787 /** \brief Indicates whether to use single or compound reference prediction.
788 * 0: SINGLE_REFERENCE;
789 * 1: COMPOUND_REFERENCE;
790 * 2: REFERENCE_MODE_SELECT.
791 * 3: Invalid.
792 *
793 * Value 2 means driver make decision to use single reference or compound reference.
794 */
795 uint32_t reference_mode : 2;
796 /** \brief Corresponds to AV1 syntax element of the same name.
797 * value range [0..1].
798 */
799 uint32_t skip_mode_present : 1;
800 /** \brief Reserved bytes for future use, must be zero. */
801 uint32_t reserved : 20;
802 } bits;
803 uint32_t value;
804 } mode_control_flags;
805
806 /** \brief Segmentation parameters. */
807 VAEncSegParamAV1 segments;
808
809 /** \brief Number of tile columns. */
810 uint8_t tile_cols;
811 /** \brief Number of tile rows. */
812 uint8_t tile_rows;
813
814 /** \brief Reserved bytes for future use, must be zero. */
815 uint16_t reserved16bits2;
816
817 /** \brief The last tile column or row size needs to be derived. */
818 uint16_t width_in_sbs_minus_1[63];
819 uint16_t height_in_sbs_minus_1[63];
820
821 /** \brief specify which tile to use for the CDF update.
822 * value range [0..127]*/
823 uint16_t context_update_tile_id;
824
825 /** \brief Corresponds to AV1 syntax element of the same name.
826 * value range [0..3].
827 */
828 uint8_t cdef_damping_minus_3;
829 /** \brief Corresponds to AV1 syntax element of the same name.
830 * value range [0..3].
831 */
832 uint8_t cdef_bits;
833 /** \brief CDEF Y strengths.
834 * value range [0..63]*/
835 uint8_t cdef_y_strengths[8];
836 /** \brief CDEF UV strengths.
837 * value range [0..63]*/
838 uint8_t cdef_uv_strengths[8];
839
840 union {
841 struct {
842 /** \brief Restoration type for Y frame.
843 * value range [0..3].
844 */
845 uint16_t yframe_restoration_type : 2;
846 /** \brief Restoration type for Cb frame.
847 * value range [0..3].
848 */
849 uint16_t cbframe_restoration_type : 2;
850 /** \brief Restoration type for Cr frame.
851 * value range [0..3].
852 */
853 uint16_t crframe_restoration_type : 2;
854 /** \brief Corresponds to AV1 syntax element of the same name.
855 * value range [0..2].
856 */
857 uint16_t lr_unit_shift : 2;
858 /** \brief Corresponds to AV1 syntax element of the same name.
859 * value range [0..1].
860 */
861 uint16_t lr_uv_shift : 1;
862 /** \brief Reserved bytes for future use, must be zero. */
863 uint16_t reserved : 7;
864 } bits;
865 uint16_t value;
866 } loop_restoration_flags;
867
868 /** \brief Global motion. */
869 VAEncWarpedMotionParamsAV1 wm[7];
870
871 /**
872 * Offset in bits for syntax base_q_idx in packed frame header bit stream
873 * from the start of the packed header data.
874 * In BRC mode, this parameter should be set and driver will update base_q_idx in
875 * uncompressed header according to this offset.
876 * In CQP mode, this parameter should be set to 0 and ignored by driver.
877 */
878 uint32_t bit_offset_qindex;
879 /**
880 * Offset in bits for syntax segmentation_enabled of frame header OBU
881 * in packed frame header bit stream from the start of the packed header data.
882 * Valid only in auto segmentation mode. Other than that, this parameter
883 * should be set to 0 and ignored by driver.
884 */
885 uint32_t bit_offset_segmentation;
886 /**
887 * Offset in bits for syntax loop_filter_params() in packed frame
888 * header bit stream from the start of the packed header data.
889 * In BRC mode, this parameter should be set and driver will update filter params
890 * in packed frame header according to this offset.
891 * In CQP mode, this parameter should be set to 0 and ignored by driver.
892 */
893 uint32_t bit_offset_loopfilter_params;
894 /**
895 * In BRC mode, underline encoder should generate the approperiate
896 * CDEF values and write back into uncompressed header. And app
897 * should provide default CDEF values in packed header. This parameter
898 * should point to the starting bit of cdef_params() syntax structure
899 * in packed header.
900 * In CQP mode, this parameter should be set to 0 and ignored by driver.
901 */
902 uint32_t bit_offset_cdef_params;
903 /**
904 * In BRC mode, this parameter indicates the actual bit usage of
905 * cdef_params() syntax structure in packed uncompressed header.
906 * In CQP mode, this parameter should be set to 0 and ignored by driver.
907 */
908 uint32_t size_in_bits_cdef_params;
909
910 /**
911 * Offset in bytes for syntax obu_size of frame header OBU in packed
912 * frame header bit stream from the start of the packed header. The frame
913 * header OBU size depends on the encoded tile sizes. It applies to both
914 * Frame Header OBU and Frame OBU if obu_size needs to be updated by
915 * underline encoder. Otherwise, app can set it to 0 and ignored by driver.
916 *
917 * In BRC mode, obu_size needs to be updated and this parameter should be set.
918 * In CQP mode, obu_size needs to be updated if \c enable_frame_obu == 1. Otherwise
919 * this parameter should be set to 0 and ignored by driver.
920 */
921 uint32_t byte_offset_frame_hdr_obu_size;
922
923 /**
924 * Frame header OBU bit stream size in bits. The frame header obu packed bit
925 * stream contains an obu header, a 4-byte long obu_size field, frame_header_obu()
926 * syntax chain, and a trailing bit if not inside a frame obu. If \c enable_frame_obu == 1,
927 * the value should include and up to the last bit of frame_header_obu() and
928 * excluding the bits generated by byte_alignment(). If \c enable_frame_obu == 0,
929 * the value should include and up to the trailing bit at the end of the frame
930 * header obu. The size will be used by encoder to calculate the final frame
931 * header size after bit shifting due to auto segmentation.
932 * In CQP mode, this parameter should be set to 0 and ignored by driver.
933 */
934 uint32_t size_in_bits_frame_hdr_obu;
935
936 /** \brief Tile Group OBU header */
937 union {
938 struct {
939 /** \brief Corresponds to AV1 syntax element of the same name.
940 * value range [0..1].
941 */
942 uint8_t obu_extension_flag : 1;
943 /** \brief Corresponds to AV1 syntax element of the same name.
944 * value range [0..1].
945 */
946 uint8_t obu_has_size_field : 1;
947 /** \brief Corresponds to AV1 syntax element of the same name.
948 * value range [0..7].
949 */
950 uint8_t temporal_id : 3;
951 /** \brief Corresponds to AV1 syntax element of the same name.
952 * value range [0..2].
953 */
954 uint8_t spatial_id : 2;
955 /** \brief Reserved bytes for future use, must be zero. */
956 uint8_t reserved : 1;
957 } bits;
958 uint8_t value;
959 } tile_group_obu_hdr_info;
960
961 /** \brief The number of frames skipped prior to the current frame.
962 * It includes only the skipped frames that were not counted before.
963 * App may generate the "show_existing_frame" short frame header OBUs
964 * and send to driver with the next frame. Default value 0.
965 */
966 uint8_t number_skip_frames;
967
968 /** \brief Reserved bytes for future use, must be zero. */
969 uint16_t reserved16bits3;
970
971 /** \brief Indicates the application forced frame size change in bytes.
972 * When the value is positive, the frame size is reduced. Otherwise, the frame
973 * size increases. The parameter can be used when application skips frames with
974 * setting of NumSkipFrames. And application can also use it for other scenarios
975 * such as inserting "show_existing_frame" at very end of the sequence.
976 */
977 int32_t skip_frames_reduced_size;
978
979 /** \brief Reserved bytes for future use, must be zero. */
980 uint32_t va_reserved[VA_PADDING_HIGH];
981 } VAEncPictureParameterBufferAV1;
982
983 /**
984 * \brief Tile Group Buffer.
985 */
986 typedef struct _VAEncTileGroupBufferAV1 {
987 /** \brief Tile group start location.
988 * The position of the first tile in current tile group
989 * in raster scan order across the frame.
990 * value range [0..127].
991 */
992 uint8_t tg_start;
993 /** \brief Tile group end location.
994 * The position of the last tile in current tile group
995 * in raster scan order across the frame.
996 * value range [0..127].
997 */
998 uint8_t tg_end;
999
1000 /** \brief Reserved bytes for future use, must be zero. */
1001 uint32_t va_reserved[VA_PADDING_LOW];
1002 } VAEncTileGroupBufferAV1;
1003
1004 /**@}*/
1005
1006 #ifdef __cplusplus
1007 }
1008 #endif
1009
1010 #endif /* VA_ENC_AV1_H */