## GstMpegvideoParser GstMpegvideoParser — Convenience library for mpeg1 and 2 video bitstream parsing. |

## Functions

gboolean | gst_mpeg_video_parse ()
gboolean | gst_mpeg_video_parse_sequence_header ()
gboolean | gst_mpeg_video_parse_picture_header ()
gboolean | gst_mpeg_video_parse_picture_extension ()
gboolean | gst_mpeg_video_parse_gop ()
gboolean | gst_mpeg_video_parse_sequence_extension ()
gboolean | gst_mpeg_video_parse_sequence_display_extension ()
gboolean | gst_mpeg_video_parse_quant_matrix_extension ()
gboolean | gst_mpeg_video_finalise_mpeg2_sequence_header ()
void | gst_mpeg_video_quant_matrix_get_raster_from_zigzag ()
void | gst_mpeg_video_quant_matrix_get_zigzag_from_raster ()

## Types and Values

enum | GstMpegVideoPacketTypeCode
enum | GstMpegVideoPacketExtensionCode
enum | GstMpegVideoLevel
enum | GstMpegVideoProfile
enum | GstMpegVideoPictureType
enum | GstMpegVideoPictureStructure
struct | GstMpegVideoSequenceHdr
struct | GstMpegVideoSequenceExt
struct | GstMpegVideoPictureHdr
struct | GstMpegVideoGop
struct | GstMpegVideoPictureExt
struct | GstMpegVideoQuantMatrixExt

## Includes

    #include <gst/codecparsers/gstmpegvideoparser.h>

## Description

Provides useful functions for mpeg videos bitstream parsing.

## Functions

### gst_mpeg_video_parse ()

    gboolean
    gst_mpeg_video_parse (GstMpegVideoPacket *packet,
                          const guint8 *data,
                          gsize size,
                          guint offset);

Parses the MPEG 1/2 video bitstream contained in `data` , and returns the offset, and if known also the size, in `packet` . This function will scan the data to find the next packet if needed.

#### Parameters

packet | a GstMpegVideoPacket to fill with the data and offset of the next packet found |
data | The data to parse |
size | The size of `data` |
offset | The offset from which to start parsing |

#### Returns

TRUE if a packet start code was found, otherwise FALSE.

### gst_mpeg_video_parse_sequence_header ()

    gboolean
    gst_mpeg_video_parse_sequence_header (GstMpegVideoSequenceHdr *seqhdr,
                                          const guint8 *data,
                                          gsize size,
                                          guint offset);

`gst_mpeg_video_parse_sequence_header` is deprecated and should not be used in newly-written code.

Use `gst_mpeg_video_packet_parse_sequence_header()` instead.

Parses the `seqhdr` Mpeg Video Sequence Header structure members from `data`

#### Parameters

seqhdr | The GstMpegVideoSequenceHdr structure to fill. | [out]
data | The data from which to parse the sequence header |
size | The size of `data` |
offset | The offset in byte from which to start parsing `data` |

#### Returns

`TRUE` if the seqhdr could be parsed correctly, `FALSE` otherwise.

### gst_mpeg_video_parse_picture_header ()

    gboolean
    gst_mpeg_video_parse_picture_header (GstMpegVideoPictureHdr *hdr,
                                         const guint8 *data,
                                         gsize size,
                                         guint offset);

`gst_mpeg_video_parse_picture_header` is deprecated and should not be used in newly-written code.

Use `gst_mpeg_video_packet_parse_picture_header()` instead.

Parsers the `hdr` Mpeg Video Picture Header structure members from `data`

#### Parameters

hdr | The GstMpegVideoPictureHdr structure to fill. | [out]
data | The data from which to parse the picture header |
size | The size of `data` |
offset | The offset in byte from which to start the parsing |

#### Returns

`TRUE` if the picture sequence could be parsed correctly, `FALSE` otherwise.

### gst_mpeg_video_parse_picture_extension ()

    gboolean
    gst_mpeg_video_parse_picture_extension
                                   (GstMpegVideoPictureExt *ext,
                                    const guint8 *data,
                                    gsize size,
                                    guint offset);

`gst_mpeg_video_parse_picture_extension` is deprecated and should not be used in newly-written code.

Use `gst_mpeg_video_packet_parse_picture_extension()` instead.

Parse the `ext` Mpeg Video Picture Extension structure members from `data`

#### Parameters

ext | The GstMpegVideoPictureExt structure to fill. | [out]
data | The data from which to parse the picture extension |
size | The size of `data` |
offset | The offset in byte from which to start the parsing |

#### Returns

`TRUE` if the picture extension could be parsed correctly, `FALSE` otherwise.

### gst_mpeg_video_parse_gop ()

    gboolean
    gst_mpeg_video_parse_gop (GstMpegVideoGop *gop,
                              const guint8 *data,
                              gsize size,
                              guint offset);

`gst_mpeg_video_parse_gop` is deprecated and should not be used in newly-written code.

Use `gst_mpeg_video_packet_parse_gop()` instead.

Parses the `gop` Mpeg Video Group of Picture structure members from `data`

#### Parameters

gop | The GstMpegVideoGop structure to fill. | [out]
data | The data from which to parse the gop |
size | The size of `data` |
offset | The offset in byte from which to start the parsing |

#### Returns

`TRUE` if the gop could be parsed correctly, `FALSE` otherwise.

### gst_mpeg_video_parse_sequence_extension ()

    gboolean
    gst_mpeg_video_parse_sequence_extension
                                   (GstMpegVideoSequenceExt *seqext,
                                    const guint8 *data,
                                    gsize size,
                                    guint offset);

`gst_mpeg_video_parse_sequence_extension` is deprecated and should not be used in newly-written code.

Use `gst_mpeg_video_packet_parse_sequence_extension()` instead.

Parses the `seqext` Mpeg Video Sequence Extension structure members from `data`

#### Parameters

seqext | The GstMpegVideoSequenceExt structure to fill. | [out]
data | The data from which to parse the sequence extension |
size | The size of `data` |
offset | The offset in byte from which to start parsing `data` |

#### Returns

`TRUE` if the seqext could be parsed correctly, `FALSE` otherwise.

### gst_mpeg_video_parse_sequence_display_extension ()

    gboolean
    gst_mpeg_video_parse_sequence_display_extension
                                   (GstMpegVideoSequenceDisplayExt *seqdisplayext,
                                    const guint8 *data,
                                    gsize size,
                                    guint offset);

`gst_mpeg_video_parse_sequence_display_extension` is deprecated and should not be used in newly-written code.

### gst_mpeg_video_parse_quant_matrix_extension ()

    gboolean
    gst_mpeg_video_parse_quant_matrix_extension
                                   (GstMpegVideoQuantMatrixExt *quant,
                                    const guint8 *data,
                                    gsize size,
                                    guint offset);

`gst_mpeg_video_parse_quant_matrix_extension` is deprecated and should not be used in newly-written code.

Use `gst_mpeg_video_packet_parse_quant_matrix_extension()` instead.

Parses the `quant` Mpeg Video Quant Matrix Extension structure members from `data`

#### Parameters

quant | The GstMpegVideoQuantMatrixExt structure to fill. | [out]
data | The data from which to parse the Quantization Matrix extension |
size | The size of `data` |
offset | The offset in byte from which to start the parsing |

#### Returns

`TRUE` if the quant matrix extension could be parsed correctly, `FALSE` otherwise.

### gst_mpeg_video_finalise_mpeg2_sequence_header ()

    gboolean
    gst_mpeg_video_finalise_mpeg2_sequence_header
                                   (GstMpegVideoSequenceHdr *hdr,
                                    GstMpegVideoSequenceExt *seqext,
                                    GstMpegVideoSequenceDisplayExt *displayext);

### gst_mpeg_video_quant_matrix_get_raster_from_zigzag ()

    void
    gst_mpeg_video_quant_matrix_get_raster_from_zigzag
                                   (guint8 out_quant[64],
                                    const guint8 quant[64]);

Converts quantization matrix `quant` from zigzag scan order to raster scan order and store the resulting factors into `out_quant` .

Note: it is an error to pass the same table in both `quant` and `out_quant` arguments.

#### Parameters

out_quant | The resulting quantization matrix. | [out]
quant | The source quantization matrix |

Since: 1.2

### gst_mpeg_video_quant_matrix_get_zigzag_from_raster ()

    void
    gst_mpeg_video_quant_matrix_get_zigzag_from_raster
                                   (guint8 out_quant[64],
                                    const guint8 quant[64]);

Converts quantization matrix `quant` from raster scan order to zigzag scan order and store the resulting factors into `out_quant` .

Note: it is an error to pass the same table in both `quant` and `out_quant` arguments.

#### Parameters

out_quant | The resulting quantization matrix. | [out]
quant | The source quantization matrix |

Since: 1.2

## Types and Values

### enum GstMpegVideoPacketTypeCode

Indicates the type of MPEG packet

#### Members

GST_MPEG_VIDEO_PACKET_PICTURE | Picture packet starting code |
GST_MPEG_VIDEO_PACKET_SLICE_MIN | Slice min packet starting code |
GST_MPEG_VIDEO_PACKET_SLICE_MAX | Slice max packet starting code |
GST_MPEG_VIDEO_PACKET_USER_DATA | User data packet starting code |
GST_MPEG_VIDEO_PACKET_SEQUENCE | Sequence packet starting code |
GST_MPEG_VIDEO_PACKET_EXTENSION | Extension packet starting code |
GST_MPEG_VIDEO_PACKET_SEQUENCE_END | Sequence end packet code |
GST_MPEG_VIDEO_PACKET_GOP | Group of Picture packet starting code |
GST_MPEG_VIDEO_PACKET_NONE | None packet code |

### enum GstMpegVideoPacketExtensionCode

Indicates what type of packets are in this block, some are mutually exclusive though - ie, sequence packs are accumulated separately. GOP & Picture may occur together or separately.

#### Members

GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE | Sequence extension code |
GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE_DISPLAY | Sequence Display extension code |
GST_MPEG_VIDEO_PACKET_EXT_QUANT_MATRIX | Quantization Matrix extension code |
GST_MPEG_VIDEO_PACKET_EXT_SEQUENCE_SCALABLE | Sequence Scalable extension code |
GST_MPEG_VIDEO_PACKET_EXT_PICTURE | Picture coding extension |

### enum GstMpegVideoLevel

Mpeg-2 Levels.

#### Members

GST_MPEG_VIDEO_LEVEL_HIGH | High level (HL) |
GST_MPEG_VIDEO_LEVEL_HIGH_1440 | High 1440 level (H-14) |
GST_MPEG_VIDEO_LEVEL_MAIN | Main level (ML) |
GST_MPEG_VIDEO_LEVEL_LOW | Low level (LL) |

### enum GstMpegVideoProfile

Mpeg-2 Profiles.

#### Members

GST_MPEG_VIDEO_PROFILE_422 | 4:2:2 profile (422) |
GST_MPEG_VIDEO_PROFILE_HIGH | High profile (HP) |
GST_MPEG_VIDEO_PROFILE_SPATIALLY_SCALABLE | Spatially Scalable profile (Spatial) |
GST_MPEG_VIDEO_PROFILE_SNR_SCALABLE | SNR Scalable profile (SNR) |
GST_MPEG_VIDEO_PROFILE_MAIN | Main profile (MP) |
GST_MPEG_VIDEO_PROFILE_SIMPLE | Simple profile (SP) |

### enum GstMpegVideoPictureType

Picture type.

#### Members

GST_MPEG_VIDEO_PICTURE_TYPE_I | Intra-coded (I) frame |
GST_MPEG_VIDEO_PICTURE_TYPE_P | Predictive-codec (P) frame |
GST_MPEG_VIDEO_PICTURE_TYPE_B | Bidirectionally predictive-coded (B) frame |
GST_MPEG_VIDEO_PICTURE_TYPE_D | D frame |

### enum GstMpegVideoPictureStructure

Picture structure type.

#### Members

GST_MPEG_VIDEO_PICTURE_STRUCTURE_TOP_FIELD | Top field |
GST_MPEG_VIDEO_PICTURE_STRUCTURE_BOTTOM_FIELD | Bottom field |
GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME | Frame picture |

### struct GstMpegVideoSequenceHdr

    struct GstMpegVideoSequenceHdr {
      guint16 width, height;
      guint8  aspect_ratio_info;
      guint8  frame_rate_code;
      guint32 bitrate_value;
      guint16 vbv_buffer_size_value;

      guint8  constrained_parameters_flag;

      guint8  load_intra_quantiser_matrix;
      guint8  intra_quantizer_matrix[64];
      guint8  load_non_intra_quantiser_matrix;
      guint8  non_intra_quantizer_matrix[64];

      /* Calculated values */
      guint   par_w, par_h;
      guint   fps_n, fps_d;
      guint   bitrate;
    };

The Mpeg2 Video Sequence Header structure.

#### Members

guint16 `width`; | Width of each frame |
guint16 `height`; | Height of each frame |
guint8 `aspect_ratio_info`; |  |
guint8 `frame_rate_code`; |  |
guint32 `bitrate_value`; | Value of the bitrate as is in the stream (400bps unit) |
guint16 `vbv_buffer_size_value`; |  |
guint8 `constrained_parameters_flag`; | `TRUE` if this stream uses contrained parameters. |
guint8 `load_intra_quantiser_matrix`; | `TRUE` indicates the presence of intra_quantiser_matrix |
guint8 `intra_quantizer_matrix`[64]; | intra-quantization table, in zigzag scan order |
guint8 `load_non_intra_quantiser_matrix`; | `TRUE` indicates the presence of non_intra_quantiser_matrix |
guint8 `non_intra_quantizer_matrix`[64]; | non-intra quantization table, in zigzag scan order |
guint `par_w`; | Calculated Pixel Aspect Ratio width |
guint `par_h`; | Calculated Pixel Aspect Ratio height |
guint `fps_n`; | Calculated Framrate nominator |
guint `fps_d`; | Calculated Framerate denominator |
guint `bitrate`; | the real bitrate of the Mpeg video stream in bits per second, 0 if VBR stream |

### struct GstMpegVideoSequenceExt

    struct GstMpegVideoSequenceExt {
      /* mpeg2 decoder profile */
      guint8 profile;
      /* mpeg2 decoder level */
      guint8 level;

      guint8 progressive;
      guint8 chroma_format;

      guint8 horiz_size_ext, vert_size_ext;

      guint16 bitrate_ext;
      guint8 vbv_buffer_size_extension;
      guint8 low_delay;
      guint8 fps_n_ext, fps_d_ext;

      /* Additional information */
      guint8 profile_level_escape_bit;
    };

The Mpeg2 Video Sequence Extension structure.

#### Members

guint8 `profile`; | mpeg2 decoder profile |
guint8 `level`; | mpeg2 decoder level |
guint8 `progressive`; | `TRUE` if the frames are progressive `FALSE` otherwise |
guint8 `chroma_format`; | indicates the chrominance format |
guint8 `horiz_size_ext`; | Horizontal size |
guint8 `vert_size_ext`; | Vertical size |
guint16 `bitrate_ext`; | The bitrate |
guint8 `vbv_buffer_size_extension`; | VBV vuffer size |
guint8 `low_delay`; | `TRUE` if the sequence doesn't contain any B-pictures, `FALSE` otherwise |
guint8 `fps_n_ext`; | Framerate nominator code |
guint8 `fps_d_ext`; | Framerate denominator code |
guint8 `profile_level_escape_bit`; | Escape bit. If set, the meaning of the `profile` and `level` fields is different. |

### struct GstMpegVideoPictureHdr

    struct GstMpegVideoPictureHdr {
      guint16 tsn;
      guint8 pic_type;
      guint16 vbv_delay;

      guint8 full_pel_forward_vector, full_pel_backward_vector;

      guint8 f_code[2][2];
    };

The Mpeg2 Video Picture Header structure.

#### Members

guint16 `tsn`; | Temporal Sequence Number |
guint8 `pic_type`; | Type of the frame |
guint16 `vbv_delay`; |  |
guint8 `full_pel_forward_vector`; | the full pel forward flag of the frame: 0 or 1. |
guint8 `full_pel_backward_vector`; | the full pel backward flag of the frame: 0 or 1. |
guint8 `f_code`[2][2]; | F code |

### struct GstMpegVideoGop

    struct GstMpegVideoGop {
      guint8 drop_frame_flag;

      guint8 hour, minute, second, frame;

      guint8 closed_gop;
      guint8 broken_link;
    };

The Mpeg Video Group of Picture structure.

#### Members

guint8 `drop_frame_flag`; | Drop Frame Flag |
guint8 `hour`; | Hour (0-23) |
guint8 `minute`; | Minute (O-59) |
guint8 `second`; | Second (0-59) |
guint8 `frame`; | Frame (0-59) |
guint8 `closed_gop`; | Closed Gop |
guint8 `broken_link`; | Broken link |

### struct GstMpegVideoPictureExt

    struct GstMpegVideoPictureExt {
      guint8 f_code[2][2];

      guint8 intra_dc_precision;
      guint8 picture_structure;
      guint8 top_field_first;
      guint8 frame_pred_frame_dct;
      guint8 concealment_motion_vectors;
      guint8 q_scale_type;
      guint8 intra_vlc_format;
      guint8 alternate_scan;
      guint8 repeat_first_field;
      guint8 chroma_420_type;
      guint8 progressive_frame;
      guint8 composite_display;
      guint8 v_axis;
      guint8 field_sequence;
      guint8 sub_carrier;
      guint8 burst_amplitude;
      guint8 sub_carrier_phase;
    };

The Mpeg2 Video Picture Extension structure.

#### Members

guint8 `f_code`[2][2]; |  |
guint8 `intra_dc_precision`; | Intra DC precision |
guint8 `picture_structure`; | Structure of the picture |
guint8 `top_field_first`; | Top field first |
guint8 `frame_pred_frame_dct`; | Frame |
guint8 `concealment_motion_vectors`; | Concealment Motion Vectors |
guint8 `q_scale_type`; | Q Scale Type |
guint8 `intra_vlc_format`; | Intra Vlc Format |
guint8 `alternate_scan`; | Alternate Scan |
guint8 `repeat_first_field`; | Repeat First Field |
guint8 `chroma_420_type`; | Chroma 420 Type |
guint8 `progressive_frame`; | `TRUE` if the frame is progressive `FALSE` otherwise |
guint8 `composite_display`; |  |
guint8 `v_axis`; |  |
guint8 `field_sequence`; |  |
guint8 `sub_carrier`; |  |
guint8 `burst_amplitude`; |  |
guint8 `sub_carrier_phase`; |  |

### struct GstMpegVideoQuantMatrixExt

    struct GstMpegVideoQuantMatrixExt {
     guint8 load_intra_quantiser_matrix;
     guint8 intra_quantiser_matrix[64];
     guint8 load_non_intra_quantiser_matrix;
     guint8 non_intra_quantiser_matrix[64];
     guint8 load_chroma_intra_quantiser_matrix;
     guint8 chroma_intra_quantiser_matrix[64];
     guint8 load_chroma_non_intra_quantiser_matrix;
     guint8 chroma_non_intra_quantiser_matrix[64];
    };

The Quant Matrix Extension structure that exposes quantization matrices in zigzag scan order. i.e. the original encoded scan order.