Merging gst-plugins-bad
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / codecparsers / gstav1parser.h
1 /*
2  * gstav1parser.h
3  *
4  *  Copyright (C) 2018 Georg Ottinger
5  *  Copyright (C) 2019-2020 Intel Corporation
6  *    Author: Georg Ottinger<g.ottinger@gmx.at>
7  *    Author: Junyan He<junyan.he@hotmail.com>
8  *    Author: Victor Jaquez <vjaquez@igalia.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  */
25
26 #ifndef __GST_AV1_PARSER_H__
27 #define __GST_AV1_PARSER_H__
28
29 #ifndef GST_USE_UNSTABLE_API
30 #warning "The AV1 parsing library is unstable API and may change in future."
31 #warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
32 #endif
33
34 #include <gst/gst.h>
35 #include <gst/codecparsers/codecparsers-prelude.h>
36
37 G_BEGIN_DECLS
38
39 #define GST_AV1_MAX_NUM_TEMPORAL_LAYERS        8
40 #define GST_AV1_MAX_NUM_SPATIAL_LAYERS         4
41 #define GST_AV1_MAX_TILE_WIDTH                 4096
42 #define GST_AV1_MAX_TILE_AREA                  (4096 * 2304)
43 #define GST_AV1_TOTAL_REFS_PER_FRAME           8
44 #define GST_AV1_MAX_SEGMENTS                   8
45 #define GST_AV1_SEG_LVL_MAX                    8
46 #define GST_AV1_MAX_TILE_COLS                  64
47 #define GST_AV1_MAX_TILE_ROWS                  64
48
49 #define GST_AV1_REFS_PER_FRAME                 7
50 #define GST_AV1_PRIMARY_REF_NONE               7
51 #define GST_AV1_SUPERRES_NUM                   8
52 #define GST_AV1_SUPERRES_DENOM_MIN             9
53 #define GST_AV1_SUPERRES_DENOM_BITS            3
54 #define GST_AV1_MAX_LOOP_FILTER                63
55 #define GST_AV1_GM_ABS_TRANS_BITS              12
56 #define GST_AV1_GM_ABS_TRANS_ONLY_BITS         9
57 #define GST_AV1_GM_ABS_ALPHA_BITS              12
58 #define GST_AV1_GM_ALPHA_PREC_BITS             15
59 #define GST_AV1_GM_TRANS_PREC_BITS             6
60 #define GST_AV1_GM_TRANS_ONLY_PREC_BITS        3
61 #define GST_AV1_WARPEDMODEL_PREC_BITS          16
62 #define GST_AV1_WARP_PARAM_REDUCE_BITS         6
63 #define GST_AV1_SELECT_SCREEN_CONTENT_TOOLS    2
64 #define GST_AV1_SELECT_INTEGER_MV              2
65 #define GST_AV1_RESTORATION_TILESIZE_MAX       256
66 #define GST_AV1_SEG_LVL_ALT_Q                  0
67 #define GST_AV1_SEG_LVL_REF_FRAME              5
68 /* Following defines are derived from the spec, but not mentioned by
69  * this particular name in the spec */
70 #define GST_AV1_CDEF_MAX                       (1 << 3)
71 #define GST_AV1_MAX_TILE_COUNT                 512
72 #define GST_AV1_MAX_OPERATING_POINTS    \
73   (GST_AV1_MAX_NUM_TEMPORAL_LAYERS * GST_AV1_MAX_NUM_SPATIAL_LAYERS)
74 #define GST_AV1_MAX_SPATIAL_LAYERS             2  /* correct? */
75 #define GST_AV1_MAX_TEMPORAL_GROUP_SIZE        8  /* correct? */
76 #define GST_AV1_MAX_TEMPORAL_GROUP_REFERENCES  8  /* correct? */
77 #define GST_AV1_MAX_NUM_Y_POINTS               16
78 #define GST_AV1_MAX_NUM_CB_POINTS              16
79 #define GST_AV1_MAX_NUM_CR_POINTS              16
80 #define GST_AV1_MAX_NUM_POS_LUMA               25
81 #define GST_AV1_MAX_NUM_PLANES                 3
82
83 #define GST_AV1_DIV_LUT_PREC_BITS              14
84 #define GST_AV1_DIV_LUT_BITS                   8
85 #define GST_AV1_DIV_LUT_NUM                    (1 << GST_AV1_DIV_LUT_BITS)
86
87
88 typedef struct _GstAV1Parser GstAV1Parser;
89
90 typedef struct _GstAV1OBUHeader GstAV1OBUHeader;
91 typedef struct _GstAV1OBU GstAV1OBU;
92
93 typedef struct _GstAV1SequenceHeaderOBU GstAV1SequenceHeaderOBU;
94 typedef struct _GstAV1MetadataOBU GstAV1MetadataOBU;
95 typedef struct _GstAV1FrameHeaderOBU GstAV1FrameHeaderOBU;
96 typedef struct _GstAV1TileListOBU GstAV1TileListOBU;
97 typedef struct _GstAV1TileGroupOBU GstAV1TileGroupOBU;
98 typedef struct _GstAV1FrameOBU GstAV1FrameOBU;
99
100 typedef struct _GstAV1OperatingPoint GstAV1OperatingPoint;
101 typedef struct _GstAV1DecoderModelInfo GstAV1DecoderModelInfo;
102 typedef struct _GstAV1TimingInfo GstAV1TimingInfo;
103 typedef struct _GstAV1ColorConfig GstAV1ColorConfig;
104 typedef struct _GstAV1MetadataITUT_T35 GstAV1MetadataITUT_T35;
105 typedef struct _GstAV1MetadataHdrCll GstAV1MetadataHdrCll;
106 typedef struct _GstAV1MetadataHdrMdcv GstAV1MetadataHdrMdcv;
107 typedef struct _GstAV1MetadataScalability GstAV1MetadataScalability;
108 typedef struct _GstAV1MetadataTimecode GstAV1MetadataTimecode;
109 typedef struct _GstAV1LoopFilterParams GstAV1LoopFilterParams;
110 typedef struct _GstAV1QuantizationParams GstAV1QuantizationParams;
111 typedef struct _GstAV1SegmenationParams GstAV1SegmenationParams;
112 typedef struct _GstAV1TileInfo GstAV1TileInfo;
113 typedef struct _GstAV1CDEFParams GstAV1CDEFParams;
114 typedef struct _GstAV1LoopRestorationParams GstAV1LoopRestorationParams;
115 typedef struct _GstAV1GlobalMotionParams GstAV1GlobalMotionParams;
116 typedef struct _GstAV1FilmGrainParams GstAV1FilmGrainParams;
117
118 typedef struct _GstAV1ReferenceFrameInfo GstAV1ReferenceFrameInfo;
119
120 /**
121  * GstAV1ParserResult:
122  * @GST_AV1_PARSER_OK: successful return
123  * @GST_AV1_PARSER_NO_MORE_DATA: the parser needs more data for one OBU
124  * @GST_AV1_PARSER_DROP: no need to handle this OBU, skip it
125  * @GST_AV1_PARSER_BITSTREAM_ERROR: stream error, for example, include invalid bits
126  * @GST_AV1_PARSER_MISSING_OBU_REFERENCE: no reference, for example, no sequence found
127  * @GST_AV1_PARSER_INVALID_OPERATION: something like invalid parameters
128  *
129  * Defines the result of parser process
130  */
131 typedef enum {
132   GST_AV1_PARSER_OK = 0,
133   GST_AV1_PARSER_NO_MORE_DATA = 1,
134   GST_AV1_PARSER_DROP = 2,
135   GST_AV1_PARSER_BITSTREAM_ERROR = 3,
136   GST_AV1_PARSER_MISSING_OBU_REFERENCE = 4,
137   GST_AV1_PARSER_INVALID_OPERATION = 5,
138 } GstAV1ParserResult;
139
140 /**
141  * GstAV1Profile:
142  * @GST_AV1_PROFILE_0: 8-bit and 10-bit 4:2:0 and 4:0:0 only.
143  * @GST_AV1_PROFILE_1: 8-bit and 10-bit 4:4:4.
144  * @GST_AV1_PROFILE_2: 8-bit and 10-bit 4:2:2, 12-bit 4:0:0 4:2:2 and 4:4:4
145  * @GST_AV1_PROFILE_UNDEFINED: unknow AV1 profile (Since: 1.20)
146  *
147  * Defines the AV1 profiles
148  */
149 /**
150  * GST_AV1_PROFILE_UNDEFINED:
151  *
152  * unknow AV1 profile
153  *
154  * Since: 1.20
155  */
156 typedef enum {
157   GST_AV1_PROFILE_0 = 0,
158   GST_AV1_PROFILE_1 = 1,
159   GST_AV1_PROFILE_2 = 2,
160   GST_AV1_PROFILE_UNDEFINED,
161 } GstAV1Profile;
162
163 /**
164  * GstAV1OBUType:
165  * @GST_AV1_OBU_RESERVED_0: Reserved 0
166  * @GST_AV1_OBU_SEQUENCE_HEADER: Sequence Header OBU
167  * @GST_AV1_OBU_TEMPORAL_DELIMITER: Temporal Delimiter OBU
168  * @GST_AV1_OBU_FRAME_HEADER: Frame Header OBU
169  * @GST_AV1_OBU_TILE_GROUP: Tile Group OBU
170  * @GST_AV1_OBU_METADATA: Metadata OBU
171  * @GST_AV1_OBU_FRAME: Frame OBU (includes Frame Header and one Tile Group)
172  * @GST_AV1_OBU_REDUNDANT_FRAME_HEADER: Redundant Frame Header OBU
173  * @GST_AV1_OBU_TILE_LIST: Tile LIst OBU
174  * @GST_AV1_OBU_RESERVED_9: Reserved 9
175  * @GST_AV1_OBU_RESERVED_10: Reserved 10
176  * @GST_AV1_OBU_RESERVED_11: Reserved 11
177  * @GST_AV1_OBU_RESERVED_12: Reserved 12
178  * @GST_AV1_OBU_RESERVED_13: Reserved 13
179  * @GST_AV1_OBU_RESERVED_14: Reserved 14
180  * @GST_AV1_OBU_PADDING: Padding
181  *
182  * Defines all the possible OBU types
183  */
184 typedef enum {
185   GST_AV1_OBU_RESERVED_0 = 0,
186   GST_AV1_OBU_SEQUENCE_HEADER = 1,
187   GST_AV1_OBU_TEMPORAL_DELIMITER = 2,
188   GST_AV1_OBU_FRAME_HEADER = 3,
189   GST_AV1_OBU_TILE_GROUP = 4,
190   GST_AV1_OBU_METADATA = 5,
191   GST_AV1_OBU_FRAME = 6,
192   GST_AV1_OBU_REDUNDANT_FRAME_HEADER = 7,
193   GST_AV1_OBU_TILE_LIST = 8,
194   GST_AV1_OBU_RESERVED_9 = 9,
195   GST_AV1_OBU_RESERVED_10 = 10,
196   GST_AV1_OBU_RESERVED_11 = 11,
197   GST_AV1_OBU_RESERVED_12 = 12,
198   GST_AV1_OBU_RESERVED_13 = 13,
199   GST_AV1_OBU_RESERVED_14 = 14,
200   GST_AV1_OBU_PADDING = 15,
201 } GstAV1OBUType;
202
203 /**
204  * GstAV1SeqLevels:
205  * @GST_AV1_SEQ_LEVEL_2_0: Level 2.0
206  * @GST_AV1_SEQ_LEVEL_2_1: Level 2.1
207  * @GST_AV1_SEQ_LEVEL_2_2: Level 2.2
208  * @GST_AV1_SEQ_LEVEL_2_3: Level 2.3
209  * @GST_AV1_SEQ_LEVEL_3_0: Level 3.0
210  * @GST_AV1_SEQ_LEVEL_3_1: Level 3.1
211  * @GST_AV1_SEQ_LEVEL_3_2: Level 3.2
212  * @GST_AV1_SEQ_LEVEL_3_3: Level 3.3
213  * @GST_AV1_SEQ_LEVEL_4_0: Level 4.0
214  * @GST_AV1_SEQ_LEVEL_4_1: Level 4.1
215  * @GST_AV1_SEQ_LEVEL_4_2: Level 4.2
216  * @GST_AV1_SEQ_LEVEL_4_3: Level 4.3
217  * @GST_AV1_SEQ_LEVEL_5_0: Level 5.0
218  * @GST_AV1_SEQ_LEVEL_5_1: Level 5.1
219  * @GST_AV1_SEQ_LEVEL_5_2: Level 5.2
220  * @GST_AV1_SEQ_LEVEL_5_3: Level 5.3
221  * @GST_AV1_SEQ_LEVEL_6_0: Level 6.0
222  * @GST_AV1_SEQ_LEVEL_6_1: Level 6.1
223  * @GST_AV1_SEQ_LEVEL_6_2: Level 6.2
224  * @GST_AV1_SEQ_LEVEL_6_3: Level 6.3
225  * @GST_AV1_SEQ_LEVEL_7_0: Level 7.0
226  * @GST_AV1_SEQ_LEVEL_7_1: Level 7.1
227  * @GST_AV1_SEQ_LEVEL_7_2: Level 7.2
228  * @GST_AV1_SEQ_LEVEL_7_3: Level 7.3
229  * @GST_AV1_SEQ_LEVELS: all valid levels
230  * @GST_AV1_SEQ_LEVEL_MAX: Maximum parameters
231  *
232  * Defines all the possible OBU types
233  */
234 typedef enum {
235   GST_AV1_SEQ_LEVEL_2_0 = 0,
236   GST_AV1_SEQ_LEVEL_2_1 = 1,
237   GST_AV1_SEQ_LEVEL_2_2 = 2,
238   GST_AV1_SEQ_LEVEL_2_3 = 3,
239   GST_AV1_SEQ_LEVEL_3_0 = 4,
240   GST_AV1_SEQ_LEVEL_3_1 = 5,
241   GST_AV1_SEQ_LEVEL_3_2 = 6,
242   GST_AV1_SEQ_LEVEL_3_3 = 7,
243   GST_AV1_SEQ_LEVEL_4_0 = 8,
244   GST_AV1_SEQ_LEVEL_4_1 = 9,
245   GST_AV1_SEQ_LEVEL_4_2 = 10,
246   GST_AV1_SEQ_LEVEL_4_3 = 11,
247   GST_AV1_SEQ_LEVEL_5_0 = 12,
248   GST_AV1_SEQ_LEVEL_5_1 = 13,
249   GST_AV1_SEQ_LEVEL_5_2 = 14,
250   GST_AV1_SEQ_LEVEL_5_3 = 15,
251   GST_AV1_SEQ_LEVEL_6_0 = 16,
252   GST_AV1_SEQ_LEVEL_6_1 = 17,
253   GST_AV1_SEQ_LEVEL_6_2 = 18,
254   GST_AV1_SEQ_LEVEL_6_3 = 19,
255   GST_AV1_SEQ_LEVEL_7_0 = 20,
256   GST_AV1_SEQ_LEVEL_7_1 = 21,
257   GST_AV1_SEQ_LEVEL_7_2 = 22,
258   GST_AV1_SEQ_LEVEL_7_3 = 23,
259   GST_AV1_SEQ_LEVELS,
260   GST_AV1_SEQ_LEVEL_MAX = 31
261 } GstAV1SeqLevels;
262
263 /**
264  * GstAV1MetadataType:
265  * @GST_AV1_METADATA_TYPE_RESERVED_0: Reserved 0
266  * @GST_AV1_METADATA_TYPE_HDR_CLL: Metadata high dynamic range content
267  *   light level semantics
268  * @GST_AV1_METADATA_TYPE_HDR_MDCV: Metadata high dynamic range mastering
269  *   display color volume semantics
270  * @GST_AV1_METADATA_TYPE_SCALABILITY: Metadata scalability semantics
271  * @GST_AV1_METADATA_TYPE_ITUT_T35: Metadata ITUT T35 semantics
272  * @GST_AV1_METADATA_TYPE_TIMECODE: Timecode semantics
273  */
274 typedef enum {
275   GST_AV1_METADATA_TYPE_RESERVED_0 = 0,
276   GST_AV1_METADATA_TYPE_HDR_CLL = 1,
277   GST_AV1_METADATA_TYPE_HDR_MDCV = 2,
278   GST_AV1_METADATA_TYPE_SCALABILITY = 3,
279   GST_AV1_METADATA_TYPE_ITUT_T35 = 4,
280   GST_AV1_METADATA_TYPE_TIMECODE = 5,
281 } GstAV1MetadataType;
282
283 /**
284  * GstAV1ScalabilityModes:
285  * @GST_AV1_SCALABILITY_L1T2: 1 spatial layer, 2 temporal layers
286  * @GST_AV1_SCALABILITY_L1T3: 1 spatial layer, 3 temporal layers
287  * @GST_AV1_SCALABILITY_L2T1: 2 spatial layer (ratio 2:1), 1 temporal layer,
288  *  inter-layer dependency
289  * @GST_AV1_SCALABILITY_L2T2: 2 spatial layer (ratio 2:1), 2 temporal layer,
290  *  inter-layer dependency
291  * @GST_AV1_SCALABILITY_L2T3: 2 spatial layer (ratio 2:1), 3 temporal layer,
292  *  inter-layer dependency
293  * @GST_AV1_SCALABILITY_S2T1: 2 spatial layer (ratio 2:1), 1 temporal layer
294  * @GST_AV1_SCALABILITY_S2T2: 2 spatial layer (ratio 2:1), 2 temporal layer
295  * @GST_AV1_SCALABILITY_S2T3: 2 spatial layer (ratio 2:1), 3 temporal layer
296  * @GST_AV1_SCALABILITY_L2T1h: 2 spatial layer (ratio 1.5:1), 1 temporal layer,
297  *  inter-layer dependency
298  * @GST_AV1_SCALABILITY_L2T2h: 2 spatial layer (ratio 1.5:1), 2 temporal layer,
299  *  inter-layer dependency
300  * @GST_AV1_SCALABILITY_L2T3h: 2 spatial layer (ratio 1.5:1), 3 temporal layer,
301  *  inter-layer dependency
302  * @GST_AV1_SCALABILITY_S2T1h: 2 spatial layer (ratio 1.5:1), 1 temporal layer
303  * @GST_AV1_SCALABILITY_S2T2h: 2 spatial layer (ratio 1.5:1), 2 temporal layer
304  * @GST_AV1_SCALABILITY_S2T3h: 2 spatial layer (ratio 1.5:1), 3 temporal layer
305  * @GST_AV1_SCALABILITY_SS: Use scalability structure #GstAV1MetadataScalability
306  */
307 typedef enum {
308   GST_AV1_SCALABILITY_L1T2 = 0,
309   GST_AV1_SCALABILITY_L1T3 = 1,
310   GST_AV1_SCALABILITY_L2T1 = 2,
311   GST_AV1_SCALABILITY_L2T2 = 3,
312   GST_AV1_SCALABILITY_L2T3 = 4,
313   GST_AV1_SCALABILITY_S2T1 = 5,
314   GST_AV1_SCALABILITY_S2T2 = 6,
315   GST_AV1_SCALABILITY_S2T3 = 7,
316   GST_AV1_SCALABILITY_L2T1h = 8,
317   GST_AV1_SCALABILITY_L2T2h = 9,
318   GST_AV1_SCALABILITY_L2T3h = 10,
319   GST_AV1_SCALABILITY_S2T1h = 11,
320   GST_AV1_SCALABILITY_S2T2h = 12,
321   GST_AV1_SCALABILITY_S2T3h = 13,
322   GST_AV1_SCALABILITY_SS = 14,
323 } GstAV1ScalabilityModes;
324
325 /**
326  * GstAV1ColorPrimaries:
327  * @GST_AV1_CP_BT_709: BT.709
328  * @GST_AV1_CP_UNSPECIFIED: Unspecified
329  * @GST_AV1_CP_BT_470_M: BT.470 System M (historical)
330  * @GST_AV1_CP_BT_470_B_G:BT.470 System B, G (historical),
331  * @GST_AV1_CP_BT_601: BT.601
332  * @GST_AV1_CP_SMPTE_240: SMPTE 240
333  * @GST_AV1_CP_GENERIC_FILM: Generic film (color filters using illuminant C,
334  * @GST_AV1_CP_BT_2020: BT.2020, BT.2100,
335  * @GST_AV1_CP_XYZ: SMPTE 428 (CIE 1921 XYZ),
336  * @GST_AV1_CP_SMPTE_431: SMPTE RP 431-2
337  * @GST_AV1_CP_SMPTE_432: SMPTE EG 432-1
338  * @GST_AV1_CP_EBU_3213: EBU Tech. 3213-E
339  */
340 typedef enum {
341   GST_AV1_CP_BT_709 = 1,
342   GST_AV1_CP_UNSPECIFIED = 2,
343   GST_AV1_CP_BT_470_M = 4,
344   GST_AV1_CP_BT_470_B_G = 5,
345   GST_AV1_CP_BT_601 = 6,
346   GST_AV1_CP_SMPTE_240 = 7,
347   GST_AV1_CP_GENERIC_FILM = 8,
348   GST_AV1_CP_BT_2020 = 9,
349   GST_AV1_CP_XYZ = 10,
350   GST_AV1_CP_SMPTE_431 = 11,
351   GST_AV1_CP_SMPTE_432 = 12,
352   GST_AV1_CP_EBU_3213 = 22,
353 } GstAV1ColorPrimaries;
354
355 /**
356  * GstAV1TransferCharacteristics:
357  * @GST_AV1_TC_RESERVED_0: For future use
358  * @GST_AV1_TC_BT_709: BT.709
359  * @GST_AV1_TC_UNSPECIFIED: Unspecified
360  * @GST_AV1_TC_RESERVED_3: For future use
361  * @GST_AV1_TC_BT_470_M: BT.470 System M (historical)
362  * @GST_AV1_TC_BT_470_B_G: BT.470 System B, G (historical)
363  * @GST_AV1_TC_BT_601: BT.601
364  * @GST_AV1_TC_SMPTE_240: SMPTE 240 M
365  * @GST_AV1_TC_LINEAR: Linear
366  * @GST_AV1_TC_LOG_100: Logarithmic (100 : 1 range)
367  * @GST_AV1_TC_LOG_100_SQRT10: Logarithmic (100 * Sqrt(10) : 1 range)
368  * @GST_AV1_TC_IEC_61966: IEC 61966-2-4
369  * @GST_AV1_TC_BT_1361: BT.1361
370  * @GST_AV1_TC_SRGB: sRGB or sYCC
371  * @GST_AV1_TC_BT_2020_10_BIT: BT.2020 10-bit systems
372  * @GST_AV1_TC_BT_2020_12_BIT: BT.2020 12-bit systems
373  * @GST_AV1_TC_SMPTE_2084: SMPTE ST 2084, ITU BT.2100 PQ
374  * @GST_AV1_TC_SMPTE_428: SMPTE ST 428
375  * @GST_AV1_TC_HLG: BT.2100 HLG, ARIB STD-B67
376  */
377 typedef enum {
378   GST_AV1_TC_RESERVED_0 = 0,
379   GST_AV1_TC_BT_709 = 1,
380   GST_AV1_TC_UNSPECIFIED = 2,
381   GST_AV1_TC_RESERVED_3 = 3,
382   GST_AV1_TC_BT_470_M = 4,
383   GST_AV1_TC_BT_470_B_G = 5,
384   GST_AV1_TC_BT_601 = 6,
385   GST_AV1_TC_SMPTE_240 = 7,
386   GST_AV1_TC_LINEAR = 8,
387   GST_AV1_TC_LOG_100 = 9,
388   GST_AV1_TC_LOG_100_SQRT10 = 10,
389   GST_AV1_TC_IEC_61966 = 11,
390   GST_AV1_TC_BT_1361 = 12,
391   GST_AV1_TC_SRGB = 13,
392   GST_AV1_TC_BT_2020_10_BIT = 14,
393   GST_AV1_TC_BT_2020_12_BIT = 15,
394   GST_AV1_TC_SMPTE_2084 = 16,
395   GST_AV1_TC_SMPTE_428 = 17,
396   GST_AV1_TC_HLG = 18,
397 } GstAV1TransferCharacteristics;
398
399 /**
400  * GstAV1MatrixCoefficients:
401  * @GST_AV1_MC_IDENTITY: Identity matrix
402  * @GST_AV1_MC_BT_709: BT.709
403  * @GST_AV1_MC_UNSPECIFIED: Unspecified
404  * @GST_AV1_MC_RESERVED_3: For future use
405  * @GST_AV1_MC_FCC: US FCC 73.628
406  * @GST_AV1_MC_BT_470_B_G: BT.470 System B, G (historical)
407  * @GST_AV1_MC_BT_601: BT.601
408  * @GST_AV1_MC_SMPTE_240: SMPTE 240 M
409  * @GST_AV1_MC_SMPTE_YCGCO: YCgCo
410  * @GST_AV1_MC_BT_2020_NCL: BT.2020 non-constant luminance, BT.2100 YCbCr
411  * @GST_AV1_MC_BT_2020_CL: BT.2020 constant luminance
412  * @GST_AV1_MC_SMPTE_2085: SMPTE ST 2085 YDzDx
413  * @GST_AV1_MC_CHROMAT_NCL: Chromaticity-derived non-constant luminance
414  * @GST_AV1_MC_CHROMAT_CL: Chromaticity-derived constant luminancw
415  * @GST_AV1_MC_ICTCP: BT.2100 ICtCp
416  */
417 typedef enum {
418   GST_AV1_MC_IDENTITY = 0,
419   GST_AV1_MC_BT_709 = 1,
420   GST_AV1_MC_UNSPECIFIED = 2,
421   GST_AV1_MC_RESERVED_3 = 3,
422   GST_AV1_MC_FCC = 4,
423   GST_AV1_MC_BT_470_B_G = 5,
424   GST_AV1_MC_BT_601 = 6,
425   GST_AV1_MC_SMPTE_240 = 7,
426   GST_AV1_MC_SMPTE_YCGCO = 8,
427   GST_AV1_MC_BT_2020_NCL = 9,
428   GST_AV1_MC_BT_2020_CL = 10,
429   GST_AV1_MC_SMPTE_2085 = 11,
430   GST_AV1_MC_CHROMAT_NCL = 12,
431   GST_AV1_MC_CHROMAT_CL = 13,
432   GST_AV1_MC_ICTCP = 14,
433 } GstAV1MatrixCoefficients;
434
435 /**
436  * GstAV1ChromaSamplePositions:
437  * @GST_AV1_CSP_UNKNOWN: Unknown (in this case the source video transfer
438  *  function must be signaled outside the AV1 bitstream).
439  * @GST_AV1_CSP_VERTICAL: Horizontally co-located with (0, 0) luma sample,
440  *  vertical position in the middle between two luma samples.
441  * @GST_AV1_CSP_COLOCATED: co-located with (0, 0) luma sample.
442  * @GST_AV1_CSP_RESERVED: For future use.
443  */
444 typedef enum {
445   GST_AV1_CSP_UNKNOWN = 0,
446   GST_AV1_CSP_VERTICAL = 1,
447   GST_AV1_CSP_COLOCATED = 2,
448   GST_AV1_CSP_RESERVED = 3,
449 } GstAV1ChromaSamplePositions;
450
451 /**
452  * GstAV1FrameType:
453  * @GST_AV1_KEY_FRAME: Key Frame
454  * @GST_AV1_INTER_FRAME: InterFrame
455  * @GST_AV1_INTRA_ONLY_FRAME: Intra-Only Frame
456  * @GST_AV1_SWITCH_FRAME: Switch Frame
457  */
458 typedef enum {
459   GST_AV1_KEY_FRAME = 0,
460   GST_AV1_INTER_FRAME = 1,
461   GST_AV1_INTRA_ONLY_FRAME = 2,
462   GST_AV1_SWITCH_FRAME = 3,
463 } GstAV1FrameType;
464
465 /**
466  * GstAV1InterpolationFilter:
467  * @GST_AV1_INTERPOLATION_FILTER_EIGHTTAP: Eighttap
468  * @GST_AV1_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH: Eighttap Smooth
469  * @GST_AV1_INTERPOLATION_FILTER_EIGHTTAP_SHARP: Eighttap Sharp
470  * @GST_AV1_INTERPOLATION_FILTER_BILINEAR: Bilinear
471  * @GST_AV1_INTERPOLATION_FILTER_SWITCHABLE: Filter is swichtable
472  */
473 typedef enum {
474   GST_AV1_INTERPOLATION_FILTER_EIGHTTAP = 0,
475   GST_AV1_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH = 1,
476   GST_AV1_INTERPOLATION_FILTER_EIGHTTAP_SHARP = 2,
477   GST_AV1_INTERPOLATION_FILTER_BILINEAR = 3,
478   GST_AV1_INTERPOLATION_FILTER_SWITCHABLE = 4,
479 } GstAV1InterpolationFilter;
480
481 /**
482  * GstAV1TXModes:
483  * @GST_AV1_TX_MODE_ONLY_4x4: the inverse transform will use only 4x4 transforms.
484  * @GST_AV1_TX_MODE_LARGEST: the inverse transform will use the largest transform
485  *   size that fits inside the block.
486  * @GST_AV1_TX_MODE_SELECT: the choice of transform size is specified explicitly
487  *   for each block.
488  */
489 typedef enum {
490   GST_AV1_TX_MODE_ONLY_4x4 = 0,
491   GST_AV1_TX_MODE_LARGEST = 1,
492   GST_AV1_TX_MODE_SELECT = 2,
493 } GstAV1TXModes;
494
495 /**
496  * GstAV1FrameRestorationType:
497  * @GST_AV1_FRAME_RESTORE_NONE: no filtering is applied
498  * @GST_AV1_FRAME_RESTORE_WIENER: Wiener filter process is invoked
499  * @GST_AV1_FRAME_RESTORE_SGRPROJ: self guided filter proces is invoked
500  * @GST_AV1_FRAME_RESTORE_SWITCHABLE: restoration filter is swichtable
501  */
502 typedef enum {
503   GST_AV1_FRAME_RESTORE_NONE = 0,
504   GST_AV1_FRAME_RESTORE_WIENER = 1,
505   GST_AV1_FRAME_RESTORE_SGRPROJ = 2,
506   GST_AV1_FRAME_RESTORE_SWITCHABLE = 3,
507 } GstAV1FrameRestorationType;
508
509 /**
510  * GstAV1ReferenceFrame:
511  * @GST_AV1_REF_INTRA_FRAME: Intra Frame Reference
512  * @GST_AV1_REF_LAST_FRAME: Last Reference Frame
513  * @GST_AV1_REF_LAST2_FRAME: Last2 Reference Frame
514  * @GST_AV1_REF_LAST3_FRAME: Last3 Reference Frame
515  * @GST_AV1_REF_GOLDEN_FRAME: Golden Reference Frame
516  * @GST_AV1_REF_BWDREF_FRAME: BWD Reference Frame
517  * @GST_AV1_REF_ALTREF2_FRAME: Alternative2 Reference Frame
518  * @GST_AV1_REF_ALTREF_FRAME: Alternative Reference Frame
519  * @GST_AV1_NUM_REF_FRAMES: Total Reference Frame Number
520  */
521 typedef enum {
522   GST_AV1_REF_INTRA_FRAME = 0,
523   GST_AV1_REF_LAST_FRAME = 1,
524   GST_AV1_REF_LAST2_FRAME = 2,
525   GST_AV1_REF_LAST3_FRAME = 3,
526   GST_AV1_REF_GOLDEN_FRAME = 4,
527   GST_AV1_REF_BWDREF_FRAME = 5,
528   GST_AV1_REF_ALTREF2_FRAME = 6,
529   GST_AV1_REF_ALTREF_FRAME = 7,
530   GST_AV1_NUM_REF_FRAMES
531 } GstAV1ReferenceFrame;
532
533 /**
534  * GstAV1WarpModelType:
535  * @GST_AV1_WARP_MODEL_IDENTITY: Warp model is just an identity transform
536  * @GST_AV1_WARP_MODEL_TRANSLATION: Warp model is a pure translation
537  * @GST_AV1_WARP_MODEL_ROTZOOM: Warp model is a rotation + symmetric zoom
538  *     + translation
539  * @GST_AV1_WARP_MODEL_AFFINE: Warp model is a general affine transform
540  */
541 typedef enum {
542   GST_AV1_WARP_MODEL_IDENTITY = 0,
543   GST_AV1_WARP_MODEL_TRANSLATION = 1,
544   GST_AV1_WARP_MODEL_ROTZOOM = 2,
545   GST_AV1_WARP_MODEL_AFFINE = 3,
546 } GstAV1WarpModelType;
547
548 /**
549  * GstAV1OBUHeader:
550  * @obu_type: the type of data structure contained in the OBU payload.
551  * @obu_extention_flag: indicates if OBU header extention is present.
552  * @obu_has_size_field: equal to 1 indicates that the obu_size syntax element will be
553  *   present. @obu_has_size_field equal to 0 indicates that the @obu_size syntax element
554  *   will not be present.
555  * @obu_temporal_id: specifies the temporal level of the data contained in the OBU.
556  * @obu_spatial_id: specifies the spatial level of the data contained in the OBU.
557  *
558  * Collect info for OBU header and OBU extension header if
559  * obu_extension_flag == 1.
560  */
561 struct _GstAV1OBUHeader {
562   GstAV1OBUType obu_type;
563   gboolean obu_extention_flag;
564   gboolean obu_has_size_field;
565   guint8 obu_temporal_id;
566   guint8 obu_spatial_id;
567 };
568
569 /**
570  * GstAV1OBU:
571  * @header: a #GstAV1OBUHeader OBU Header
572  * @obu_type: the type of data structure contained in the OBU payload.
573  * @data: references the current data chunk that holds the OBU
574  * @obu_size: size of the OBU, not include header size
575  *
576  * It is the general representation of AV1 OBU (Open Bitstream
577  * Unit). One OBU include its header and payload.
578  */
579 struct _GstAV1OBU {
580   GstAV1OBUHeader header;
581   GstAV1OBUType obu_type;
582   guint8 *data;
583   guint32 obu_size;
584 };
585
586 /**
587  * GstAV1OperatingPoint:
588  * @seq_level_idx: specifies the level that the coded video sequence conforms to.
589  * @seq_tier: specifies the tier that the coded video sequence conforms to.
590  * @idc: contains a bitmask that indicates which spatial and temporal layers should be
591  *   decoded. Bit k is equal to 1 if temporal layer k should be decoded (for k between
592  *   0 and 7). Bit j+8 is equal to 1 if spatial layer j should be decoded (for j between
593  *   0 and 3).
594  * @decoder_model_present_for_this_op: equal to one indicates that there is a decoder model
595  *   associated with this operating point. @decoder_model_present_for_this_op equal to zero
596  *   indicates that there is not a decoder model associated.
597  * @decoder_buffer_delay: specifies the time interval between the arrival of the first bit
598  *   in the smoothing buffer and the subsequent removal of the data that belongs to the
599  *   first coded frame for operating point op, measured in units of 1/90000 seconds. The
600  *   length of @decoder_buffer_delay is specified by @buffer_delay_length_minus_1 + 1, in bits.
601  * @encoder_buffer_delay: specifies, in combination with @decoder_buffer_delay syntax element,
602  *   the first bit arrival time of frames to be decoded to the smoothing buffer.
603  *   @encoder_buffer_delay is measured in units of 1/90000 seconds. For a video sequence that
604  *   includes one or more random access points the sum of @decoder_buffer_delay and
605  *   @encoder_buffer_delay shall be kept constant.
606  * @low_delay_mode_flag: equal to 1 indicates that the smoothing buffer operates in low-delay
607  *   mode for operating point op. In low-delay mode late decode times and buffer underflow
608  *   are both permitted. @low_delay_mode_flag equal to 0 indicates that the smoothing buffer
609  *   operates in strict mode, where buffer underflow is not allowed.
610  * @initial_display_delay_present_for_this_op: equal to 1 indicates that
611  *   @initial_display_delay_minus_1 is specified for this operating. 0 indicates that
612  *   @initial_display_delay_minus_1 is not specified for this operating point.
613  * @initial_display_delay_minus_1: plus 1 specifies, for operating point i, the number of
614  *   decoded frames that should be present in the buffer pool before the first presentable
615  *   frame is displayed. This will ensure that all presentable frames in the sequence can
616  *   be decoded at or before the time that they are scheduled for display.
617  */
618 struct _GstAV1OperatingPoint {
619   guint8 seq_level_idx;
620   guint8 seq_tier;
621   guint16 idc;
622   gboolean decoder_model_present_for_this_op;
623   guint8 decoder_buffer_delay;
624   guint8 encoder_buffer_delay;
625   gboolean low_delay_mode_flag;
626   gboolean initial_display_delay_present_for_this_op;
627   guint8 initial_display_delay_minus_1;
628 };
629
630 /**
631  * GstAV1DecoderModelInfo:
632  * @buffer_delay_length_minus_1: plus 1 specifies the length of the
633  *   @decoder_buffer_delay and the @encoder_buffer_delay syntax elements,
634  *   in bits.
635  * @num_units_in_decoding_tick: is the number of time units of a decoding clock
636  *   operating at the frequency @time_scale Hz that corresponds to one increment
637  *   of a clock tick counter.
638  * @buffer_removal_time_length_minus_1: plus 1 specifies the length of the
639  *   @buffer_removal_time syntax element, in bits.
640  * @frame_presentation_time_length_minus_1: plus 1 specifies the length of the
641  *   @frame_presentation_time syntax element, in bits.
642  */
643 struct _GstAV1DecoderModelInfo {
644   guint8 buffer_delay_length_minus_1;
645   guint32 num_units_in_decoding_tick;
646   guint8 buffer_removal_time_length_minus_1;
647   guint8 frame_presentation_time_length_minus_1;
648 };
649
650 /**
651  * GstAV1TimingInfo:
652  * @num_units_in_display_tick: is the number of time units of a clock operating at the
653  *   frequency @time_scale Hz that corresponds to one increment of a clock tick counter.
654  *   A clock tick, in seconds, is equal to num_units_in_display_tick divided by time_scale.
655  *   It is a requirement of bitstream conformance that num_units_in_display_tick is greater
656  *   than 0.
657  * @time_scale: is the number of time units that pass in one second. It is a requirement of
658  *   bitstream conformance that @time_scale is greater than 0.
659  * @equal_picture_interval: equal to 1 indicates that pictures should be displayed according
660  *   to their output order with the number of ticks between two consecutive pictures (without
661  *   dropping frames) specified by @num_ticks_per_picture_minus_1 + 1. @equal_picture_interval
662  *   equal to 0 indicates that the interval between two consecutive pictures is not specified.
663  * @num_ticks_per_picture_minus_1: plus 1 specifies the number of clock ticks corresponding
664  *   to output time between two consecutive pictures in the output order. It is a requirement
665  *   of bitstream conformance that the value of @num_ticks_per_picture_minus_1 shall be in the
666  *   range of 0 to (1 << 32) - 2, inclusive.
667  */
668 struct _GstAV1TimingInfo {
669   guint32 num_units_in_display_tick;
670   guint32 time_scale;
671   gboolean equal_picture_interval;
672   guint32 num_ticks_per_picture_minus_1;
673 };
674
675 /**
676  * GstAV1ColorConfig:
677  * @high_bitdepth: syntax element which, together with @seq_profile, determine the bit depth.
678  * @twelve_bit: is syntax elements which, together with @seq_profile and @high_bitdepth,
679  *   determines the bit depth.
680  * @mono_chrome: equal to 1 indicates that the video does not contain U and V color planes.
681  *   @mono_chrome equal to 0 indicates that the video contains Y, U, and V color planes.
682  * @color_description_present_flag: equal to 1 specifies that color_primaries,
683  *   @transfer_characteristics, and @matrix_coefficients are present.
684  *   @color_description_present_flag equal to 0 specifies that @color_primaries,
685  *   @transfer_characteristics and @matrix_coefficients are not present.
686  * @color_primaries: is an integer that is defined by the "Color primaries" section of
687  *   ISO/IEC 23091-4/ITU-T H.273.
688  * @transfer_characteristics: is an integer that is defined by the "Transfer characteristics"
689  *   section of ISO/IEC 23091-4/ITU-T H.273.
690  * @matrix_coefficients: is an integer that is defined by the "Matrix coefficients" section
691  *   of ISO/IEC 23091-4/ITU-T H.273.
692  * @color_range: is a binary value that is associated with the VideoFullRangeFlag variable
693  *   specified in ISO/IEC 23091-4/ITU-T H.273. color range equal to 0 shall be referred to
694  *   as the studio swing representation and color range equal to 1 shall be referred to as
695  *   the full swing representation for all intents relating to this specification.
696  * @subsampling_x, @subsampling_y: specify the chroma subsampling format. If
697  *   @matrix_coefficients is equal to GST_AV1_MC_IDENTITY, it is a requirement of bitstream
698  *   conformance that @subsampling_x is equal to 0 and @subsampling_y is equal to 0.
699  * @chroma_sample_position specifies the sample position for subsampled streams:
700  * @separate_uv_delta_q: equal to 1 indicates that the U and V planes may have separate
701  *  delta quantizer values. @separate_uv_delta_q equal to 0 indicates that the U and V
702  *  planes will share the same delta quantizer value.
703  */
704 struct _GstAV1ColorConfig {
705   gboolean high_bitdepth;
706   gboolean twelve_bit;
707   gboolean mono_chrome;
708   gboolean color_description_present_flag;
709   GstAV1ColorPrimaries color_primaries;
710   GstAV1TransferCharacteristics transfer_characteristics;
711   GstAV1MatrixCoefficients matrix_coefficients;
712   gboolean color_range;
713   guint8 subsampling_x;
714   guint8 subsampling_y;
715   GstAV1ChromaSamplePositions chroma_sample_position;
716   gboolean separate_uv_delta_q;
717 };
718
719 /**
720  * GstAV1SequenceHeaderOBU:
721  * @seq_profile: specifies the features that can be used in the coded video sequence
722  * @still_picture: equal to 1 specifies that the bitstream contains only one coded frame.
723  * @reduced_still_picture_header: specifies that the syntax elements not needed by a still
724  *   picture are omitted.
725  * @frame_width_bits_minus_1: specifies the number of bits minus 1 used for transmitting
726  *   the frame width syntax elements.
727  * @frame_height_bits_minus_1: specifies the number of bits minus 1 used for transmitting
728  *   the frame height syntax elements.
729  * @max_frame_width_minus_1: specifies the maximum frame width minus 1 for the frames
730  *   represented by this sequenceheader.
731  * @max_frame_height_minus_1: specifies the maximum frame height minus 1 for the frames
732  *   represented by this sequenceheader.
733  * @frame_id_numbers_present_flag: specifies whether frame id numbers are present in the bitstream.
734  * @delta_frame_id_length_minus_2: specifies the number of bits minus 2 used to encode
735  *   delta_frame_id syntax elements.
736  * @additional_frame_id_length_minus_1: is used to calculate the number of bits used to
737  *   encode the frame_id syntax element.
738  * @use_128x128_superblock: when equal to 1, indicates that superblocks contain 128x128 luma
739  *   samples. When equal to 0, it indicates that superblocks contain 64x64 luma samples.
740  *   (The number of contained chroma samples depends on @subsampling_x and @subsampling_y).
741  * @enable_filter_intra: equal to 1 specifies that the @use_filter_intra syntax element may
742  *   be present. @enable_filter_intra equal to 0 specifies that the @use_filter_intra syntax
743  *   element will not be present.
744  * @enable_intra_edge_filter: specifies whether the intra edge filtering process should be enabled.
745  * @enable_interintra_compound: equal to 1 specifies that the mode info for inter blocks may
746  *   contain the syntax element interintra. @enable_interintra_compound equal to 0 specifies
747  *   that the syntax element interintra will not be present.
748  * @enable_masked_compound: equal to 1 specifies that the mode info for inter blocks may
749  *   contain the syntax element @compound_type. @enable_masked_compound equal to 0 specifies
750  *   that the syntax element @compound_type will not be present.
751  * @enable_warped_motion: equal to 1 indicates that the allow_warped_motion syntax element
752  *   may be present. @enable_warped_motion equal to 0 indicates that the @allow_warped_motion
753  *   syntax element will not be present.
754  * @enable_order_hint: equal to 1 indicates that tools based on the values of order hints
755  *   may be used. @enable_order_hint equal to 0 indicates that tools based on order hints
756  *   are disabled.
757  * @enable_dual_filter: equal to 1 indicates that the inter prediction filter type may be
758  *   specified independently in the horizontal and vertical directions. If the flag is equal
759  *   to 0, only one filter type may be specified, which is then used in both directions.
760  * @enable_jnt_comp: equal to 1 indicates that the distance weights process may be used
761  *   for inter prediction.
762  * @enable_ref_frame_mvs: equal to 1 indicates that the @use_ref_frame_mvs syntax element
763  *   may be present. @enable_ref_frame_mvs equal to 0 indicates that the @use_ref_frame_mvs
764  *   syntax element will not be present.
765  * @seq_choose_screen_content_tools: equal to 0 indicates that the @seq_force_screen_content_tools
766  *   syntax element will be present. @seq_choose_screen_content_tools equal to 1 indicates
767  *   that @seq_force_screen_content_tools should be set equal to SELECT_SCREEN_CONTENT_TOOLS.
768  * @seq_force_screen_content_tools: equal to SELECT_SCREEN_CONTENT_TOOLS indicates that the
769  *   @allow_screen_content_tools syntax element will be present in the frame header. Otherwise,
770  *   @seq_force_screen_content_tools contains the value for @allow_screen_content_tools.
771  * @seq_choose_integer_mv: equal to 0 indicates that the seq_force_integer_mv syntax element
772  *   will be present. @seq_choose_integer_mv equal to 1 indicates that @seq_force_integer_mv
773  *   should be set equal to SELECT_INTEGER_MV.
774  * @seq_force_integer_mv: equal to SELECT_INTEGER_MV indicates that the @force_integer_mv
775  *   syntax element will be present in the frame header (providing allow_screen_content_tools
776  *   is equal to 1). Otherwise, @seq_force_integer_mv contains the value for @force_integer_mv.
777  * @order_hint_bits_minus_1: is used to compute OrderHintBits.
778  * @enable_superres: equal to 1 specifies that the use_superres syntax element will be present
779  *   in the uncompressed header. enable_superres equal to 0 specifies that the use_superres
780  *   syntax element will not be present (instead use_superres will be set to 0 in the
781  *   uncompressed header without being read).
782  * @enable_cdef: equal to 1 specifies that cdef filtering may be enabled. enable_cdef equal
783  *   to 0 specifies that cdef filtering is disabled.
784  * @enable_restoration: equal to 1 specifies that loop restoration filtering may be enabled.
785  *   enable_restoration equal to 0 specifies that loop restoration filtering is disabled.
786  * @film_grain_params_present: specifies whether film grain parameters are present in the bitstream.
787  * @operating_points_cnt_minus_1: indicates the number of operating points minus 1 present
788  *   in this bitstream.
789  * @operating_points: specifies the corresponding operating point for a set of operating
790  *   parameters.
791  * @decoder_model_info_present_flag: specifies whether the decoder model info is present in
792  *   the bitstream.
793  * @decoder_model_info: holds information about the decoder model.
794  * @initial_display_delay_present_flag: specifies whether initial display delay information
795  *   is present in the bitstream or not.
796  * @timing_info_present_flag: specifies whether timing info is present in the bitstream.
797  * @timing_info: holds the timing information.
798  * @color_config: hold the color configuration.
799  * @order_hint_bits: specifies the number of bits used for the order_hint syntax element.
800  * @bit_depth: the bit depth of the stream.
801  * @num_planes: the YUV plane number.
802  */
803 struct _GstAV1SequenceHeaderOBU {
804   GstAV1Profile seq_profile;
805   gboolean still_picture;
806   guint8 reduced_still_picture_header;
807
808   guint8 frame_width_bits_minus_1;
809   guint8 frame_height_bits_minus_1;
810   guint16 max_frame_width_minus_1;
811   guint16 max_frame_height_minus_1;
812
813   gboolean frame_id_numbers_present_flag;
814   guint8 delta_frame_id_length_minus_2;
815   guint8 additional_frame_id_length_minus_1;
816
817   gboolean use_128x128_superblock;
818   gboolean enable_filter_intra;
819   gboolean enable_intra_edge_filter;
820   gboolean enable_interintra_compound;
821   gboolean enable_masked_compound;
822   gboolean enable_warped_motion;
823   gboolean enable_order_hint;
824   gboolean enable_dual_filter;
825   gboolean enable_jnt_comp;
826   gboolean enable_ref_frame_mvs;
827   gboolean seq_choose_screen_content_tools;
828   guint8 seq_force_screen_content_tools;
829   gboolean seq_choose_integer_mv;
830   guint8 seq_force_integer_mv;
831   gint8 order_hint_bits_minus_1;
832
833   gboolean enable_superres;
834   gboolean enable_cdef;
835   gboolean enable_restoration;
836
837   guint8 film_grain_params_present;
838
839   guint8 operating_points_cnt_minus_1;
840   GstAV1OperatingPoint operating_points[GST_AV1_MAX_OPERATING_POINTS];
841
842   gboolean decoder_model_info_present_flag;
843   GstAV1DecoderModelInfo decoder_model_info;
844   guint8 initial_display_delay_present_flag;
845
846   gboolean timing_info_present_flag;
847   GstAV1TimingInfo timing_info;
848
849   GstAV1ColorConfig color_config;
850
851   /* Global var calculated by sequence */
852   guint8 order_hint_bits; /* OrderHintBits */
853   guint8 bit_depth; /* BitDepth */
854   guint8 num_planes; /* NumPlanes */
855 };
856
857 /**
858  * GstAV1MetadataITUT_T35:
859  * @itu_t_t35_country_code: shall be a byte having a value specified as a country code by
860  *   Annex A of Recommendation ITU-T T.35.
861  * @itu_t_t35_country_code_extension_byte: shall be a byte having a value specified as a
862  *   country code by Annex B of Recommendation ITU-T T.35.
863  * @itu_t_t35_payload_bytes: shall be bytes containing data registered as specified in
864  *   Recommendation ITU-T T.35.
865  */
866 struct _GstAV1MetadataITUT_T35 {
867   guint8 itu_t_t35_country_code;
868   guint8 itu_t_t35_country_code_extention_byte;
869   /* itu_t_t35_payload_bytes - not specified at this spec */
870   guint8 *itu_t_t35_payload_bytes;
871 };
872
873 /**
874  * GstAV1MetadataHdrCll:
875  * @max_cll: specifies the maximum content light level as specified in CEA-861.3, Appendix A.
876  * @max_fall: specifies the maximum frame-average light level as specified in CEA-861.3, Appendix A.
877  *
878  * High Dynamic Range content light level syntax metadata.
879  */
880 struct _GstAV1MetadataHdrCll {
881   guint16 max_cll;
882   guint16 max_fall;
883 };
884
885 /**
886  * GstAV1MetadataHdrMdcv:
887  * @primary_chromaticity_x: specifies a 0.16 fixed-point X chromaticity coordinate as
888  *   defined by CIE 1931, where i = 0,1,2 specifies Red, Green, Blue respectively.
889  * @primary_chromaticity_y: specifies a 0.16 fixed-point Y chromaticity coordinate as
890  *   defined by CIE 1931, where i = 0,1,2 specifies Red, Green, Blue respectively.
891  * @white_point_chromaticity_x: specifies a 0.16 fixed-point white X chromaticity coordinate
892  *   as defined by CIE 1931.
893  * @white_point_chromaticity_y: specifies a 0.16 fixed-point white Y chromaticity coordinate
894  *   as defined by CIE 1931.
895  * @luminance_max: is a 24.8 fixed-point maximum luminance, represented in candelas per
896  *   square meter.
897  * @luminance_min: is a 18.14 fixed-point minimum luminance, represented in candelas per
898  *   square meter.
899  *
900  *  High Dynamic Range mastering display color volume metadata.
901  */
902 struct _GstAV1MetadataHdrMdcv {
903   guint16 primary_chromaticity_x[3];
904   guint16 primary_chromaticity_y[3];
905   guint16 white_point_chromaticity_x;
906   guint16 white_point_chromaticity_y;
907   guint32 luminance_max;
908   guint32 luminance_min;
909 };
910
911 /**
912  * GstAV1MetadataScalability:
913  * @scalability_mode_idc: indicates the picture prediction structure of the bitstream.
914  * @spatial_layers_cnt_minus_1: indicates the number of spatial layers present in the video
915  *   sequence minus one.
916  * @spatial_layer_description_present_flag: indicates when set to 1 that the
917  *   spatial_layer_ref_id is present for each of the (@spatial_layers_cnt_minus_1 + 1) layers,
918  *   or that it is not present when set to 0.
919  * @spatial_layer_dimensions_present_flag: indicates when set to 1 that the
920  *   @spatial_layer_max_width and @spatial_layer_max_height parameters are present for each of
921  *   the (@spatial_layers_cnt_minus_1 + 1) layers, or that it they are not present when set to 0.
922  * @temporal_group_description_present_flag: indicates when set to 1 that the temporal
923  *   dependency information is present, or that it is not when set to 0.
924  * @spatial_layer_max_width: specifies the maximum frame width for the frames with
925  *   @spatial_id equal to i. This number must not be larger than @max_frame_width_minus_1 + 1.
926  * @spatial_layer_max_height: specifies the maximum frame height for the frames with
927  *   @spatial_id equal to i. This number must not be larger than @max_frame_height_minus_1 + 1.
928  * @spatial_layer_ref_id: specifies the @spatial_id value of the frame within the current
929  *   temporal unit that the frame of layer i uses for reference. If no frame within the
930  *   current temporal unit is used for reference the value must be equal to 255.
931  * @temporal_group_size: indicates the number of pictures in a temporal picture group. If the
932  *   @temporal_group_size is greater than 0, then the scalability structure data allows the
933  *   inter-picture temporal dependency structure of the video sequence to be specified. If the
934  *   @temporal_group_size is greater than 0, then for @temporal_group_size pictures in the
935  *   temporal group, each picture's temporal layer id (@temporal_id), switch up points
936  *   (@temporal_group_temporal_switching_up_point_flag and
937  *   @temporal_group_spatial_switching_up_point_flag), and the reference picture indices
938  *   (@temporal_group_ref_pic_diff) are specified. The first picture specified in a temporal
939  *   group must have @temporal_id equal to 0. If the parameter @temporal_group_size is not
940  *   present or set to 0, then either there is only one temporal layer or there is no fixed
941  *   inter-picture temporal dependency present going forward in the video sequence. Note that
942  *   for a given picture, all frames follow the same inter-picture temporal dependency
943  *   structure. However, the frame rate of each layer can be different from each other. The
944  *   specified dependency structure in the scalability structure data must be for the highest
945  *   frame rate layer.
946  * @temporal_group_temporal_id: specifies the temporal_id value for the i-th picture in
947  *   the temporal group.
948  * @temporal_group_temporal_switching_up_point_flag: is set to 1 if subsequent (in decoding
949  *   order) pictures with a @temporal_id higher than @temporal_group_temporal_id[i] do not
950  *   depend on any picture preceding the current picture (in coding order) with @temporal_id
951  *   higher than @temporal_group_temporal_id[ i ].
952  * @temporal_group_spatial_switching_up_point_flag: is set to 1 if spatial layers of the
953  *   current picture in the temporal group (i.e., pictures with a spatial_id higher than zero)
954  *   do not depend on any picture preceding the current picture in the temporal group.
955  * @temporal_group_ref_cnt: indicates the number of reference pictures used by the i-th
956  *   picture in the temporal group.
957  * @temporal_group_ref_pic_diff: indicates, for the i-th picture in the temporal group,
958  *   the temporal distance between the i-th picture and the j-th reference picture used by
959  *   the i-th picture. The temporal distance is measured in frames, counting only frames of
960  *   identical @spatial_id values.
961  *
962  * The scalability metadata OBU is intended for use by intermediate
963  * processing entities that may perform selective layer elimination.
964  */
965 struct _GstAV1MetadataScalability {
966   GstAV1ScalabilityModes scalability_mode_idc;
967   guint8 spatial_layers_cnt_minus_1;
968   gboolean spatial_layer_dimensions_present_flag;
969   gboolean spatial_layer_description_present_flag;
970   gboolean temporal_group_description_present_flag;
971   guint16 spatial_layer_max_width[GST_AV1_MAX_SPATIAL_LAYERS];
972   guint16 spatial_layer_max_height[GST_AV1_MAX_SPATIAL_LAYERS];
973   guint8 spatial_layer_ref_id[GST_AV1_MAX_SPATIAL_LAYERS];
974   guint8 temporal_group_size;
975
976   guint8 temporal_group_temporal_id[GST_AV1_MAX_TEMPORAL_GROUP_SIZE];
977   guint8 temporal_group_temporal_switching_up_point_flag[GST_AV1_MAX_TEMPORAL_GROUP_SIZE];
978   guint8 temporal_group_spatial_switching_up_point_flag[GST_AV1_MAX_TEMPORAL_GROUP_SIZE];
979   guint8 temporal_group_ref_cnt[GST_AV1_MAX_TEMPORAL_GROUP_SIZE];
980   guint8 temporal_group_ref_pic_diff[GST_AV1_MAX_TEMPORAL_GROUP_SIZE]
981                                     [GST_AV1_MAX_TEMPORAL_GROUP_REFERENCES];
982 };
983
984 /**
985  * GstAV1MetadataTimecode:
986  * @counting_type: specifies the method of dropping values of the n_frames syntax element as
987  *   specified in AV1 Spec 6.1.1. @counting_type should be the same for all pictures in the
988  *   coded video sequence.
989  * @full_timestamp_flag: equal to 1 indicates that the the @seconds_value, @minutes_value,
990  *   @hours_value syntax elements will be present. @full_timestamp_flag equal to 0 indicates
991  *   that there are flags to control the presence of these syntax elements.
992  * @discontinuity_flag: equal to 0 indicates that the difference between the current value
993  *   of clockTimestamp and the value of clockTimestamp computed from the previous set of
994  *   timestamp syntax elements in output order can be interpreted as the time difference
995  *   between the times of origin or capture of the associated frames or fields.
996  *   @discontinuity_flag equal to 1 indicates that the difference between the current value of
997  *   clockTimestamp and the value of clockTimestamp computed from the previous set of clock
998  *   timestamp syntax elements in output order should not be interpreted as the time difference
999  *   between the times of origin or capture of the associated frames or fields.
1000  * @cnt_dropped_flag: specifies the skipping of one or more values of @n_frames using the
1001  *   counting method specified by counting_type.
1002  * @n_frames: is used to compute clockTimestamp. When @timing_info_present_flag is equal to 1,
1003  *   @n_frames shall be less than maxFps, where maxFps is specified by
1004  *   maxFps = ceil( time_scale / ( 2 * @num_units_in_display_tick ) ).
1005  * @seconds_flag: equal to 1 specifies that @seconds_value and @minutes_flag are present when
1006  *   @full_timestamp_flag is equal to 0. @seconds_flag equal to 0 specifies that @seconds_value
1007  *   and @minutes_flag are not present.
1008  * @seconds_value: is used to compute clockTimestamp and shall be in the range of 0 to 59.
1009  *   When @seconds_value is not present, its value is inferred to be equal to the value of
1010  *   @seconds_value for the previous set of clock timestamp syntax elements in decoding order,
1011  *   and it is required that such a previous @seconds_value shall have been present.
1012  * @minutes_flag: equal to 1 specifies that @minutes_value and @hours_flag are present when
1013  *   @full_timestamp_flag is equal to 0 and @seconds_flag is equal to 1. @minutes_flag equal to 0
1014  *   specifies that @minutes_value and @hours_flag are not present.
1015  * @minutes_value: specifies the value of mm used to compute clockTimestamp and shall be in
1016  *   the range of 0 to 59, inclusive. When minutes_value is not present, its value is inferred
1017  *   to be equal to the value of @minutes_value for the previous set of clock timestamp syntax
1018  *   elements in decoding order, and it is required that such a previous @minutes_value shall
1019  *   have been present.
1020  * @hours_flag: equal to 1 specifies that @hours_value is present when @full_timestamp_flag is
1021  *   equal to 0 and @seconds_flag is equal to 1 and @minutes_flag is equal to 1.
1022  * @hours_value: is used to compute clockTimestamp and shall be in the range of 0 to 23,
1023  *   inclusive. When @hours_value is not present, its value is inferred to be equal to the
1024  *   value of @hours_value for the previous set of clock timestamp syntax elements in decoding
1025  *   order, and it is required that such a previous @hours_value shall have been present.
1026  * @time_offset_length: greater than 0 specifies the length in bits of the @time_offset_value
1027  *   syntax element. @time_offset_length equal to 0 specifies that the @time_offset_value syntax
1028  *   element is not present. @time_offset_length should be the same for all pictures in the
1029  *   coded video sequence.
1030  * @time_offset_value: is used to compute clockTimestamp. The number of bits used to represent
1031  *   @time_offset_value is equal to @time_offset_length. When @time_offset_value is not present,
1032  *   its value is inferred to be equal to 0.
1033  */
1034 struct _GstAV1MetadataTimecode {
1035   guint8 counting_type;       /* candidate for sperate Type GstAV1TimecodeCountingType */
1036   gboolean full_timestamp_flag;
1037   gboolean discontinuity_flag;
1038   gboolean cnt_dropped_flag;
1039   guint8 n_frames;
1040   gboolean seconds_flag;
1041   guint8 seconds_value;
1042   gboolean minutes_flag;
1043   guint8 minutes_value;
1044   gboolean hours_flag;
1045   guint8 hours_value;
1046   guint8 time_offset_length;
1047   guint32 time_offset_value;
1048 };
1049
1050 /**
1051  * GstAV1MetadataOBU:
1052  * @metadata_type: type of metadata
1053  * @itut_t35: ITUT T35 metadata
1054  * @hdrcll: high dynamic range content light level metadata
1055  * @hdrcmdcv: high dynamic range mastering display color volume metadata_type
1056  * @scalability: Scalability metadata
1057  * @timecode: Timecode metadata
1058  */
1059 struct _GstAV1MetadataOBU {
1060   GstAV1MetadataType metadata_type;
1061   union {
1062     GstAV1MetadataITUT_T35 itut_t35;
1063     GstAV1MetadataHdrCll hdr_cll;
1064     GstAV1MetadataHdrMdcv hdr_mdcv;
1065     GstAV1MetadataScalability scalability;
1066     GstAV1MetadataTimecode timecode;
1067   };
1068 };
1069
1070 /**
1071  * GstAV1LoopFilterParams:
1072  * @loop_filter_level: is an array containing loop filter strength values. Different loop
1073  *   filter strength values from the array are used depending on the image plane being
1074  *   filtered, and the edge direction (vertical or horizontal) being filtered.
1075  * @loop_filter_sharpness: indicates the sharpness level. The @loop_filter_level and
1076  *   @loop_filter_sharpness together determine when a block edge is filtered, and by how much
1077  *   the filtering can change the sample values. The loop filter process is described in AV1
1078  *   Bitstream Spec. section 7.14.
1079  * @loop_filter_delta_enabled: equal to 1 means that the filter level depends on the mode and
1080  *   reference frame used to predict a block. @loop_filter_delta_enabled equal to 0 means that
1081  *   the filter level does not depend on the mode and reference frame.
1082  * @loop_filter_delta_update: equal to 1 means that the bitstream contains additional syntax
1083  *   elements that specify which mode and reference frame deltas are to be updated.
1084  *   @loop_filter_delta_update equal to 0 means that these syntax elements are not present.
1085  * @loop_filter_ref_deltas: contains the adjustment needed for the filter level based on
1086  *   the chosen reference frame. If this syntax element is not present in the bitstream,
1087  *   it maintains its previous value.
1088  * @loop_filter_mode_deltas: contains the adjustment needed for the filter level based on
1089  *   the chosen mode. If this syntax element is not present in the bitstream, it maintains
1090  *   its previous value.
1091  * @delta_lf_present: specifies whether loop filter delta values are present in the bitstream.
1092  * @delta_lf_res: specifies the left shift which should be applied to decoded loop filter
1093  *   delta values.
1094  * @delta_lf_multi: equal to 1 specifies that separate loop filter deltas are sent for
1095  *   horizontal luma edges, vertical luma edges, the U edges, and the V edges. @delta_lf_multi
1096  *   equal to 0 specifies that the same loop filter delta is used for all edges.
1097  */
1098 struct _GstAV1LoopFilterParams {
1099   guint8 loop_filter_level[4];
1100   guint8 loop_filter_sharpness;
1101   gboolean loop_filter_delta_enabled;
1102   gboolean loop_filter_delta_update;
1103
1104   gint8 loop_filter_ref_deltas[GST_AV1_TOTAL_REFS_PER_FRAME];
1105   gint8 loop_filter_mode_deltas[2];
1106
1107   gboolean delta_lf_present;
1108   guint8 delta_lf_res;
1109   guint8 delta_lf_multi;
1110 };
1111
1112 /**
1113  * GstAV1QuantizationParams:
1114  * @base_q_idx: indicates the base frame qindex. This is used for Y AC coefficients and as
1115  *   the base value for the other quantizers.
1116  * @diff_uv_delta: equal to 1 indicates that the U and V delta quantizer values are coded
1117  *   separately. @diff_uv_delta equal to 0 indicates that the U and V delta quantizer values
1118  *   share a common value.
1119  * @using_qmatrix: specifies that the quantizer matrix will be used to compute quantizers.
1120  * @qm_y: specifies the level in the quantizer matrix that should be used for luma plane decoding.
1121  * @qm_u: specifies the level in the quantizer matrix that should be used for chroma U plane decoding.
1122  * @qm_v: specifies the level in the quantizer matrix that should be used for chroma V plane decoding.
1123  * @delta_q_present: specifies whether quantizer index delta values are present in the bitstream.
1124  * @delta_q_res: specifies the left shift which should be applied to decoded quantizer index
1125  *   delta values.
1126  * @delta_q_y_dc: indicates the Y DC quantizer relative to base_q_idx.
1127  * @delta_q_u_dc: indicates the U DC quantizer relative to base_q_idx.
1128  * @delta_q_u_ac: indicates the U AC quantizer relative to base_q_idx.
1129  * @delta_q_v_dc: indicates the V DC quantizer relative to base_q_idx.
1130  * @delta_q_v_ac: indicates the V AC quantizer relative to base_q_idx.
1131  */
1132 struct _GstAV1QuantizationParams {
1133   guint8 base_q_idx;
1134   gboolean diff_uv_delta;
1135   gboolean using_qmatrix;
1136   guint8 qm_y;
1137   guint8 qm_u;
1138   guint8 qm_v;
1139
1140   gboolean delta_q_present;
1141   guint8 delta_q_res;
1142
1143   gint8 delta_q_y_dc; /* DeltaQYDc */
1144   gint8 delta_q_u_dc; /* DeltaQUDc */
1145   gint8 delta_q_u_ac; /* DeltaQUAc */
1146   gint8 delta_q_v_dc; /* DeltaQVDc */
1147   gint8 delta_q_v_ac; /* DeltaQVAc */
1148 };
1149
1150 /**
1151  * GstAV1SegmenationParams:
1152  * @segmentation_enabled: equal to 1 indicates that this frame makes use of the segmentation
1153  *   tool; @segmentation_enabled equal to 0 indicates that the frame does not use segmentation.
1154  * @segmentation_update_map: equal to 1 indicates that the segmentation map are updated during
1155  *   the decoding of this frame. @segmentation_update_map equal to 0 means that the segmentation
1156  *   map from the previous frame is used.
1157  * @segmentation_temporal_update: equal to 1 indicates that the updates to the segmentation map
1158  *   are coded relative to the existing segmentation map. @segmentation_temporal_update equal to
1159  *   0 indicates that the new segmentation map is coded without reference to the existing
1160  *   segmentation map.
1161  * @segmentation_update_data: equal to 1 indicates that new parameters are about to be
1162  *   specified for each segment. @segmentation_update_data equal to 0 indicates that the
1163  *   segmentation parameters should keep their existing values.
1164  * @feature_enabled: set to 1 when the feature of segmentation is enabled.
1165  * @feature_data: the value of according segmentation feature.
1166  * @seg_id_pre_skip: equal to 1 indicates that the segment id will be read before the skip
1167  *   syntax element. @seg_id_pre_skip equal to 0 indicates that the skip syntax element will be
1168  *   read first.
1169  * @last_active_seg_id: indicates the highest numbered segment id that has some enabled feature.
1170  *   This is used when decoding the segment id to only decode choices corresponding to used
1171  *   segments.
1172  */
1173 struct _GstAV1SegmenationParams {
1174   gboolean segmentation_enabled;
1175   guint8 segmentation_update_map;
1176   guint8 segmentation_temporal_update;
1177   guint8 segmentation_update_data;
1178
1179   gint8 feature_enabled[GST_AV1_MAX_SEGMENTS][GST_AV1_SEG_LVL_MAX]; /* FeatureEnabled */
1180   gint16 feature_data[GST_AV1_MAX_SEGMENTS][GST_AV1_SEG_LVL_MAX]; /* FeatureData */
1181   guint8 seg_id_pre_skip; /* SegIdPreSkip */
1182   guint8 last_active_seg_id; /* LastActiveSegId */
1183 };
1184
1185 /**
1186  * GstAV1TileInfo:
1187  * @uniform_tile_spacing_flag: equal to 1 means that the tiles are uniformly spaced across the
1188  *   frame. (In other words, all tiles are the same size except for the ones at the right and
1189  *   bottom edge which can be smaller.) @uniform_tile_spacing_flag equal to 0 means that the
1190  *   tile sizes are coded.
1191  * @increment_tile_rows_log2: is used to compute @tile_rows_log2.
1192  * @width_in_sbs_minus_1: specifies the width of a tile minus 1 in units of superblocks.
1193  * @height_in_sbs_minus_1: specifies the height of a tile minus 1 in units of superblocks.
1194  * @tile_size_bytes_minus_1: is used to compute @tile_size_bytes
1195  * @context_update_tile_id: specifies which tile to use for the CDF update.
1196  * @mi_col_starts: is an array specifying the start column (in units of 4x4 luma samples) for
1197  *   each tile across the image.
1198  * @mi_row_starts: is an array specifying the start row (in units of 4x4 luma samples) for
1199  *   each tile down the image.
1200  * @tile_cols_log2: specifies the base 2 logarithm of the desired number of tiles across the frame.
1201  * @tile_cols: specifies the number of tiles across the frame. It is a requirement of bitstream
1202  *   conformance that @tile_cols is less than or equal to GST_AV1_MAX_TILE_COLS.
1203  * @tile_rows_log2: specifies the base 2 logarithm of the desired number of tiles down the frame.
1204  * @tile_rows: specifies the number of tiles down the frame. It is a requirement of bitstream
1205  *   conformance that @tile_rows is less than or equal to GST_AV1_MAX_TILE_ROWS.
1206  * @tile_size_bytes: specifies the number of bytes needed to code each tile size.
1207  */
1208 struct _GstAV1TileInfo {
1209   guint8 uniform_tile_spacing_flag;
1210   gint increment_tile_rows_log2;
1211   gint width_in_sbs_minus_1[GST_AV1_MAX_TILE_COLS];
1212   gint height_in_sbs_minus_1[GST_AV1_MAX_TILE_ROWS];
1213   gint tile_size_bytes_minus_1;
1214   guint8 context_update_tile_id;
1215
1216   guint32 mi_col_starts[GST_AV1_MAX_TILE_COLS + 1]; /* MiColStarts */
1217   guint32 mi_row_starts[GST_AV1_MAX_TILE_ROWS + 1]; /* MiRowStarts */
1218   guint8 tile_cols_log2; /* TileColsLog2 */
1219   guint8 tile_cols; /* TileCols */
1220   guint8 tile_rows_log2; /* TileRowsLog2 */
1221   guint8 tile_rows; /* TileRows */
1222   guint8 tile_size_bytes; /* TileSizeBytes */
1223 };
1224
1225 /**
1226  * GstAV1CDEFParams:
1227  * @cdef_damping: controls the amount of damping in the deringing filter.
1228  * @cdef_bits: specifies the number of bits needed to specify which CDEF filter to apply.
1229  * @cdef_y_pri_strength: specify the strength of the primary filter (Y component)
1230  * @cdef_uv_pri_strength: specify the strength of the primary filter (UV components).
1231  * @cdef_y_sec_strength: specify the strength of the secondary filter (Y component).
1232  * @cdef_uv_sec_strength: specify the strength of the secondary filter (UV components).
1233  *
1234  * Parameters of Constrained Directional Enhancement Filter (CDEF).
1235  */
1236 struct _GstAV1CDEFParams {
1237   guint8 cdef_damping;
1238   guint8 cdef_bits;
1239   guint8 cdef_y_pri_strength[GST_AV1_CDEF_MAX];
1240   guint8 cdef_y_sec_strength[GST_AV1_CDEF_MAX];
1241   guint8 cdef_uv_pri_strength[GST_AV1_CDEF_MAX];
1242   guint8 cdef_uv_sec_strength[GST_AV1_CDEF_MAX];
1243 };
1244
1245 /**
1246  * GstAV1LoopRestorationParams:
1247  * @lr_unit_shift: specifies if the luma restoration size should be halved.
1248  * @lr_uv_shift: is only present for 4:2:0 formats and specifies if the chroma size should be
1249  *   half the luma size.
1250  * @frame_restoration_type: specifies the type of restoration used for each plane.
1251  * @loop_restoration_size: specifies the size of loop restoration units in units of samples in
1252  *   the current plane.
1253  * @uses_lr: indicates if any plane uses loop restoration.
1254  */
1255 struct _GstAV1LoopRestorationParams {
1256   guint8 lr_unit_shift;
1257   gboolean lr_uv_shift;
1258
1259   GstAV1FrameRestorationType frame_restoration_type[GST_AV1_MAX_NUM_PLANES]; /* FrameRestorationType */
1260   guint32 loop_restoration_size[GST_AV1_MAX_NUM_PLANES]; /* LoopRestorationSize */
1261   guint8 uses_lr; /* UsesLr */
1262 };
1263
1264 /**
1265  * GstAV1GlobalMotionParams:
1266  * @is_global: specifies whether global motion parameters are present for a particular
1267  *   reference frame.
1268  * @is_rot_zoom: specifies whether a particular reference frame uses rotation and zoom
1269  *   global motion.
1270  * @is_translation: specifies whether a particular reference frame uses translation
1271  *   global motion.
1272  * @gm_params: is set equal to SavedGmParams[ frame_to_show_map_idx ][ ref ][ j ] for
1273  *   ref = LAST_FRAME..ALTREF_FRAME, for j = 0..5.
1274  * @gm_type: specifying the type of global motion.
1275  * @invalid: whether this global motion parameters is invalid. (Since: 1.20)
1276  */
1277 /**
1278  * _GstAV1GlobalMotionParams.invalid:
1279  *
1280  * whether this global motion parameters is invalid.
1281  *
1282  * Since: 1.20
1283  */
1284 struct _GstAV1GlobalMotionParams {
1285   gboolean is_global[GST_AV1_NUM_REF_FRAMES];
1286   gboolean is_rot_zoom[GST_AV1_NUM_REF_FRAMES];
1287   gboolean is_translation[GST_AV1_NUM_REF_FRAMES];
1288   gint32 gm_params[GST_AV1_NUM_REF_FRAMES][6];
1289
1290   GstAV1WarpModelType gm_type[GST_AV1_NUM_REF_FRAMES]; /* GmType */
1291   gboolean invalid[GST_AV1_NUM_REF_FRAMES];
1292 };
1293
1294 /**
1295  * GstAV1FilmGrainParams:
1296  * @apply_grain: equal to 1 specifies that film grain should be added to this frame.
1297  *   apply_grain equal to 0 specifies that film grain should not be added.
1298  * @grain_seed: specifies the starting value for the pseudo-random numbers used during film
1299  *   grain synthesis.
1300  * @update_grain: equal to 1 means that a new set of parameters should be sent. @update_grain
1301  *   equal to 0 means that the previous set of parameters should be used.
1302  * @film_grain_params_ref_idx: indicates which reference frame contains the film grain
1303  *   parameters to be used for this frame.
1304  * @num_y_points: specifies the number of points for the piece-wise linear scaling function
1305  *   of the luma component. It is a requirement of bitstream conformance that @num_y_points is
1306  *   less than or equal to 14.
1307  * @point_y_value: represents the x (luma value) coordinate for the i-th point of the
1308  *   piecewise linear scaling function for luma component. The values are signaled on the
1309  *   scale of 0..255. (In case of 10 bit video, these values correspond to luma values divided
1310  *   by 4. In case of 12 bit video, these values correspond to luma values divided by 16.)
1311  *   If i is greater than 0, it is a r equirement of bitstream conformance that
1312  *   @point_y_value[ i ] is greater than @point_y_value[ i - 1 ] (this ensures the x coordinates
1313  *   are specified in increasing order).
1314  * @point_y_scaling: represents the scaling (output) value for the i-th point of the
1315  *   piecewise linear scaling function for luma component.
1316  * @chroma_scaling_from_luma: specifies that the chroma scaling is inferred from the luma scaling.
1317  * @num_cb_points: specifies the number of points for the piece-wise linear scaling function
1318  *   of the cb component. It is a requirement of bitstream conformance that @num_cb_points is
1319  *   less than or equal to 10.
1320  * @point_cb_value: represents the x coordinate for the i-th point of the piece-wise linear
1321  *   scaling function for cb component. The values are signaled on the scale of 0..255. If i
1322  *   is greater than 0, it is a requirement of bitstream conformance that point_cb_value[ i ]
1323  *   is greater than point_cb_value[ i - 1 ].
1324  * @point_cb_scaling: represents the scaling (output) value for the i-th point of the
1325  *   piecewise linear scaling function for cb component.
1326  * @num_cr_points: specifies represents the number of points for the piece-wise linear scaling
1327  *   function of the cr component. It is a requirement of bitstream conformance that
1328  *   num_cr_points is less than or equal to 10. If subsampling_x is equal to 1 and
1329  *   @subsampling_y is equal to 1 and num_cb_points is equal to 0, it is a requirement of
1330  *   bitstream conformance that num_cr_points is equal to 0. If @subsampling_x is equal to 1
1331  *   and @subsampling_y is equal to 1 and @num_cb_points is not equal to 0, it is a requirement
1332  *   of bitstream conformance that @num_cr_points is not equal to 0.
1333  * @point_cr_value: represents the x coordinate for the i-th point of the piece-wise linear
1334  *   scaling function for cr component. The values are signaled on the scale of 0..255. If i
1335  *   is greater than 0, it is a requirement of bitstream conformance that @point_cr_value[ i ]
1336  *   is greater than @point_cr_value[ i - 1 ].
1337  * @point_cr_scaling: represents the scaling (output) value for the i-th point of the
1338  *   piecewise linear scaling function for cr component.
1339  * @grain_scaling_minus_8: represents the shift - 8 applied to the values of the chroma
1340  *   component. The @grain_scaling_minus_8 can take values of 0..3 and determines the range and
1341  *   quantization step of the standard deviation of film grain.
1342  * @ar_coeff_lag: specifies the number of auto-regressive coefficients for luma and chroma.
1343  * @ar_coeffs_y_plus_128: specifies auto-regressive coefficients used for the Y plane.
1344  * @ar_coeffs_cb_plus_128: specifies auto-regressive coefficients used for the U plane.
1345  * @ar_coeffs_cr_plus_128: specifies auto-regressive coefficients used for the V plane.
1346  * @ar_coeff_shift_minus_6: specifies the range of the auto-regressive coefficients. Values
1347  *   of 0, 1, 2, and 3 correspond to the ranges for auto-regressive coefficients of [-2, 2),
1348  *   [-1, 1), [-0.5, 0.5) and [-0.25, 0.25) respectively.
1349  * @grain_scale_shift: specifies how much the Gaussian random numbers should be scaled down
1350  *   during the grain synthesis process.
1351  * @cb_mult: represents a multiplier for the cb component used in derivation of the input
1352  *   index to the cb component scaling function.
1353  * @cb_luma_mult: represents a multiplier for the average luma component used in derivation
1354  *   of the input index to the cb component scaling function.
1355  * @cb_offset: represents an offset used in derivation of the input index to the cb component
1356  *   scaling function.
1357  * @cr_mult: represents a multiplier for the cr component used in derivation of the input
1358  *   index to the cr component scaling function.
1359  * @cr_luma_mult: represents a multiplier for the average luma component used in derivation
1360  *   of the input index to the cr component scaling function.
1361  * @cr_offset: represents an offset used in derivation of the input index to the cr component
1362  *   scaling function.
1363  * @overlap_flag: equal to 1 indicates that the overlap between film grain blocks shall be
1364  *   applied. overlap_flag equal to 0 indicates that the overlap between film grain blocks
1365  *   shall not be applied.
1366  * @clip_to_restricted_range: equal to 1 indicates that clipping to the restricted (studio)
1367  *   range shall be applied to the sample values after adding the film grain (see the
1368  *   semantics for color_range for an explanation of studio swing). clip_to_restricted_range
1369  *   equal to 0 indicates that clipping to the full range shall be applied to the sample
1370  *   values after adding the film grain.
1371  */
1372 struct _GstAV1FilmGrainParams {
1373   gboolean apply_grain;
1374   guint16 grain_seed;
1375   gboolean update_grain;
1376   guint8 film_grain_params_ref_idx;
1377   guint8 num_y_points;
1378   guint8 point_y_value[GST_AV1_MAX_NUM_Y_POINTS];
1379   guint8 point_y_scaling[GST_AV1_MAX_NUM_Y_POINTS];
1380   guint8 chroma_scaling_from_luma;
1381   guint8 num_cb_points;
1382   guint8 point_cb_value[GST_AV1_MAX_NUM_CB_POINTS];
1383   guint8 point_cb_scaling[GST_AV1_MAX_NUM_CB_POINTS];
1384   guint8 num_cr_points;
1385   guint8 point_cr_value[GST_AV1_MAX_NUM_CR_POINTS];
1386   guint8 point_cr_scaling[GST_AV1_MAX_NUM_CR_POINTS];
1387   guint8 grain_scaling_minus_8;
1388   guint8 ar_coeff_lag;
1389   guint8 ar_coeffs_y_plus_128[GST_AV1_MAX_NUM_POS_LUMA];
1390   guint8 ar_coeffs_cb_plus_128[GST_AV1_MAX_NUM_POS_LUMA];
1391   guint8 ar_coeffs_cr_plus_128[GST_AV1_MAX_NUM_POS_LUMA];
1392   guint8 ar_coeff_shift_minus_6;
1393   guint8 grain_scale_shift;
1394   guint8 cb_mult;
1395   guint8 cb_luma_mult;
1396   guint8 cb_offset;
1397   guint8 cr_mult;
1398   guint8 cr_luma_mult;
1399   guint8 cr_offset;
1400   gboolean overlap_flag;
1401   gboolean clip_to_restricted_range;
1402 };
1403
1404 /**
1405  * GstAV1FrameHeaderOBU:
1406  * @show_existing_frame: equal to 1, indicates the frame indexed by @frame_to_show_map_idx is
1407  *   to be output; @show_existing_frame equal to 0 indicates that further processing is required.
1408  *   If @obu_type is equal to #GST_AV1_OBU_FRAME, it is a requirement of bitstream conformance that
1409  *   @show_existing_frame is equal to 0.
1410  * @frame_to_show_map_idx: specifies the frame to be output. It is only available if
1411  *   @show_existing_frame is 1.
1412  * @frame_presentation_time: specifies the presentation time of the frame in clock ticks
1413  *   DispCT counted from the removal time of the last frame with frame_type equal to KEY_FRAME
1414  *   for the operating point that is being decoded. The syntax element is signaled as a fixed
1415  *   length unsigned integer with a length in bits given by
1416  *   @frame_presentation_time_length_minus_1 + 1. The @frame_presentation_time is the remainder
1417  *   of a modulo 1 << (@frame_presentation_time_length_minus_1 + 1) counter.
1418  * @tu_presentation_delay: is a syntax element used by the decoder model. It does not affect
1419  *   the decoding process.
1420  * @display_frame_id: provides the frame id number for the frame to output. It is a requirement
1421  *   of bitstream conformance that whenever @display_frame_id is read, the value matches
1422  *   @ref_frame_id[ @frame_to_show_map_idx ] (the value of @current_frame_id at the time that the
1423  *   frame indexed by @frame_to_show_map_idx was stored), and that
1424  *   @ref_valid[ @frame_to_show_map_idx ] is equjal to 1. It is a requirement of bitstream
1425  *   conformance that the number of bits needed to read @display_frame_id does not exceed 16.
1426  *   This is equivalent to the constraint that idLen <= 16
1427  * @frame_type: specifies the type of the frame.
1428  * @show_frame: equal to 1 specifies that this frame should be immediately output once decoded.
1429  *   show_frame equal to 0 specifies that this frame should not be immediately output. (It may
1430  *   be output later if a later uncompressed header uses @show_existing_frame equal to 1).
1431  * @showable_frame: equal to 1 specifies that the frame may be output using the
1432  *   @show_existing_frame mechanism. showable_frame equal to 0 specifies that this frame will
1433  *   not be output using the @show_existing_frame mechanism. It is a requirement of bitstream
1434  *   conformance that when @show_existing_frame is used to show a previous frame, that the
1435  *   value of @showable_frame for the previous frame was equal to 1. It is a requirement of
1436  *   bitstream conformance that a particular showable frame is output via the
1437  *   @show_existing_frame mechanism at most once.
1438  * @error_resilient_mode: equal to 1 indicates that error resilient mode is enabled;
1439  *   @error_resilient_mode equal to 0 indicates that error resilient mode is disabled.
1440  * @disable_cdf_update: specifies whether the CDF update in the symbol decoding process should
1441  *   be disabled.
1442  * @allow_screen_content_tools: equal to 1 indicates that intra blocks may use palette encoding;
1443  *   @allow_screen_content_tools equal to 0 indicates that palette encoding is never used.
1444  * @force_integer_mv: equal to 1 specifies that motion vectors will always be integers.
1445  *   @force_integer_mv equal to 0 specifies that motion vectors can contain fractional bits.
1446  * @current_frame_id: specifies the frame id number for the current frame. Frame id numbers
1447  *   are additional information that do not affect the decoding process, but provide decoders
1448  *   with a way of detecting missing reference frames so that appropriate action can be taken.
1449  * @frame_size_override_flag: equal to 0 specifies that the frame size is equal to the size in
1450  *   the sequence header. @frame_size_override_flag equal to 1 specifies that the frame size
1451  *   will either be specified as the size of one of the reference frames, or computed from the
1452  *   @frame_width_minus_1 and @frame_height_minus_1 syntax elements.
1453  * @order_hint: is used to compute order_hint.
1454  * @primary_ref_frame: specifies which reference frame contains the CDF values and other state
1455  *   that should be loaded at the start of the frame.
1456  * @buffer_removal_time_present_flag: equal to 1 specifies that @buffer_removal_time is present
1457  *   in the bitstream. @buffer_removal_time_present_flag equal to 0 specifies that
1458  *   @buffer_removal_time is not present in the bitstream.
1459  * @buffer_removal_time: specifies the frame removal time in units of DecCT clock ticks
1460  *   counted from the removal time of the last frame with frame_type equal to KEY_FRAME for
1461  *   operating point opNum. @buffer_removal_time is signaled as a fixed length unsigned integer
1462  *   with a length in bits given by @buffer_removal_time_length_minus_1 + 1. @buffer_removal_time
1463  *   is the remainder of a modulo 1 << ( @buffer_removal_time_length_minus_1 + 1 ) counter.
1464  * @refresh_frame_flags: contains a bitmask that specifies which reference frame slots will be
1465  *   updated with the current frame after it is decoded. If @frame_type is equal to
1466  *   #GST_AV1_INTRA_ONLY_FRAME, it is a requirement of bitstream conformance that
1467  *   @refresh_frame_flags is not equal to 0xff.
1468  * @ref_order_hint: specifies the expected output order hint for each reference buffer.
1469  * @allow_intrabc: equal to 1 indicates that intra block copy may be used in this frame.
1470  *   allow_intrabc equal to 0 indicates that intra block copy is not allowed in this frame.
1471  * @frame_refs_short_signaling: equal to 1 indicates that only two reference frames are
1472  *   explicitly signaled. frame_refs_short_signaling equal to 0 indicates that all reference
1473  *   frames are explicitly signaled.
1474  * @last_frame_idx: specifies the reference frame to use for LAST_FRAME.
1475  * @gold_frame_idx: specifies the reference frame to use for GOLDEN_FRAME.
1476  * @ref_frame_idx[i]: specifies which reference frames are used by inter frames.
1477  * @delta_frame_id_minus_1 is used to calculate @delta_frame_id.
1478  * @allow_high_precision_mv: equal to 0 specifies that motion vectors are specified to quarter
1479  *   pel precision; @allow_high_precision_mv equal to 1 specifies that motion vectors are
1480  *   specified to eighth pel precision.
1481  * @is_motion_mode_switchable: equal to 0 specifies that only the SIMPLE motion mode will be used.
1482  * @use_ref_frame_mvs: equal to 1 specifies that motion vector information from a previous
1483  *   frame can be used when decoding the current frame. @use_ref_frame_mvs equal to 0 specifies
1484  *   that this information will not be used.
1485  * @disable_frame_end_update_cdf: equal to 1 indicates that the end of frame CDF update is
1486  *   disabled; @disable_frame_end_update_cdf equal to 0 indicates that the end of frame CDF
1487  *   update is enabled.
1488  * @allow_warped_motion: equal to 1 indicates that the syntax element @motion_mode may be
1489  *   present. @allow_warped_motion equal to 0 indicates that the syntax element motion_mode
1490  *   will not be present (this means that LOCALWARP cannot be signaled if @allow_warped_motion
1491  *   is equal to 0).
1492  * @reduced_tx_set: equal to 1 specifies that the frame is restricted to a reduced subset of
1493  *   the full set of transform types.
1494  * @render_and_frame_size_different: equal to 0 means that the render width and height are
1495  *   inferred from the frame width and height. @render_and_frame_size_different equal to 1
1496  *   means that the render width and height are explicitly coded in the bitstream.
1497  * @use_superres: equal to 0 indicates that no upscaling is needed. @use_superres equal to 1
1498  *   indicates that upscaling is needed.
1499  * @is_filter_switchable: equal to 1 indicates that the filter selection is signaled at the
1500  *   block level; @is_filter_switchable equal to 0 indicates that the filter selection is
1501  *   signaled at the frame level.
1502  * @interpolation_filter: a #GstAV1InterpolationFilter that specifies the filter selection used
1503  *   for performing inter prediction.
1504  * @loop_filter_params: a #GstAV1LoopFilterParams holding the loop filter parameters.
1505  * @quantization_params: a #GstAV1QuantizationParams holding the quantization parameters.
1506  * @segmentation_params: a #GstAV1SegmenationParams holding the segementation parameters.
1507  * @tile_info: a #GstAV1TileInfo holding the tile info.
1508  * @cdef_params: a #GstAV1CDEFParams holding the CDEF paramters.
1509  * @loop_restoration_params: a #GstAV1LoopRestorationParams holding the loop restoration parameters.
1510  * @tx_mode_select: is used to compute TxMode.
1511  * @skip_mode_present: equal to 1 specifies that the syntax element @skip_mode will be coded
1512  *   in the bitstream. @skip_mode_present equal to 0 specifies that @skip_mode will not be used
1513  *   for this frame.
1514  * @reference_select: equal to 1 specifies that the mode info for inter blocks contains the
1515  *   syntax element comp_mode that indicates whether to use single or compound reference
1516  *   prediction. Reference_select equal to 0 specifies that all interblocks will use single
1517  *   prediction.
1518  * @global_motion_params: a #GstAV1GlobalMotionParams holding the global motion parameters.
1519  * @film_grain_params: a #GstAV1FilmGrainParams holding the Film Grain parameters.
1520  * @superres_denom: is the denominator of a fraction that specifies the ratio between the
1521  *   superblock width before and after upscaling.
1522  * @frame_is_intra: if equal to 0 indicating that this frame may use inter prediction.
1523  * @order_hints: specifies the expected output order for each reference frame.
1524  * @ref_frame_sign_bias: specifies the intended direction of the motion vector in time for
1525  *   each reference frame.
1526  * @coded_lossless: is a variable that is equal to 1 when all segments use lossless encoding.
1527  * @all_lossless: is a variable that is equal to 1 when @coded_lossless is equal to 1 and
1528  *   @frame_width is equal to @upscaled_width. This indicates that the frame is fully lossless
1529  *   at the upscaled resolution.
1530  * @lossless_array: whether the segmentation is lossless.
1531  * @seg_qm_Level: the segmentation's qm level.
1532  * @upscaled_width: the upscaled width.
1533  * @frame_width: the frame width.
1534  * @frame_height: the frame height.
1535  * @render_width: the frame width to be rendered.
1536  * @render_height: the frame height to be rendered.
1537  * @tx_mode: specifies how the transform size is determined.
1538  * @skip_mode_frame: specifies the frames to use for compound prediction when @skip_mode is 1.
1539  */
1540 struct _GstAV1FrameHeaderOBU {
1541   gboolean show_existing_frame;
1542   gint8 frame_to_show_map_idx;
1543   guint32 frame_presentation_time;
1544   guint32 tu_presentation_delay;
1545   guint32 display_frame_id;
1546   GstAV1FrameType frame_type;
1547   gboolean show_frame;
1548   gboolean showable_frame;
1549   gboolean error_resilient_mode;
1550   gboolean disable_cdf_update;
1551   guint8 allow_screen_content_tools;
1552   gboolean force_integer_mv;
1553   guint32 current_frame_id;
1554   gboolean frame_size_override_flag;
1555   guint32 order_hint;
1556   guint8 primary_ref_frame;
1557   gboolean buffer_removal_time_present_flag;
1558   guint32 buffer_removal_time[GST_AV1_MAX_OPERATING_POINTS];
1559   guint8 refresh_frame_flags;
1560   guint32 ref_order_hint[GST_AV1_NUM_REF_FRAMES];
1561   gboolean allow_intrabc;
1562   gboolean frame_refs_short_signaling;
1563   gint8 last_frame_idx;
1564   gint8 gold_frame_idx;
1565   gint8 ref_frame_idx[GST_AV1_REFS_PER_FRAME];
1566   gboolean allow_high_precision_mv;
1567   gboolean is_motion_mode_switchable;
1568   gboolean use_ref_frame_mvs;
1569   gboolean disable_frame_end_update_cdf;
1570   gboolean allow_warped_motion;
1571   gboolean reduced_tx_set;
1572   gboolean render_and_frame_size_different;
1573   gboolean use_superres;
1574   gboolean is_filter_switchable;
1575   GstAV1InterpolationFilter interpolation_filter;
1576   GstAV1LoopFilterParams loop_filter_params;
1577   GstAV1QuantizationParams quantization_params;
1578   GstAV1SegmenationParams segmentation_params;
1579   GstAV1TileInfo tile_info;
1580   GstAV1CDEFParams cdef_params;
1581   GstAV1LoopRestorationParams loop_restoration_params;
1582   gboolean tx_mode_select;
1583   gboolean skip_mode_present;
1584   gboolean reference_select;
1585   GstAV1GlobalMotionParams global_motion_params;
1586   GstAV1FilmGrainParams film_grain_params;
1587
1588   /* Global vars set by frame header */
1589   guint32 superres_denom; /* SuperresDenom */
1590   guint8 frame_is_intra; /* FrameIsIntra */
1591   guint32 order_hints[GST_AV1_NUM_REF_FRAMES]; /* OrderHints */
1592   guint32 ref_frame_sign_bias[GST_AV1_NUM_REF_FRAMES]; /* RefFrameSignBias */
1593
1594   guint8 coded_lossless; /* CodedLossless */
1595   guint8 all_lossless; /* AllLossless */
1596   guint8 lossless_array[GST_AV1_MAX_SEGMENTS]; /* LosslessArray */
1597   guint8 seg_qm_Level[3][GST_AV1_MAX_SEGMENTS]; /* SegQMLevel */
1598
1599   guint32 upscaled_width; /* UpscaledWidth */
1600   guint32 frame_width; /* FrameWidth */
1601   guint32 frame_height; /* FrameHeight */
1602   guint32 render_width;  /* RenderWidth */
1603   guint32 render_height; /* RenderHeight */
1604
1605   GstAV1TXModes tx_mode; /* TxMode */
1606
1607   guint8 skip_mode_frame[2]; /* SkipModeFrame */
1608 };
1609
1610 /**
1611  * GstAV1ReferenceFrameInfo:
1612  *
1613  * All the info related to a reference frames.
1614  */
1615 struct _GstAV1ReferenceFrameInfo {
1616   struct {
1617     gboolean ref_valid; /* RefValid */
1618     guint32 ref_frame_id; /* RefFrameId */
1619     guint32 ref_upscaled_width; /* RefUpscaledWidth */
1620     guint32 ref_frame_width; /* RefFrameWidth */
1621     guint32 ref_frame_height; /* RefFrameHeight */
1622     guint32 ref_render_width; /* RefRenderWidth */
1623     guint32 ref_render_height; /* RefRenderHeight */
1624     guint32 ref_mi_cols; /* RefMiCols */
1625     guint32 ref_mi_rows; /* RefMiRows */
1626     GstAV1FrameType ref_frame_type; /* RefFrameType */
1627     guint8 ref_subsampling_x; /* RefSubsamplingX */
1628     guint8 ref_subsampling_y; /* RefSubsamplingY */
1629     guint8 ref_bit_depth; /* RefBitDepth */
1630     guint32 ref_order_hint; /* RefOrderHint */
1631     GstAV1SegmenationParams ref_segmentation_params;
1632     GstAV1GlobalMotionParams ref_global_motion_params;
1633     GstAV1LoopFilterParams ref_lf_params;
1634     GstAV1FilmGrainParams ref_film_grain_params;
1635     GstAV1TileInfo ref_tile_info;
1636   } entry[GST_AV1_NUM_REF_FRAMES];
1637 };
1638
1639 /**
1640  * GstAV1TileListOBU:
1641  * @output_frame_width_in_tiles_minus_1: plus one is the width of the output frame, in tile units.
1642  * @output_frame_height_in_tiles_minus_1: plus one is the height of the output frame, in tile units.
1643  * @tile_count_minus_1: plus one is the number of @tile_list_entry in the list. It is a requirement
1644  *   of bitstream conformance that @tile_count_minus_1 is less than or equal to 511.
1645  * @anchor_frame_idx: is the index into an array AnchorFrames of the frames that the tile uses
1646  *   for prediction. The AnchorFrames array is provided by external means and may change for
1647  *   each tile list OBU. The process for creating the AnchorFrames array is outside of the
1648  *   scope of this specification. It is a requirement of bitstream conformance that
1649  *   @anchor_frame_idx is less than or equal to 127.
1650  * @anchor_tile_row: the row coordinate of the tile in the frame that it belongs, in tile
1651  *   units. It is a requirement of bitstream conformance that @anchor_tile_row is less than @tile_rows.
1652  * @anchor_tile_col: is the column coordinate of the tile in the frame that it belongs, in tile
1653  *   units. It is a requirement of bitstream conformance that @anchor_tile_col is less than @tile_cols.
1654  * @tile_data_size_minus_1: plus one is the size of the coded tile data, @coded_tile_data, in bytes.
1655  * @coded_tile_data: are the @tile_data_size_minus_1 + 1 bytes of the coded tile.
1656  */
1657 struct _GstAV1TileListOBU {
1658   guint8 output_frame_width_in_tiles_minus_1;
1659   guint8 output_frame_height_in_tiles_minus_1;
1660   guint16 tile_count_minus_1;
1661   struct {
1662     gint8 anchor_frame_idx;
1663     guint8 anchor_tile_row;
1664     guint8 anchor_tile_col;
1665     guint16 tile_data_size_minus_1;
1666     /* Just refer to obu's data, invalid after OBU data released */
1667     guint8 *coded_tile_data;
1668   } entry[GST_AV1_MAX_TILE_COUNT];
1669 };
1670
1671 /**
1672  * GstAV1TileListOBU:
1673  * @tile_start_and_end_present_flag: specifies whether @tg_start and @tg_end are present
1674  *   in the bitstream. If @tg_start and @tg_end are not present in the bitstream, this
1675  *   tile group covers the entire frame. If @obu_type is equal to #GST_AV1_OBU_FRAME, it is a
1676  *   requirement of bitstream conformance that the value of @tile_start_and_end_present_flag
1677  *   is equal to 0.
1678  * @tg_start: specifies the zero-based index of the first tile in the current tile group.
1679  *   It is a requirement of bitstream conformance that the value of @tg_start is equal to
1680  *   the value of TileNum at the point that tile_group_obu is invoked.
1681  * @tg_end: specifies the zero-based index of the last tile in the current tile group.
1682  *   It is a requirement of bitstream conformance that the value of tg_end is greater
1683  *   than or equal to tg_start. It is a requirement of bitstream conformance that the
1684  *   value of tg_end for the last tile group in each frame is equal to num_tiles-1.
1685  * @tile_offset: Offset from the OBU data, the real data start of this tile.
1686  * @tg_size: Data size of this tile.
1687  * @tile_row: Tile index in row.
1688  * @tile_col: Tile index in column.
1689  * @mi_row_start: start position in mi rows
1690  * @mi_row_end: end position in mi rows
1691  * @mi_col_start: start position in mi cols
1692  * @mi_col_end: end position in mi cols
1693  * @num_tiles: specifies the total number of tiles in the frame.
1694  */
1695 struct _GstAV1TileGroupOBU {
1696   gboolean tile_start_and_end_present_flag;
1697   guint8 tg_start;
1698   guint8 tg_end;
1699   struct {
1700     guint32 tile_offset; /* Tile data offset from the OBU data. */
1701     guint32 tile_size; /* Data size of this tile */
1702     guint32 tile_row; /* tileRow */
1703     guint32 tile_col; /* tileCol */
1704     /* global varialbes */
1705     guint32 mi_row_start; /* MiRowStart */
1706     guint32 mi_row_end; /* MiRowEnd */
1707     guint32 mi_col_start; /* MiColStart */
1708     guint32 mi_col_end; /* MiColEnd */
1709   } entry[GST_AV1_MAX_TILE_COUNT];
1710
1711   guint32 num_tiles; /* NumTiles */
1712 };
1713
1714 /**
1715  * GstAV1FrameOBU:
1716  * @frame_header: a #GstAV1FrameHeaderOBU holding frame_header data.
1717  * @tile_group: a #GstAV1TileGroupOBU holding tile_group data.
1718  */
1719 struct _GstAV1FrameOBU {
1720   GstAV1TileGroupOBU tile_group;
1721   GstAV1FrameHeaderOBU frame_header;
1722 };
1723
1724 /**
1725  * GstAV1Parser:
1726  *
1727  * #GstAV1Parser opaque structure
1728  *
1729  * Instantiante it with gst_av1_parser_new() and destroy it with
1730  * gst_av1_parser_free()
1731  */
1732 struct _GstAV1Parser
1733 {
1734   /*< private >*/
1735   struct
1736   {
1737     guint32 operating_point;    /* Set by choose_operating_point() */
1738     guint8 seen_frame_header;   /* SeenFrameHeader */
1739     guint32 operating_point_idc;        /* OperatingPointIdc */
1740     gboolean sequence_changed;  /* Received a new sequence */
1741     gboolean begin_first_frame; /* already find the first frame */
1742
1743     /* frame */
1744     guint32 upscaled_width;     /* UpscaledWidth */
1745     guint32 frame_width;        /* FrameWidth */
1746     guint32 frame_height;       /* FrameHeight */
1747     guint32 mi_cols;            /* MiCols */
1748     guint32 mi_rows;            /* MiRows */
1749     guint32 render_width;       /* RenderWidth */
1750     guint32 render_height;      /* RenderHeight */
1751     guint32 prev_frame_id;      /* PrevFrameID */
1752     guint32 current_frame_id;   /* the current frame ID */
1753     GstAV1ReferenceFrameInfo ref_info;  /* RefInfo */
1754
1755     guint32 mi_col_starts[GST_AV1_MAX_TILE_COLS + 1];   /* MiColStarts */
1756     guint32 mi_row_starts[GST_AV1_MAX_TILE_ROWS + 1];   /* MiRowStarts */
1757     guint8 tile_cols_log2;      /* TileColsLog2 */
1758     guint8 tile_cols;           /* TileCols */
1759     guint8 tile_rows_log2;      /* TileRowsLog2 */
1760     guint8 tile_rows;           /* TileRows */
1761     guint8 tile_size_bytes;     /* TileSizeBytes */
1762   } state;
1763
1764   gboolean annex_b;
1765   guint32 temporal_unit_size;
1766   /* consumed of this temporal unit */
1767   guint32 temporal_unit_consumed;
1768   guint32 frame_unit_size;
1769   /* consumed of this frame unit */
1770   guint32 frame_unit_consumed;
1771
1772   GstAV1SequenceHeaderOBU *seq_header;
1773 };
1774
1775 GST_CODEC_PARSERS_API
1776 void
1777 gst_av1_parser_reset (GstAV1Parser * parser, gboolean annex_b);
1778
1779 GST_CODEC_PARSERS_API
1780 void
1781 gst_av1_parser_reset_annex_b (GstAV1Parser * parser);
1782
1783 GST_CODEC_PARSERS_API
1784 GstAV1ParserResult
1785 gst_av1_parser_identify_one_obu (GstAV1Parser * parser, const guint8 * data,
1786     guint32 size, GstAV1OBU * obu, guint32 * consumed);
1787
1788 GST_CODEC_PARSERS_API
1789 GstAV1ParserResult
1790 gst_av1_parser_parse_sequence_header_obu (GstAV1Parser * parser,
1791     GstAV1OBU * obu, GstAV1SequenceHeaderOBU * seq_header);
1792
1793 GST_CODEC_PARSERS_API
1794 GstAV1ParserResult
1795 gst_av1_parser_parse_temporal_delimiter_obu (GstAV1Parser * parser,
1796     GstAV1OBU * obu);
1797
1798 GST_CODEC_PARSERS_API
1799 GstAV1ParserResult
1800 gst_av1_parser_parse_metadata_obu (GstAV1Parser * parser, GstAV1OBU * obu,
1801     GstAV1MetadataOBU * metadata);
1802
1803 GST_CODEC_PARSERS_API
1804 GstAV1ParserResult
1805 gst_av1_parser_parse_tile_list_obu (GstAV1Parser * parser, GstAV1OBU * obu,
1806     GstAV1TileListOBU * tile_list);
1807
1808 GST_CODEC_PARSERS_API
1809 GstAV1ParserResult
1810 gst_av1_parser_parse_tile_group_obu (GstAV1Parser * parser, GstAV1OBU * obu,
1811     GstAV1TileGroupOBU * tile_group);
1812
1813 GST_CODEC_PARSERS_API
1814 GstAV1ParserResult
1815 gst_av1_parser_parse_frame_header_obu (GstAV1Parser * parser, GstAV1OBU * obu,
1816     GstAV1FrameHeaderOBU * frame_header);
1817
1818 GST_CODEC_PARSERS_API
1819 GstAV1ParserResult
1820 gst_av1_parser_parse_frame_obu (GstAV1Parser * parser, GstAV1OBU * obu,
1821     GstAV1FrameOBU * frame);
1822
1823 GST_CODEC_PARSERS_API
1824 GstAV1ParserResult
1825 gst_av1_parser_reference_frame_loading (GstAV1Parser * parser,
1826     GstAV1FrameHeaderOBU * frame_header);
1827
1828 GST_CODEC_PARSERS_API
1829 GstAV1ParserResult
1830 gst_av1_parser_reference_frame_update (GstAV1Parser * parser,
1831     GstAV1FrameHeaderOBU * frame_header);
1832
1833 GST_CODEC_PARSERS_API
1834 GstAV1ParserResult
1835 gst_av1_parser_set_operating_point (GstAV1Parser * parser,
1836     gint32 operating_point);
1837
1838 GST_CODEC_PARSERS_API
1839 GstAV1Parser * gst_av1_parser_new (void);
1840
1841 GST_CODEC_PARSERS_API
1842 void gst_av1_parser_free (GstAV1Parser * parser);
1843
1844 G_END_DECLS
1845
1846 #endif /* __GST_AV1_PARSER_H__ */