• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: Top-Bottom packing
222  * @GST_H264_FRAME_PACKING_TEMPORAL_INTERLEAVING: Temporal interleaving
223  *
224  * Frame packing arrangement types.
225  *
226  * Since: 1.6
227  */
228 typedef enum
229 {
230   GST_H264_FRAME_PACKING_NONE                           = 6,
231   GST_H264_FRAME_PACKING_CHECKERBOARD_INTERLEAVING      = 0,
232   GST_H264_FRAME_PACKING_COLUMN_INTERLEAVING            = 1,
233   GST_H264_FRAME_PACKING_ROW_INTERLEAVING               = 2,
234   GST_H264_FRAME_PACKING_SIDE_BY_SIDE                   = 3,
235   GST_H264_FRMAE_PACKING_TOP_BOTTOM                     = 4,
236   GST_H264_FRAME_PACKING_TEMPORAL_INTERLEAVING          = 5
237 } GstH264FramePackingType;
238 
239 /**
240  * GstH264SEIPayloadType:
241  * @GST_H264_SEI_BUF_PERIOD: Buffering Period SEI Message
242  * @GST_H264_SEI_PIC_TIMING: Picture Timing SEI Message
243  * @GST_H264_SEI_REGISTERED_USER_DATA: Registered user data (D.2.5)
244  * @GST_H264_SEI_RECOVERY_POINT: Recovery Point SEI Message (D.2.7)
245  * @GST_H264_SEI_STEREO_VIDEO_INFO: stereo video info SEI message (Since: 1.6)
246  * @GST_H264_SEI_FRAME_PACKING: Frame Packing Arrangement (FPA) message that
247  *     contains the 3D arrangement for stereoscopic 3D video (Since: 1.6)
248  * @GST_H264_SEI_MASTERING_DISPLAY_COLOUR_VOLUME: Mastering display colour volume information SEI message (D.2.29) (Since: 1.18)
249  * @GST_H264_SEI_CONTENT_LIGHT_LEVEL: Content light level information SEI message (D.2.31) (Since: 1.18)
250  * @GST_H264_SEI_UNHANDLED_PAYLOAD: Unhandled SEI message. This may or may not
251  *     be defined by spec (Since 1.18)
252  * ...
253  *
254  * The type of SEI message.
255  */
256 typedef enum
257 {
258   GST_H264_SEI_BUF_PERIOD = 0,
259   GST_H264_SEI_PIC_TIMING = 1,
260   GST_H264_SEI_REGISTERED_USER_DATA = 4,
261   GST_H264_SEI_RECOVERY_POINT = 6,
262   GST_H264_SEI_STEREO_VIDEO_INFO = 21,
263   GST_H264_SEI_FRAME_PACKING = 45,
264   GST_H264_SEI_MASTERING_DISPLAY_COLOUR_VOLUME = 137,
265   GST_H264_SEI_CONTENT_LIGHT_LEVEL = 144,
266       /* and more...  */
267 
268   /* Unhandled SEI type */
269   GST_H264_SEI_UNHANDLED_PAYLOAD = -1
270 } GstH264SEIPayloadType;
271 
272 /**
273  * GstH264SEIPicStructType:
274  * @GST_H264_SEI_PIC_STRUCT_FRAME: Picture is a frame
275  * @GST_H264_SEI_PIC_STRUCT_TOP_FIELD: Top field of frame
276  * @GST_H264_SEI_PIC_STRUCT_BOTTOM_FIELD: Bottom field of frame
277  * @GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM: Top bottom field of frame
278  * @GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP: bottom top field of frame
279  * @GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP: top bottom top field of frame
280  * @GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: bottom top bottom field of frame
281  * @GST_H264_SEI_PIC_STRUCT_FRAME_DOUBLING: indicates that the frame should
282  *  be displayed two times consecutively
283  * @GST_H264_SEI_PIC_STRUCT_FRAME_TRIPLING: indicates that the frame should be
284  *  displayed three times consecutively
285  *
286  * SEI pic_struct type
287  */
288 typedef enum
289 {
290   GST_H264_SEI_PIC_STRUCT_FRAME             = 0,
291   GST_H264_SEI_PIC_STRUCT_TOP_FIELD         = 1,
292   GST_H264_SEI_PIC_STRUCT_BOTTOM_FIELD      = 2,
293   GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM        = 3,
294   GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP        = 4,
295   GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP    = 5,
296   GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6,
297   GST_H264_SEI_PIC_STRUCT_FRAME_DOUBLING    = 7,
298   GST_H264_SEI_PIC_STRUCT_FRAME_TRIPLING    = 8
299 } GstH264SEIPicStructType;
300 
301 /**
302  * GstH264SliceType:
303  *
304  * Type of Picture slice
305  */
306 
307 typedef enum
308 {
309   GST_H264_P_SLICE    = 0,
310   GST_H264_B_SLICE    = 1,
311   GST_H264_I_SLICE    = 2,
312   GST_H264_SP_SLICE   = 3,
313   GST_H264_SI_SLICE   = 4,
314   GST_H264_S_P_SLICE  = 5,
315   GST_H264_S_B_SLICE  = 6,
316   GST_H264_S_I_SLICE  = 7,
317   GST_H264_S_SP_SLICE = 8,
318   GST_H264_S_SI_SLICE = 9
319 } GstH264SliceType;
320 
321 /**
322  * GstH264CtType
323  *
324  * Mapping of ct_type to source picture scan
325  *
326  * Since: 1.16
327  */
328 
329 typedef enum
330 {
331   GST_H264_CT_TYPE_PROGRESSIVE = 0,
332   GST_H264_CT_TYPE_INTERLACED = 1,
333   GST_H264_CT_TYPE_UNKNOWN = 2,
334 } GstCtType;
335 
336 typedef struct _GstH264NalParser              GstH264NalParser;
337 
338 typedef struct _GstH264NalUnit                GstH264NalUnit;
339 typedef struct _GstH264NalUnitExtensionMVC    GstH264NalUnitExtensionMVC;
340 
341 typedef struct _GstH264SPSExtMVCView          GstH264SPSExtMVCView;
342 typedef struct _GstH264SPSExtMVCLevelValue    GstH264SPSExtMVCLevelValue;
343 typedef struct _GstH264SPSExtMVCLevelValueOp  GstH264SPSExtMVCLevelValueOp;
344 typedef struct _GstH264SPSExtMVC              GstH264SPSExtMVC;
345 
346 typedef struct _GstH264SPS                    GstH264SPS;
347 typedef struct _GstH264PPS                    GstH264PPS;
348 typedef struct _GstH264HRDParams              GstH264HRDParams;
349 typedef struct _GstH264VUIParams              GstH264VUIParams;
350 
351 typedef struct _GstH264RefPicListModification GstH264RefPicListModification;
352 typedef struct _GstH264DecRefPicMarking       GstH264DecRefPicMarking;
353 typedef struct _GstH264RefPicMarking          GstH264RefPicMarking;
354 typedef struct _GstH264PredWeightTable        GstH264PredWeightTable;
355 typedef struct _GstH264SliceHdr               GstH264SliceHdr;
356 
357 typedef struct _GstH264ClockTimestamp         GstH264ClockTimestamp;
358 typedef struct _GstH264PicTiming              GstH264PicTiming;
359 typedef struct _GstH264RegisteredUserData     GstH264RegisteredUserData;
360 typedef struct _GstH264BufferingPeriod        GstH264BufferingPeriod;
361 typedef struct _GstH264RecoveryPoint          GstH264RecoveryPoint;
362 typedef struct _GstH264StereoVideoInfo        GstH264StereoVideoInfo;
363 typedef struct _GstH264FramePacking           GstH264FramePacking;
364 typedef struct _GstH264MasteringDisplayColourVolume GstH264MasteringDisplayColourVolume;
365 typedef struct _GstH264ContentLightLevel        GstH264ContentLightLevel;
366 typedef struct _GstH264SEIUnhandledPayload    GstH264SEIUnhandledPayload;
367 typedef struct _GstH264SEIMessage             GstH264SEIMessage;
368 
369 /**
370  * GstH264NalUnitExtensionMVC:
371  * @non_idr_flag: If equal to 0, it specifies that the current access
372  *   unit is an IDR access unit
373  * @priority_id: The priority identifier for the NAL unit
374  * @view_id: The view identifier for the NAL unit
375  * @temporal_id: The temporal identifier for the NAL unit
376  * @anchor_pic_flag: If equal to 1, it specifies that the current
377  *   access unit is an anchor access unit
378  * @inter_view_flag: If equal to 0, it specifies that the current view
379  *   component is not used for inter-view prediction by any other view
380  *   component in the current access unit
381  *
382  * Since: 1.6
383  */
384 struct _GstH264NalUnitExtensionMVC
385 {
386   guint8 non_idr_flag;
387   guint8 priority_id;
388   guint16 view_id;
389   guint8 temporal_id;
390   guint8 anchor_pic_flag;
391   guint8 inter_view_flag;
392 };
393 
394 /**
395  * GstH264NalUnit:
396  * @ref_idc: not equal to 0 specifies that the content of the NAL unit
397  *  contains a sequence parameter set, a sequence parameter set
398  *  extension, a subset sequence parameter set, a picture parameter
399  *  set, a slice of a reference picture, a slice data partition of a
400  *  reference picture, or a prefix NAL unit preceding a slice of a
401  *  reference picture.
402  * @type: A #GstH264NalUnitType
403  * @idr_pic_flag: calculated idr_pic_flag
404  * @size: The size of the NAL unit starting from @offset, thus
405  *  including the header bytes. e.g. @type (nal_unit_type),
406  *  but not the start code.
407  * @offset: The offset of the first byte of the NAL unit header,
408  *  just after the start code.
409  * @sc_offset: The offset of the first byte of the start code of
410  *  the NAL unit.
411  * @valid: If the NAL unit is valid, which means it has
412  *  already been parsed
413  * @data: The data array from which the NAL unit has been parsed,
414  *  into which the offset and sc_offset apply.
415  * @header_bytes: The size of the NALU header in bytes. The NALU
416  *  header is the 1-byte type code, and for extension / prefix NALs
417  *  includes the extension header bytes. @offset + @header_bytes is
418  *  therefore the first byte of the actual packet payload.
419  *  (Since: 1.6)
420  * @extension_type: the extension type for prefix NAL/MVC/SVC
421  *  (Since: 1.6)
422  *
423  * Structure defining the NAL unit headers
424  */
425 struct _GstH264NalUnit
426 {
427   guint16 ref_idc;
428   guint16 type;
429 
430   /* calculated values */
431   guint8 idr_pic_flag;
432   guint size;
433   guint offset;
434   guint sc_offset;
435   gboolean valid;
436 
437   guint8 *data;
438 
439   guint8 header_bytes;
440   guint8 extension_type;
441   union {
442     GstH264NalUnitExtensionMVC mvc;
443   } extension;
444 };
445 
446 /**
447  * GstH264HRDParams:
448  * @cpb_cnt_minus1: plus 1 specifies the number of alternative
449  *    CPB specifications in the bitstream
450  * @bit_rate_scale: specifies the maximum input bit rate of the
451  * SchedSelIdx-th CPB
452  * @cpb_size_scale: specifies the CPB size of the SchedSelIdx-th CPB
453  * @guint32 bit_rate_value_minus1: specifies the maximum input bit rate for the
454  * SchedSelIdx-th CPB
455  * @cpb_size_value_minus1: is used together with cpb_size_scale to specify the
456  * SchedSelIdx-th CPB size
457  * @cbr_flag: Specifies if running in constant or intermittent bit rate mode
458  * @initial_cpb_removal_delay_length_minus1: specifies the length in bits of
459  * the cpb_removal_delay syntax element
460  * @cpb_removal_delay_length_minus1: specifies the length in bits of the
461  * dpb_output_delay syntax element
462  * @dpb_output_delay_length_minus1: >0 specifies the length in bits of the time_offset syntax element.
463  * =0 specifies that the time_offset syntax element is not present
464  * @time_offset_length: Length of the time offset
465  *
466  * Defines the HRD parameters
467  */
468 struct _GstH264HRDParams
469 {
470   guint8 cpb_cnt_minus1;
471   guint8 bit_rate_scale;
472   guint8 cpb_size_scale;
473 
474   guint32 bit_rate_value_minus1[32];
475   guint32 cpb_size_value_minus1[32];
476   guint8 cbr_flag[32];
477 
478   guint8 initial_cpb_removal_delay_length_minus1;
479   guint8 cpb_removal_delay_length_minus1;
480   guint8 dpb_output_delay_length_minus1;
481   guint8 time_offset_length;
482 };
483 
484 /**
485  * GstH264VUIParams:
486  * @aspect_ratio_info_present_flag: %TRUE specifies that aspect_ratio_idc is present.
487  *  %FALSE specifies that aspect_ratio_idc is not present
488  * @aspect_ratio_idc specifies the value of the sample aspect ratio of the luma samples
489  * @sar_width indicates the horizontal size of the sample aspect ratio
490  * @sar_height indicates the vertical size of the sample aspect ratio
491  * @overscan_info_present_flag: %TRUE overscan_appropriate_flag is present %FALSE otherwise
492  * @overscan_appropriate_flag: %TRUE indicates that the cropped decoded pictures
493  *  output are suitable for display using overscan. %FALSE the cropped decoded pictures
494  *  output contain visually important information
495  * @video_signal_type_present_flag: %TRUE specifies that video_format, video_full_range_flag and
496  *  colour_description_present_flag are present.
497  * @video_format: indicates the representation of the picture
498  * @video_full_range_flag: indicates the black level and range of the luma and chroma signals
499  * @colour_description_present_flag: %TRUE specifies that colour_primaries,
500  *  transfer_characteristics and matrix_coefficients are present
501  * @colour_primaries: indicates the chromaticity coordinates of the source primaries
502  * @transfer_characteristics: indicates the opto-electronic transfer characteristic
503  * @matrix_coefficients: describes the matrix coefficients used in deriving luma and chroma signals
504  * @chroma_loc_info_present_flag: %TRUE specifies that chroma_sample_loc_type_top_field and
505  *  chroma_sample_loc_type_bottom_field are present, %FALSE otherwise
506  * @chroma_sample_loc_type_top_field: specify the location of chroma for top field
507  * @chroma_sample_loc_type_bottom_field specify the location of chroma for bottom field
508  * @timing_info_present_flag: %TRUE specifies that num_units_in_tick,
509  *  time_scale and fixed_frame_rate_flag are present in the bitstream
510  * @num_units_in_tick: is the number of time units of a clock operating at the frequency time_scale Hz
511  * time_scale: is the number of time units that pass in one second
512  * @fixed_frame_rate_flag: %TRUE indicates that the temporal distance between the HRD output times
513  *  of any two consecutive pictures in output order is constrained as specified in the spec, %FALSE
514  *  otherwise.
515  * @nal_hrd_parameters_present_flag: %TRUE if NAL HRD parameters exist in the bitstream
516  * @vcl_hrd_parameters_present_flag: %TRUE if VCL HRD parameters exist in the bitstream
517  * @low_delay_hrd_flag: specifies the HRD operational mode
518  * @pic_struct_present_flag: %TRUE specifies that picture timing SEI messages are present or not
519  * @bitstream_restriction_flag: %TRUE specifies that the following coded video sequence bitstream restriction
520  * parameters are present
521  * @motion_vectors_over_pic_boundaries_flag: %FALSE indicates that no sample outside the
522  *  picture boundaries and no sample at a fractional sample position, %TRUE indicates that one or more
523  *  samples outside picture boundaries may be used in inter prediction
524  * @max_bytes_per_pic_denom: indicates a number of bytes not exceeded by the sum of the sizes of
525  *  the VCL NAL units associated with any coded picture in the coded video sequence.
526  * @max_bits_per_mb_denom: indicates the maximum number of coded bits of macroblock_layer
527  * @log2_max_mv_length_horizontal: indicate the maximum absolute value of a decoded horizontal
528  * motion vector component
529  * @log2_max_mv_length_vertical: indicate the maximum absolute value of a decoded vertical
530  *  motion vector component
531  * @num_reorder_frames: indicates the maximum number of frames, complementary field pairs,
532  *  or non-paired fields that precede any frame,
533  * @max_dec_frame_buffering: specifies the required size of the HRD decoded picture buffer in
534  *  units of frame buffers.
535  *
536  * The structure representing the VUI parameters.
537  */
538 struct _GstH264VUIParams
539 {
540   guint8 aspect_ratio_info_present_flag;
541   guint8 aspect_ratio_idc;
542   /* if aspect_ratio_idc == 255 */
543   guint16 sar_width;
544   guint16 sar_height;
545 
546   guint8 overscan_info_present_flag;
547   /* if overscan_info_present_flag */
548   guint8 overscan_appropriate_flag;
549 
550   guint8 video_signal_type_present_flag;
551   guint8 video_format;
552   guint8 video_full_range_flag;
553   guint8 colour_description_present_flag;
554   guint8 colour_primaries;
555   guint8 transfer_characteristics;
556   guint8 matrix_coefficients;
557 
558   guint8 chroma_loc_info_present_flag;
559   guint8 chroma_sample_loc_type_top_field;
560   guint8 chroma_sample_loc_type_bottom_field;
561 
562   guint8 timing_info_present_flag;
563   /* if timing_info_present_flag */
564   guint32 num_units_in_tick;
565   guint32 time_scale;
566   guint8 fixed_frame_rate_flag;
567 
568   guint8 nal_hrd_parameters_present_flag;
569   /* if nal_hrd_parameters_present_flag */
570   GstH264HRDParams nal_hrd_parameters;
571 
572   guint8 vcl_hrd_parameters_present_flag;
573   /* if vcl_hrd_parameters_present_flag */
574   GstH264HRDParams vcl_hrd_parameters;
575 
576   guint8 low_delay_hrd_flag;
577   guint8 pic_struct_present_flag;
578 
579   guint8 bitstream_restriction_flag;
580   /*  if bitstream_restriction_flag */
581   guint8 motion_vectors_over_pic_boundaries_flag;
582   guint32 max_bytes_per_pic_denom;
583   guint32 max_bits_per_mb_denom;
584   guint32 log2_max_mv_length_horizontal;
585   guint32 log2_max_mv_length_vertical;
586   guint32 num_reorder_frames;
587   guint32 max_dec_frame_buffering;
588 
589   /* calculated values */
590   guint par_n;
591   guint par_d;
592 };
593 
594 /**
595  * GstH264SPSExtMVCView:
596  * @num_anchor_refs_l0: specifies the number of view components for
597  *   inter-view prediction in the initialized RefPicList0 in decoding
598  *   anchor view components.
599  * @anchor_ref_l0: specifies the view_id for inter-view prediction in
600  *   the initialized RefPicList0 in decoding anchor view components.
601  * @num_anchor_refs_l1: specifies the number of view components for
602  *   inter-view prediction in the initialized RefPicList1 in decoding
603  *   anchor view components.
604  * @anchor_ref_l1: specifies the view_id for inter-view prediction in
605  *   the initialized RefPicList1 in decoding anchor view components.
606  * @num_non_anchor_refs_l0: specifies the number of view components
607  *   for inter-view prediction in the initialized RefPicList0 in
608  *   decoding non-anchor view components.
609  * @non_anchor_ref_l0: specifies the view_id for inter-view prediction
610  *   in the initialized RefPicList0 in decoding non-anchor view
611  *   components.
612  * @num_non_anchor_refs_l1: specifies the number of view components
613  *   for inter-view prediction in the initialized RefPicList1 in
614  *   decoding non-anchor view components.
615  * @non_anchor_ref_l1: specifies the view_id for inter-view prediction
616  *   in the initialized RefPicList1 in decoding non-anchor view
617  *   components.
618  *
619  * Represents inter-view dependency relationships for the coded video
620  * sequence.
621  *
622  * Since: 1.6
623  */
624 struct _GstH264SPSExtMVCView
625 {
626   guint16 view_id;
627   guint8 num_anchor_refs_l0;
628   guint16 anchor_ref_l0[15];
629   guint8 num_anchor_refs_l1;
630   guint16 anchor_ref_l1[15];
631   guint8 num_non_anchor_refs_l0;
632   guint16 non_anchor_ref_l0[15];
633   guint8 num_non_anchor_refs_l1;
634   guint16 non_anchor_ref_l1[15];
635 };
636 
637 /**
638  * GstH264SPSExtMVCLevelValueOp:
639  *
640  * Represents an operation point for the coded video sequence.
641  *
642  * Since: 1.6
643  */
644 struct _GstH264SPSExtMVCLevelValueOp
645 {
646   guint8 temporal_id;
647   guint16 num_target_views_minus1;
648   guint16 *target_view_id;
649   guint16 num_views_minus1;
650 };
651 
652 /**
653  * GstH264SPSExtMVCLevelValue:
654  * @level_idc: specifies the level value signalled for the coded video
655  *   sequence
656  * @num_applicable_ops_minus1: plus 1 specifies the number of
657  *   operation points to which the level indicated by level_idc applies
658  * @applicable_op: specifies the applicable operation point
659  *
660  * Represents level values for a subset of the operation points for
661  * the coded video sequence.
662  *
663  * Since: 1.6
664  */
665 struct _GstH264SPSExtMVCLevelValue
666 {
667   guint8 level_idc;
668   guint16 num_applicable_ops_minus1;
669   GstH264SPSExtMVCLevelValueOp *applicable_op;
670 };
671 
672 /**
673  * GstH264SPSExtMVC:
674  * @num_views_minus1: plus 1 specifies the maximum number of coded
675  *   views in the coded video sequence
676  * @view: array of #GstH264SPSExtMVCView
677  * @num_level_values_signalled_minus1: plus 1 specifies the number of
678  *   level values signalled for the coded video sequence.
679  * @level_value: array of #GstH264SPSExtMVCLevelValue
680  *
681  * Represents the parsed `seq_parameter_set_mvc_extension()`.
682  *
683  * Since: 1.6
684 	 */
685 struct _GstH264SPSExtMVC
686 {
687   guint16 num_views_minus1;
688   GstH264SPSExtMVCView *view;
689   guint8 num_level_values_signalled_minus1;
690   GstH264SPSExtMVCLevelValue *level_value;
691 };
692 
693 /**
694  * GstH264SPS:
695  * @id: The ID of the sequence parameter set
696  * @profile_idc: indicate the profile to which the coded video sequence conforms
697  *
698  * H264 Sequence Parameter Set (SPS)
699  */
700 struct _GstH264SPS
701 {
702   gint id;
703 
704   guint8 profile_idc;
705   guint8 constraint_set0_flag;
706   guint8 constraint_set1_flag;
707   guint8 constraint_set2_flag;
708   guint8 constraint_set3_flag;
709   guint8 constraint_set4_flag;
710   guint8 constraint_set5_flag;
711   guint8 level_idc;
712 
713   guint8 chroma_format_idc;
714   guint8 separate_colour_plane_flag;
715   guint8 bit_depth_luma_minus8;
716   guint8 bit_depth_chroma_minus8;
717   guint8 qpprime_y_zero_transform_bypass_flag;
718 
719   guint8 scaling_matrix_present_flag;
720   guint8 scaling_lists_4x4[6][16];
721   guint8 scaling_lists_8x8[6][64];
722 
723   guint8 log2_max_frame_num_minus4;
724   guint8 pic_order_cnt_type;
725 
726   /* if pic_order_cnt_type == 0 */
727   guint8 log2_max_pic_order_cnt_lsb_minus4;
728 
729   /* else if pic_order_cnt_type == 1 */
730   guint8 delta_pic_order_always_zero_flag;
731   gint32 offset_for_non_ref_pic;
732   gint32 offset_for_top_to_bottom_field;
733   guint8 num_ref_frames_in_pic_order_cnt_cycle;
734   gint32 offset_for_ref_frame[255];
735 
736   /* FIXME rename according to spec, max_num_ref_frames */
737   guint32 num_ref_frames;
738   guint8 gaps_in_frame_num_value_allowed_flag;
739   guint32 pic_width_in_mbs_minus1;
740   guint32 pic_height_in_map_units_minus1;
741   guint8 frame_mbs_only_flag;
742 
743   guint8 mb_adaptive_frame_field_flag;
744 
745   guint8 direct_8x8_inference_flag;
746 
747   guint8 frame_cropping_flag;
748 
749   /* if frame_cropping_flag */
750   guint32 frame_crop_left_offset;
751   guint32 frame_crop_right_offset;
752   guint32 frame_crop_top_offset;
753   guint32 frame_crop_bottom_offset;
754 
755   guint8 vui_parameters_present_flag;
756   /* if vui_parameters_present_flag */
757   GstH264VUIParams vui_parameters;
758 
759   /* calculated values */
760   guint8 chroma_array_type;
761   guint32 max_frame_num;
762   gint width, height;
763   gint crop_rect_width, crop_rect_height;
764   gint crop_rect_x, crop_rect_y;
765   gint fps_num_removed, fps_den_removed; /* FIXME: remove */
766   gboolean valid;
767 
768   /* Subset SPS extensions */
769   guint8 extension_type;
770   union {
771     GstH264SPSExtMVC mvc;
772   } extension;
773 };
774 
775 /**
776  * GstH264PPS:
777  *
778  * H264 Picture Parameter Set
779  */
780 struct _GstH264PPS
781 {
782   gint id;
783 
784   GstH264SPS *sequence;
785 
786   guint8 entropy_coding_mode_flag;
787   guint8 pic_order_present_flag;
788 
789   guint32 num_slice_groups_minus1;
790 
791   /* if num_slice_groups_minus1 > 0 */
792   guint8 slice_group_map_type;
793   /* and if slice_group_map_type == 0 */
794   guint32 run_length_minus1[8];
795   /* or if slice_group_map_type == 2 */
796   guint32 top_left[8];
797   guint32 bottom_right[8];
798   /* or if slice_group_map_type == (3, 4, 5) */
799   guint8 slice_group_change_direction_flag;
800   guint32 slice_group_change_rate_minus1;
801   /* or if slice_group_map_type == 6 */
802   guint32 pic_size_in_map_units_minus1;
803   guint8 *slice_group_id;
804 
805   /* FIXME rename to num_ref_idx_l{0,1}_default_active_minus1 */
806   guint8 num_ref_idx_l0_active_minus1;
807   guint8 num_ref_idx_l1_active_minus1;
808   guint8 weighted_pred_flag;
809   guint8 weighted_bipred_idc;
810   gint8 pic_init_qp_minus26;
811   gint8 pic_init_qs_minus26;
812   gint8 chroma_qp_index_offset;
813   guint8 deblocking_filter_control_present_flag;
814   guint8 constrained_intra_pred_flag;
815   guint8 redundant_pic_cnt_present_flag;
816 
817   guint8 transform_8x8_mode_flag;
818 
819   guint8 scaling_lists_4x4[6][16];
820   guint8 scaling_lists_8x8[6][64];
821 
822   guint8 second_chroma_qp_index_offset;
823 
824   gboolean valid;
825 
826   /* Since: 1.18 */
827   guint8 pic_scaling_matrix_present_flag;
828 };
829 
830 struct _GstH264RefPicListModification
831 {
832   guint8 modification_of_pic_nums_idc;
833   union
834   {
835     /* if modification_of_pic_nums_idc == 0 || 1 */
836     guint32 abs_diff_pic_num_minus1;
837     /* if modification_of_pic_nums_idc == 2 */
838     guint32 long_term_pic_num;
839     /* if modification_of_pic_nums_idc == 4 || 5 */
840     guint32 abs_diff_view_idx_minus1;
841   } value;
842 };
843 
844 struct _GstH264PredWeightTable
845 {
846   guint8 luma_log2_weight_denom;
847   guint8 chroma_log2_weight_denom;
848 
849   gint16 luma_weight_l0[32];
850   gint8 luma_offset_l0[32];
851 
852   /* if seq->ChromaArrayType != 0 */
853   gint16 chroma_weight_l0[32][2];
854   gint8 chroma_offset_l0[32][2];
855 
856   /* if slice->slice_type % 5 == 1 */
857   gint16 luma_weight_l1[32];
858   gint8 luma_offset_l1[32];
859 
860   /* and if seq->ChromaArrayType != 0 */
861   gint16 chroma_weight_l1[32][2];
862   gint8 chroma_offset_l1[32][2];
863 };
864 
865 struct _GstH264RefPicMarking
866 {
867   guint8 memory_management_control_operation;
868 
869   guint32 difference_of_pic_nums_minus1;
870   guint32 long_term_pic_num;
871   guint32 long_term_frame_idx;
872   guint32 max_long_term_frame_idx_plus1;
873 };
874 
875 struct _GstH264DecRefPicMarking
876 {
877   /* if slice->nal_unit.IdrPicFlag */
878   guint8 no_output_of_prior_pics_flag;
879   guint8 long_term_reference_flag;
880 
881   guint8 adaptive_ref_pic_marking_mode_flag;
882   GstH264RefPicMarking ref_pic_marking[10];
883   guint8 n_ref_pic_marking;
884 
885   /* Size of the dec_ref_pic_marking() syntax element in bits (Since: 1.18) */
886   guint bit_size;
887 };
888 
889 
890 struct _GstH264SliceHdr
891 {
892   guint32 first_mb_in_slice;
893   guint32 type;
894   GstH264PPS *pps;
895 
896   /* if seq->separate_colour_plane_flag */
897   guint8 colour_plane_id;
898 
899   guint16 frame_num;
900 
901   guint8 field_pic_flag;
902   guint8 bottom_field_flag;
903 
904   /* if nal_unit.type == 5 */
905   guint16 idr_pic_id;
906 
907   /* if seq->pic_order_cnt_type == 0 */
908   guint16 pic_order_cnt_lsb;
909   /* if seq->pic_order_present_flag && !field_pic_flag */
910   gint32 delta_pic_order_cnt_bottom;
911 
912   gint32 delta_pic_order_cnt[2];
913   guint8 redundant_pic_cnt;
914 
915   /* if slice_type == B_SLICE */
916   guint8 direct_spatial_mv_pred_flag;
917 
918   guint8 num_ref_idx_l0_active_minus1;
919   guint8 num_ref_idx_l1_active_minus1;
920 
921   guint8 ref_pic_list_modification_flag_l0;
922   guint8 n_ref_pic_list_modification_l0;
923   GstH264RefPicListModification ref_pic_list_modification_l0[32];
924   guint8 ref_pic_list_modification_flag_l1;
925   guint8 n_ref_pic_list_modification_l1;
926   GstH264RefPicListModification ref_pic_list_modification_l1[32];
927 
928   GstH264PredWeightTable pred_weight_table;
929   /* if nal_unit.ref_idc != 0 */
930   GstH264DecRefPicMarking dec_ref_pic_marking;
931 
932   guint8 cabac_init_idc;
933   gint8 slice_qp_delta;
934   gint8 slice_qs_delta;
935 
936   guint8 disable_deblocking_filter_idc;
937   gint8 slice_alpha_c0_offset_div2;
938   gint8 slice_beta_offset_div2;
939 
940   guint16 slice_group_change_cycle;
941 
942   /* calculated values */
943   guint32 max_pic_num;
944   gboolean valid;
945 
946   /* Size of the slice_header() in bits */
947   guint header_size;
948 
949   /* Number of emulation prevention bytes (EPB) in this slice_header() */
950   guint n_emulation_prevention_bytes;
951 
952   /* Since: 1.18 */
953   guint8 num_ref_idx_active_override_flag;
954   guint8 sp_for_switch_flag;
955 
956   /*
957    * Size of the pic_order_cnt related syntax elements pic_order_cnt_lsb,
958    * delta_pic_order_cnt_bottom, delta_pic_order_cnt[0], and
959    * delta_pic_order_cnt[1]. (Since: 1.18)
960    */
961   guint pic_order_cnt_bit_size;
962 };
963 
964 /**
965  * GstH264ClockTimestamp:
966  * @ct_type: indicates the scan type, 0: progressive, 1: interlaced, 2: unknown,
967  *   3: reserved
968  * @nuit_field_based_flag: used in calculating clockTimestamp
969  * @counting_type: specifies the method of dropping values of the n_frames
970  * @full_timestamp_flag: equal to 1 specifies that the n_frames syntax element
971  *   is followed by seconds_value, minutes_value, and hours_value (Since 1.18)
972  * @discontinuity_flag: indicates whether the difference between the current
973  *   value of clockTimestamp and the value of clockTimestamp computed from the
974  *   previous clock timestamp can be interpreted as the time difference or not.
975  * @cnt_dropped_flag: specifies the skipping of one or more values of n_frames
976  *   using the counting method specified by counting_type
977  * @n_frames: specifies the value of nFrames used to compute clockTimestamp
978  * @seconds_flag: equal to 1 specifies that @seconds_value and minutes_flag are
979  *   present when @full_timestamp_flag is equal to 0
980  * @seconds_value: specifies the value of seconds to compute clockTimestamp
981  * @minutes_flag: equal to 1 specifies that @minutes_value and hours_flag are
982  *   present when @full_timestamp_flag is equal to 0 and @seconds_flag is
983  *   equal to 1
984  * @minutes_value: specifies the value of minutes to compute clockTimestamp
985  * @hours_flag: equal to 1 specifies that @hours_value is present when
986  *   @full_timestamp_flag is equal to 0 and @seconds_flag is equal to 1 and
987  *   @minutes_flag is equal to 1
988  * @time_offset: specifies the value of tOffset used to compute clockTimestamp
989  */
990 struct _GstH264ClockTimestamp
991 {
992   guint8 ct_type;
993   guint8 nuit_field_based_flag;
994   guint8 counting_type;
995   guint8 full_timestamp_flag;
996   guint8 discontinuity_flag;
997   guint8 cnt_dropped_flag;
998   guint8 n_frames;
999 
1000   guint8 seconds_flag;
1001   guint8 seconds_value;
1002 
1003   guint8 minutes_flag;
1004   guint8 minutes_value;
1005 
1006   guint8 hours_flag;
1007   guint8 hours_value;
1008 
1009   guint32 time_offset;
1010 };
1011 
1012 /**
1013  * GstH264FramePacking:
1014  *
1015  * Since: 1.6
1016  */
1017 struct _GstH264FramePacking
1018 {
1019   guint32 frame_packing_id;
1020   guint8 frame_packing_cancel_flag;
1021   guint8 frame_packing_type; /* GstH264FramePackingType */
1022   guint8 quincunx_sampling_flag;
1023   guint8 content_interpretation_type;
1024   guint8 spatial_flipping_flag;
1025   guint8 frame0_flipped_flag;
1026   guint8 field_views_flag;
1027   guint8 current_frame_is_frame0_flag;
1028   guint8 frame0_self_contained_flag;
1029   guint8 frame1_self_contained_flag;
1030   guint8 frame0_grid_position_x;
1031   guint8 frame0_grid_position_y;
1032   guint8 frame1_grid_position_x;
1033   guint8 frame1_grid_position_y;
1034   guint16 frame_packing_repetition_period;
1035 };
1036 
1037 /**
1038  * GstH264StereoVideoInfo:
1039  *
1040  * Since: 1.6
1041  */
1042 struct _GstH264StereoVideoInfo
1043 {
1044   guint8 field_views_flag;
1045   guint8 top_field_is_left_view_flag;
1046   guint8 current_frame_is_left_view_flag;
1047   guint8 next_frame_is_second_view_flag;
1048   guint8 left_view_self_contained_flag;
1049   guint8 right_view_self_contained_flag;
1050 };
1051 
1052 /**
1053  * GstH264PicTiming:
1054  * @CpbDpbDelaysPresentFlag: non-zero if linked
1055  *   GstH264VUIParams::nal_hrd_parameters_present_flag or
1056  *   GstH264VUIParams::vcl_hrd_parameters_present_flag is non-zero (Since: 1.18)
1057  * @cpb_removal_delay_length_minus1: specifies the length of @cpb_removal_delay
1058  *   in bits (Since 1.18)
1059  * @dpb_output_delay_length_minus1: specifies the length of @dpb_output_delay
1060  *   in bits (Since 1.18)
1061  * @cpb_removal_delay: specifies how many clock ticks to wait after removal from
1062  *   the CPB of the access unit associated with the most recent buffering period
1063  *   SEI message in a preceding access unit before removing from the
1064  *   buffer the access unit data associated with the picture timing SEI message
1065  * @dpb_output_delay: used to compute the DPB output time of the picture
1066  * @pic_struct_present_flag: GstH264VUIParams::pic_struct_present_flag
1067  * @pic_struct: indicates whether a picture should be displayed as a frame or
1068  *   one or more fields
1069  * @clock_timestamp_flag: equal to 1 indicates that a number of clock timestamp
1070  *   syntax elements are present
1071  * @clock_timestamp: a #GstH264ClockTimestamp
1072  * @time_offset_length: specifies the length time_offset of
1073  *   #GstH264ClockTimestamp in bits (Since 1.18)
1074  */
1075 struct _GstH264PicTiming
1076 {
1077   /* from vui */
1078   guint8 CpbDpbDelaysPresentFlag;
1079   /* if CpbDpbDelaysPresentFlag */
1080   guint8 cpb_removal_delay_length_minus1;
1081   guint8 dpb_output_delay_length_minus1;
1082   guint32 cpb_removal_delay;
1083   guint32 dpb_output_delay;
1084 
1085   guint8 pic_struct_present_flag;
1086   /* if pic_struct_present_flag */
1087   guint8 pic_struct;
1088 
1089   guint8 clock_timestamp_flag[3];
1090   GstH264ClockTimestamp clock_timestamp[3];
1091   guint8 time_offset_length;
1092 };
1093 
1094 /**
1095  * GstH264RegisteredUserData:
1096  * The User data registered by Rec. ITU-T T.35 SEI messag.
1097  * @country_code: an itu_t_t35_country_code.
1098  * @country_code_extension: an itu_t_t35_country_code_extension_byte.
1099  *   Should be ignored when @country_code is not 0xff
1100  * @data: the data of itu_t_t35_payload_byte
1101  *   excluding @country_code and @country_code_extension
1102  * @size: the size of @data in bytes
1103  *
1104  * Since: 1.16
1105  */
1106 struct _GstH264RegisteredUserData
1107 {
1108   guint8 country_code;
1109   guint8 country_code_extension;
1110   const guint8 *data;
1111   guint size;
1112 };
1113 
1114 struct _GstH264BufferingPeriod
1115 {
1116   GstH264SPS *sps;
1117 
1118   /* seq->vui_parameters->nal_hrd_parameters_present_flag */
1119   guint32 nal_initial_cpb_removal_delay[32];
1120   guint32 nal_initial_cpb_removal_delay_offset[32];
1121 
1122   /* seq->vui_parameters->vcl_hrd_parameters_present_flag */
1123   guint32 vcl_initial_cpb_removal_delay[32];
1124   guint32 vcl_initial_cpb_removal_delay_offset[32];
1125 };
1126 
1127 struct _GstH264RecoveryPoint
1128 {
1129   guint32 recovery_frame_cnt;
1130   guint8 exact_match_flag;
1131   guint8 broken_link_flag;
1132   guint8 changing_slice_group_idc;
1133 };
1134 
1135 /**
1136  * GstH264MasteringDisplayColourVolume:
1137  * The colour volume (primaries, white point and luminance range) of display
1138  * defined by SMPTE ST 2086.
1139  *
1140  * D.2.29
1141  *
1142  * Since: 1.18
1143  */
1144 struct _GstH264MasteringDisplayColourVolume
1145 {
1146   guint16 display_primaries_x[3];
1147   guint16 display_primaries_y[3];
1148   guint16 white_point_x;
1149   guint16 white_point_y;
1150   guint32 max_display_mastering_luminance;
1151   guint32 min_display_mastering_luminance;
1152 };
1153 
1154 /**
1155  * GstH264ContentLightLevel:
1156  * The upper bounds for the nominal target brightness light level
1157  * as specified in CEA-861.3
1158  *
1159  * D.2.31
1160  *
1161  * Since: 1.18
1162  */
1163 struct _GstH264ContentLightLevel
1164 {
1165   guint16 max_content_light_level;
1166   guint16 max_pic_average_light_level;
1167 };
1168 
1169 /**
1170  * GstH264SEIUnhandledPayload:
1171  * @payloadType: Payload type
1172  * @data: payload raw data excluding payload type and payload size byte
1173  * @size: the size of @data
1174  *
1175  * Contains unhandled SEI payload data. This SEI may or may not
1176  * be defined by spec
1177  *
1178  * Since: 1.18
1179  */
1180 struct _GstH264SEIUnhandledPayload
1181 {
1182   guint payloadType;
1183 
1184   guint8 *data;
1185   guint size;
1186 };
1187 
1188 struct _GstH264SEIMessage
1189 {
1190   GstH264SEIPayloadType payloadType;
1191 
1192   union {
1193     GstH264BufferingPeriod buffering_period;
1194     GstH264PicTiming pic_timing;
1195     GstH264RegisteredUserData registered_user_data;
1196     GstH264RecoveryPoint recovery_point;
1197     GstH264StereoVideoInfo stereo_video_info;
1198     GstH264FramePacking frame_packing;
1199     GstH264MasteringDisplayColourVolume mastering_display_colour_volume;
1200     GstH264ContentLightLevel content_light_level;
1201     GstH264SEIUnhandledPayload unhandled_payload;
1202     /* ... could implement more */
1203   } payload;
1204 };
1205 
1206 /**
1207  * GstH264NalParser:
1208  *
1209  * H264 NAL Parser (opaque structure).
1210  */
1211 struct _GstH264NalParser
1212 {
1213   /*< private >*/
1214   GstH264SPS sps[GST_H264_MAX_SPS_COUNT];
1215   GstH264PPS pps[GST_H264_MAX_PPS_COUNT];
1216   GstH264SPS *last_sps;
1217   GstH264PPS *last_pps;
1218 };
1219 
1220 GST_CODEC_PARSERS_API
1221 GstH264NalParser *gst_h264_nal_parser_new             (void);
1222 
1223 GST_CODEC_PARSERS_API
1224 GstH264ParserResult gst_h264_parser_identify_nalu     (GstH264NalParser *nalparser,
1225                                                        const guint8 *data, guint offset,
1226                                                        gsize size, GstH264NalUnit *nalu);
1227 
1228 GST_CODEC_PARSERS_API
1229 GstH264ParserResult gst_h264_parser_identify_nalu_unchecked (GstH264NalParser *nalparser,
1230                                                        const guint8 *data, guint offset,
1231                                                        gsize size, GstH264NalUnit *nalu);
1232 
1233 GST_CODEC_PARSERS_API
1234 GstH264ParserResult gst_h264_parser_identify_nalu_avc (GstH264NalParser *nalparser, const guint8 *data,
1235                                                        guint offset, gsize size, guint8 nal_length_size,
1236                                                        GstH264NalUnit *nalu);
1237 
1238 GST_CODEC_PARSERS_API
1239 GstH264ParserResult gst_h264_parser_parse_nal         (GstH264NalParser *nalparser,
1240                                                        GstH264NalUnit *nalu);
1241 
1242 GST_CODEC_PARSERS_API
1243 GstH264ParserResult gst_h264_parser_parse_slice_hdr   (GstH264NalParser *nalparser, GstH264NalUnit *nalu,
1244                                                        GstH264SliceHdr *slice, gboolean parse_pred_weight_table,
1245                                                        gboolean parse_dec_ref_pic_marking);
1246 
1247 GST_CODEC_PARSERS_API
1248 GstH264ParserResult gst_h264_parser_parse_subset_sps  (GstH264NalParser *nalparser, GstH264NalUnit *nalu,
1249                                                        GstH264SPS *sps);
1250 
1251 GST_CODEC_PARSERS_API
1252 GstH264ParserResult gst_h264_parser_parse_sps         (GstH264NalParser *nalparser, GstH264NalUnit *nalu,
1253                                                        GstH264SPS *sps);
1254 
1255 GST_CODEC_PARSERS_API
1256 GstH264ParserResult gst_h264_parser_parse_pps         (GstH264NalParser *nalparser,
1257                                                        GstH264NalUnit *nalu, GstH264PPS *pps);
1258 
1259 GST_CODEC_PARSERS_API
1260 GstH264ParserResult gst_h264_parser_parse_sei         (GstH264NalParser *nalparser,
1261                                                        GstH264NalUnit *nalu, GArray ** messages);
1262 
1263 GST_CODEC_PARSERS_API
1264 GstH264ParserResult gst_h264_parser_update_sps        (GstH264NalParser *nalparser,
1265                                                        GstH264SPS *sps);
1266 
1267 GST_CODEC_PARSERS_API
1268 GstH264ParserResult gst_h264_parser_update_pps        (GstH264NalParser *nalparser,
1269                                                        GstH264PPS *pps);
1270 
1271 GST_CODEC_PARSERS_API
1272 void gst_h264_nal_parser_free                         (GstH264NalParser *nalparser);
1273 
1274 GST_CODEC_PARSERS_API
1275 GstH264ParserResult gst_h264_parse_subset_sps         (GstH264NalUnit *nalu,
1276                                                        GstH264SPS *sps);
1277 
1278 GST_CODEC_PARSERS_API
1279 GstH264ParserResult gst_h264_parse_sps                (GstH264NalUnit *nalu,
1280                                                        GstH264SPS *sps);
1281 
1282 GST_CODEC_PARSERS_API
1283 GstH264ParserResult gst_h264_parse_pps                (GstH264NalParser *nalparser,
1284                                                        GstH264NalUnit *nalu, GstH264PPS *pps);
1285 
1286 GST_CODEC_PARSERS_API
1287 void                gst_h264_sps_clear                (GstH264SPS *sps);
1288 
1289 GST_CODEC_PARSERS_API
1290 void                gst_h264_pps_clear                (GstH264PPS *pps);
1291 
1292 GST_CODEC_PARSERS_API
1293 void                gst_h264_sei_clear                (GstH264SEIMessage *sei);
1294 
1295 GST_CODEC_PARSERS_API
1296 void    gst_h264_quant_matrix_8x8_get_zigzag_from_raster (guint8 out_quant[64],
1297                                                           const guint8 quant[64]);
1298 
1299 GST_CODEC_PARSERS_API
1300 void    gst_h264_quant_matrix_8x8_get_raster_from_zigzag (guint8 out_quant[64],
1301                                                           const guint8 quant[64]);
1302 
1303 GST_CODEC_PARSERS_API
1304 void    gst_h264_quant_matrix_4x4_get_zigzag_from_raster (guint8 out_quant[16],
1305                                                           const guint8 quant[16]);
1306 
1307 GST_CODEC_PARSERS_API
1308 void    gst_h264_quant_matrix_4x4_get_raster_from_zigzag (guint8 out_quant[16],
1309                                                           const guint8 quant[16]);
1310 
1311 GST_CODEC_PARSERS_API
1312 void gst_h264_video_calculate_framerate (const GstH264SPS * sps, guint field_pic_flag,
1313     guint pic_struct, gint * fps_num, gint * fps_den);
1314 
1315 GST_CODEC_PARSERS_API
1316 GstMemory * gst_h264_create_sei_memory (guint8 start_code_prefix_length,
1317                                         GArray * messages);
1318 
1319 GST_CODEC_PARSERS_API
1320 GstMemory * gst_h264_create_sei_memory_avc (guint8 nal_length_size,
1321                                             GArray * messages);
1322 
1323 GST_CODEC_PARSERS_API
1324 GstBuffer * gst_h264_parser_insert_sei (GstH264NalParser * nalparser,
1325                                         GstBuffer * au,
1326                                         GstMemory * sei);
1327 
1328 GST_CODEC_PARSERS_API
1329 GstBuffer * gst_h264_parser_insert_sei_avc (GstH264NalParser * nalparser,
1330                                             guint8 nal_length_size,
1331                                             GstBuffer * au,
1332                                             GstMemory * sei);
1333 
1334 G_END_DECLS
1335 
1336 #endif
1337