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