h264parser: Update doc for GST_H264_FRMAE_PACKING_TOP_BOTTOM
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / codecparsers / gsth264parser.h
1 /* Gstreamer
2  * Copyright (C) <2011> Intel Corporation
3  * Copyright (C) <2011> Collabora Ltd.
4  * Copyright (C) <2011> Thibault Saunier <thibault.saunier@collabora.com>
5  *
6  * Some bits C-c,C-v'ed and s/4/3 from h264parse and videoparsers/h264parse.c:
7  *    Copyright (C) <2010> Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
8  *    Copyright (C) <2010> Collabora Multimedia
9  *    Copyright (C) <2010> Nokia Corporation
10  *
11  *    (C) 2005 Michal Benes <michal.benes@itonis.tv>
12  *    (C) 2008 Wim Taymans <wim.taymans@gmail.com>
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Library General Public
16  * License as published by the Free Software Foundation; either
17  * version 2 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * Library General Public License for more details.
23  *
24  * You should have received a copy of the GNU Library General Public
25  * License along with this library; if not, write to the
26  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
27  * Boston, MA 02110-1301, USA.
28  */
29
30 #ifndef __GST_H264_PARSER_H__
31 #define __GST_H264_PARSER_H__
32
33 #ifndef GST_USE_UNSTABLE_API
34 #warning "The H.264 parsing library is unstable API and may change in future."
35 #warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
36 #endif
37
38 #include <gst/gst.h>
39 #include <gst/codecparsers/codecparsers-prelude.h>
40
41 G_BEGIN_DECLS
42
43 #define GST_H264_MAX_SPS_COUNT   32
44 #define GST_H264_MAX_PPS_COUNT   256
45 #define GST_H264_MAX_VIEW_COUNT  1024
46 #define GST_H264_MAX_VIEW_ID     (GST_H264_MAX_VIEW_COUNT - 1)
47
48 #define GST_H264_IS_P_SLICE(slice)  (((slice)->type % 5) == GST_H264_P_SLICE)
49 #define GST_H264_IS_B_SLICE(slice)  (((slice)->type % 5) == GST_H264_B_SLICE)
50 #define GST_H264_IS_I_SLICE(slice)  (((slice)->type % 5) == GST_H264_I_SLICE)
51 #define GST_H264_IS_SP_SLICE(slice) (((slice)->type % 5) == GST_H264_SP_SLICE)
52 #define GST_H264_IS_SI_SLICE(slice) (((slice)->type % 5) == GST_H264_SI_SLICE)
53
54 /**
55  * GST_H264_IS_SVC_NALU:
56  * @nalu: a #GstH264NalUnit
57  *
58  * Check if @nalu is a scalable extension NAL unit.
59  *
60  * Since: 1.6
61  */
62 #define GST_H264_IS_SVC_NALU(nalu) \
63   ((nalu)->extension_type == GST_H264_NAL_EXTENSION_SVC)
64
65 /**
66  * GST_H264_IS_MVC_NALU:
67  * @nalu: a #GstH264NalUnit
68  *
69  * Check if @nalu is a multiview extension NAL unit.
70  *
71  * Since: 1.6
72  */
73 #define GST_H264_IS_MVC_NALU(nalu) \
74   ((nalu)->extension_type == GST_H264_NAL_EXTENSION_MVC)
75
76 /**
77  * GstH264Profile:
78  * @GST_H264_PROFILE_BASELINE: Baseline profile (A.2.1)
79  * @GST_H264_PROFILE_MAIN: Main profile (A.2.2)
80  * @GST_H264_PROFILE_EXTENDED: Extended profile (A.2.3)
81  * @GST_H264_PROFILE_HIGH: High profile (A.2.4),
82  * or Progressive High profile (A.2.4.1), or Constrained High profile (A.2.4.2)
83  * depending on constraint_set4_flag and constraint_set5_flag
84  * @GST_H264_PROFILE_HIGH10: High 10 profile (A.2.5) or High 10 Intra
85  *   profile (A.2.8), or Progressive High 10 profile (A.2.5.1) depending on
86  *   constraint_set3_flag and constraint_set4_flag
87  * @GST_H264_PROFILE_HIGH_422: High 4:2:2 profile (A.2.6) or High
88  *   4:2:2 Intra profile (A.2.9), depending on constraint_set3_flag
89  * @GST_H264_PROFILE_HIGH_444: High 4:4:4 Predictive profile (A.2.7)
90  *   or High 4:4:4 Intra profile (A.2.10), depending on the value of
91  *   constraint_set3_flag
92  * @GST_H264_PROFILE_MULTIVIEW_HIGH: Multiview High profile (H.10.1.1)
93  * @GST_H264_PROFILE_STEREO_HIGH: Stereo High profile (H.10.1.2)
94  * @GST_H264_PROFILE_SCALABLE_BASELINE: Scalable Baseline profile (G.10.1.1)
95  * @GST_H264_PROFILE_SCALABLE_HIGH: Scalable High profile (G.10.1.2)
96  *   or Scalable High Intra profile (G.10.1.3), depending on the value
97  *   of constraint_set3_flag
98  *
99  * H.264 Profiles.
100  *
101  * Since: 1.2
102  */
103 typedef enum {
104   GST_H264_PROFILE_BASELINE             = 66,
105   GST_H264_PROFILE_MAIN                 = 77,
106   GST_H264_PROFILE_EXTENDED             = 88,
107   GST_H264_PROFILE_HIGH                 = 100,
108   GST_H264_PROFILE_HIGH10               = 110,
109   GST_H264_PROFILE_HIGH_422             = 122,
110   GST_H264_PROFILE_HIGH_444             = 244,
111   GST_H264_PROFILE_MULTIVIEW_HIGH       = 118,
112   GST_H264_PROFILE_STEREO_HIGH          = 128,
113   GST_H264_PROFILE_SCALABLE_BASELINE    = 83,
114   GST_H264_PROFILE_SCALABLE_HIGH        = 86
115 } GstH264Profile;
116
117 /**
118  * GstH264NalUnitType:
119  * @GST_H264_NAL_UNKNOWN: Unknown nal type
120  * @GST_H264_NAL_SLICE: Slice nal
121  * @GST_H264_NAL_SLICE_DPA: DPA slice nal
122  * @GST_H264_NAL_SLICE_DPB: DPB slice nal
123  * @GST_H264_NAL_SLICE_DPC: DPC slice nal
124  * @GST_H264_NAL_SLICE_IDR: DPR slice nal
125  * @GST_H264_NAL_SEI: Supplemental enhancement information (SEI) nal unit
126  * @GST_H264_NAL_SPS: Sequence parameter set (SPS) nal unit
127  * @GST_H264_NAL_PPS: Picture parameter set (PPS) nal unit
128  * @GST_H264_NAL_AU_DELIMITER: Access unit (AU) delimiter nal unit
129  * @GST_H264_NAL_SEQ_END: End of sequence nal unit
130  * @GST_H264_NAL_STREAM_END: End of stream nal unit
131  * @GST_H264_NAL_FILLER_DATA: Filler data nal lunit
132  * @GST_H264_NAL_SPS_EXT: Sequence parameter set (SPS) extension NAL unit
133  * @GST_H264_NAL_PREFIX_UNIT: Prefix NAL unit
134  * @GST_H264_NAL_SUBSET_SPS: Subset sequence parameter set (SSPS) NAL unit
135  * @GST_H264_NAL_DEPTH_SPS: Depth parameter set (DPS) NAL unit
136  * @GST_H264_NAL_SLICE_AUX: Auxiliary coded picture without partitioning NAL unit
137  * @GST_H264_NAL_SLICE_EXT: Coded slice extension NAL unit
138  * @GST_H264_NAL_SLICE_DEPTH: Coded slice extension for depth or 3D-AVC texture view
139  *
140  * Indicates the type of H264 Nal Units
141  */
142 typedef enum
143 {
144   GST_H264_NAL_UNKNOWN      = 0,
145   GST_H264_NAL_SLICE        = 1,
146   GST_H264_NAL_SLICE_DPA    = 2,
147   GST_H264_NAL_SLICE_DPB    = 3,
148   GST_H264_NAL_SLICE_DPC    = 4,
149   GST_H264_NAL_SLICE_IDR    = 5,
150   GST_H264_NAL_SEI          = 6,
151   GST_H264_NAL_SPS          = 7,
152   GST_H264_NAL_PPS          = 8,
153   GST_H264_NAL_AU_DELIMITER = 9,
154   GST_H264_NAL_SEQ_END      = 10,
155   GST_H264_NAL_STREAM_END   = 11,
156   GST_H264_NAL_FILLER_DATA  = 12,
157   GST_H264_NAL_SPS_EXT      = 13,
158   GST_H264_NAL_PREFIX_UNIT  = 14,
159   GST_H264_NAL_SUBSET_SPS   = 15,
160   GST_H264_NAL_DEPTH_SPS    = 16,
161   GST_H264_NAL_SLICE_AUX    = 19,
162   GST_H264_NAL_SLICE_EXT    = 20,
163   GST_H264_NAL_SLICE_DEPTH  = 21
164 } GstH264NalUnitType;
165
166 /**
167  * GstH264NalUnitExtensionType:
168  * @GST_H264_NAL_EXTENSION_NONE: No NAL unit header extension is available
169  * @GST_H264_NAL_EXTENSION_SVC: NAL unit header extension for SVC (Annex G)
170  * @GST_H264_NAL_EXTENSION_MVC: NAL unit header extension for MVC (Annex H)
171  *
172  * Indicates the type of H.264 NAL unit extension.
173  *
174  * Since: 1.6
175  */
176 typedef enum
177 {
178   GST_H264_NAL_EXTENSION_NONE = 0,
179   GST_H264_NAL_EXTENSION_SVC,
180   GST_H264_NAL_EXTENSION_MVC,
181 } GstH264NalUnitExtensionType;
182
183 /**
184  * GstH264ParserResult:
185  * @GST_H264_PARSER_OK: The parsing succeeded
186  * @GST_H264_PARSER_BROKEN_DATA: The data to parse is broken
187  * @GST_H264_PARSER_BROKEN_LINK: The link to structure needed for the parsing couldn't be found
188  * @GST_H264_PARSER_ERROR: An error occurred when parsing
189  * @GST_H264_PARSER_NO_NAL: No NAL unit found during the parsing
190  * @GST_H264_PARSER_NO_NAL_END: Start of the NAL unit found, but not the end.
191  *     This will be returned if no start/sync marker for the next NAL unit was
192  *     found. In this case the parser will assume that the end of the data is
193  *     also the end of the NAL unit. Whether this assumption is correct or not
194  *     depends on the context, which only the caller can know, which is why a
195  *     special result value is returned in this case. If the data is NAL-aligned
196  *     then #GST_H264_PARSER_NO_NAL_END can be treated just like
197  *     #GST_H264_PARSER_OK. If the data is not guaranteed to be NAL-aligned,
198  *     then the caller probably wants to collect more data until there's another
199  *     sync marker or the end of the stream has been reached.
200  *
201  * The result of parsing H264 data.
202  */
203 typedef enum
204 {
205   GST_H264_PARSER_OK,
206   GST_H264_PARSER_BROKEN_DATA,
207   GST_H264_PARSER_BROKEN_LINK,
208   GST_H264_PARSER_ERROR,
209   GST_H264_PARSER_NO_NAL,
210   GST_H264_PARSER_NO_NAL_END
211 } GstH264ParserResult;
212
213 /**
214  * GstH264FramePackingType:
215  * @GST_H264_FRAME_PACKING_NONE: A complete 2D frame without any frame packing
216  * @GST_H264_FRAME_PACKING_CHECKERBOARD_INTERLEAVING: Checkerboard
217  *   based interleaving
218  * @GST_H264_FRAME_PACKING_COLUMN_INTERLEAVING: Column based interleaving
219  * @GST_H264_FRAME_PACKING_ROW_INTERLEAVING: Row based interleaving
220  * @GST_H264_FRAME_PACKING_SIDE_BY_SIDE: Side-by-side packing
221  * @GST_H264_FRMAE_PACKING_TOP_BOTTOM: Deprecated; use GST_H264_FRAME_PACKING_TOP_BOTTOM instead
222  * @GST_H264_FRAME_PACKING_TOP_BOTTOM: Top-Bottom packing (Since: 1.22)
223  * @GST_H264_FRAME_PACKING_TEMPORAL_INTERLEAVING: Temporal interleaving
224  *
225  * Frame packing arrangement types.
226  *
227  * Since: 1.6
228  */
229 typedef enum
230 {
231   GST_H264_FRAME_PACKING_NONE                           = 6,
232   GST_H264_FRAME_PACKING_CHECKERBOARD_INTERLEAVING      = 0,
233   GST_H264_FRAME_PACKING_COLUMN_INTERLEAVING            = 1,
234   GST_H264_FRAME_PACKING_ROW_INTERLEAVING               = 2,
235   GST_H264_FRAME_PACKING_SIDE_BY_SIDE                   = 3,
236   GST_H264_FRMAE_PACKING_TOP_BOTTOM                     = 4,
237
238   /**
239    * GST_H264_FRAME_PACKING_TOP_BOTTOM:
240    *
241    * Top-Bottom packing
242    *
243    * Since: 1.22
244    */
245   GST_H264_FRAME_PACKING_TOP_BOTTOM                     = 4,
246   GST_H264_FRAME_PACKING_TEMPORAL_INTERLEAVING          = 5
247 } GstH264FramePackingType;
248
249 /**
250  * GstH264SEIPayloadType:
251  * @GST_H264_SEI_BUF_PERIOD: Buffering Period SEI Message
252  * @GST_H264_SEI_PIC_TIMING: Picture Timing SEI Message
253  * @GST_H264_SEI_REGISTERED_USER_DATA: Registered user data (D.2.5)
254  * @GST_H264_SEI_RECOVERY_POINT: Recovery Point SEI Message (D.2.7)
255  * @GST_H264_SEI_STEREO_VIDEO_INFO: stereo video info SEI message (Since: 1.6)
256  * @GST_H264_SEI_FRAME_PACKING: Frame Packing Arrangement (FPA) message that
257  *     contains the 3D arrangement for stereoscopic 3D video (Since: 1.6)
258  * @GST_H264_SEI_MASTERING_DISPLAY_COLOUR_VOLUME: Mastering display colour volume information SEI message (D.2.29) (Since: 1.18)
259  * @GST_H264_SEI_CONTENT_LIGHT_LEVEL: Content light level information SEI message (D.2.31) (Since: 1.18)
260  * @GST_H264_SEI_UNHANDLED_PAYLOAD: Unhandled SEI message. This may or may not
261  *     be defined by spec (Since 1.18)
262  * ...
263  *
264  * The type of SEI message.
265  */
266 /**
267  * GST_H264_SEI_USER_DATA_UNREGISTERED:
268  *
269  * User Data Unregistered (D.2.6)
270  *
271  * Since: 1.22
272  */
273
274 typedef enum
275 {
276   GST_H264_SEI_BUF_PERIOD = 0,
277   GST_H264_SEI_PIC_TIMING = 1,
278   GST_H264_SEI_REGISTERED_USER_DATA = 4,
279   GST_H264_SEI_USER_DATA_UNREGISTERED = 5,
280   GST_H264_SEI_RECOVERY_POINT = 6,
281   GST_H264_SEI_STEREO_VIDEO_INFO = 21,
282   GST_H264_SEI_FRAME_PACKING = 45,
283   GST_H264_SEI_MASTERING_DISPLAY_COLOUR_VOLUME = 137,
284   GST_H264_SEI_CONTENT_LIGHT_LEVEL = 144,
285       /* and more...  */
286
287   /* Unhandled SEI type */
288   GST_H264_SEI_UNHANDLED_PAYLOAD = -1
289 } GstH264SEIPayloadType;
290
291 /**
292  * GstH264SEIPicStructType:
293  * @GST_H264_SEI_PIC_STRUCT_FRAME: Picture is a frame
294  * @GST_H264_SEI_PIC_STRUCT_TOP_FIELD: Top field of frame
295  * @GST_H264_SEI_PIC_STRUCT_BOTTOM_FIELD: Bottom field of frame
296  * @GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM: Top bottom field of frame
297  * @GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP: bottom top field of frame
298  * @GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP: top bottom top field of frame
299  * @GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: bottom top bottom field of frame
300  * @GST_H264_SEI_PIC_STRUCT_FRAME_DOUBLING: indicates that the frame should
301  *  be displayed two times consecutively
302  * @GST_H264_SEI_PIC_STRUCT_FRAME_TRIPLING: indicates that the frame should be
303  *  displayed three times consecutively
304  *
305  * SEI pic_struct type
306  */
307 typedef enum
308 {
309   GST_H264_SEI_PIC_STRUCT_FRAME             = 0,
310   GST_H264_SEI_PIC_STRUCT_TOP_FIELD         = 1,
311   GST_H264_SEI_PIC_STRUCT_BOTTOM_FIELD      = 2,
312   GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM        = 3,
313   GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP        = 4,
314   GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP    = 5,
315   GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6,
316   GST_H264_SEI_PIC_STRUCT_FRAME_DOUBLING    = 7,
317   GST_H264_SEI_PIC_STRUCT_FRAME_TRIPLING    = 8
318 } GstH264SEIPicStructType;
319
320 /**
321  * GstH264SliceType:
322  *
323  * Type of Picture slice
324  */
325
326 typedef enum
327 {
328   GST_H264_P_SLICE    = 0,
329   GST_H264_B_SLICE    = 1,
330   GST_H264_I_SLICE    = 2,
331   GST_H264_SP_SLICE   = 3,
332   GST_H264_SI_SLICE   = 4,
333   GST_H264_S_P_SLICE  = 5,
334   GST_H264_S_B_SLICE  = 6,
335   GST_H264_S_I_SLICE  = 7,
336   GST_H264_S_SP_SLICE = 8,
337   GST_H264_S_SI_SLICE = 9
338 } GstH264SliceType;
339
340 /**
341  * GstH264CtType
342  *
343  * Mapping of ct_type to source picture scan
344  *
345  * Since: 1.16
346  */
347
348 typedef enum
349 {
350   GST_H264_CT_TYPE_PROGRESSIVE = 0,
351   GST_H264_CT_TYPE_INTERLACED = 1,
352   GST_H264_CT_TYPE_UNKNOWN = 2,
353 } GstCtType;
354
355 typedef struct _GstH264NalParser              GstH264NalParser;
356
357 typedef struct _GstH264NalUnit                GstH264NalUnit;
358 typedef struct _GstH264NalUnitExtensionMVC    GstH264NalUnitExtensionMVC;
359
360 typedef struct _GstH264SPSExtMVCView          GstH264SPSExtMVCView;
361 typedef struct _GstH264SPSExtMVCLevelValue    GstH264SPSExtMVCLevelValue;
362 typedef struct _GstH264SPSExtMVCLevelValueOp  GstH264SPSExtMVCLevelValueOp;
363 typedef struct _GstH264SPSExtMVC              GstH264SPSExtMVC;
364
365 typedef struct _GstH264SPS                    GstH264SPS;
366 typedef struct _GstH264PPS                    GstH264PPS;
367 typedef struct _GstH264HRDParams              GstH264HRDParams;
368 typedef struct _GstH264VUIParams              GstH264VUIParams;
369
370 typedef struct _GstH264RefPicListModification GstH264RefPicListModification;
371 typedef struct _GstH264DecRefPicMarking       GstH264DecRefPicMarking;
372 typedef struct _GstH264RefPicMarking          GstH264RefPicMarking;
373 typedef struct _GstH264PredWeightTable        GstH264PredWeightTable;
374 typedef struct _GstH264SliceHdr               GstH264SliceHdr;
375
376 typedef struct _GstH264ClockTimestamp         GstH264ClockTimestamp;
377 typedef struct _GstH264PicTiming              GstH264PicTiming;
378 typedef struct _GstH264RegisteredUserData     GstH264RegisteredUserData;
379 typedef struct _GstH264UserDataUnregistered   GstH264UserDataUnregistered;
380 typedef struct _GstH264BufferingPeriod        GstH264BufferingPeriod;
381 typedef struct _GstH264RecoveryPoint          GstH264RecoveryPoint;
382 typedef struct _GstH264StereoVideoInfo        GstH264StereoVideoInfo;
383 typedef struct _GstH264FramePacking           GstH264FramePacking;
384 typedef struct _GstH264MasteringDisplayColourVolume GstH264MasteringDisplayColourVolume;
385 typedef struct _GstH264ContentLightLevel        GstH264ContentLightLevel;
386 typedef struct _GstH264SEIUnhandledPayload    GstH264SEIUnhandledPayload;
387 typedef struct _GstH264SEIMessage             GstH264SEIMessage;
388 typedef struct _GstH264DecoderConfigRecord    GstH264DecoderConfigRecord;
389
390 /**
391  * GstH264NalUnitExtensionMVC:
392  * @non_idr_flag: If equal to 0, it specifies that the current access
393  *   unit is an IDR access unit
394  * @priority_id: The priority identifier for the NAL unit
395  * @view_id: The view identifier for the NAL unit
396  * @temporal_id: The temporal identifier for the NAL unit
397  * @anchor_pic_flag: If equal to 1, it specifies that the current
398  *   access unit is an anchor access unit
399  * @inter_view_flag: If equal to 0, it specifies that the current view
400  *   component is not used for inter-view prediction by any other view
401  *   component in the current access unit
402  *
403  * Since: 1.6
404  */
405 struct _GstH264NalUnitExtensionMVC
406 {
407   guint8 non_idr_flag;
408   guint8 priority_id;
409   guint16 view_id;
410   guint8 temporal_id;
411   guint8 anchor_pic_flag;
412   guint8 inter_view_flag;
413 };
414
415 /**
416  * GstH264NalUnit:
417  * @ref_idc: not equal to 0 specifies that the content of the NAL unit
418  *  contains a sequence parameter set, a sequence parameter set
419  *  extension, a subset sequence parameter set, a picture parameter
420  *  set, a slice of a reference picture, a slice data partition of a
421  *  reference picture, or a prefix NAL unit preceding a slice of a
422  *  reference picture.
423  * @type: A #GstH264NalUnitType
424  * @idr_pic_flag: calculated idr_pic_flag
425  * @size: The size of the NAL unit starting from @offset, thus
426  *  including the header bytes. e.g. @type (nal_unit_type),
427  *  but not the start code.
428  * @offset: The offset of the first byte of the NAL unit header,
429  *  just after the start code.
430  * @sc_offset: The offset of the first byte of the start code of
431  *  the NAL unit.
432  * @valid: If the NAL unit is valid, which means it has
433  *  already been parsed
434  * @data: The data array from which the NAL unit has been parsed,
435  *  into which the offset and sc_offset apply.
436  * @header_bytes: The size of the NALU header in bytes. The NALU
437  *  header is the 1-byte type code, and for extension / prefix NALs
438  *  includes the extension header bytes. @offset + @header_bytes is
439  *  therefore the first byte of the actual packet payload.
440  *  (Since: 1.6)
441  * @extension_type: the extension type for prefix NAL/MVC/SVC
442  *  (Since: 1.6)
443  *
444  * Structure defining the NAL unit headers
445  */
446 struct _GstH264NalUnit
447 {
448   guint16 ref_idc;
449   guint16 type;
450
451   /* calculated values */
452   guint8 idr_pic_flag;
453   guint size;
454   guint offset;
455   guint sc_offset;
456   gboolean valid;
457
458   guint8 *data;
459
460   guint8 header_bytes;
461   guint8 extension_type;
462   union {
463     GstH264NalUnitExtensionMVC mvc;
464   } extension;
465 };
466
467 /**
468  * GstH264HRDParams:
469  * @cpb_cnt_minus1: plus 1 specifies the number of alternative
470  *    CPB specifications in the bitstream
471  * @bit_rate_scale: specifies the maximum input bit rate of the
472  * SchedSelIdx-th CPB
473  * @cpb_size_scale: specifies the CPB size of the SchedSelIdx-th CPB
474  * @guint32 bit_rate_value_minus1: specifies the maximum input bit rate for the
475  * SchedSelIdx-th CPB
476  * @cpb_size_value_minus1: is used together with cpb_size_scale to specify the
477  * SchedSelIdx-th CPB size
478  * @cbr_flag: Specifies if running in constant or intermittent bit rate mode
479  * @initial_cpb_removal_delay_length_minus1: specifies the length in bits of
480  * the cpb_removal_delay syntax element
481  * @cpb_removal_delay_length_minus1: specifies the length in bits of the
482  * dpb_output_delay syntax element
483  * @dpb_output_delay_length_minus1: >0 specifies the length in bits of the time_offset syntax element.
484  * =0 specifies that the time_offset syntax element is not present
485  * @time_offset_length: Length of the time offset
486  *
487  * Defines the HRD parameters
488  */
489 struct _GstH264HRDParams
490 {
491   guint8 cpb_cnt_minus1;
492   guint8 bit_rate_scale;
493   guint8 cpb_size_scale;
494
495   guint32 bit_rate_value_minus1[32];
496   guint32 cpb_size_value_minus1[32];
497   guint8 cbr_flag[32];
498
499   guint8 initial_cpb_removal_delay_length_minus1;
500   guint8 cpb_removal_delay_length_minus1;
501   guint8 dpb_output_delay_length_minus1;
502   guint8 time_offset_length;
503 };
504
505 /**
506  * GstH264VUIParams:
507  * @aspect_ratio_info_present_flag: %TRUE specifies that aspect_ratio_idc is present.
508  *  %FALSE specifies that aspect_ratio_idc is not present
509  * @aspect_ratio_idc specifies the value of the sample aspect ratio of the luma samples
510  * @sar_width indicates the horizontal size of the sample aspect ratio
511  * @sar_height indicates the vertical size of the sample aspect ratio
512  * @overscan_info_present_flag: %TRUE overscan_appropriate_flag is present %FALSE otherwise
513  * @overscan_appropriate_flag: %TRUE indicates that the cropped decoded pictures
514  *  output are suitable for display using overscan. %FALSE the cropped decoded pictures
515  *  output contain visually important information
516  * @video_signal_type_present_flag: %TRUE specifies that video_format, video_full_range_flag and
517  *  colour_description_present_flag are present.
518  * @video_format: indicates the representation of the picture
519  * @video_full_range_flag: indicates the black level and range of the luma and chroma signals
520  * @colour_description_present_flag: %TRUE specifies that colour_primaries,
521  *  transfer_characteristics and matrix_coefficients are present
522  * @colour_primaries: indicates the chromaticity coordinates of the source primaries
523  * @transfer_characteristics: indicates the opto-electronic transfer characteristic
524  * @matrix_coefficients: describes the matrix coefficients used in deriving luma and chroma signals
525  * @chroma_loc_info_present_flag: %TRUE specifies that chroma_sample_loc_type_top_field and
526  *  chroma_sample_loc_type_bottom_field are present, %FALSE otherwise
527  * @chroma_sample_loc_type_top_field: specify the location of chroma for top field
528  * @chroma_sample_loc_type_bottom_field specify the location of chroma for bottom field
529  * @timing_info_present_flag: %TRUE specifies that num_units_in_tick,
530  *  time_scale and fixed_frame_rate_flag are present in the bitstream
531  * @num_units_in_tick: is the number of time units of a clock operating at the frequency time_scale Hz
532  * time_scale: is the number of time units that pass in one second
533  * @fixed_frame_rate_flag: %TRUE indicates that the temporal distance between the HRD output times
534  *  of any two consecutive pictures in output order is constrained as specified in the spec, %FALSE
535  *  otherwise.
536  * @nal_hrd_parameters_present_flag: %TRUE if NAL HRD parameters exist in the bitstream
537  * @vcl_hrd_parameters_present_flag: %TRUE if VCL HRD parameters exist in the bitstream
538  * @low_delay_hrd_flag: specifies the HRD operational mode
539  * @pic_struct_present_flag: %TRUE specifies that picture timing SEI messages are present or not
540  * @bitstream_restriction_flag: %TRUE specifies that the following coded video sequence bitstream restriction
541  * parameters are present
542  * @motion_vectors_over_pic_boundaries_flag: %FALSE indicates that no sample outside the
543  *  picture boundaries and no sample at a fractional sample position, %TRUE indicates that one or more
544  *  samples outside picture boundaries may be used in inter prediction
545  * @max_bytes_per_pic_denom: indicates a number of bytes not exceeded by the sum of the sizes of
546  *  the VCL NAL units associated with any coded picture in the coded video sequence.
547  * @max_bits_per_mb_denom: indicates the maximum number of coded bits of macroblock_layer
548  * @log2_max_mv_length_horizontal: indicate the maximum absolute value of a decoded horizontal
549  * motion vector component
550  * @log2_max_mv_length_vertical: indicate the maximum absolute value of a decoded vertical
551  *  motion vector component
552  * @num_reorder_frames: indicates the maximum number of frames, complementary field pairs,
553  *  or non-paired fields that precede any frame,
554  * @max_dec_frame_buffering: specifies the required size of the HRD decoded picture buffer in
555  *  units of frame buffers.
556  *
557  * The structure representing the VUI parameters.
558  */
559 struct _GstH264VUIParams
560 {
561   guint8 aspect_ratio_info_present_flag;
562   guint8 aspect_ratio_idc;
563   /* if aspect_ratio_idc == 255 */
564   guint16 sar_width;
565   guint16 sar_height;
566
567   guint8 overscan_info_present_flag;
568   /* if overscan_info_present_flag */
569   guint8 overscan_appropriate_flag;
570
571   guint8 video_signal_type_present_flag;
572   guint8 video_format;
573   guint8 video_full_range_flag;
574   guint8 colour_description_present_flag;
575   guint8 colour_primaries;
576   guint8 transfer_characteristics;
577   guint8 matrix_coefficients;
578
579   guint8 chroma_loc_info_present_flag;
580   guint8 chroma_sample_loc_type_top_field;
581   guint8 chroma_sample_loc_type_bottom_field;
582
583   guint8 timing_info_present_flag;
584   /* if timing_info_present_flag */
585   guint32 num_units_in_tick;
586   guint32 time_scale;
587   guint8 fixed_frame_rate_flag;
588
589   guint8 nal_hrd_parameters_present_flag;
590   /* if nal_hrd_parameters_present_flag */
591   GstH264HRDParams nal_hrd_parameters;
592
593   guint8 vcl_hrd_parameters_present_flag;
594   /* if vcl_hrd_parameters_present_flag */
595   GstH264HRDParams vcl_hrd_parameters;
596
597   guint8 low_delay_hrd_flag;
598   guint8 pic_struct_present_flag;
599
600   guint8 bitstream_restriction_flag;
601   /*  if bitstream_restriction_flag */
602   guint8 motion_vectors_over_pic_boundaries_flag;
603   guint32 max_bytes_per_pic_denom;
604   guint32 max_bits_per_mb_denom;
605   guint32 log2_max_mv_length_horizontal;
606   guint32 log2_max_mv_length_vertical;
607   guint32 num_reorder_frames;
608   guint32 max_dec_frame_buffering;
609
610   /* calculated values */
611   guint par_n;
612   guint par_d;
613 };
614
615 /**
616  * GstH264SPSExtMVCView:
617  * @num_anchor_refs_l0: specifies the number of view components for
618  *   inter-view prediction in the initialized RefPicList0 in decoding
619  *   anchor view components.
620  * @anchor_ref_l0: specifies the view_id for inter-view prediction in
621  *   the initialized RefPicList0 in decoding anchor view components.
622  * @num_anchor_refs_l1: specifies the number of view components for
623  *   inter-view prediction in the initialized RefPicList1 in decoding
624  *   anchor view components.
625  * @anchor_ref_l1: specifies the view_id for inter-view prediction in
626  *   the initialized RefPicList1 in decoding anchor view components.
627  * @num_non_anchor_refs_l0: specifies the number of view components
628  *   for inter-view prediction in the initialized RefPicList0 in
629  *   decoding non-anchor view components.
630  * @non_anchor_ref_l0: specifies the view_id for inter-view prediction
631  *   in the initialized RefPicList0 in decoding non-anchor view
632  *   components.
633  * @num_non_anchor_refs_l1: specifies the number of view components
634  *   for inter-view prediction in the initialized RefPicList1 in
635  *   decoding non-anchor view components.
636  * @non_anchor_ref_l1: specifies the view_id for inter-view prediction
637  *   in the initialized RefPicList1 in decoding non-anchor view
638  *   components.
639  *
640  * Represents inter-view dependency relationships for the coded video
641  * sequence.
642  *
643  * Since: 1.6
644  */
645 struct _GstH264SPSExtMVCView
646 {
647   guint16 view_id;
648   guint8 num_anchor_refs_l0;
649   guint16 anchor_ref_l0[15];
650   guint8 num_anchor_refs_l1;
651   guint16 anchor_ref_l1[15];
652   guint8 num_non_anchor_refs_l0;
653   guint16 non_anchor_ref_l0[15];
654   guint8 num_non_anchor_refs_l1;
655   guint16 non_anchor_ref_l1[15];
656 };
657
658 /**
659  * GstH264SPSExtMVCLevelValueOp:
660  *
661  * Represents an operation point for the coded video sequence.
662  *
663  * Since: 1.6
664  */
665 struct _GstH264SPSExtMVCLevelValueOp
666 {
667   guint8 temporal_id;
668   guint16 num_target_views_minus1;
669   guint16 *target_view_id;
670   guint16 num_views_minus1;
671 };
672
673 /**
674  * GstH264SPSExtMVCLevelValue:
675  * @level_idc: specifies the level value signalled for the coded video
676  *   sequence
677  * @num_applicable_ops_minus1: plus 1 specifies the number of
678  *   operation points to which the level indicated by level_idc applies
679  * @applicable_op: specifies the applicable operation point
680  *
681  * Represents level values for a subset of the operation points for
682  * the coded video sequence.
683  *
684  * Since: 1.6
685  */
686 struct _GstH264SPSExtMVCLevelValue
687 {
688   guint8 level_idc;
689   guint16 num_applicable_ops_minus1;
690   GstH264SPSExtMVCLevelValueOp *applicable_op;
691 };
692
693 /**
694  * GstH264SPSExtMVC:
695  * @num_views_minus1: plus 1 specifies the maximum number of coded
696  *   views in the coded video sequence
697  * @view: array of #GstH264SPSExtMVCView
698  * @num_level_values_signalled_minus1: plus 1 specifies the number of
699  *   level values signalled for the coded video sequence.
700  * @level_value: array of #GstH264SPSExtMVCLevelValue
701  *
702  * Represents the parsed `seq_parameter_set_mvc_extension()`.
703  *
704  * Since: 1.6
705          */
706 struct _GstH264SPSExtMVC
707 {
708   guint16 num_views_minus1;
709   GstH264SPSExtMVCView *view;
710   guint8 num_level_values_signalled_minus1;
711   GstH264SPSExtMVCLevelValue *level_value;
712 };
713
714 /**
715  * GstH264SPS:
716  * @id: The ID of the sequence parameter set
717  * @profile_idc: indicate the profile to which the coded video sequence conforms
718  *
719  * H264 Sequence Parameter Set (SPS)
720  */
721 struct _GstH264SPS
722 {
723   gint id;
724
725   guint8 profile_idc;
726   guint8 constraint_set0_flag;
727   guint8 constraint_set1_flag;
728   guint8 constraint_set2_flag;
729   guint8 constraint_set3_flag;
730   guint8 constraint_set4_flag;
731   guint8 constraint_set5_flag;
732   guint8 level_idc;
733
734   guint8 chroma_format_idc;
735   guint8 separate_colour_plane_flag;
736   guint8 bit_depth_luma_minus8;
737   guint8 bit_depth_chroma_minus8;
738   guint8 qpprime_y_zero_transform_bypass_flag;
739
740   guint8 scaling_matrix_present_flag;
741   guint8 scaling_lists_4x4[6][16];
742   guint8 scaling_lists_8x8[6][64];
743
744   guint8 log2_max_frame_num_minus4;
745   guint8 pic_order_cnt_type;
746
747   /* if pic_order_cnt_type == 0 */
748   guint8 log2_max_pic_order_cnt_lsb_minus4;
749
750   /* else if pic_order_cnt_type == 1 */
751   guint8 delta_pic_order_always_zero_flag;
752   gint32 offset_for_non_ref_pic;
753   gint32 offset_for_top_to_bottom_field;
754   guint8 num_ref_frames_in_pic_order_cnt_cycle;
755   gint32 offset_for_ref_frame[255];
756
757   /* FIXME rename according to spec, max_num_ref_frames */
758   guint32 num_ref_frames;
759   guint8 gaps_in_frame_num_value_allowed_flag;
760   guint32 pic_width_in_mbs_minus1;
761   guint32 pic_height_in_map_units_minus1;
762   guint8 frame_mbs_only_flag;
763
764   guint8 mb_adaptive_frame_field_flag;
765
766   guint8 direct_8x8_inference_flag;
767
768   guint8 frame_cropping_flag;
769
770   /* if frame_cropping_flag */
771   guint32 frame_crop_left_offset;
772   guint32 frame_crop_right_offset;
773   guint32 frame_crop_top_offset;
774   guint32 frame_crop_bottom_offset;
775
776   guint8 vui_parameters_present_flag;
777   /* if vui_parameters_present_flag */
778   GstH264VUIParams vui_parameters;
779
780   /* calculated values */
781   guint8 chroma_array_type;
782   guint32 max_frame_num;
783   gint width, height;
784   gint crop_rect_width, crop_rect_height;
785   gint crop_rect_x, crop_rect_y;
786   gint fps_num_removed, fps_den_removed; /* FIXME: remove */
787   gboolean valid;
788
789   /* Subset SPS extensions */
790   guint8 extension_type;
791   union {
792     GstH264SPSExtMVC mvc;
793   } extension;
794 };
795
796 /**
797  * GstH264PPS:
798  *
799  * H264 Picture Parameter Set
800  */
801 struct _GstH264PPS
802 {
803   gint id;
804
805   GstH264SPS *sequence;
806
807   guint8 entropy_coding_mode_flag;
808   guint8 pic_order_present_flag;
809
810   guint32 num_slice_groups_minus1;
811
812   /* if num_slice_groups_minus1 > 0 */
813   guint8 slice_group_map_type;
814   /* and if slice_group_map_type == 0 */
815   guint32 run_length_minus1[8];
816   /* or if slice_group_map_type == 2 */
817   guint32 top_left[8];
818   guint32 bottom_right[8];
819   /* or if slice_group_map_type == (3, 4, 5) */
820   guint8 slice_group_change_direction_flag;
821   guint32 slice_group_change_rate_minus1;
822   /* or if slice_group_map_type == 6 */
823   guint32 pic_size_in_map_units_minus1;
824   guint8 *slice_group_id;
825
826   /* FIXME rename to num_ref_idx_l{0,1}_default_active_minus1 */
827   guint8 num_ref_idx_l0_active_minus1;
828   guint8 num_ref_idx_l1_active_minus1;
829   guint8 weighted_pred_flag;
830   guint8 weighted_bipred_idc;
831   gint8 pic_init_qp_minus26;
832   gint8 pic_init_qs_minus26;
833   gint8 chroma_qp_index_offset;
834   guint8 deblocking_filter_control_present_flag;
835   guint8 constrained_intra_pred_flag;
836   guint8 redundant_pic_cnt_present_flag;
837
838   guint8 transform_8x8_mode_flag;
839
840   guint8 scaling_lists_4x4[6][16];
841   guint8 scaling_lists_8x8[6][64];
842
843   guint8 second_chroma_qp_index_offset;
844
845   gboolean valid;
846
847   /* Since: 1.18 */
848   guint8 pic_scaling_matrix_present_flag;
849 };
850
851 struct _GstH264RefPicListModification
852 {
853   guint8 modification_of_pic_nums_idc;
854   union
855   {
856     /* if modification_of_pic_nums_idc == 0 || 1 */
857     guint32 abs_diff_pic_num_minus1;
858     /* if modification_of_pic_nums_idc == 2 */
859     guint32 long_term_pic_num;
860     /* if modification_of_pic_nums_idc == 4 || 5 */
861     guint32 abs_diff_view_idx_minus1;
862   } value;
863 };
864
865 struct _GstH264PredWeightTable
866 {
867   guint8 luma_log2_weight_denom;
868   guint8 chroma_log2_weight_denom;
869
870   gint16 luma_weight_l0[32];
871   gint8 luma_offset_l0[32];
872
873   /* if seq->ChromaArrayType != 0 */
874   gint16 chroma_weight_l0[32][2];
875   gint8 chroma_offset_l0[32][2];
876
877   /* if slice->slice_type % 5 == 1 */
878   gint16 luma_weight_l1[32];
879   gint8 luma_offset_l1[32];
880
881   /* and if seq->ChromaArrayType != 0 */
882   gint16 chroma_weight_l1[32][2];
883   gint8 chroma_offset_l1[32][2];
884 };
885
886 struct _GstH264RefPicMarking
887 {
888   guint8 memory_management_control_operation;
889
890   guint32 difference_of_pic_nums_minus1;
891   guint32 long_term_pic_num;
892   guint32 long_term_frame_idx;
893   guint32 max_long_term_frame_idx_plus1;
894 };
895
896 struct _GstH264DecRefPicMarking
897 {
898   /* if slice->nal_unit.IdrPicFlag */
899   guint8 no_output_of_prior_pics_flag;
900   guint8 long_term_reference_flag;
901
902   guint8 adaptive_ref_pic_marking_mode_flag;
903   GstH264RefPicMarking ref_pic_marking[10];
904   guint8 n_ref_pic_marking;
905
906   /* Size of the dec_ref_pic_marking() syntax element in bits (Since: 1.18) */
907   guint bit_size;
908 };
909
910
911 struct _GstH264SliceHdr
912 {
913   guint32 first_mb_in_slice;
914   guint32 type;
915   GstH264PPS *pps;
916
917   /* if seq->separate_colour_plane_flag */
918   guint8 colour_plane_id;
919
920   guint16 frame_num;
921
922   guint8 field_pic_flag;
923   guint8 bottom_field_flag;
924
925   /* if nal_unit.type == 5 */
926   guint16 idr_pic_id;
927
928   /* if seq->pic_order_cnt_type == 0 */
929   guint16 pic_order_cnt_lsb;
930   /* if seq->pic_order_present_flag && !field_pic_flag */
931   gint32 delta_pic_order_cnt_bottom;
932
933   gint32 delta_pic_order_cnt[2];
934   guint8 redundant_pic_cnt;
935
936   /* if slice_type == B_SLICE */
937   guint8 direct_spatial_mv_pred_flag;
938
939   guint8 num_ref_idx_l0_active_minus1;
940   guint8 num_ref_idx_l1_active_minus1;
941
942   guint8 ref_pic_list_modification_flag_l0;
943   guint8 n_ref_pic_list_modification_l0;
944   GstH264RefPicListModification ref_pic_list_modification_l0[32];
945   guint8 ref_pic_list_modification_flag_l1;
946   guint8 n_ref_pic_list_modification_l1;
947   GstH264RefPicListModification ref_pic_list_modification_l1[32];
948
949   GstH264PredWeightTable pred_weight_table;
950   /* if nal_unit.ref_idc != 0 */
951   GstH264DecRefPicMarking dec_ref_pic_marking;
952
953   guint8 cabac_init_idc;
954   gint8 slice_qp_delta;
955   gint8 slice_qs_delta;
956
957   guint8 disable_deblocking_filter_idc;
958   gint8 slice_alpha_c0_offset_div2;
959   gint8 slice_beta_offset_div2;
960
961   guint16 slice_group_change_cycle;
962
963   /* calculated values */
964   guint32 max_pic_num;
965   gboolean valid;
966
967   /* Size of the slice_header() in bits */
968   guint header_size;
969
970   /* Number of emulation prevention bytes (EPB) in this slice_header() */
971   guint n_emulation_prevention_bytes;
972
973   /* Since: 1.18 */
974   guint8 num_ref_idx_active_override_flag;
975   guint8 sp_for_switch_flag;
976
977   /*
978    * Size of the pic_order_cnt related syntax elements pic_order_cnt_lsb,
979    * delta_pic_order_cnt_bottom, delta_pic_order_cnt[0], and
980    * delta_pic_order_cnt[1]. (Since: 1.18)
981    */
982   guint pic_order_cnt_bit_size;
983 };
984
985 /**
986  * GstH264ClockTimestamp:
987  * @ct_type: indicates the scan type, 0: progressive, 1: interlaced, 2: unknown,
988  *   3: reserved
989  * @nuit_field_based_flag: used in calculating clockTimestamp
990  * @counting_type: specifies the method of dropping values of the n_frames
991  * @full_timestamp_flag: equal to 1 specifies that the n_frames syntax element
992  *   is followed by seconds_value, minutes_value, and hours_value (Since 1.18)
993  * @discontinuity_flag: indicates whether the difference between the current
994  *   value of clockTimestamp and the value of clockTimestamp computed from the
995  *   previous clock timestamp can be interpreted as the time difference or not.
996  * @cnt_dropped_flag: specifies the skipping of one or more values of n_frames
997  *   using the counting method specified by counting_type
998  * @n_frames: specifies the value of nFrames used to compute clockTimestamp
999  * @seconds_flag: equal to 1 specifies that @seconds_value and minutes_flag are
1000  *   present when @full_timestamp_flag is equal to 0
1001  * @seconds_value: specifies the value of seconds to compute clockTimestamp
1002  * @minutes_flag: equal to 1 specifies that @minutes_value and hours_flag are
1003  *   present when @full_timestamp_flag is equal to 0 and @seconds_flag is
1004  *   equal to 1
1005  * @minutes_value: specifies the value of minutes to compute clockTimestamp
1006  * @hours_flag: equal to 1 specifies that @hours_value is present when
1007  *   @full_timestamp_flag is equal to 0 and @seconds_flag is equal to 1 and
1008  *   @minutes_flag is equal to 1
1009  * @time_offset: specifies the value of tOffset used to compute clockTimestamp
1010  */
1011 struct _GstH264ClockTimestamp
1012 {
1013   guint8 ct_type;
1014   guint8 nuit_field_based_flag;
1015   guint8 counting_type;
1016   guint8 full_timestamp_flag;
1017   guint8 discontinuity_flag;
1018   guint8 cnt_dropped_flag;
1019   guint8 n_frames;
1020
1021   guint8 seconds_flag;
1022   guint8 seconds_value;
1023
1024   guint8 minutes_flag;
1025   guint8 minutes_value;
1026
1027   guint8 hours_flag;
1028   guint8 hours_value;
1029
1030   guint32 time_offset;
1031 };
1032
1033 /**
1034  * GstH264FramePacking:
1035  *
1036  * Since: 1.6
1037  */
1038 struct _GstH264FramePacking
1039 {
1040   guint32 frame_packing_id;
1041   guint8 frame_packing_cancel_flag;
1042   guint8 frame_packing_type; /* GstH264FramePackingType */
1043   guint8 quincunx_sampling_flag;
1044   guint8 content_interpretation_type;
1045   guint8 spatial_flipping_flag;
1046   guint8 frame0_flipped_flag;
1047   guint8 field_views_flag;
1048   guint8 current_frame_is_frame0_flag;
1049   guint8 frame0_self_contained_flag;
1050   guint8 frame1_self_contained_flag;
1051   guint8 frame0_grid_position_x;
1052   guint8 frame0_grid_position_y;
1053   guint8 frame1_grid_position_x;
1054   guint8 frame1_grid_position_y;
1055   guint16 frame_packing_repetition_period;
1056 };
1057
1058 /**
1059  * GstH264StereoVideoInfo:
1060  *
1061  * Since: 1.6
1062  */
1063 struct _GstH264StereoVideoInfo
1064 {
1065   guint8 field_views_flag;
1066   guint8 top_field_is_left_view_flag;
1067   guint8 current_frame_is_left_view_flag;
1068   guint8 next_frame_is_second_view_flag;
1069   guint8 left_view_self_contained_flag;
1070   guint8 right_view_self_contained_flag;
1071 };
1072
1073 /**
1074  * GstH264PicTiming:
1075  * @CpbDpbDelaysPresentFlag: non-zero if linked
1076  *   GstH264VUIParams::nal_hrd_parameters_present_flag or
1077  *   GstH264VUIParams::vcl_hrd_parameters_present_flag is non-zero (Since: 1.18)
1078  * @cpb_removal_delay_length_minus1: specifies the length of @cpb_removal_delay
1079  *   in bits (Since 1.18)
1080  * @dpb_output_delay_length_minus1: specifies the length of @dpb_output_delay
1081  *   in bits (Since 1.18)
1082  * @cpb_removal_delay: specifies how many clock ticks to wait after removal from
1083  *   the CPB of the access unit associated with the most recent buffering period
1084  *   SEI message in a preceding access unit before removing from the
1085  *   buffer the access unit data associated with the picture timing SEI message
1086  * @dpb_output_delay: used to compute the DPB output time of the picture
1087  * @pic_struct_present_flag: GstH264VUIParams::pic_struct_present_flag
1088  * @pic_struct: indicates whether a picture should be displayed as a frame or
1089  *   one or more fields
1090  * @clock_timestamp_flag: equal to 1 indicates that a number of clock timestamp
1091  *   syntax elements are present
1092  * @clock_timestamp: a #GstH264ClockTimestamp
1093  * @time_offset_length: specifies the length time_offset of
1094  *   #GstH264ClockTimestamp in bits (Since 1.18)
1095  */
1096 struct _GstH264PicTiming
1097 {
1098   /* from vui */
1099   guint8 CpbDpbDelaysPresentFlag;
1100   /* if CpbDpbDelaysPresentFlag */
1101   guint8 cpb_removal_delay_length_minus1;
1102   guint8 dpb_output_delay_length_minus1;
1103   guint32 cpb_removal_delay;
1104   guint32 dpb_output_delay;
1105
1106   guint8 pic_struct_present_flag;
1107   /* if pic_struct_present_flag */
1108   guint8 pic_struct;
1109
1110   guint8 clock_timestamp_flag[3];
1111   GstH264ClockTimestamp clock_timestamp[3];
1112   guint8 time_offset_length;
1113 };
1114
1115 /**
1116  * GstH264RegisteredUserData:
1117  * The User data registered by Rec. ITU-T T.35 SEI messag.
1118  * @country_code: an itu_t_t35_country_code.
1119  * @country_code_extension: an itu_t_t35_country_code_extension_byte.
1120  *   Should be ignored when @country_code is not 0xff
1121  * @data: the data of itu_t_t35_payload_byte
1122  *   excluding @country_code and @country_code_extension
1123  * @size: the size of @data in bytes
1124  *
1125  * Since: 1.16
1126  */
1127 struct _GstH264RegisteredUserData
1128 {
1129   guint8 country_code;
1130   guint8 country_code_extension;
1131   const guint8 *data;
1132   guint size;
1133 };
1134
1135 /**
1136  * GstH264UserDataUnregistered:
1137  * @uuid: an uuid_iso_iec_11578.
1138  * @data: the data of user_data_payload_byte
1139  * @size: the size of @data in bytes
1140  *
1141  * The User data unregistered SEI message syntax.
1142  *
1143  * Since: 1.22
1144  */
1145 struct _GstH264UserDataUnregistered
1146 {
1147   guint8 uuid[16];
1148   const guint8 *data;
1149   guint size;
1150 };
1151
1152 struct _GstH264BufferingPeriod
1153 {
1154   GstH264SPS *sps;
1155
1156   /* seq->vui_parameters->nal_hrd_parameters_present_flag */
1157   guint32 nal_initial_cpb_removal_delay[32];
1158   guint32 nal_initial_cpb_removal_delay_offset[32];
1159
1160   /* seq->vui_parameters->vcl_hrd_parameters_present_flag */
1161   guint32 vcl_initial_cpb_removal_delay[32];
1162   guint32 vcl_initial_cpb_removal_delay_offset[32];
1163 };
1164
1165 struct _GstH264RecoveryPoint
1166 {
1167   guint32 recovery_frame_cnt;
1168   guint8 exact_match_flag;
1169   guint8 broken_link_flag;
1170   guint8 changing_slice_group_idc;
1171 };
1172
1173 /**
1174  * GstH264MasteringDisplayColourVolume:
1175  * The colour volume (primaries, white point and luminance range) of display
1176  * defined by SMPTE ST 2086.
1177  *
1178  * D.2.29
1179  *
1180  * Since: 1.18
1181  */
1182 struct _GstH264MasteringDisplayColourVolume
1183 {
1184   guint16 display_primaries_x[3];
1185   guint16 display_primaries_y[3];
1186   guint16 white_point_x;
1187   guint16 white_point_y;
1188   guint32 max_display_mastering_luminance;
1189   guint32 min_display_mastering_luminance;
1190 };
1191
1192 /**
1193  * GstH264ContentLightLevel:
1194  * The upper bounds for the nominal target brightness light level
1195  * as specified in CEA-861.3
1196  *
1197  * D.2.31
1198  *
1199  * Since: 1.18
1200  */
1201 struct _GstH264ContentLightLevel
1202 {
1203   guint16 max_content_light_level;
1204   guint16 max_pic_average_light_level;
1205 };
1206
1207 /**
1208  * GstH264SEIUnhandledPayload:
1209  * @payloadType: Payload type
1210  * @data: payload raw data excluding payload type and payload size byte
1211  * @size: the size of @data
1212  *
1213  * Contains unhandled SEI payload data. This SEI may or may not
1214  * be defined by spec
1215  *
1216  * Since: 1.18
1217  */
1218 struct _GstH264SEIUnhandledPayload
1219 {
1220   guint payloadType;
1221
1222   guint8 *data;
1223   guint size;
1224 };
1225
1226 /**
1227  * _GstH264SEIMessage.payload.user_data_unregistered:
1228  *
1229  * User Data Unregistered
1230  *
1231  * Since: 1.22
1232  */
1233 struct _GstH264SEIMessage
1234 {
1235   GstH264SEIPayloadType payloadType;
1236
1237   union {
1238     GstH264BufferingPeriod buffering_period;
1239     GstH264PicTiming pic_timing;
1240     GstH264RegisteredUserData registered_user_data;
1241     GstH264RecoveryPoint recovery_point;
1242     GstH264StereoVideoInfo stereo_video_info;
1243     GstH264FramePacking frame_packing;
1244     GstH264MasteringDisplayColourVolume mastering_display_colour_volume;
1245     GstH264ContentLightLevel content_light_level;
1246     GstH264SEIUnhandledPayload unhandled_payload;
1247     GstH264UserDataUnregistered user_data_unregistered;
1248     /* ... could implement more */
1249   } payload;
1250 };
1251
1252 /**
1253  * GstH264DecoderConfigRecord:
1254  *
1255  * Contains AVCDecoderConfigurationRecord data as defined in ISO/IEC 14496-15
1256  *
1257  * Since: 1.22
1258  */
1259 struct _GstH264DecoderConfigRecord
1260 {
1261   /**
1262    * GstH264DecoderConfigRecord.configuration_version:
1263    *
1264    * Indicates configurationVersion, must be 1
1265    */
1266   guint8 configuration_version;
1267
1268   /**
1269    * GstH264DecoderConfigRecord.profile_indication:
1270    *
1271    * H.264 profile indication
1272    */
1273   guint8 profile_indication;
1274
1275   /**
1276    * GstH264DecoderConfigRecord.profile_compatibility:
1277    *
1278    * H.264 profile compatibility
1279    */
1280   guint8 profile_compatibility;
1281
1282   /**
1283    * GstH264DecoderConfigRecord.level_indication:
1284    *
1285    * H.264 level indiction
1286    */
1287   guint8 level_indication;
1288
1289   /**
1290    * GstH264DecoderConfigRecord.length_size_minus_one:
1291    *
1292    * Indicates the length in bytes of the NAL unit length field
1293    */
1294   guint8 length_size_minus_one;
1295
1296   /**
1297    * GstH264DecoderConfigRecord.sps
1298    *
1299    * Array of identified #GstH264NalUnit from sequenceParameterSetNALUnit.
1300    * This array may contain non-SPS nal units such as SEI message
1301    */
1302   GArray *sps;
1303
1304   /**
1305    * GstH264DecoderConfigRecord.pps
1306    *
1307    * Array of identified #GstH264NalUnit from pictureParameterSetNALUnit.
1308    * This array may contain non-PPS nal units such as SEI message
1309    */
1310   GArray *pps;
1311
1312   /**
1313    * GstH264DecoderConfigRecord.chroma_format_present
1314    *
1315    * %TRUE if chroma information is present. Otherwise below values
1316    * have no meaning
1317    */
1318   gboolean chroma_format_present;
1319
1320   /**
1321    * GstH264DecoderConfigRecord.chroma_format
1322    *
1323    * chroma_format_idc defined in ISO/IEC 14496-10
1324    */
1325   guint8 chroma_format;
1326
1327   /**
1328    * GstH264DecoderConfigRecord.bit_depth_luma_minus8
1329    *
1330    * Indicates bit depth of luma component
1331    */
1332   guint8 bit_depth_luma_minus8;
1333
1334   /**
1335    * GstH264DecoderConfigRecord.bit_depth_chroma_minus8
1336    *
1337    * Indicates bit depth of chroma component
1338    */
1339   guint8 bit_depth_chroma_minus8;
1340
1341   /**
1342    * GstH264DecoderConfigRecord.sps_ext
1343    *
1344    * Array of identified #GstH264NalUnit from sequenceParameterSetExtNALUnit.
1345    */
1346   GArray *sps_ext;
1347
1348   /*< private >*/
1349   gpointer _gst_reserved[GST_PADDING];
1350 };
1351
1352 /**
1353  * GstH264NalParser:
1354  *
1355  * H264 NAL Parser (opaque structure).
1356  */
1357 struct _GstH264NalParser
1358 {
1359   /*< private >*/
1360   GstH264SPS sps[GST_H264_MAX_SPS_COUNT];
1361   GstH264PPS pps[GST_H264_MAX_PPS_COUNT];
1362   GstH264SPS *last_sps;
1363   GstH264PPS *last_pps;
1364 };
1365
1366 GST_CODEC_PARSERS_API
1367 GstH264NalParser *gst_h264_nal_parser_new             (void);
1368
1369 GST_CODEC_PARSERS_API
1370 GstH264ParserResult gst_h264_parser_identify_nalu     (GstH264NalParser *nalparser,
1371                                                        const guint8 *data, guint offset,
1372                                                        gsize size, GstH264NalUnit *nalu);
1373
1374 GST_CODEC_PARSERS_API
1375 GstH264ParserResult gst_h264_parser_identify_nalu_unchecked (GstH264NalParser *nalparser,
1376                                                        const guint8 *data, guint offset,
1377                                                        gsize size, GstH264NalUnit *nalu);
1378
1379 GST_CODEC_PARSERS_API
1380 GstH264ParserResult gst_h264_parser_identify_nalu_avc (GstH264NalParser *nalparser, const guint8 *data,
1381                                                        guint offset, gsize size, guint8 nal_length_size,
1382                                                        GstH264NalUnit *nalu);
1383
1384 GST_CODEC_PARSERS_API
1385 GstH264ParserResult gst_h264_parser_parse_nal         (GstH264NalParser *nalparser,
1386                                                        GstH264NalUnit *nalu);
1387
1388 GST_CODEC_PARSERS_API
1389 GstH264ParserResult gst_h264_parser_parse_slice_hdr   (GstH264NalParser *nalparser, GstH264NalUnit *nalu,
1390                                                        GstH264SliceHdr *slice, gboolean parse_pred_weight_table,
1391                                                        gboolean parse_dec_ref_pic_marking);
1392
1393 GST_CODEC_PARSERS_API
1394 GstH264ParserResult gst_h264_parser_parse_subset_sps  (GstH264NalParser *nalparser, GstH264NalUnit *nalu,
1395                                                        GstH264SPS *sps);
1396
1397 GST_CODEC_PARSERS_API
1398 GstH264ParserResult gst_h264_parser_parse_sps         (GstH264NalParser *nalparser, GstH264NalUnit *nalu,
1399                                                        GstH264SPS *sps);
1400
1401 GST_CODEC_PARSERS_API
1402 GstH264ParserResult gst_h264_parser_parse_pps         (GstH264NalParser *nalparser,
1403                                                        GstH264NalUnit *nalu, GstH264PPS *pps);
1404
1405 GST_CODEC_PARSERS_API
1406 GstH264ParserResult gst_h264_parser_parse_sei         (GstH264NalParser *nalparser,
1407                                                        GstH264NalUnit *nalu, GArray ** messages);
1408
1409 GST_CODEC_PARSERS_API
1410 GstH264ParserResult gst_h264_parser_update_sps        (GstH264NalParser *nalparser,
1411                                                        GstH264SPS *sps);
1412
1413 GST_CODEC_PARSERS_API
1414 GstH264ParserResult gst_h264_parser_update_pps        (GstH264NalParser *nalparser,
1415                                                        GstH264PPS *pps);
1416
1417 GST_CODEC_PARSERS_API
1418 void gst_h264_nal_parser_free                         (GstH264NalParser *nalparser);
1419
1420 GST_CODEC_PARSERS_API
1421 GstH264ParserResult gst_h264_parse_subset_sps         (GstH264NalUnit *nalu,
1422                                                        GstH264SPS *sps);
1423
1424 GST_CODEC_PARSERS_API
1425 GstH264ParserResult gst_h264_parse_sps                (GstH264NalUnit *nalu,
1426                                                        GstH264SPS *sps);
1427
1428 GST_CODEC_PARSERS_API
1429 GstH264ParserResult gst_h264_parse_pps                (GstH264NalParser *nalparser,
1430                                                        GstH264NalUnit *nalu, GstH264PPS *pps);
1431
1432 GST_CODEC_PARSERS_API
1433 void                gst_h264_sps_clear                (GstH264SPS *sps);
1434
1435 GST_CODEC_PARSERS_API
1436 void                gst_h264_pps_clear                (GstH264PPS *pps);
1437
1438 GST_CODEC_PARSERS_API
1439 void                gst_h264_sei_clear                (GstH264SEIMessage *sei);
1440
1441 GST_CODEC_PARSERS_API
1442 void    gst_h264_quant_matrix_8x8_get_zigzag_from_raster (guint8 out_quant[64],
1443                                                           const guint8 quant[64]);
1444
1445 GST_CODEC_PARSERS_API
1446 void    gst_h264_quant_matrix_8x8_get_raster_from_zigzag (guint8 out_quant[64],
1447                                                           const guint8 quant[64]);
1448
1449 GST_CODEC_PARSERS_API
1450 void    gst_h264_quant_matrix_4x4_get_zigzag_from_raster (guint8 out_quant[16],
1451                                                           const guint8 quant[16]);
1452
1453 GST_CODEC_PARSERS_API
1454 void    gst_h264_quant_matrix_4x4_get_raster_from_zigzag (guint8 out_quant[16],
1455                                                           const guint8 quant[16]);
1456
1457 GST_CODEC_PARSERS_API
1458 void gst_h264_video_calculate_framerate (const GstH264SPS * sps, guint field_pic_flag,
1459     guint pic_struct, gint * fps_num, gint * fps_den);
1460
1461 GST_CODEC_PARSERS_API
1462 GstMemory * gst_h264_create_sei_memory (guint8 start_code_prefix_length,
1463                                         GArray * messages);
1464
1465 GST_CODEC_PARSERS_API
1466 GstMemory * gst_h264_create_sei_memory_avc (guint8 nal_length_size,
1467                                             GArray * messages);
1468
1469 GST_CODEC_PARSERS_API
1470 GstBuffer * gst_h264_parser_insert_sei (GstH264NalParser * nalparser,
1471                                         GstBuffer * au,
1472                                         GstMemory * sei);
1473
1474 GST_CODEC_PARSERS_API
1475 GstBuffer * gst_h264_parser_insert_sei_avc (GstH264NalParser * nalparser,
1476                                             guint8 nal_length_size,
1477                                             GstBuffer * au,
1478                                             GstMemory * sei);
1479
1480 GST_CODEC_PARSERS_API
1481 void        gst_h264_decoder_config_record_free (GstH264DecoderConfigRecord * config);
1482
1483 GST_CODEC_PARSERS_API
1484 GstH264ParserResult gst_h264_parser_parse_decoder_config_record (GstH264NalParser * nalparser,
1485                                                                  const guint8 * data,
1486                                                                  gsize size,
1487                                                                  GstH264DecoderConfigRecord ** config);
1488
1489 G_END_DECLS
1490
1491 #endif