2 * Copyright (C) <2011> Intel Corporation
3 * Copyright (C) <2011> Collabora Ltd.
4 * Copyright (C) <2011> Thibault Saunier <thibault.saunier@collabora.com>
6 * From bad/sys/vdpau/mpeg/mpegutil.c:
7 * Copyright (C) <2007> Jan Schmidt <thaytan@mad.scientist.com>
8 * Copyright (C) <2009> Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
26 #ifndef __GST_MPEG_VIDEO_UTILS_H__
27 #define __GST_MPEG_VIDEO_UTILS_H__
34 * GstMpegVideoPacketTypeCode:
35 * @GST_MPEG_VIDEO_PACKET_PICTURE: Picture packet starting code
36 * @GST_MPEG_VIDEO_PACKET_SLICE_MIN: Picture packet starting code
37 * @GST_MPEG_VIDEO_PACKET_SLICE_MAX: Slice max packet starting code
38 * @GST_MPEG_VIDEO_PACKET_SEQUENCE : Sequence packet starting code
39 * @GST_MPEG_VIDEO_PACKET_EXTENSION: Extension packet starting code
40 * @GST_MPEG_VIDEO_PACKET_SEQUENCE_END: Sequence end packet code
41 * @GST_MPEG_VIDEO_PACKET_GOP: Group of Picture packet starting code
42 * @GST_MPEG_VIDEO_PACKET_NONE: None packet code
44 * Indicates the type of MPEG packet
47 GST_MPEG_VIDEO_PACKET_PICTURE = 0x00,
48 GST_MPEG_VIDEO_PACKET_SLICE_MIN = 0x01,
49 GST_MPEG_VIDEO_PACKET_SLICE_MAX = 0xaf,
50 GST_MPEG_VIDEO_PACKET_SEQUENCE = 0xb3,
51 GST_MPEG_VIDEO_PACKET_EXTENSION = 0xb5,
52 GST_MPEG_VIDEO_PACKET_SEQUENCE_END = 0xb7,
53 GST_MPEG_VIDEO_PACKET_GOP = 0xb8,
54 GST_MPEG_VIDEO_PACKET_NONE = 0xff
55 } GstMpegVideoPacketTypeCode;
58 * GstMpegVideoPacketExtensionCode:
59 * @GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE: Sequence extension code
60 * @GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE_DISPLAY: Display extension code
61 * @GST_MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX: Quantizer extension code
62 * @GST_MPEG_VIDEO_PACKET_EXT_GOP: Group Of Picture extension code
64 * Indicates what type of packets are in this
65 * block, some are mutually * exclusive though - ie, sequence packs are
66 * accumulated separately. GOP & Picture may occur together or separately
69 GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE = 0x01,
70 GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE_DISPLAY = 0x02,
71 GST_MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX = 0x03,
72 GST_MPEG_VIDEO_PACKET_EXT_GOP = 0x04
73 } GstMpegVideoPacketExtensionCode;
77 * @GST_MPEG_VIDEO_LEVEL_LOW
78 * @GST_MPEG_VIDEO_LEVEL_MAIN
79 * @GST_MPEG_VIDEO_LEVEL_HIGH_1440
80 * @GST_MPEG_VIDEO_LEVEL_HIGH
82 * Indicates the level in use
85 GST_MPEG_VIDEO_LEVEL_HIGH = 0x04,
86 GST_MPEG_VIDEO_LEVEL_HIGH_1440 = 0x06,
87 GST_MPEG_VIDEO_LEVEL_MAIN = 0x08,
88 GST_MPEG_VIDEO_LEVEL_LOW = 0x0a
92 * GstMpegVideoProfile:
93 * @GST_MPEG_VIDEO_PROFILE_422,
94 * @GST_MPEG_VIDEO_PROFILE_HIGH,
95 * @GST_MPEG_VIDEO_PROFILE_SPATIALLY_SCALABLE,
96 * @GST_MPEG_VIDEO_PROFILE_SNR_SCALABLE,
97 * @GST_MPEG_VIDEO_PROFILE_MAIN,
98 * @GST_MPEG_VIDEO_PROFILE_SIMPLE,
100 * Indicates the profile type in use
103 GST_MPEG_VIDEO_PROFILE_422 = 0x00,
104 GST_MPEG_VIDEO_PROFILE_HIGH = 0x01,
105 GST_MPEG_VIDEO_PROFILE_SPATIALLY_SCALABLE = 0x02,
106 GST_MPEG_VIDEO_PROFILE_SNR_SCALABLE = 0x03,
107 GST_MPEG_VIDEO_PROFILE_MAIN = 0x04,
108 GST_MPEG_VIDEO_PROFILE_SIMPLE = 0x05
109 } GstMpegVideoProfile;
112 * GstMpegVideoPictureType:
113 * @GST_MPEG_VIDEO_PICTURE_TYPE_I: Type I
114 * @GST_MPEG_VIDEO_PICTURE_TYPE_P: Type P
115 * @GST_MPEG_VIDEO_PICTURE_TYPE_B: Type B
116 * @GST_MPEG_VIDEO_PICTURE_TYPE_D: Type D
118 * Indicates the type of picture
121 GST_MPEG_VIDEO_PICTURE_TYPE_I = 0x01,
122 GST_MPEG_VIDEO_PICTURE_TYPE_P = 0x02,
123 GST_MPEG_VIDEO_PICTURE_TYPE_B = 0x03,
124 GST_MPEG_VIDEO_PICTURE_TYPE_D = 0x04
125 } GstMpegVideoPictureType;
128 * GstMpegVideoPictureStructure:
129 * @GST_MPEG_VIDEO_PICTURE_STRUCTURE_TOP_FIELD: Top field
130 * @GST_MPEG_VIDEO_PICTURE_STRUCTURE_BOTTOM_FIELD: Bottom field
131 * @GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME: Frame
133 * Indicates the structure of picture
136 GST_MPEG_VIDEO_PICTURE_STRUCTURE_TOP_FIELD = 0x01,
137 GST_MPEG_VIDEO_PICTURE_STRUCTURE_BOTTOM_FIELD = 0x02,
138 GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME = 0x03
139 } GstMpegVideoPictureStructure;
141 typedef struct _GstMpegVideoSequenceHdr GstMpegVideoSequenceHdr;
142 typedef struct _GstMpegVideoSequenceExt GstMpegVideoSequenceExt;
143 typedef struct _GstMpegVideoPictureHdr GstMpegVideoPictureHdr;
144 typedef struct _GstMpegVideoGop GstMpegVideoGop;
145 typedef struct _GstMpegVideoPictureExt GstMpegVideoPictureExt;
146 typedef struct _GstMpegVideoQuantMatrixExt GstMpegVideoQuantMatrixExt;
147 typedef struct _GstMpegVideoTypeOffsetSize GstMpegVideoTypeOffsetSize;
150 * GstMpegVideoSequenceHdr:
151 * @width: Width of each frame
152 * @height: Height of each frame
153 * @par_w: Calculated Pixel Aspect Ratio width
154 * @par_h: Pixel Aspect Ratio height
155 * @fps_n: Calculated Framrate nominator
156 * @fps_d: Calculated Framerate denominator
157 * @bitrate_value: Value of the bitrate as is in the stream (400bps unit)
158 * @bitrate: the real bitrate of the Mpeg video stream in bits per second, 0 if VBR stream
159 * @constrained_parameters_flag: %TRUE if this stream uses contrained parameters.
160 * @intra_quantizer_matrix: intra-quantization table
161 * @non_intra_quantizer_matrix: non-intra quantization table
163 * The Mpeg2 Video Sequence Header structure.
165 struct _GstMpegVideoSequenceHdr
167 guint16 width, height;
168 guint8 aspect_ratio_info;
169 guint8 frame_rate_code;
170 guint32 bitrate_value;
171 guint16 vbv_buffer_size_value;
173 guint8 constrained_parameters_flag;
175 guint8 intra_quantizer_matrix[64];
176 guint8 non_intra_quantizer_matrix[64];
178 /* Calculated values */
185 * GstMpegVideoSequenceExt:
186 * @profile: mpeg2 decoder profil
187 * @level: mpeg2 decoder level
188 * @progressive: %TRUE if the frames are progressive %FALSE otherwize
189 * @chroma_format: indicates the chrominance format
190 * @horiz_size_ext: Horizontal size
191 * @vert_size_ext: Vertical size
192 * @bitrate_ext: The bitrate
193 * @vbv_buffer_size_extension: Vbv vuffer size
194 * @low_delay: %TRUE if the sequence doesn't contain any B-pitcture, %FALSE
196 * @fps_n_ext: Framerate nominator code
197 * @fps_d_ext: Framerate denominator code
199 * The Mpeg2 Video Sequence Extension structure.
201 struct _GstMpegVideoSequenceExt
203 /* mpeg2 decoder profile */
205 /* mpeg2 decoder level */
209 guint8 chroma_format;
211 guint8 horiz_size_ext, vert_size_ext;
214 guint8 vbv_buffer_size_extension;
216 guint8 fps_n_ext, fps_d_ext;
221 * GstMpegVideoQuantMatrixExt:
222 * @load_intra_quantiser_matrix
223 * @intra_quantiser_matrix
224 * @load_non_intra_quantiser_matrix
225 * @non_intra_quantiser_matrix:
226 * @load_chroma_intra_quantiser_matrix
227 * @chroma_intra_quantiser_matrix
228 * @load_chroma_non_intra_quantiser_matrix
229 * @chroma_non_intra_quantiser_matrix
231 * The Quant Matrix Extension structure
233 struct _GstMpegVideoQuantMatrixExt
235 guint8 load_intra_quantiser_matrix;
236 guint8 intra_quantiser_matrix[64];
237 guint8 load_non_intra_quantiser_matrix;
238 guint8 non_intra_quantiser_matrix[64];
239 guint8 load_chroma_intra_quantiser_matrix;
240 guint8 chroma_intra_quantiser_matrix[64];
241 guint8 load_chroma_non_intra_quantiser_matrix;
242 guint8 chroma_non_intra_quantiser_matrix[64];
246 * GstMpegVideoPictureHdr:
247 * @tsn: Temporal Sequence Number
248 * @pic_type: Type of the frame
249 * @full_pel_forward_vector: the full pel forward flag of
251 * @full_pel_backward_vector: the full pel backward flag
252 * of the frame: 0 or 1.
255 * The Mpeg2 Video Picture Header structure.
257 struct _GstMpegVideoPictureHdr
262 guint8 full_pel_forward_vector, full_pel_backward_vector;
268 * GstMpegVideoPictureExt:
269 * @intra_dc_precision: Intra DC precision
270 * @picture_structure: Structure of the picture
271 * @top_field_first: Top field first
272 * @frame_pred_frame_dct: Frame
273 * @concealment_motion_vectors: Concealment Motion Vectors
274 * @q_scale_type: Q Scale Type
275 * @intra_vlc_format: Intra Vlc Format
276 * @alternate_scan: Alternate Scan
277 * @repeat_first_field: Repeat First Field
278 * @chroma_420_type: Chroma 420 Type
279 * @progressive_frame: %TRUE if the frame is progressive %FALSE otherwize
281 * The Mpeg2 Video Picture Extension structure.
283 struct _GstMpegVideoPictureExt
287 guint8 intra_dc_precision;
288 guint8 picture_structure;
289 guint8 top_field_first;
290 guint8 frame_pred_frame_dct;
291 guint8 concealment_motion_vectors;
293 guint8 intra_vlc_format;
294 guint8 alternate_scan;
295 guint8 repeat_first_field;
296 guint8 chroma_420_type;
297 guint8 progressive_frame;
298 guint8 composite_display;
300 guint8 field_sequence;
302 guint8 burst_amplitude;
303 guint8 sub_carrier_phase;
308 * @drop_frame_flag: Drop Frame Flag
310 * @minute: Minute (O-59)
311 * @second: Second (0-59)
312 * @frame: Frame (0-59)
313 * @closed_gop: Closed Gop
314 * @broken_gop: Broken Gop
316 * The Mpeg Video Group of Picture structure.
318 struct _GstMpegVideoGop
320 guint8 drop_frame_flag;
322 guint8 hour, minute, second, frame;
329 * GstMpegVideoTypeOffsetSize:
330 * @type: the type of the packet that start at @offset
331 * @offset: the offset of the packet start in bytes, it is the exact, start of the packet, no sync code included
332 * @size: The size in bytes of the packet or -1 if the end wasn't found. It is the exact size of the packet, no sync code included
334 * A structure that contains the type of a packet, its offset and its size
336 struct _GstMpegVideoTypeOffsetSize
343 GList * gst_mpeg_video_parse (guint8 * data, gsize size, guint offset);
345 gboolean gst_mpeg_video_parse_sequence_header (GstMpegVideoSequenceHdr * params,
346 guint8 * data, gsize size, guint offset);
348 gboolean gst_mpeg_video_parse_picture_header (GstMpegVideoPictureHdr* hdr,
349 guint8 * data, gsize size, guint offset);
351 gboolean gst_mpeg_video_parse_picture_extension (GstMpegVideoPictureExt *ext,
352 guint8 * data, gsize size, guint offset);
354 gboolean gst_mpeg_video_parse_gop (GstMpegVideoGop * gop,
355 guint8 * data, gsize size, guint offset);
357 gboolean gst_mpeg_video_parse_sequence_extension (GstMpegVideoSequenceExt * seqext,
358 guint8 * data, gsize size, guint offset);
360 gboolean gst_mpeg_video_parse_quant_matrix_extension (GstMpegVideoQuantMatrixExt * quant,
361 guint8 * data, gsize size, guint offset);