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

source code of include/va/va_enc_av1.h