• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Gstreamer H.265 bitstream parser
2  * Copyright (C) 2013 Intel Corporation
3  * Copyright (C) 2013 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
4  *
5  *  Contact: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef __GST_H265_PARSER_H__
24 #define __GST_H265_PARSER_H__
25 
26 #ifndef GST_USE_UNSTABLE_API
27 #warning "The H.265 parsing library is unstable API and may change in future."
28 #warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
29 #endif
30 
31 #include <gst/gst.h>
32 #include <gst/codecparsers/codecparsers-prelude.h>
33 
34 G_BEGIN_DECLS
35 
36 #define GST_H265_MAX_SUB_LAYERS   8
37 #define GST_H265_MAX_VPS_COUNT   16
38 #define GST_H265_MAX_SPS_COUNT   16
39 #define GST_H265_MAX_PPS_COUNT   64
40 
41 #define GST_H265_IS_B_SLICE(slice)  ((slice)->type == GST_H265_B_SLICE)
42 #define GST_H265_IS_P_SLICE(slice)  ((slice)->type == GST_H265_P_SLICE)
43 #define GST_H265_IS_I_SLICE(slice)  ((slice)->type == GST_H265_I_SLICE)
44 
45 /**
46  * GST_H265_IS_NAL_TYPE_IDR:
47  * @nal_type: a #GstH265NalUnitType
48  *
49  * Check whether @nal_type is IDR or not
50  *
51  * Since: 1.18
52  */
53 #define GST_H265_IS_NAL_TYPE_IDR(nal_type) \
54   ((nal_type) == GST_H265_NAL_SLICE_IDR_W_RADL || (nal_type) == GST_H265_NAL_SLICE_IDR_N_LP)
55 
56 /**
57  * GST_H265_IS_NAL_TYPE_IRAP:
58  * @nal_type: a #GstH265NalUnitType
59  *
60  * Check whether @nal_type is IRAP or not
61  *
62  * Since: 1.18
63  */
64 #define GST_H265_IS_NAL_TYPE_IRAP(nal_type) \
65   ((nal_type) >= GST_H265_NAL_SLICE_BLA_W_LP && (nal_type) <= RESERVED_IRAP_NAL_TYPE_MAX)
66 
67 /**
68  * GST_H265_IS_NAL_TYPE_BLA:
69  * @nal_type: a #GstH265NalUnitType
70  *
71  * Check whether @nal_type is BLA or not
72  *
73  * Since: 1.18
74  */
75 #define GST_H265_IS_NAL_TYPE_BLA(nal_type) \
76   ((nal_type) >= GST_H265_NAL_SLICE_BLA_W_LP && (nal_type) <= GST_H265_NAL_SLICE_BLA_N_LP)
77 
78 /**
79  * GST_H265_IS_NAL_TYPE_CRA:
80  * @nal_type: a #GstH265NalUnitType
81  *
82  * Check whether @nal_type is CRA or not
83  *
84  * Since: 1.18
85  */
86 #define GST_H265_IS_NAL_TYPE_CRA(nal_type) \
87   ((nal_type) == GST_H265_NAL_SLICE_CRA_NUT)
88 
89 /**
90  * GST_H265_IS_NAL_TYPE_RADL:
91  * @nal_type: a #GstH265NalUnitType
92  *
93  * Check whether @nal_type is RADL or not
94  *
95  * Since: 1.18
96  */
97 #define GST_H265_IS_NAL_TYPE_RADL(nal_type) \
98   ((nal_type) == GST_H265_NAL_SLICE_RADL_N || (nal_type) == GST_H265_NAL_SLICE_RADL_R)
99 
100 /**
101  * GST_H265_IS_NAL_TYPE_RASL:
102  * @nal_type: a #GstH265NalUnitType
103  *
104  * Check whether @nal_type is RASL or not
105  *
106  * Since: 1.18
107  */
108 #define GST_H265_IS_NAL_TYPE_RASL(nal_type) \
109   ((nal_type) == GST_H265_NAL_SLICE_RASL_N || (nal_type) == GST_H265_NAL_SLICE_RASL_R)
110 
111 /**
112  * GstH265Profile:
113  * @GST_H265_PROFILE_MAIN: Main profile (A.3.2)
114  * @GST_H265_PROFILE_MAIN_10: Main 10 profile (A.3.3)
115  * @GST_H265_PROFILE_MAIN_STILL_PICTURE: Main Still Picture profile (A.3.4)
116  * @GST_H265_PROFILE_MONOCHROME: Monochrome profile (A.3.4)
117  * @GST_H265_PROFILE_MONOCHROME_12: Monochrome 12-bits profile (A.3.4)
118  * @GST_H265_PROFILE_MONOCHROME_16: Monochrome 16-bits profile (A.3.4)
119  * @GST_H265_PROFILE_MAIN_12: Main profile 12-bits (A.3.4)
120  * @GST_H265_PROFILE_MAIN_422_10: Main 4:2:2 profile 10-bits (A.3.4)
121  * @GST_H265_PROFILE_MAIN_422_12: Main 4:2:2 profile 12-bits (A.3.4)
122  * @GST_H265_PROFILE_MAIN_444: Main 4:4:4 profile (A.3.4)
123  * @GST_H265_PROFILE_MAIN_444_10: Main 4:4:4 10-bits profile (A.3.4)
124  * @GST_H265_PROFILE_MAIN_444_12: Main 4:4:4 12-bits profile (A.3.4)
125  * @GST_H265_PROFILE_MAIN_INTRA: Main Intra profile (A.3.4)
126  * @GST_H265_PROFILE_MAIN_10_INTRA: Main Intra 10-bits profile (A.3.4)
127  * @GST_H265_PROFILE_MAIN_12_INTRA: Main Intra 12-bits profile (A.3.4)
128  * @GST_H265_PROFILE_MAIN_422_10_INTRA: Main Intra 4:2:2 10-bits profile (A.3.4)
129  * @GST_H265_PROFILE_MAIN_422_12_INTRA: Main Intra 4:2:2 12-bits profile (A.3.4)
130  * @GST_H265_PROFILE_MAIN_444_INTRA: Main Intra 4:4:4 profile (A.3.4)
131  * @GST_H265_PROFILE_MAIN_444_10_INTRA: Main Intra 4:4:4 10-bits profile (A.3.4)
132  * @GST_H265_PROFILE_MAIN_444_12_INTRA: Main Intra 4:4:4 12-bits profile (A.3.4)
133  * @GST_H265_PROFILE_MAIN_444_16_INTRA: Main Intra 4:4:4 16-bits profile (A.3.4)
134  * @GST_H265_PROFILE_MAIN_444_STILL_PICTURE: Main 4:4:4 Still Picture profile (A.3.4)
135  * @GST_H265_PROFILE_MAIN_444_16_STILL_PICTURE: Main 4:4:4 16-bits Still Picture profile (A.3.4)
136  * @GST_H265_PROFILE_MONOCHROME_10:  Monochrome 10-bits profile (A.3.5) (Since: 1.18)
137  * @GST_H265_PROFILE_HIGH_THROUGHPUT_444: High Throughput 4:4:4 profile (A.3.6) (Since: 1.18)
138  * @GST_H265_PROFILE_HIGH_THROUGHPUT_444_10: High Throughput 4:4:4 10-bits profile (A.3.6) (Since: 1.18)
139  * @GST_H265_PROFILE_HIGH_THROUGHPUT_444_14: High Throughput 4:4:4 14-bits profile (A.3.6) (Since: 1.18)
140  * @GST_H265_PROFILE_HIGH_THROUGHPUT_444_16_INTRA: High Throughput 4:4:4 16-bits Intra profile (A.3.6) (Since: 1.18)
141  * @GST_H265_PROFILE_SCREEN_EXTENDED_MAIN: Screen-Extended Main profile (A.3.7) (Since: 1.18)
142  * @GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_10: Screen-Extended Main 10-bits profile (A.3.7) (Since: 1.18)
143  * @GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_444: Screen-Extended Main 4:4:4 profile (A.3.7) (Since: 1.18)
144  * @GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_444_10: Screen-Extended Main 4:4:4 10-bits profile (A.3.7) (Since: 1.18)
145  * @GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444: Screen-Extended High Throughput 4:4:4 profile (A.3.7) (Since: 1.18)
146  * @GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_10: Screen-Extended High Throughput 4:4:4 10-bits profile (A.3.7) (Since: 1.18)
147  * @GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_14: Screen-Extended High Throughput 4:4:4 14-bits profile (A.3.7) (Since: 1.18)
148  * @GST_H265_PROFILE_MULTIVIEW_MAIN: Multiview Main profile (G.11.1) (Since: 1.18)
149  * @GST_H265_PROFILE_SCALABLE_MAIN: Scalable Main profile (H.11.1) (Since: 1.18)
150  * @GST_H265_PROFILE_SCALABLE_MAIN_10: Scalable Main 10-bits profile (H.11.1) (Since: 1.18)
151  * @GST_H265_PROFILE_SCALABLE_MONOCHROME: Scalable Monochrome profile (H.11.1) (Since: 1.18)
152  * @GST_H265_PROFILE_SCALABLE_MONOCHROME_12: Scalable Monochrome 12-bits profile (H.11.1) (Since: 1.18)
153  * @GST_H265_PROFILE_SCALABLE_MONOCHROME_16: Scalable Monochrome 16-bits profile (H.11.1) (Since: 1.18)
154  * @GST_H265_PROFILE_SCALABLE_MAIN_444: Scalable Main 4:4:4 profile (H.11.1) (Since: 1.18)
155  * @GST_H265_PROFILE_3D_MAIN: 3D Main 4:4:4 profile (I.11.1) (Since: 1.18)
156  *
157  * H.265 Profiles.
158  *
159  */
160 typedef enum {
161   GST_H265_PROFILE_INVALID              = -1,
162   GST_H265_PROFILE_MAIN                 = 1,
163   GST_H265_PROFILE_MAIN_10              = 2,
164   GST_H265_PROFILE_MAIN_STILL_PICTURE   = 3,
165   GST_H265_PROFILE_MONOCHROME,
166   GST_H265_PROFILE_MONOCHROME_12,
167   GST_H265_PROFILE_MONOCHROME_16,
168   GST_H265_PROFILE_MAIN_12,
169   GST_H265_PROFILE_MAIN_422_10,
170   GST_H265_PROFILE_MAIN_422_12,
171   GST_H265_PROFILE_MAIN_444,
172   GST_H265_PROFILE_MAIN_444_10,
173   GST_H265_PROFILE_MAIN_444_12,
174   GST_H265_PROFILE_MAIN_INTRA,
175   GST_H265_PROFILE_MAIN_10_INTRA,
176   GST_H265_PROFILE_MAIN_12_INTRA,
177   GST_H265_PROFILE_MAIN_422_10_INTRA,
178   GST_H265_PROFILE_MAIN_422_12_INTRA,
179   GST_H265_PROFILE_MAIN_444_INTRA,
180   GST_H265_PROFILE_MAIN_444_10_INTRA,
181   GST_H265_PROFILE_MAIN_444_12_INTRA,
182   GST_H265_PROFILE_MAIN_444_16_INTRA,
183   GST_H265_PROFILE_MAIN_444_STILL_PICTURE,
184   GST_H265_PROFILE_MAIN_444_16_STILL_PICTURE,
185   GST_H265_PROFILE_MONOCHROME_10,
186   GST_H265_PROFILE_HIGH_THROUGHPUT_444,
187   GST_H265_PROFILE_HIGH_THROUGHPUT_444_10,
188   GST_H265_PROFILE_HIGH_THROUGHPUT_444_14,
189   GST_H265_PROFILE_HIGH_THROUGHPUT_444_16_INTRA,
190   GST_H265_PROFILE_SCREEN_EXTENDED_MAIN,
191   GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_10,
192   GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_444,
193   GST_H265_PROFILE_SCREEN_EXTENDED_MAIN_444_10,
194   GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444,
195   GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_10,
196   GST_H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_14,
197   GST_H265_PROFILE_MULTIVIEW_MAIN,
198   GST_H265_PROFILE_SCALABLE_MAIN,
199   GST_H265_PROFILE_SCALABLE_MAIN_10,
200   GST_H265_PROFILE_SCALABLE_MONOCHROME,
201   GST_H265_PROFILE_SCALABLE_MONOCHROME_12,
202   GST_H265_PROFILE_SCALABLE_MONOCHROME_16,
203   GST_H265_PROFILE_SCALABLE_MAIN_444,
204   GST_H265_PROFILE_3D_MAIN,
205 
206   /* end of the profiles */
207   GST_H265_PROFILE_MAX
208 } GstH265Profile;
209 
210 /**
211  * GstH265ProfileIDC:
212  * @GST_H265_PROFILE_IDC_MAIN: Main profile (A.3.2)
213  * @GST_H265_PROFILE_IDC_MAIN_10: Main 10 profile (A.3.3)
214  * @GST_H265_PROFILE_IDC_MAIN_STILL_PICTURE: Main Still Picture profile (A.3.4)
215  * @GST_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSION: Format range extensions profile (A.3.5)
216  * @GST_H265_PROFILE_IDC_HIGH_THROUGHPUT: High throughput profiles (A.3.6)
217  * @GST_H265_PROFILE_IDC_MULTIVIEW_MAIN: Multiview Main profiles (G.11.1) (Since: 1.18)
218  * @GST_H265_PROFILE_IDC_SCALABLE_MAIN: Scalable Main and Scalable Main 10 profile (H.11.1) (Since: 1.18)
219  * @GST_H265_PROFILE_IDC_SCREEN_CONTENT_CODING: Screen content coding extensions profiles (A.3.7)
220  * @GST_H265_PROFILE_IDC_3D_MAIN: 3D Main profile (I.11.1) (Since: 1.18)
221  * @GST_H265_PROFILE_IDC_SCALABLE_FORMAT_RANGE_EXTENSION: Scalable Format range extensions profiles (H.11.1) (Since: 1.18)
222  * @GST_H265_PROFILE_IDC_HIGH_THROUGHPUT_SCREEN_CONTENT_CODING_EXTENSION: High throughput screen content coding extensions profiles (A.3.8) (Since: 1.18)
223  *
224  * Valid values for the profile_idc field. This is different from
225  * #GstH265Profile as an extension idc can be used to encode a whole variety of
226  * profiles.
227  *
228  */
229 typedef enum {
230   GST_H265_PROFILE_IDC_MAIN                   = 1,
231   GST_H265_PROFILE_IDC_MAIN_10                = 2,
232   GST_H265_PROFILE_IDC_MAIN_STILL_PICTURE     = 3,
233   GST_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSION = 4,
234   GST_H265_PROFILE_IDC_HIGH_THROUGHPUT        = 5,
235   GST_H265_PROFILE_IDC_MULTIVIEW_MAIN         = 6,
236   GST_H265_PROFILE_IDC_SCALABLE_MAIN          = 7,
237   GST_H265_PROFILE_IDC_3D_MAIN                = 8,
238   GST_H265_PROFILE_IDC_SCREEN_CONTENT_CODING  = 9,
239   GST_H265_PROFILE_IDC_SCALABLE_FORMAT_RANGE_EXTENSION = 10,
240   GST_H265_PROFILE_IDC_HIGH_THROUGHPUT_SCREEN_CONTENT_CODING_EXTENSION = 11,
241 } GstH265ProfileIDC;
242 
243 /**
244  * GstH265NalUnitType:
245  * @GST_H265_NAL_SLICE_TRAIL_N: Slice nal of a non-TSA, non-STSA trailing picture
246  * @GST_H265_NAL_SLICE_TRAIL_R: Slice nal of a non-TSA, non-STSA trailing picture
247  * @GST_H265_NAL_SLICE_TSA_N: Slice nal of a TSA picture
248  * @GST_H265_NAL_SLICE_TSA_R: Slice nal of a TSA picture
249  * @GST_H265_NAL_SLICE_STSA_N: Slice nal of a STSA picture
250  * @GST_H265_NAL_SLICE_STSA_R: Slice nal of a STSA picture
251  * @GST_H265_NAL_SLICE_RADL_N: Slice nal of a RADL picture
252  * @GST_H265_NAL_SLICE_RADL_R: Slice nal of a RADL piicture
253  * @GST_H265_NAL_SLICE_RASL_N: Slice nal of a RASL picture
254  * @GST_H265_NAL_SLICE_RASL_R: Slice nal of a RASL picture
255  * @GST_H265_NAL_SLICE_BLA_W_LP: Slice nal of a BLA picture
256  * @GST_H265_NAL_SLICE_BLA_W_RADL: Slice nal of a BLA picture
257  * @GST_H265_NAL_SLICE_BLA_N_LP: Slice nal of a BLA picture
258  * @GST_H265_NAL_SLICE_IDR_W_RADL: Slice nal of an IDR picture
259  * @GST_H265_NAL_SLICE_IDR_N_LP: Slice nal of an IDR picture
260  * @GST_H265_NAL_SLICE_CRA_NUT: Slice nal of a CRA picture
261  * @GST_H265_NAL_VPS: Video parameter set(VPS) nal unit
262  * @GST_H265_NAL_SPS: Sequence parameter set (SPS) nal unit
263  * @GST_H265_NAL_PPS: Picture parameter set (PPS) nal unit
264  * @GST_H265_NAL_AUD: Access unit (AU) delimiter nal unit
265  * @GST_H265_NAL_EOS: End of sequence (EOS) nal unit
266  * @GST_H265_NAL_EOB: End of bitstream (EOB) nal unit
267  * @GST_H265_NAL_FD: Filler data (FD) nal lunit
268  * @GST_H265_NAL_PREFIX_SEI: Supplemental enhancement information prefix nal unit
269  * @GST_H265_NAL_SUFFIX_SEI: Suppliemental enhancement information suffix nal unit
270  *
271  * Indicates the type of H265 Nal Units
272  */
273 typedef enum
274 {
275   GST_H265_NAL_SLICE_TRAIL_N    = 0,
276   GST_H265_NAL_SLICE_TRAIL_R    = 1,
277   GST_H265_NAL_SLICE_TSA_N      = 2,
278   GST_H265_NAL_SLICE_TSA_R      = 3,
279   GST_H265_NAL_SLICE_STSA_N     = 4,
280   GST_H265_NAL_SLICE_STSA_R     = 5,
281   GST_H265_NAL_SLICE_RADL_N     = 6,
282   GST_H265_NAL_SLICE_RADL_R     = 7,
283   GST_H265_NAL_SLICE_RASL_N     = 8,
284   GST_H265_NAL_SLICE_RASL_R     = 9,
285   GST_H265_NAL_SLICE_BLA_W_LP   = 16,
286   GST_H265_NAL_SLICE_BLA_W_RADL = 17,
287   GST_H265_NAL_SLICE_BLA_N_LP   = 18,
288   GST_H265_NAL_SLICE_IDR_W_RADL = 19,
289   GST_H265_NAL_SLICE_IDR_N_LP   = 20,
290   GST_H265_NAL_SLICE_CRA_NUT    = 21,
291   GST_H265_NAL_VPS              = 32,
292   GST_H265_NAL_SPS              = 33,
293   GST_H265_NAL_PPS              = 34,
294   GST_H265_NAL_AUD              = 35,
295   GST_H265_NAL_EOS              = 36,
296   GST_H265_NAL_EOB              = 37,
297   GST_H265_NAL_FD               = 38,
298   GST_H265_NAL_PREFIX_SEI       = 39,
299   GST_H265_NAL_SUFFIX_SEI       = 40
300 } GstH265NalUnitType;
301 
302 #define RESERVED_NON_IRAP_SUBLAYER_NAL_TYPE_MIN 10
303 #define RESERVED_NON_IRAP_SUBLAYER_NAL_TYPE_MAX 15
304 
305 #define RESERVED_IRAP_NAL_TYPE_MIN 22
306 #define RESERVED_IRAP_NAL_TYPE_MAX 23
307 
308 #define RESERVED_NON_IRAP_NAL_TYPE_MIN 24
309 #define RESERVED_NON_IRAP_NAL_TYPE_MAX 31
310 
311 #define RESERVED_NON_VCL_NAL_TYPE_MIN 41
312 #define RESERVED_NON_VCL_NAL_TYPE_MAX 47
313 
314 #define UNSPECIFIED_NON_VCL_NAL_TYPE_MIN 48
315 #define UNSPECIFIED_NON_VCL_NAL_TYPE_MAX 63
316 
317 /**
318  * GstH265ParserResult:
319  * @GST_H265_PARSER_OK: The parsing succeeded
320  * @GST_H265_PARSER_BROKEN_DATA: The data to parse is broken
321  * @GST_H265_PARSER_BROKEN_LINK: The link to structure needed for the parsing couldn't be found
322  * @GST_H265_PARSER_ERROR: An error accured when parsing
323  * @GST_H265_PARSER_NO_NAL: No nal found during the parsing
324  * @GST_H265_PARSER_NO_NAL_END: Start of the nal found, but not the end.
325  *
326  * The result of parsing H265 data.
327  */
328 typedef enum
329 {
330   GST_H265_PARSER_OK,
331   GST_H265_PARSER_BROKEN_DATA,
332   GST_H265_PARSER_BROKEN_LINK,
333   GST_H265_PARSER_ERROR,
334   GST_H265_PARSER_NO_NAL,
335   GST_H265_PARSER_NO_NAL_END
336 } GstH265ParserResult;
337 
338 /**
339  * GstH265SEIPayloadType:
340  * @GST_H265_SEI_BUF_PERIOD: Buffering Period SEI Message
341  * @GST_H265_SEI_PIC_TIMING: Picture Timing SEI Message
342  * @GST_H265_SEI_REGISTERED_USER_DATA: Registered user data (D.2.5)
343  * @GST_H265_SEI_RECOVERY_POINT: Recovery Point SEI Message (D.3.8)
344  * @GST_H265_SEI_TIME_CODE: Time code SEI message (D.2.27) (Since: 1.16)
345  * @GST_H265_SEI_MASTERING_DISPLAY_COLOUR_VOLUME: Mastering display colour volume information SEI message (D.2.28) (Since: 1.18)
346  * @GST_H265_SEI_CONTENT_LIGHT_LEVEL: Content light level information SEI message (D.2.35) (Since: 1.18)
347  * ...
348  *
349  * The type of SEI message.
350  */
351 typedef enum
352 {
353   GST_H265_SEI_BUF_PERIOD = 0,
354   GST_H265_SEI_PIC_TIMING = 1,
355   GST_H265_SEI_REGISTERED_USER_DATA = 4,
356   GST_H265_SEI_RECOVERY_POINT = 6,
357   GST_H265_SEI_TIME_CODE = 136,
358   GST_H265_SEI_MASTERING_DISPLAY_COLOUR_VOLUME = 137,
359   GST_H265_SEI_CONTENT_LIGHT_LEVEL = 144,
360       /* and more...  */
361 } GstH265SEIPayloadType;
362 
363 /**
364  * GstH265SEIPicStructType:
365  * @GST_H265_SEI_PIC_STRUCT_FRAME: Picture is a frame
366  * @GST_H265_SEI_PIC_STRUCT_TOP_FIELD: Top field of frame
367  * @GST_H265_SEI_PIC_STRUCT_BOTTOM_FIELD: Botom field of frame
368  * @GST_H265_SEI_PIC_STRUCT_TOP_BOTTOM: Top bottom field of frame
369  * @GST_H265_SEI_PIC_STRUCT_BOTTOM_TOP: bottom top field of frame
370  * @GST_H265_SEI_PIC_STRUCT_TOP_BOTTOM_TOP: top bottom top field of frame
371  * @GST_H265_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: bottom top bottom field of frame
372  * @GST_H265_SEI_PIC_STRUCT_FRAME_DOUBLING: indicates that the frame should
373  *  be displayed two times consecutively
374  * @GST_H265_SEI_PIC_STRUCT_FRAME_TRIPLING: indicates that the frame should be
375  *  displayed three times consecutively
376  * @GST_H265_SEI_PIC_STRUCT_TOP_PAIRED_PREVIOUS_BOTTOM: top field paired with
377  *  previous bottom field in output order
378  * @GST_H265_SEI_PIC_STRUCT_BOTTOM_PAIRED_PREVIOUS_TOP: bottom field paried with
379  *  previous top field in output order
380  * @GST_H265_SEI_PIC_STRUCT_TOP_PAIRED_NEXT_BOTTOM: top field paired with next
381  *  bottom field in output order
382  * @GST_H265_SEI_PIC_STRUCT_BOTTOM_PAIRED_NEXT_TOP: bottom field paired with
383  *  next top field in output order
384  *
385  * SEI pic_struct type
386  */
387 typedef enum
388 {
389   GST_H265_SEI_PIC_STRUCT_FRAME                         = 0,
390   GST_H265_SEI_PIC_STRUCT_TOP_FIELD                     = 1,
391   GST_H265_SEI_PIC_STRUCT_BOTTOM_FIELD                  = 2,
392   GST_H265_SEI_PIC_STRUCT_TOP_BOTTOM                    = 3,
393   GST_H265_SEI_PIC_STRUCT_BOTTOM_TOP                    = 4,
394   GST_H265_SEI_PIC_STRUCT_TOP_BOTTOM_TOP                = 5,
395   GST_H265_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM             = 6,
396   GST_H265_SEI_PIC_STRUCT_FRAME_DOUBLING                = 7,
397   GST_H265_SEI_PIC_STRUCT_FRAME_TRIPLING                = 8,
398   GST_H265_SEI_PIC_STRUCT_TOP_PAIRED_PREVIOUS_BOTTOM    = 9,
399   GST_H265_SEI_PIC_STRUCT_BOTTOM_PAIRED_PREVIOUS_TOP    = 10,
400   GST_H265_SEI_PIC_STRUCT_TOP_PAIRED_NEXT_BOTTOM        = 11,
401   GST_H265_SEI_PIC_STRUCT_BOTTOM_PAIRED_NEXT_TOP        = 12
402 } GstH265SEIPicStructType;
403 
404 /**
405  * GstH265SliceType:
406  *
407  * Type of Picture slice
408  */
409 
410 typedef enum
411 {
412   GST_H265_B_SLICE    = 0,
413   GST_H265_P_SLICE    = 1,
414   GST_H265_I_SLICE    = 2
415 } GstH265SliceType;
416 
417 typedef enum
418 {
419   GST_H265_QUANT_MATIX_4X4   = 0,
420   GST_H265_QUANT_MATIX_8X8   = 1,
421   GST_H265_QUANT_MATIX_16X16 = 2,
422   GST_H265_QUANT_MATIX_32X32 = 3
423 } GstH265QuantMatrixSize;
424 
425 typedef struct _GstH265Parser                   GstH265Parser;
426 
427 typedef struct _GstH265NalUnit                  GstH265NalUnit;
428 
429 typedef struct _GstH265VPS                      GstH265VPS;
430 typedef struct _GstH265SPS                      GstH265SPS;
431 typedef struct _GstH265PPS                      GstH265PPS;
432 typedef struct _GstH265ProfileTierLevel         GstH265ProfileTierLevel;
433 typedef struct _GstH265SubLayerHRDParams        GstH265SubLayerHRDParams;
434 typedef struct _GstH265HRDParams                GstH265HRDParams;
435 typedef struct _GstH265VUIParams                GstH265VUIParams;
436 typedef struct _GstH265SPSExtensionParams       GstH265SPSExtensionParams;
437 typedef struct _GstH265SPSSccExtensionParams    GstH265SPSSccExtensionParams;
438 typedef struct _GstH265PPSExtensionParams       GstH265PPSExtensionParams;
439 typedef struct _GstH265PPSSccExtensionParams    GstH265PPSSccExtensionParams;
440 
441 typedef struct _GstH265ScalingList              GstH265ScalingList;
442 typedef struct _GstH265RefPicListModification   GstH265RefPicListModification;
443 typedef struct _GstH265PredWeightTable          GstH265PredWeightTable;
444 typedef struct _GstH265ShortTermRefPicSet       GstH265ShortTermRefPicSet;
445 typedef struct _GstH265SliceHdr                 GstH265SliceHdr;
446 
447 typedef struct _GstH265PicTiming                GstH265PicTiming;
448 typedef struct _GstH265RegisteredUserData     	GstH265RegisteredUserData;
449 typedef struct _GstH265BufferingPeriod          GstH265BufferingPeriod;
450 typedef struct _GstH265RecoveryPoint            GstH265RecoveryPoint;
451 typedef struct _GstH265TimeCode                 GstH265TimeCode;
452 typedef struct _GstH265MasteringDisplayColourVolume GstH265MasteringDisplayColourVolume;
453 typedef struct _GstH265ContentLightLevel        GstH265ContentLightLevel;
454 typedef struct _GstH265SEIMessage               GstH265SEIMessage;
455 
456 /**
457  * GstH265NalUnit:
458  * @type: A #GstH265NalUnitType
459  * @layer_id: A nal unit layer id
460  * @temporal_id_plus1: A nal unit temporal identifier
461  * @size: The size of the nal unit starting from @offset
462  * @offset: The offset of the actual start of the nal unit
463  * @sc_offset:The offset of the start code of the nal unit
464  * @valid: If the nal unit is valid, which mean it has
465  * already been parsed
466  * @data: The data from which the Nalu has been parsed
467  *
468  * Structure defining the Nal unit headers
469  */
470 struct _GstH265NalUnit
471 {
472   guint8 type;
473   guint8 layer_id;
474   guint8 temporal_id_plus1;
475 
476   /* calculated values */
477   guint size;
478   guint offset;
479   guint sc_offset;
480   gboolean valid;
481 
482   guint8 *data;
483   guint8 header_bytes;
484 };
485 
486 /**
487  * GstH265ProfileTierLevel:
488  * @profile_space: specifies the context for the interpretation of
489  *   general_profile_idc and general_profile_combatibility_flag
490  * @tier_flag: the tier context for the interpretation of general_level_idc
491  * @profile_idc: profile id
492  * @profile_compatibility_flag: compatibility flags
493  * @progressive_source_flag: flag to indicate the type of stream
494  * @interlaced_source_flag: flag to indicate the type of stream
495  * @non_packed_constraint_flag: indicate the presence of frame packing
496  *   arrangement sei message
497  * @frame_only_constraint_flag: recognize the field_seq_flag
498  * @max_12bit_constraint_flag: used to define profile extensions, see Annex A
499  * @max_10bit_constraint_flag: used to define profile extensions, see Annex A
500  * @max_8bit_constraint_flag: used to define profile extensions, see Annex A
501  * @max_422chroma_constraint_flag: used to define profile extensions, see Annex A
502  * @max_420chroma_constraint_flag: used to define profile extensions, see Annex A
503  * @max_monochrome_constraint_flag: used to define profile extensions, see Annex A
504  * @intra_constraint_flag: used to define profile extensions, see Annex A
505  * @one_picture_only_constraint_flag: used to define profile extensions, see Annex A
506  * @lower_bit_rate_constraint_flag: used to define profile extensions, see Annex A
507  * @max_14bit_constraint_flag: used to define profile extensions, see Annex A
508  * @level idc: indicate the level which the CVS confirms
509  * @sub_layer_profile_present_flag: sublayer profile presence ind
510  * @sub_layer_level_present_flag:sublayer level presence indicator.
511  * @sub_layer_profile_space: profile space for sublayers
512  * @sub_layer_tier_flag: tier flags for sublayers.
513  * @sub_layer_profile_idc: conformant profile indicator for sublayers.
514  * @sub_layer_profile_compatibility_flag[6][32]: compatibility flags for sublayers
515  * @sub_layer_progressive_source_flag:progressive stream indicator for sublayer
516  * @sub_layer_interlaced_source_flag: interlaced stream indicator for sublayer
517  * @sub_layer_non_packed_constraint_flag: indicate the presence of
518  *   frame packing arrangement sei message with in sublayers
519  * @sub_layer_frame_only_constraint_flag:recognize the sublayer
520  *   specific field_seq_flag
521  * @sub_layer_level_idc:indicate the sublayer specific level
522  *
523  * Define ProfileTierLevel parameters
524  */
525 struct _GstH265ProfileTierLevel {
526   guint8 profile_space;
527   guint8 tier_flag;
528   guint8 profile_idc;
529 
530   guint8 profile_compatibility_flag[32];
531 
532   guint8 progressive_source_flag;
533   guint8 interlaced_source_flag;
534   guint8 non_packed_constraint_flag;
535   guint8 frame_only_constraint_flag;
536 
537   guint8 max_12bit_constraint_flag;
538   guint8 max_10bit_constraint_flag;
539   guint8 max_8bit_constraint_flag;
540   guint8 max_422chroma_constraint_flag;
541   guint8 max_420chroma_constraint_flag;
542   guint8 max_monochrome_constraint_flag;
543   guint8 intra_constraint_flag;
544   guint8 one_picture_only_constraint_flag;
545   guint8 lower_bit_rate_constraint_flag;
546   guint8 max_14bit_constraint_flag;
547 
548   guint8 level_idc;
549 
550   guint8 sub_layer_profile_present_flag[6];
551   guint8 sub_layer_level_present_flag[6];
552 
553   guint8 sub_layer_profile_space[6];
554   guint8 sub_layer_tier_flag[6];
555   guint8 sub_layer_profile_idc[6];
556   guint8 sub_layer_profile_compatibility_flag[6][32];
557   guint8 sub_layer_progressive_source_flag[6];
558   guint8 sub_layer_interlaced_source_flag[6];
559   guint8 sub_layer_non_packed_constraint_flag[6];
560   guint8 sub_layer_frame_only_constraint_flag[6];
561   guint8 sub_layer_level_idc[6];
562 };
563 
564 /**
565  * GstH265SubLayerHRDParams:
566  * @bit_rate_value_minus1:togeter with bit_rate_scale, it specifies
567  *   the maximum input bitrate when the CPB operates at the access
568  *   unit level
569  * @cpb_size_value_minus1: is used together with cpb_size_scale to
570  *   specify the CPB size when the CPB operates at the access unit
571  *   level
572  * @cpb_size_du_value_minus1: is used together with cpb_size_du_scale
573  *   to specify the CPB size when the CPB operates at sub-picture
574  *   level
575  * @bit_rate_du_value_minus1: together with bit_rate_scale, it
576  *   specifies the maximum input bit rate when the CPB operates at the
577  *   sub-picture level
578  * @cbr_flag: indicate whether HSS operates in intermittent bit rate
579  *   mode or constant bit rate mode.
580  *
581  * Defines the Sublayer HRD parameters
582  */
583 struct _GstH265SubLayerHRDParams
584 {
585   guint32 bit_rate_value_minus1[32];
586   guint32 cpb_size_value_minus1[32];
587 
588   guint32 cpb_size_du_value_minus1[32];
589   guint32 bit_rate_du_value_minus1[32];
590 
591   guint8 cbr_flag[32];
592 };
593 
594 /**
595  * GstH265HRDParams:
596  * @nal_hrd_parameters_present_flag: indicate the presence of NAL HRD parameters
597  * @vcl_hrd_parameters_present_flag: indicate the presence of VCL HRD parameters
598  * @sub_pic_hrd_params_present_flag: indicate the presence of sub_pic_hrd_params
599  * @tick_divisor_minus2: is used to specify the clock sub-tick
600  * @du_cpb_removal_delay_increment_length_minus1: specifies the length,
601  *   in bits, of the nal_initial_cpb_removal_delay
602  * @sub_pic_cpb_params_in_pic_timing_sei_flag: specifies the length, in bits, of
603  *   the cpb_delay_offset and the au_cpb_removal_delay_minus1 syntax elements.
604  * @dpb_output_delay_du_length_minu1: specifies the length, in bits, of the
605  *   dpb_delay_offset and the pic_dpb_output_delay syntax elements
606  * @bit_rate_scale: maximum input bitrate
607  * @cpb_size_scale: CPB size when operates in access unit level
608  * @cpb_size_du_scale: CPB size when operates in sub-picture level
609  * @initial_cpb_removal_delay_length_minus1: specifies the length, in bits, of the
610  *   nal_initial_cpb_removal_delay, nal_initial_cpb_removal_offset,
611  *   vcl_initial_cpb_removal_delay and vcl_initial_cpb_removal_offset.
612  * @au_cpb_removal_delay_length_minus1: specifies the length, in bits, of the
613  *   cpb_delay_offset and the au_cpb_removal_delay_minus1 syntax elements
614  * @dpb_output_delay_length_minus1: specifies the length, in bits, of the
615  *   dpb_delay_offset and the pic_dpb_output_delay syntax elements
616  * @fixed_pic_rate_general_flag: flag to indicate the presence of constraint
617  *   on the temporal distance between the HRD output times of consecutive
618  *   pictures in output order
619  * @fixed_pic_rate_within_cvs_flag: same as fixed_pic_rate_general_flag
620  * @elemental_duration_in_tc_minus1: temporal distance in clock ticks
621  * @low_delay_hrd_flag: specifies the HRD operational mode
622  * @cpb_cnt_minus1:specifies the number of alternative CPS specifications.
623  * @sublayer_hrd_params: Sublayer HRD parameters.
624  *
625  * Defines the HRD parameters
626  */
627 struct _GstH265HRDParams
628 {
629   guint8 nal_hrd_parameters_present_flag;
630   guint8 vcl_hrd_parameters_present_flag;
631   guint8 sub_pic_hrd_params_present_flag;
632 
633   guint8 tick_divisor_minus2;
634   guint8 du_cpb_removal_delay_increment_length_minus1;
635   guint8 sub_pic_cpb_params_in_pic_timing_sei_flag;
636   guint8 dpb_output_delay_du_length_minus1;
637 
638   guint8 bit_rate_scale;
639   guint8 cpb_size_scale;
640   guint8 cpb_size_du_scale;
641 
642   guint8 initial_cpb_removal_delay_length_minus1;
643   guint8 au_cpb_removal_delay_length_minus1;
644   guint8 dpb_output_delay_length_minus1;
645 
646   guint8 fixed_pic_rate_general_flag [7];
647   guint8 fixed_pic_rate_within_cvs_flag [7];
648   guint16 elemental_duration_in_tc_minus1 [7];
649   guint8 low_delay_hrd_flag [7];
650   guint8 cpb_cnt_minus1[7];
651 
652   GstH265SubLayerHRDParams sublayer_hrd_params[7];
653 };
654 
655 /**
656  * GstH265VPS:
657  * @id: vps id
658  * @base_layer_internal_flag and @base_layer_available_flag:
659  *   specify availability of base layer
660  * @max_layers_minus1: should be zero, but can be other values in future
661  * @max_sub_layers_minus1:specifies the maximum number of temporal sub-layers
662  * @temporal_id_nesting_flag: specifies whether inter prediction is
663  *   additionally restricted
664  * @profile_tier_level: ProfileTierLevel info
665  * @sub_layer_ordering_info_present_flag: indicates the presence of
666  *   vps_max_dec_pic_buffering_minus1, vps_max_num_reorder_pics and
667  *   vps_max_latency_increase_plus1
668  * @max_dec_pic_buffering_minus1: specifies the maximum required size
669  *   of the decoded picture buffer
670  * @max_num_reorder_pics: indicates the maximum allowed number of
671  *   pictures that can precede any picture in the CVS in decoding
672  *   order
673  * @max_latency_increase_plus1: is used to compute the value of
674  *   VpsMaxLatencyPictures
675  * @max_layer_id: specifies the maximum allowed value of nuh_layer_id
676  * @num_layer_sets_minus1: specifies the number of layer sets
677  * @layer_id_included_flag: specifies whether a nuh_layer_id included
678  *   in the layer identifier list
679  * @timing_info_present_flag: indicate the presence of
680  *   num_units_in_tick, time_scale, poc_proportional_to_timing_flag
681  *   and num_hrd_parameters
682  * @num_units_in_tick: number of time units in a tick
683  * @time_scale: number of time units that pass in one second
684  * @poc_proportional_to_timing_flag: indicate whether the picture
685  *   order count is proportional to output timin
686  * @num_ticks_poc_diff_one_minus1: specifies the number of clock ticks
687  *   corresponding to a difference of picture order count values equal
688  *   to 1
689  * @num_hrd_parameters: number of hrd_parameters present
690  * @hrd_layer_set_idx: index to the list of layer hrd params.
691  * @hrd_params: the GstH265HRDParams list
692  *
693  * Defines the VPS parameters
694  */
695 struct _GstH265VPS {
696   guint8 id;
697 
698   guint8 base_layer_internal_flag;
699   guint8 base_layer_available_flag;
700 
701   guint8 max_layers_minus1;
702   guint8 max_sub_layers_minus1;
703   guint8 temporal_id_nesting_flag;
704 
705   GstH265ProfileTierLevel profile_tier_level;
706 
707   guint8 sub_layer_ordering_info_present_flag;
708   guint8 max_dec_pic_buffering_minus1[GST_H265_MAX_SUB_LAYERS];
709   guint8 max_num_reorder_pics[GST_H265_MAX_SUB_LAYERS];
710   guint32 max_latency_increase_plus1[GST_H265_MAX_SUB_LAYERS];
711 
712   guint8 max_layer_id;
713   guint16 num_layer_sets_minus1;
714 
715   guint8 timing_info_present_flag;
716   guint32 num_units_in_tick;
717   guint32 time_scale;
718   guint8 poc_proportional_to_timing_flag;
719   guint32 num_ticks_poc_diff_one_minus1;
720 
721   guint16 num_hrd_parameters;
722 
723   /* FIXME: following HRD related info should be an array */
724   guint16 hrd_layer_set_idx;
725   guint8 cprms_present_flag;
726   GstH265HRDParams hrd_params;
727 
728   guint8 vps_extension;
729 
730   gboolean valid;
731 };
732 /**
733  * GstH265ShortTermRefPicSet:
734  * @inter_ref_pic_set_prediction_flag: %TRUE specifies that the stRpsIdx-th candidate
735  *  short-term RPS is predicted from another candidate short-term RPS
736  * @delta_idx_minus1: plus 1 specifies the difference between the value of source and
737  *  candidate short term RPS.
738  * @delta_rps_sign: delta_rps_sign and abs_delta_rps_minus1 together specify
739  *  the value of the variable deltaRps.
740  * @abs_delta_rps_minus1: delta_rps_sign and abs_delta_rps_minus1 together specify
741  *  the value of the variable deltaRps
742  * @NumDeltaPocs: sum of @NumNegativePics and @NumPositivePics.
743  * @NumNegativePics: Derived value depending on inter_ref_pic_set_prediction_flag.
744  *  If inter_ref_pic_set_prediction_flag is equal to 0, this specifies
745  *  the number of entries in the stRpsIdx-th candidate
746  *  short-term RPS that have poc values less than the poc of the current picture.
747  * @NumPositivePics: Derived value depending on inter_ref_pic_set_prediction_flag.
748  *  If inter_ref_pic_set_prediction_flag is equal to 0, this specifies
749  *  the number of entires in the stRpsIdx-th candidate
750  *  short-term RPS that have poc values greater than the poc value of the current picture.
751  * @UsedByCurrPicS0: Derived value depending on inter_ref_pic_set_prediction_flag.
752  *  If inter_ref_pic_set_prediction_flag is equal to 0,
753  *  equal to zero specifies that the i-th entry in the stRpsIdx-th
754  *  candidate short-term RPS that has poc value less than of the current picture
755  *  is not used for reference by the current picture
756  * @UsedByCurrPicS1: Derived value depending on inter_ref_pic_set_prediction_flag.
757  *  If inter_ref_pic_set_prediction_flag is equal to 0,
758  *  equal to zero specifies that the i-th entry in the current
759  *  candidate short-term RPS that has poc value greater than that of the current picture
760  *  is not used for reference by the current picture.
761  * @DeltaPocS0: Derived value depending on inter_ref_pic_set_prediction_flag.
762  *  See 7.4.8 Short-term reference picture set semantics
763  * @DeltaPocS1: Derived value depending on inter_ref_pic_set_prediction_flag.
764  *  See 7.4.8 Short-term reference picture set semantics
765  * @NumDeltaPocsOfRefRpsIdx: The value of NumDeltaPocs[RefRpsIdx].
766  *  If inter_ref_pic_set_prediction_flag is equal to 0,
767  *  this value should be ignored (Since: 1.18)
768  *
769  * Defines the #GstH265ShortTermRefPicSet params
770  */
771 struct _GstH265ShortTermRefPicSet
772 {
773   guint8 inter_ref_pic_set_prediction_flag;
774   guint8 delta_idx_minus1;
775   guint8 delta_rps_sign;
776   guint16 abs_delta_rps_minus1;
777 
778   /* calculated values */
779   guint8 NumDeltaPocs;
780   guint8 NumNegativePics;
781   guint8 NumPositivePics;
782   guint8 UsedByCurrPicS0[16];
783   guint8 UsedByCurrPicS1[16];
784   gint32 DeltaPocS0[16];
785   gint32 DeltaPocS1[16];
786   guint8 NumDeltaPocsOfRefRpsIdx;
787 };
788 
789 /**
790  * GstH265VUIParams:
791  * @aspect_ratio_info_present_flag: %TRUE specifies that aspect_ratio_idc is present.
792  *  %FALSE specifies that aspect_ratio_idc is not present
793  * @aspect_ratio_idc specifies the value of the sample aspect ratio of the luma samples
794  * @sar_width indicates the horizontal size of the sample aspect ratio
795  * @sar_height indicates the vertical size of the sample aspect ratio
796  * @overscan_info_present_flag: %TRUE overscan_appropriate_flag is present %FALSE otherwise
797  * @overscan_appropriate_flag: %TRUE indicates that the cropped decoded pictures
798  *  output are suitable for display using overscan. %FALSE the cropped decoded pictures
799  *  output contain visually important information
800  * @video_signal_type_present_flag: %TRUE specifies that video_format, video_full_range_flag and
801  *  colour_description_present_flag are present.
802  * @video_format: indicates the representation of the picture
803  * @video_full_range_flag: indicates the black level and range of the luma and chroma signals
804  * @colour_description_present_flag: %TRUE specifies that colour_primaries,
805  *  transfer_characteristics and matrix_coefficients are present
806  * @colour_primaries: indicates the chromaticity coordinates of the source primaries
807  * @transfer_characteristics: indicates the opto-electronic transfer characteristic
808  * @matrix_coefficients: describes the matrix coefficients used in deriving luma and chroma signals
809  * @chroma_loc_info_present_flag: %TRUE specifies that chroma_sample_loc_type_top_field and
810  *  chroma_sample_loc_type_bottom_field are present, %FALSE otherwise
811  * @chroma_sample_loc_type_top_field: specify the location of chroma for top field
812  * @chroma_sample_loc_type_bottom_field specify the location of chroma for bottom field
813  * @neutral_chroma_indication_flag: %TRUE indicate that the value of chroma samples is equla
814  *  to 1<<(BitDepthchrom-1).
815  * @field_seq_flag: %TRUE indicate field and %FALSE indicate frame
816  * @frame_field_info_present_flag: %TRUE indicate picture timing SEI messages are present for every
817  *   picture and include the pic_struct, source_scan_type, and duplicate_flag syntax elements.
818  * @default_display_window_flag: %TRUE indicate that the default display window parameters present
819  * def_disp_win_left_offset:left offset of display rect
820  * def_disp_win_right_offset: right offset of display rect
821  * def_disp_win_top_offset: top offset of display rect
822  * def_disp_win_bottom_offset: bottom offset of display rect
823  * @timing_info_present_flag: %TRUE specifies that num_units_in_tick,
824  *  time_scale and fixed_frame_rate_flag are present in the bitstream
825  * @num_units_in_tick: is the number of time units of a clock operating at the frequency time_scale Hz
826  * @time_scale: is the number of time units that pass in one second
827  * @poc_proportional_to_timing_flag: %TRUE indicates that the picture order count value for each picture
828  *  in the CVS that is not the first picture in the CVS, in decoding order, is proportional to the output
829  *  time of the picture relative to the output time of the first picture in the CVS.
830  * @num_ticks_poc_diff_one_minus1: plus 1 specifies the number of clock ticks corresponding to a
831  *  difference of picture order count values equal to 1
832  * @hrd_parameters_present_flag: %TRUE if hrd parameters present in the bitstream
833  * @bitstream_restriction_flag: %TRUE specifies that the following coded video sequence bitstream restriction
834  * parameters are present
835  * @tiles_fixed_structure_flag: %TRUE indicates that each PPS that is active in the CVS has the same value
836  *   of the syntax elements num_tile_columns_minus1, num_tile_rows_minus1, uniform_spacing_flag,
837  *   column_width_minus1, row_height_minus1 and loop_filter_across_tiles_enabled_flag, when present
838  * @motion_vectors_over_pic_boundaries_flag: %FALSE indicates that no sample outside the
839  *  picture boundaries and no sample at a fractional sample position, %TRUE indicates that one or more
840  *  samples outside picture boundaries may be used in inter prediction
841  * @restricted_ref_pic_list_flag: %TRUE indicates that all P and B slices (when present) that belong to
842  *  the same picture have an identical reference picture list 0, and that all B slices (when present)
843  *   that belong to the same picture have an identical reference picture list 1
844  * @min_spatial_segmentation_idc: when not equal to 0, establishes a bound on the maximum possible size
845  *  of distinct coded spatial segmentation regions in the pictures of the CVS
846  * @max_bytes_per_pic_denom: indicates a number of bytes not exceeded by the sum of the sizes of
847  *  the VCL NAL units associated with any coded picture in the coded video sequence.
848  * @max_bits_per_min_cu_denom: indicates an upper bound for the number of coded bits of coding_unit
849  *  data for any coding block in any picture of the CVS
850  * @log2_max_mv_length_horizontal: indicate the maximum absolute value of a decoded horizontal
851  * motion vector component
852  * @log2_max_mv_length_vertical: indicate the maximum absolute value of a decoded vertical
853  *  motion vector component
854  *
855  * The structure representing the VUI parameters.
856  */
857 struct _GstH265VUIParams
858 {
859   guint8 aspect_ratio_info_present_flag;
860   guint8 aspect_ratio_idc;
861   /* if aspect_ratio_idc == 255 */
862   guint16 sar_width;
863   guint16 sar_height;
864 
865   guint8 overscan_info_present_flag;
866   /* if overscan_info_present_flag */
867   guint8 overscan_appropriate_flag;
868 
869   guint8 video_signal_type_present_flag;
870   guint8 video_format;
871   guint8 video_full_range_flag;
872   guint8 colour_description_present_flag;
873   guint8 colour_primaries;
874   guint8 transfer_characteristics;
875   guint8 matrix_coefficients;
876 
877   guint8 chroma_loc_info_present_flag;
878   guint8 chroma_sample_loc_type_top_field;
879   guint8 chroma_sample_loc_type_bottom_field;
880 
881   guint8 neutral_chroma_indication_flag;
882   guint8 field_seq_flag;
883   guint8 frame_field_info_present_flag;
884   guint8 default_display_window_flag;
885   guint32 def_disp_win_left_offset;
886   guint32 def_disp_win_right_offset;
887   guint32 def_disp_win_top_offset;
888   guint32 def_disp_win_bottom_offset;
889 
890   guint8 timing_info_present_flag;
891   /* if timing_info_present_flag */
892   guint32 num_units_in_tick;
893   guint32 time_scale;
894   guint8 poc_proportional_to_timing_flag;
895   /* if poc_proportional_to_timing_flag */
896   guint32 num_ticks_poc_diff_one_minus1;
897   guint8 hrd_parameters_present_flag;
898   /*if hrd_parameters_present_flat */
899   GstH265HRDParams hrd_params;
900 
901   guint8 bitstream_restriction_flag;
902   /*  if bitstream_restriction_flag */
903   guint8 tiles_fixed_structure_flag;
904   guint8 motion_vectors_over_pic_boundaries_flag;
905   guint8 restricted_ref_pic_lists_flag;
906   guint16 min_spatial_segmentation_idc;
907   guint8 max_bytes_per_pic_denom;
908   guint8 max_bits_per_min_cu_denom;
909   guint8 log2_max_mv_length_horizontal;
910   guint8 log2_max_mv_length_vertical;
911 
912   /* calculated values */
913   guint par_n;
914   guint par_d;
915 };
916 
917 /**
918  * GstH265SPSExtensionParams:
919  * @transform_skip_rotation_enabled_flag: %TRUE specifies that a rotation is applied to
920  *   the residual data block from intra 4X4 blocks coded using a transform skip operation.
921  * @transform_skip_context_enabled_flag: %TRUE specifies tspecifies that a particular
922  *   context is used for the parsing of the sig_coeff_flag for transform blocks with a skipped
923  *   transform.
924  * @implicit_residual_dpcm_enabled_flag: %TRUE specifies that  the residual modification process
925  *   for blocks using a transform bypass may be used for intra blocks in the CVS
926  * @explicit_residual_dpcm_enabled_flag: %TRUE specifies that the residual modification process
927  *   for blocks using a transform bypass may be used for inter blocks in the CVS
928  * @extended_precision_processing_flag: %TRUE specifies that an extended dynamic range is used
929  *   for coefficient parsing and inverse transform processing
930  * @intra_smoothing_disabled_flag: %TRUE specifies that  the filtering process of neighbouring
931  *   samples is unconditionally disabled for intra prediction
932  * @high_precision_offsets_enabled_flag: %TRUE specifies that weighted prediction offset values
933  *   are signalled using a bit-depth-dependent precision.
934  * @persistent_rice_adaptation_enabled_flag: %TRUE specifies that the Rice parameter derivation
935  *   for the binarization of coeff_abs_level_remaining[] is initialized at the start of each
936  *   sub-block using mode dependent statistics accumulated from previous sub-blocks.
937  * @cabac_bypass_alignment_enabled_flag: %TRUE specifies that a context-based adaptive binary
938  *   arithmetic coding (CABAC) alignment process is used prior to bypass decoding of the syntax
939  *   elements coeff_sign_flag[] and coeff_abs_level_remaining[]
940  *
941  * Defines the GstH265SPSExtensionParams
942  */
943 struct _GstH265SPSExtensionParams {
944   guint8 transform_skip_rotation_enabled_flag;
945   guint8 transform_skip_context_enabled_flag;
946   guint8 implicit_rdpcm_enabled_flag;
947   guint8 explicit_rdpcm_enabled_flag;
948   guint8 extended_precision_processing_flag;
949   guint8 intra_smoothing_disabled_flag;
950   guint8 high_precision_offsets_enabled_flag;
951   guint8 persistent_rice_adaptation_enabled_flag;
952   guint8 cabac_bypass_alignment_enabled_flag;
953 };
954 
955 /**
956  * GstH265SPSSccExtensionParams:
957  * @sps_curr_pic_ref_enabled_flag: equal to 1 specifies that a picture in the CVS may be
958  *   included in a reference picture list of a slice of the picture itself.
959  * @palette_mode_enabled_flag: equal to 1 specifies that the decoding process for palette mode
960  *   may be used for intra blocks. Equal to 0 specifies that the decoding process for palette
961  *   mode is not applied.
962  * @palette_max_size: specifies the maximum allowed palette size.
963  * @delta_palette_max_predictor_size: specifies the difference between the maximum allowed
964  *   palette predictor size and the maximum allowed palette size.
965  * @sps_palette_predictor_initializers_present_flag: equal to 1 specifies that the sequence
966  *   palette predictors are initialized using the sps_palette_predictor_initializer specified
967  *   in clause 7.3.2.2.3.
968  * @sps_num_palette_predictor_initializer_minus1: plus 1 specifies the number of entries in
969  *   the sequence palette predictor initializer.
970  * @sps_palette_predictor_initializer: specifies the value of the comp-th component of the
971  *   i-th palette entry in the SPS that is used to initialize the array PredictorPaletteEntries.
972  * @motion_vector_resolution_control_idc: controls the presence and inference of the
973  *   use_integer_mv_flag that specifies the resolution of motion vectors for inter prediction.
974  * @intra_boundary_filtering_disabled_flag: equal to 1 specifies that the intra boundary
975  *   filtering process is unconditionally disabled for intra prediction.
976  * Defines the _GstH265SPSSccExtensionParams
977  *
978  * Since: 1.18
979  */
980 struct _GstH265SPSSccExtensionParams {
981   guint8 sps_curr_pic_ref_enabled_flag;
982   guint8 palette_mode_enabled_flag;
983   guint8 palette_max_size;
984   guint8 delta_palette_max_predictor_size;
985   guint8 sps_palette_predictor_initializers_present_flag;
986   guint8 sps_num_palette_predictor_initializer_minus1;
987   guint32 sps_palette_predictor_initializer[3][128];
988   guint8 motion_vector_resolution_control_idc;
989   guint8 intra_boundary_filtering_disabled_flag;
990 };
991 
992 /**
993  * GstH265PPSExtensionParams:
994  * @log2_max_transform_skip_block_size_minus2: plus 2 specifies the maximum transform block size for which
995  *   transform_skip_flag may be present in coded pictures referring to the PPS.
996  * @cross_component_prediction_enabled_flag: equal to 1 specifies that log2_res_scale_abs_plus1 and
997  *   res_scale_sign_flag may be present in the transform unit syntax for pictures referring to the PPS.
998  * @chroma_qp_offset_list_enabled_flag: equal to 1 specifies that the cu_chroma_qp_offset_flag may be
999  *   present in the transform unit syntax.
1000  * @diff_cu_chroma_qp_offset_depth: specifies the difference between the luma coding tree block size and
1001  *   the minimum luma coding block size of coding units that convey cu_chroma_qp_offset_flag.
1002  * @chroma_qp_offset_list_len_minus1: plus 1 specifies the number of cb_qp_offset_list[] and
1003  *   cr_qp_offset_list[] syntax elements that are present in the PPS.
1004  * @cb_qp_offset_list: specify offsets used in the derivation of qp cb.
1005  * @cr_qp_offset_list: specify offsets used in the derivation of qp cr.
1006  * @log2_sao_offset_scale_luma: the base 2 logarithm of the scaling parameter that is used to scale sample
1007  *   adaptive offset (SAO) offset values for luma samples.
1008  * @log2_sao_offset_scale_chroma: the base 2 logarithm of the scaling parameter that is used to scale SAO
1009  *   offset values for chroma samples.
1010  *
1011  * Defines the GstH265SPSExtensionParams
1012  */
1013 struct _GstH265PPSExtensionParams {
1014   guint32 log2_max_transform_skip_block_size_minus2;
1015   guint8 cross_component_prediction_enabled_flag;
1016   guint8 chroma_qp_offset_list_enabled_flag;
1017   guint8 diff_cu_chroma_qp_offset_depth;
1018   guint8 chroma_qp_offset_list_len_minus1;
1019   gint8 cb_qp_offset_list[6];
1020   gint8 cr_qp_offset_list[6];
1021   guint8 log2_sao_offset_scale_luma;
1022   guint8 log2_sao_offset_scale_chroma;
1023 };
1024 
1025 /**
1026  * GstH265PPSSccExtensionParams:
1027  * @pps_curr_pic_ref_enabled_flag: equal to 1 specifies that a picture referring to the PPS may
1028  *   be included in a reference picture list of a slice of the picture itself.
1029  * @residual_adaptive_colour_transform_enabled_flag: equal to 1 specifies that an adaptive
1030  *   colour transform may be applied to the residual in the decoding process.
1031  * @pps_slice_act_qp_offsets_present_flag: equal to 1 specifies that slice_act_y_qp_offset,
1032  *   slice_act_cb_qp_offset, slice_act_cr_qp_offset are present in the slice header.
1033  * @pps_act_y_qp_offset_plus5 @pps_act_cb_qp_offset_plus5 @pps_act_cr_qp_offset_plus3:
1034  *   are used to determine the offsets that are applied to the quantization parameter values
1035  *   qp derived in clause 8.6.2 for the luma, Cb and Cr components, respectively, when
1036  *   tu_residual_act_flag[ xTbY ][ yTbY ] is equal to 1.
1037  * @pps_palette_predictor_initializers_present_flag: equal to 1 specifies that the palette
1038  *   predictor initializers used for the pictures referring to the PPS are derived based on
1039  *   the palette predictor initializers specified by the PPS.
1040  * @pps_num_palette_predictor_initializer: specifies the number of entries in the picture
1041  *   palette predictor initializer.
1042  * @monochrome_palette_flag: equal to 1 specifies that the pictures that refer to this PPS
1043  *   are monochrome. Equal to 0 specifies that the pictures that refer to this PPS have
1044  *   multiple components.
1045  * @luma_bit_depth_entry_minus8: plus 8 specifies the bit depth of the luma component of the
1046  *   entries of the palette predictor initializer.
1047  * @chroma_bit_depth_entry_minus8: plus 8 specifies the bit depth of the chroma components of
1048  *   the entries of the palette predictor initializer.
1049  * @pps_palette_predictor_initializer: specifies the value of the comp-th component of the
1050  *   i-th palette entry in the PPS that is used to initialize the array PredictorPaletteEntries.
1051  * Defines the _GstH265PPSSccExtensionParams
1052  *
1053  * Since: 1.18
1054  */
1055 struct _GstH265PPSSccExtensionParams {
1056   guint8 pps_curr_pic_ref_enabled_flag;
1057   guint8 residual_adaptive_colour_transform_enabled_flag;
1058   guint8 pps_slice_act_qp_offsets_present_flag;
1059   guint8 pps_act_y_qp_offset_plus5;
1060   guint8 pps_act_cb_qp_offset_plus5;
1061   guint8 pps_act_cr_qp_offset_plus3;
1062   guint8 pps_palette_predictor_initializers_present_flag;
1063   guint8 pps_num_palette_predictor_initializer;
1064   guint8 monochrome_palette_flag;
1065   guint8 luma_bit_depth_entry_minus8;
1066   guint32 chroma_bit_depth_entry_minus8;
1067   guint32 pps_palette_predictor_initializer[3][128];
1068 };
1069 
1070 /**
1071  * GstH265ScalingList:
1072  * @scaling_list_dc_coef_minus8_16x16: this plus 8 specifies the DC
1073  *   Coefficient values for 16x16 scaling list
1074  * @scaling_list_dc_coef_minus8_32x32: this plus 8 specifies the DC
1075  *   Coefficient values for 32x32 scaling list
1076  * @scaling_lists_4x4: 4x4 scaling list
1077  * @scaling_lists_8x8: 8x8 scaling list
1078  * @scaling_lists_16x16: 16x16 scaling list
1079  * @guint8 scaling_lists_32x32: 32x32 scaling list
1080  *
1081  * Defines the GstH265ScalingList
1082  */
1083 struct _GstH265ScalingList {
1084 
1085   gint16 scaling_list_dc_coef_minus8_16x16[6];
1086   gint16 scaling_list_dc_coef_minus8_32x32[2];
1087 
1088   guint8 scaling_lists_4x4 [6][16];
1089   guint8 scaling_lists_8x8 [6][64];
1090   guint8 scaling_lists_16x16 [6][64];
1091   guint8 scaling_lists_32x32 [2][64];
1092 };
1093 
1094 /**
1095  * GstH265SPS:
1096  * @id: The ID of the sequence parameter set
1097  * @profile_idc: indicate the profile to which the coded video sequence conforms
1098  *
1099  * H265 Sequence Parameter Set (SPS)
1100  */
1101 struct _GstH265SPS
1102 {
1103   guint8 id;
1104 
1105   GstH265VPS *vps;
1106 
1107   guint8 max_sub_layers_minus1;
1108   guint8 temporal_id_nesting_flag;
1109 
1110   GstH265ProfileTierLevel profile_tier_level;
1111 
1112   guint8 chroma_format_idc;
1113   guint8 separate_colour_plane_flag;
1114   guint16 pic_width_in_luma_samples;
1115   guint16 pic_height_in_luma_samples;
1116 
1117   guint8 conformance_window_flag;
1118   /* if conformance_window_flag */
1119   guint32 conf_win_left_offset;
1120   guint32 conf_win_right_offset;
1121   guint32 conf_win_top_offset;
1122   guint32 conf_win_bottom_offset;
1123 
1124   guint8 bit_depth_luma_minus8;
1125   guint8 bit_depth_chroma_minus8;
1126   guint8 log2_max_pic_order_cnt_lsb_minus4;
1127 
1128   guint8 sub_layer_ordering_info_present_flag;
1129   guint8 max_dec_pic_buffering_minus1[GST_H265_MAX_SUB_LAYERS];
1130   guint8 max_num_reorder_pics[GST_H265_MAX_SUB_LAYERS];
1131   guint8 max_latency_increase_plus1[GST_H265_MAX_SUB_LAYERS];
1132 
1133   guint8 log2_min_luma_coding_block_size_minus3;
1134   guint8 log2_diff_max_min_luma_coding_block_size;
1135   guint8 log2_min_transform_block_size_minus2;
1136   guint8 log2_diff_max_min_transform_block_size;
1137   guint8 max_transform_hierarchy_depth_inter;
1138   guint8 max_transform_hierarchy_depth_intra;
1139 
1140   guint8 scaling_list_enabled_flag;
1141   /* if scaling_list_enabled_flag */
1142   guint8 scaling_list_data_present_flag;
1143 
1144   GstH265ScalingList scaling_list;
1145 
1146   guint8 amp_enabled_flag;
1147   guint8 sample_adaptive_offset_enabled_flag;
1148   guint8 pcm_enabled_flag;
1149   /* if pcm_enabled_flag */
1150   guint8 pcm_sample_bit_depth_luma_minus1;
1151   guint8 pcm_sample_bit_depth_chroma_minus1;
1152   guint8 log2_min_pcm_luma_coding_block_size_minus3;
1153   guint8 log2_diff_max_min_pcm_luma_coding_block_size;
1154   guint8 pcm_loop_filter_disabled_flag;
1155 
1156   guint8 num_short_term_ref_pic_sets;
1157   GstH265ShortTermRefPicSet short_term_ref_pic_set[65];
1158 
1159   guint8 long_term_ref_pics_present_flag;
1160   /* if long_term_ref_pics_present_flag */
1161   guint8 num_long_term_ref_pics_sps;
1162   guint16 lt_ref_pic_poc_lsb_sps[32];
1163   guint8 used_by_curr_pic_lt_sps_flag[32];
1164 
1165   guint8 temporal_mvp_enabled_flag;
1166   guint8 strong_intra_smoothing_enabled_flag;
1167   guint8 vui_parameters_present_flag;
1168 
1169   /* if vui_parameters_present_flat */
1170   GstH265VUIParams vui_params;
1171 
1172   guint8 sps_extension_flag;
1173 
1174   /* if sps_extension_present_flag */
1175   guint8 sps_range_extension_flag;
1176   guint8 sps_multilayer_extension_flag;
1177   guint8 sps_3d_extension_flag;
1178   guint8 sps_scc_extension_flag;
1179   guint8 sps_extension_4bits;
1180 
1181   /* if sps_range_extension_flag */
1182   GstH265SPSExtensionParams sps_extnsion_params;
1183   /* if sps_scc_extension_flag */
1184   GstH265SPSSccExtensionParams sps_scc_extension_params;
1185 
1186   /* calculated values */
1187   guint8 chroma_array_type;
1188   gint width, height;
1189   gint crop_rect_width, crop_rect_height;
1190   gint crop_rect_x, crop_rect_y;
1191   gint fps_num, fps_den;
1192   gboolean valid;
1193 };
1194 
1195 /**
1196  * GstH265PPS:
1197  *
1198  * H265 Picture Parameter Set
1199  */
1200 struct _GstH265PPS
1201 {
1202   guint id;
1203 
1204   GstH265SPS *sps;
1205 
1206   guint8 dependent_slice_segments_enabled_flag;
1207   guint8 output_flag_present_flag;
1208   guint8 num_extra_slice_header_bits;
1209   guint8 sign_data_hiding_enabled_flag;
1210   guint8 cabac_init_present_flag;
1211   guint8 num_ref_idx_l0_default_active_minus1;
1212   guint8 num_ref_idx_l1_default_active_minus1;
1213   gint8 init_qp_minus26;
1214   guint8 constrained_intra_pred_flag;
1215   guint8 transform_skip_enabled_flag;
1216   guint8 cu_qp_delta_enabled_flag;
1217   /*if cu_qp_delta_enabled_flag */
1218   guint8 diff_cu_qp_delta_depth;
1219 
1220   gint8 cb_qp_offset;
1221   gint8 cr_qp_offset;
1222   guint8 slice_chroma_qp_offsets_present_flag;
1223   guint8 weighted_pred_flag;
1224   guint8 weighted_bipred_flag;
1225   guint8 transquant_bypass_enabled_flag;
1226   guint8 tiles_enabled_flag;
1227   guint8 entropy_coding_sync_enabled_flag;
1228 
1229   guint8 num_tile_columns_minus1;
1230   guint8 num_tile_rows_minus1;
1231   guint8 uniform_spacing_flag;
1232   guint32 column_width_minus1[20];
1233   guint32 row_height_minus1[22];
1234   guint8 loop_filter_across_tiles_enabled_flag;
1235 
1236   guint8 loop_filter_across_slices_enabled_flag;
1237   guint8 deblocking_filter_control_present_flag;
1238   guint8 deblocking_filter_override_enabled_flag;
1239   guint8 deblocking_filter_disabled_flag;
1240   gint8 beta_offset_div2;
1241   gint8 tc_offset_div2;
1242 
1243   guint8 scaling_list_data_present_flag;
1244 
1245   GstH265ScalingList scaling_list;
1246 
1247   guint8 lists_modification_present_flag;
1248   guint8 log2_parallel_merge_level_minus2;
1249   guint8 slice_segment_header_extension_present_flag;
1250 
1251   guint8 pps_extension_flag;
1252 
1253   /* if pps_extension_flag*/
1254   guint8 pps_range_extension_flag;
1255   guint8 pps_multilayer_extension_flag;
1256   guint8 pps_3d_extension_flag;
1257   guint8 pps_scc_extension_flag;
1258   guint8 pps_extension_4bits;
1259 
1260   /* if pps_range_extension_flag*/
1261   GstH265PPSExtensionParams pps_extension_params;
1262   /* if pps_scc_extension_flag*/
1263   GstH265PPSSccExtensionParams pps_scc_extension_params;
1264 
1265   /* calculated values */
1266   guint32 PicWidthInCtbsY;
1267   guint32 PicHeightInCtbsY;
1268   gboolean valid;
1269 };
1270 
1271 struct _GstH265RefPicListModification
1272 {
1273   guint8 ref_pic_list_modification_flag_l0;
1274   guint32 list_entry_l0[15];
1275   guint8 ref_pic_list_modification_flag_l1;
1276   guint32 list_entry_l1[15];
1277 };
1278 
1279 struct _GstH265PredWeightTable
1280 {
1281   guint8 luma_log2_weight_denom;
1282   gint8 delta_chroma_log2_weight_denom;
1283 
1284   guint8 luma_weight_l0_flag[15];
1285   guint8  chroma_weight_l0_flag[15];
1286   gint8 delta_luma_weight_l0[15];
1287   gint8 luma_offset_l0[15];
1288   gint8 delta_chroma_weight_l0 [15][2];
1289   gint16 delta_chroma_offset_l0 [15][2];
1290 
1291   guint8 luma_weight_l1_flag[15];
1292   guint8 chroma_weight_l1_flag[15];
1293   gint8 delta_luma_weight_l1[15];
1294   gint8 luma_offset_l1[15];
1295   gint8 delta_chroma_weight_l1[15][2];
1296   gint16 delta_chroma_offset_l1[15][2];
1297 };
1298 
1299 /**
1300  * GstH265SliceHdr:
1301  * @first_slice_segment_in_pic_flag: equal to 1 if this slice segment is
1302  *   the first slice segment of the picture in decoding order
1303  * @no_output_of_prior_pics_flag: affects the output of previously-decoded pictures
1304  *   in the decoded picture buffer after the decoding of an IDR or a BLA picture
1305  *   that is not the first picture in the bitstream as specified in Annex C
1306  * @pps: a #GstH265PPS
1307  * @dependent_slice_segment_flag: equal to 1 if the value of each slice segment header
1308  *   syntax element that is not present is inferred to be equal to the value of corresponding
1309  *   slice segment header syntax element in the slice header.
1310  * @segment_address: the address of the first CTB in the slice segment
1311  * @type: slice type (B, P, or I)
1312  * @pic_output_flag: affects the decoded picture output and removal processes
1313  *   as specified in Annex C.
1314  * @colour_plane_id: specifies the colour plane associated with the current slice RBSP
1315  *   when separate_colour_plane_flag is equal to 1
1316  * @pic_order_cnt_lsb: the picture order count modulo MaxPicOrderCntLsb for the current picture
1317  * @short_term_ref_pic_set_sps_flag: equal to 1 specifies that the short-term RPS
1318  *   of the current picture is derived based on the active SPS.
1319  * @short_term_ref_pic_sets: a #GstH265ShortTermRefPicSet structure
1320  * @short_term_ref_pic_set_idx: the index of st_ref_pic_set syntax structure
1321  *   that is used for derivation of the short-term RPS of the current picture.
1322  * @num_long_term_sps: the number of entries in the long-term RPS of current picture
1323  *   that are derived based on the syntax in active SPS.
1324  * @num_long_term_pics: the number of entries in the long-term RPS of the current picture
1325  *   that are directly signalled in the slice header.
1326  * @lt_idx_sps: the index of candidate long-term reference pictures
1327  *   specified in the active SPS.
1328  * @poc_lsb_lt: the value of the picture order count modulo MaxPicOrderCntLsb
1329  *   of the each entry in the long-term RPS of the current picture.
1330  * @used_by_curr_pic_lt_flag: equal to 0 if the entry in the long-term RPS
1331  *   of the current picture is not used for reference by the current picture.
1332  * @delta_poc_msb_present_flag: equal to 1 if i-th delta_poc_msb_cycle_lt[] is present.
1333  * @delta_poc_msb_cycle_lt: used to determine the value of the most significant bits
1334  *   of the picture order count value of the i-th entry in the long-term RPS of the current picture.
1335  * @temporal_mvp_enabled_flag: whether temporal motion vector predictors can be used for inter prediction.
1336  * @sao_luma_flag: equal to 1 if SAO is enabled for the luma component in the current slice.
1337  * @sao_chroma_flag: equal to 1 if SAO is enabled for the chroma component in the current slice.
1338  * @num_ref_idx_active_override_flag: equal to 1 specifies that the syntax elements
1339  *   num_ref_idx_l0_active_minus1 and num_ref_idx_l1_active_minus1 are present.
1340  * @num_ref_idx_l0_active_minus1: the maximum reference index for reference picture list 0
1341  *   that may be used to decode the slice.
1342  * @num_ref_idx_l1_active_minus1: the maximum reference index for reference picture list 1
1343  *   that may be used to decode the slice.
1344  * @ref_pic_list_modification: a #GstH265RefPicListModification
1345  * @mvd_l1_zero_flag: equal to 1 if the mvd_coding sytanx structure is not parsed
1346  * @cabac_init_flag: specifies the method for determining the initialization table
1347  *   used in the initialization process for context variables.
1348  * @collocated_from_l0_flag: equal to 1 specifies that the collocated picture
1349  *   used for temporal motion vector prediction is derived from reference picture list 0.
1350  * @collocated_ref_idx: the reference index of the collocated picture
1351  *   used for temporal motion vector prediction.
1352  * @pred_weight_table: a #GstH265PredWeightTable
1353  * @five_minus_max_num_merge_cand: specifies the maximum number of merging motion vector prediction (MVP)
1354  *   candidates supported in the slice.
1355  * @use_integer_mv_flag: equal to 1 specifies that the resolution of motion vectors for inter
1356  *   prediction in the current slice is integer. (Since: 1.18)
1357  * @qp_delta: specifies the inital value of QPy to be used for the coding blocks in the slice.
1358  * @cb_qp_offset: a difference to be added to the value of pps_cb_qp_offset.
1359  * @cr_qp_offset: a difference to be added to the value of pps_cr_qp_offset.
1360  * @slice_act_y_qp_offset: specify offsets to the quantization parameter values qP derived in
1361  *   clause 8.6.2 for luma components. (Since: 1.18)
1362  * @slice_act_cb_qp_offset: specify offsets to the quantization parameter values qP derived in
1363  *   clause 8.6.2 for Cb components. (Since: 1.18)
1364  * @slice_act_cr_qp_offset: specify offsets to the quantization parameter values qP derived in
1365  *   clause 8.6.2 for Cr components. (Since: 1.18)
1366  * @cu_chroma_qp_offset_enabled_flag: equal to 1 if the cu_chroma_qp_offset_flag
1367  *   may be present in the transform unit syntax. (Since: 1.18)
1368  * @deblocking_filter_override_flag: equal to 1 if deblocking paramertes are present in the slice header.
1369  * @deblocking_filter_disabled_flag: equal to 1 specifies that the operation of
1370  *   the deblocking filter is not applied for the current slice.
1371  * @beta_offset_div2: deblocking parameter offset for beta divided by 2 for the current slice.
1372  * @tc_offset_div2: deblocking parameter offset for tC divided by 2 for the current slice.
1373  * @loop_filter_across_slices_enabled_flag: equal to 1 specifies that in-loop filtering
1374  *   operation may be performed across the left and upper boundaries of the current slice.
1375  * @num_entry_point_offsets: specifies the number of entry_point_offset_minus1 syntax elements
1376  *   in the slice header.
1377  * @offset_len_minus1: specifies the length of the entry_point_minus1 syntax elements
1378  *   in bits.
1379  * @entry_point_offset_minus1: the entry point offset in bytes.
1380  * @NumPocTotalCurr: calculated NumPocTotalCurr which is used for
1381  *   decoding process for reference picture set
1382  * @header_size: the calculated size of the slice_header\() in bits.
1383  * @n_emulation_prevention_bytes: number of emulation prevention bytes (EPB)
1384  *   in this slice_header\()
1385  * @short_term_ref_pic_set_size: the calculated size of short_term_ref_pic_set\()
1386  *   in bits. (Since: 1.18)
1387  */
1388 struct _GstH265SliceHdr
1389 {
1390   guint8 first_slice_segment_in_pic_flag;
1391   guint8 no_output_of_prior_pics_flag;
1392 
1393   GstH265PPS *pps;
1394 
1395   guint8 dependent_slice_segment_flag;
1396   guint32 segment_address;
1397 
1398   guint8 type;
1399 
1400   guint8 pic_output_flag;
1401   guint8 colour_plane_id;
1402   guint16 pic_order_cnt_lsb;
1403 
1404   guint8  short_term_ref_pic_set_sps_flag;
1405   GstH265ShortTermRefPicSet short_term_ref_pic_sets;
1406   guint8 short_term_ref_pic_set_idx;
1407 
1408   guint8 num_long_term_sps;
1409   guint8 num_long_term_pics;
1410   guint8 lt_idx_sps[16];
1411   guint32 poc_lsb_lt[16];
1412   guint8 used_by_curr_pic_lt_flag[16];
1413   guint8 delta_poc_msb_present_flag[16];
1414   guint32 delta_poc_msb_cycle_lt[16];
1415 
1416   guint8 temporal_mvp_enabled_flag;
1417   guint8 sao_luma_flag;
1418   guint8 sao_chroma_flag;
1419   guint8 num_ref_idx_active_override_flag;
1420   guint8 num_ref_idx_l0_active_minus1;
1421   guint8 num_ref_idx_l1_active_minus1;
1422 
1423   GstH265RefPicListModification ref_pic_list_modification;
1424 
1425   guint8 mvd_l1_zero_flag;
1426   guint8 cabac_init_flag;
1427   guint8 collocated_from_l0_flag;
1428   guint8 collocated_ref_idx;
1429 
1430   GstH265PredWeightTable pred_weight_table;
1431 
1432   guint8 five_minus_max_num_merge_cand;
1433   guint8 use_integer_mv_flag;
1434 
1435   gint8 qp_delta;
1436   gint8 cb_qp_offset;
1437   gint8 cr_qp_offset;
1438   gint8 slice_act_y_qp_offset;
1439   gint8 slice_act_cb_qp_offset;
1440   gint8 slice_act_cr_qp_offset;
1441 
1442   guint8 cu_chroma_qp_offset_enabled_flag;
1443 
1444   guint8 deblocking_filter_override_flag;
1445   guint8 deblocking_filter_disabled_flag;
1446   gint8 beta_offset_div2;
1447   gint8 tc_offset_div2;
1448 
1449   guint8 loop_filter_across_slices_enabled_flag;
1450 
1451   guint32 num_entry_point_offsets;
1452   guint8 offset_len_minus1;
1453   guint32 *entry_point_offset_minus1;
1454 
1455   /* calculated values */
1456 
1457   gint NumPocTotalCurr;
1458   /* Size of the slice_header() in bits */
1459   guint header_size;
1460   /* Number of emulation prevention bytes (EPB) in this slice_header() */
1461   guint n_emulation_prevention_bytes;
1462 
1463   /* Size of short_term_ref_pic_set() in bits */
1464   guint short_term_ref_pic_set_size;
1465 };
1466 
1467 struct _GstH265PicTiming
1468 {
1469   guint8 pic_struct;
1470   guint8 source_scan_type;
1471   guint8 duplicate_flag;
1472 
1473   guint8 au_cpb_removal_delay_minus1;
1474   guint8 pic_dpb_output_delay;
1475   guint8 pic_dpb_output_du_delay;
1476   guint32 num_decoding_units_minus1;
1477   guint8 du_common_cpb_removal_delay_flag;
1478   guint8 du_common_cpb_removal_delay_increment_minus1;
1479   guint32 *num_nalus_in_du_minus1;
1480   guint8 *du_cpb_removal_delay_increment_minus1;
1481 };
1482 
1483 struct _GstH265BufferingPeriod
1484 {
1485   GstH265SPS *sps;
1486 
1487   guint8 irap_cpb_params_present_flag;
1488   guint8 cpb_delay_offset;
1489   guint8 dpb_delay_offset;
1490   guint8 concatenation_flag;
1491   guint8 au_cpb_removal_delay_delta_minus1;
1492 
1493   /* seq->vui_parameters->nal_hrd_parameters_present_flag */
1494   guint8 nal_initial_cpb_removal_delay[32];
1495   guint8 nal_initial_cpb_removal_offset[32];
1496   guint8 nal_initial_alt_cpb_removal_delay[32];
1497   guint8 nal_initial_alt_cpb_removal_offset [32];
1498 
1499   /* seq->vui_parameters->vcl_hrd_parameters_present_flag */
1500   guint8 vcl_initial_cpb_removal_delay[32];
1501   guint8 vcl_initial_cpb_removal_offset[32];
1502   guint8 vcl_initial_alt_cpb_removal_delay[32];
1503   guint8 vcl_initial_alt_cpb_removal_offset[32];
1504 };
1505 
1506 struct _GstH265RecoveryPoint
1507 {
1508   gint32 recovery_poc_cnt;
1509   guint8 exact_match_flag;
1510   guint8 broken_link_flag;
1511 };
1512 
1513 /**
1514  * GstH265RegisteredUserData:
1515  * The User data registered by Rec. ITU-T T.35 SEI message.
1516  * @country_code: an itu_t_t35_country_code.
1517  * @country_code_extension: an itu_t_t35_country_code_extension_byte.
1518  *   Should be ignored when @country_code is not 0xff
1519  * @data: the data of itu_t_t35_payload_byte
1520  *   excluding @country_code and @country_code_extension
1521  * @size: the size of @data in bytes
1522  *
1523  * Since: 1.18
1524  */
1525 struct _GstH265RegisteredUserData
1526 {
1527   guint8 country_code;
1528   guint8 country_code_extension;
1529   const guint8 *data;
1530   guint size;
1531 };
1532 
1533 
1534 /**
1535  * GstH265TimeCode:
1536  * The time code SEI message provides time code information similar to that
1537  * defined by SMPTE ST 12-1 (2014) for field(s) or frame(s) of the current
1538  * picture.
1539  *
1540  * D.2.27
1541  *
1542  * Since: 1.16
1543  */
1544 struct _GstH265TimeCode
1545 {
1546   guint8 num_clock_ts;
1547   guint8 clock_timestamp_flag[3];
1548   guint8 units_field_based_flag[3];
1549   guint8 counting_type[3];
1550   guint8 full_timestamp_flag[3];
1551   guint8 discontinuity_flag[3];
1552   guint8 cnt_dropped_flag[3];
1553   guint16 n_frames[3];
1554   guint8 seconds_flag[3];
1555   guint8 seconds_value[3];
1556   guint8 minutes_flag[3];
1557   guint8 minutes_value[3];
1558   guint8 hours_flag[3];
1559   guint8 hours_value[3];
1560   guint8 time_offset_length[3];
1561   guint32 time_offset_value[3];
1562 };
1563 
1564 /**
1565  * GstH265MasteringDisplayColourVolume:
1566  * The colour volume (primaries, white point and luminance range) of display
1567  * defined by SMPTE ST 2086.
1568  *
1569  * D.2.28
1570  *
1571  * Since: 1.18
1572  */
1573 struct _GstH265MasteringDisplayColourVolume
1574 {
1575   guint16 display_primaries_x[3];
1576   guint16 display_primaries_y[3];
1577   guint16 white_point_x;
1578   guint16 white_point_y;
1579   guint32 max_display_mastering_luminance;
1580   guint32 min_display_mastering_luminance;
1581 };
1582 
1583 /**
1584  * GstH265ContentLightLevel:
1585  * The upper bounds for the nominal target brightness light level
1586  * as specified in CEA-861.3
1587  *
1588  * D.2.35
1589  *
1590  * Since: 1.18
1591  */
1592 struct _GstH265ContentLightLevel
1593 {
1594   guint16 max_content_light_level;
1595   guint16 max_pic_average_light_level;
1596 };
1597 
1598 struct _GstH265SEIMessage
1599 {
1600   GstH265SEIPayloadType payloadType;
1601 
1602   union {
1603     GstH265BufferingPeriod buffering_period;
1604     GstH265PicTiming pic_timing;
1605     GstH265RegisteredUserData registered_user_data;
1606     GstH265RecoveryPoint recovery_point;
1607     GstH265TimeCode time_code;
1608     GstH265MasteringDisplayColourVolume mastering_display_colour_volume;
1609     GstH265ContentLightLevel content_light_level;
1610     /* ... could implement more */
1611   } payload;
1612 };
1613 
1614 /**
1615  * GstH265Parser:
1616  *
1617  * H265 NAL Parser (opaque structure).
1618  */
1619 struct _GstH265Parser
1620 {
1621   /*< private >*/
1622   GstH265VPS vps[GST_H265_MAX_VPS_COUNT];
1623   GstH265SPS sps[GST_H265_MAX_SPS_COUNT];
1624   GstH265PPS pps[GST_H265_MAX_PPS_COUNT];
1625   GstH265VPS *last_vps;
1626   GstH265SPS *last_sps;
1627   GstH265PPS *last_pps;
1628 };
1629 
1630 GST_CODEC_PARSERS_API
1631 GstH265Parser *     gst_h265_parser_new               (void);
1632 
1633 GST_CODEC_PARSERS_API
1634 GstH265ParserResult gst_h265_parser_identify_nalu      (GstH265Parser  * parser,
1635                                                         const guint8   * data,
1636                                                         guint            offset,
1637                                                         gsize            size,
1638                                                         GstH265NalUnit * nalu);
1639 
1640 GST_CODEC_PARSERS_API
1641 GstH265ParserResult gst_h265_parser_identify_nalu_unchecked (GstH265Parser * parser,
1642                                                         const guint8   * data,
1643                                                         guint            offset,
1644                                                         gsize            size,
1645                                                         GstH265NalUnit * nalu);
1646 
1647 GST_CODEC_PARSERS_API
1648 GstH265ParserResult gst_h265_parser_identify_nalu_hevc (GstH265Parser  * parser,
1649                                                         const guint8   * data,
1650                                                         guint            offset,
1651                                                         gsize            size,
1652                                                         guint8           nal_length_size,
1653                                                         GstH265NalUnit * nalu);
1654 
1655 GST_CODEC_PARSERS_API
1656 GstH265ParserResult gst_h265_parser_parse_nal       (GstH265Parser   * parser,
1657                                                      GstH265NalUnit  * nalu);
1658 
1659 GST_CODEC_PARSERS_API
1660 GstH265ParserResult gst_h265_parser_parse_slice_hdr (GstH265Parser   * parser,
1661                                                      GstH265NalUnit  * nalu,
1662                                                      GstH265SliceHdr * slice);
1663 
1664 GST_CODEC_PARSERS_API
1665 GstH265ParserResult gst_h265_parser_parse_vps       (GstH265Parser   * parser,
1666                                                      GstH265NalUnit  * nalu,
1667                                                      GstH265VPS      * vps);
1668 
1669 GST_CODEC_PARSERS_API
1670 GstH265ParserResult gst_h265_parser_parse_sps       (GstH265Parser   * parser,
1671                                                      GstH265NalUnit  * nalu,
1672                                                      GstH265SPS      * sps,
1673                                                      gboolean          parse_vui_params);
1674 
1675 GST_CODEC_PARSERS_API
1676 GstH265ParserResult gst_h265_parser_parse_pps       (GstH265Parser   * parser,
1677                                                      GstH265NalUnit  * nalu,
1678                                                      GstH265PPS      * pps);
1679 
1680 GST_CODEC_PARSERS_API
1681 GstH265ParserResult gst_h265_parser_parse_sei       (GstH265Parser   * parser,
1682                                                      GstH265NalUnit  * nalu,
1683                                                      GArray **messages);
1684 
1685 GST_CODEC_PARSERS_API
1686 GstH265ParserResult gst_h265_parser_update_vps      (GstH265Parser   * parser,
1687                                                      GstH265VPS      * vps);
1688 
1689 GST_CODEC_PARSERS_API
1690 GstH265ParserResult gst_h265_parser_update_sps      (GstH265Parser   * parser,
1691                                                      GstH265SPS      * sps);
1692 
1693 GST_CODEC_PARSERS_API
1694 GstH265ParserResult gst_h265_parser_update_pps      (GstH265Parser   * parser,
1695                                                      GstH265PPS      * pps);
1696 
1697 GST_CODEC_PARSERS_API
1698 void                gst_h265_parser_free            (GstH265Parser  * parser);
1699 
1700 GST_CODEC_PARSERS_API
1701 GstH265ParserResult gst_h265_parse_vps              (GstH265NalUnit * nalu,
1702                                                      GstH265VPS     * vps);
1703 
1704 GST_CODEC_PARSERS_API
1705 GstH265ParserResult gst_h265_parse_sps              (GstH265Parser  * parser,
1706                                                      GstH265NalUnit * nalu,
1707                                                      GstH265SPS     * sps,
1708                                                      gboolean         parse_vui_params);
1709 
1710 GST_CODEC_PARSERS_API
1711 GstH265ParserResult gst_h265_parse_pps              (GstH265Parser  * parser,
1712                                                      GstH265NalUnit * nalu,
1713                                                      GstH265PPS     * pps);
1714 
1715 GST_CODEC_PARSERS_API
1716 gboolean            gst_h265_slice_hdr_copy (GstH265SliceHdr       * dst_slice,
1717                                              const GstH265SliceHdr * src_slice);
1718 
1719 GST_CODEC_PARSERS_API
1720 void                gst_h265_slice_hdr_free (GstH265SliceHdr * slice_hdr);
1721 
1722 GST_CODEC_PARSERS_API
1723 gboolean            gst_h265_sei_copy       (GstH265SEIMessage       * dest_sei,
1724                                              const GstH265SEIMessage * src_sei);
1725 
1726 GST_CODEC_PARSERS_API
1727 void                gst_h265_sei_free       (GstH265SEIMessage * sei);
1728 
1729 GST_CODEC_PARSERS_API
1730 void    gst_h265_quant_matrix_4x4_get_zigzag_from_raster (guint8 out_quant[16],
1731                                                           const guint8 quant[16]);
1732 
1733 GST_CODEC_PARSERS_API
1734 void    gst_h265_quant_matrix_4x4_get_raster_from_zigzag (guint8 out_quant[16],
1735                                                           const guint8 quant[16]);
1736 
1737 GST_CODEC_PARSERS_API
1738 void    gst_h265_quant_matrix_8x8_get_zigzag_from_raster (guint8 out_quant[64],
1739                                                           const guint8 quant[64]);
1740 
1741 GST_CODEC_PARSERS_API
1742 void    gst_h265_quant_matrix_8x8_get_raster_from_zigzag (guint8 out_quant[64],
1743                                                           const guint8 quant[64]);
1744 
1745 #define gst_h265_quant_matrix_16x16_get_zigzag_from_raster \
1746         gst_h265_quant_matrix_8x8_get_zigzag_from_raster
1747 #define gst_h265_quant_matrix_16x16_get_raster_from_zigzag \
1748         gst_h265_quant_matrix_8x8_get_raster_from_zigzag
1749 #define gst_h265_quant_matrix_32x32_get_zigzag_from_raster \
1750         gst_h265_quant_matrix_8x8_get_zigzag_from_raster
1751 #define gst_h265_quant_matrix_32x32_get_raster_from_zigzag \
1752         gst_h265_quant_matrix_8x8_get_raster_from_zigzag
1753 
1754 GST_CODEC_PARSERS_API
1755 void    gst_h265_quant_matrix_4x4_get_uprightdiagonal_from_raster (guint8 out_quant[16],
1756                                                           const guint8 quant[16]);
1757 
1758 GST_CODEC_PARSERS_API
1759 void    gst_h265_quant_matrix_4x4_get_raster_from_uprightdiagonal (guint8 out_quant[16],
1760                                                           const guint8 quant[16]);
1761 
1762 GST_CODEC_PARSERS_API
1763 void    gst_h265_quant_matrix_8x8_get_uprightdiagonal_from_raster (guint8 out_quant[64],
1764                                                           const guint8 quant[64]);
1765 
1766 GST_CODEC_PARSERS_API
1767 void    gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal (guint8 out_quant[64],
1768                                                           const guint8 quant[64]);
1769 
1770 #define gst_h265_quant_matrix_16x16_get_uprightdiagonal_from_raster \
1771         gst_h265_quant_matrix_8x8_get_uprightdiagonal_from_raster
1772 #define gst_h265_quant_matrix_16x16_get_raster_from_uprightdiagonal\
1773         gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal
1774 #define gst_h265_quant_matrix_32x32_get_uprightdiagonal_from_raster \
1775         gst_h265_quant_matrix_8x8_get_uprightdiagonal_from_raster
1776 #define gst_h265_quant_matrix_32x32_get_raster_from_uprightdiagonal\
1777         gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal
1778 
1779 GST_CODEC_PARSERS_API
1780 GstH265Profile gst_h265_profile_tier_level_get_profile (const GstH265ProfileTierLevel * ptl);
1781 
1782 GST_CODEC_PARSERS_API
1783 const gchar * gst_h265_profile_to_string (GstH265Profile profile);
1784 
1785 GST_CODEC_PARSERS_API
1786 GstH265Profile gst_h265_profile_from_string (const gchar * string);
1787 
1788 GST_CODEC_PARSERS_API
1789 GstMemory * gst_h265_create_sei_memory (guint8 layer_id,
1790                                         guint8 temporal_id_plus1,
1791                                         guint8 start_code_prefix_length,
1792                                         GArray * messages);
1793 
1794 GST_CODEC_PARSERS_API
1795 GstMemory * gst_h265_create_sei_memory_hevc (guint8 layer_id,
1796                                              guint8 temporal_id_plus1,
1797                                              guint8 nal_length_size,
1798                                              GArray * messages);
1799 
1800 GST_CODEC_PARSERS_API
1801 GstBuffer * gst_h265_parser_insert_sei (GstH265Parser * parser,
1802                                         GstBuffer * au,
1803                                         GstMemory * sei);
1804 
1805 GST_CODEC_PARSERS_API
1806 GstBuffer * gst_h265_parser_insert_sei_hevc (GstH265Parser * parser,
1807                                              guint8 nal_length_size,
1808                                              GstBuffer * au,
1809                                              GstMemory * sei);
1810 
1811 GST_CODEC_PARSERS_API
1812 GstH265Profile gst_h265_get_profile_from_sps (GstH265SPS * sps);
1813 
1814 G_END_DECLS
1815 #endif
1816