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