## GstH264Parser GstH264Parser — Convenience library for h264 video bitstream parsing. |

## Functions

#define | GST_H264_IS_P_SLICE()
#define | GST_H264_IS_B_SLICE()
#define | GST_H264_IS_I_SLICE()
#define | GST_H264_IS_SP_SLICE()
#define | GST_H264_IS_SI_SLICE()
GstH264ParserResult | gst_h264_parser_identify_nalu ()
GstH264ParserResult | gst_h264_parser_identify_nalu_avc ()
GstH264ParserResult | gst_h264_parser_parse_nal ()
GstH264ParserResult | gst_h264_parser_parse_slice_hdr ()
GstH264ParserResult | gst_h264_parser_parse_sps ()
GstH264ParserResult | gst_h264_parser_parse_pps ()
GstH264ParserResult | gst_h264_parser_parse_sei ()
GstH264NalParser * | gst_h264_nal_parser_new ()
void | gst_h264_nal_parser_free ()
GstH264ParserResult | gst_h264_parse_sps ()
GstH264ParserResult | gst_h264_parse_pps ()
void | gst_h264_pps_clear ()
void | gst_h264_quant_matrix_8x8_get_zigzag_from_raster ()
void | gst_h264_quant_matrix_8x8_get_raster_from_zigzag ()
void | gst_h264_quant_matrix_4x4_get_zigzag_from_raster ()
void | gst_h264_quant_matrix_4x4_get_raster_from_zigzag ()
void | gst_h264_video_calculate_framerate ()

## Types and Values

#define | GST_H264_MAX_SPS_COUNT
#define | GST_H264_MAX_PPS_COUNT
enum | GstH264NalUnitType
enum | GstH264ParserResult
enum | GstH264SEIPayloadType
enum | GstH264SEIPicStructType
enum | GstH264SliceType
struct | GstH264NalParser
struct | GstH264NalUnit
struct | GstH264SPS
struct | GstH264PPS
struct | GstH264HRDParams
struct | GstH264VUIParams
struct | GstH264DecRefPicMarking
struct | GstH264RefPicMarking
struct | GstH264PredWeightTable
struct | GstH264SliceHdr
struct | GstH264ClockTimestamp
struct | GstH264PicTiming
struct | GstH264BufferingPeriod
struct | GstH264SEIMessage

## Includes

    #include <gst/codecparsers/gsth264parser.h>

## Description

It offers bitstream parsing in both AVC (length-prefixed) and Annex B (0x000001 start code prefix) format. To identify a NAL unit in a bitstream and parse its headers, first call:

- gst_h264_parser_identify_nalu to identify a NAL unit in an Annex B type bitstream

- gst_h264_parser_identify_nalu_avc to identify a NAL unit in an AVC type bitstream

The following functions are then available for parsing the structure of the GstH264NalUnit, depending on the GstH264NalUnitType:

- From GST_H264_NAL_SLICE to GST_H264_NAL_SLICE_IDR: gst_h264_parser_parse_slice_hdr

- GST_H264_NAL_SEI: gst_h264_parser_parse_sei

- GST_H264_NAL_SPS: gst_h264_parser_parse_sps

- GST_H264_NAL_PPS: gst_h264_parser_parse_pps

- Any other: gst_h264_parser_parse_nal

One of these functions *must* be called on every NAL unit in the bitstream, in order to keep the internal structures of the GstH264NalParser up to date. It is legal to call gst_h264_parser_parse_nal on NAL units of any type, if no special parsing of the current NAL unit is required by the application.

For more details about the structures, look at the ITU-T H.264 and ISO/IEC 14496-10 â€“ MPEG-4 Part 10 specifications, available at:

- ITU-T H.264: http://www.itu.int/rec/T-REC-H.264

- ISO/IEC 14496-10: http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=56538

## Functions

### GST_H264_IS_P_SLICE()

    #define GST_H264_IS_P_SLICE(slice)  (((slice)->type % 5) == GST_H264_P_SLICE)

### GST_H264_IS_B_SLICE()

    #define GST_H264_IS_B_SLICE(slice)  (((slice)->type % 5) == GST_H264_B_SLICE)

### GST_H264_IS_I_SLICE()

    #define GST_H264_IS_I_SLICE(slice)  (((slice)->type % 5) == GST_H264_I_SLICE)

### GST_H264_IS_SP_SLICE()

    #define GST_H264_IS_SP_SLICE(slice) (((slice)->type % 5) == GST_H264_SP_SLICE)

### GST_H264_IS_SI_SLICE()

    #define GST_H264_IS_SI_SLICE(slice) (((slice)->type % 5) == GST_H264_SI_SLICE)

### gst_h264_parser_identify_nalu ()

    GstH264ParserResult
    gst_h264_parser_identify_nalu (GstH264NalParser *nalparser,
                                   const guint8 *data,
                                   guint offset,
                                   gsize size,
                                   GstH264NalUnit *nalu);

Parses the headers of an Annex B coded NAL unit from `data` and puts the result into `nalu` .

#### Parameters

nalparser | a GstH264NalParser |
data | The data to parse, containing an Annex B coded NAL unit |
offset | the offset in `data` from which to parse the NAL unit |
size | the size of `data` |
nalu | The GstH264NalUnit to store the identified NAL unit in |

#### Returns

a GstH264ParserResult

### gst_h264_parser_identify_nalu_avc ()

    GstH264ParserResult
    gst_h264_parser_identify_nalu_avc (GstH264NalParser *nalparser,
                                       const guint8 *data,
                                       guint offset,
                                       gsize size,
                                       guint8 nal_length_size,
                                       GstH264NalUnit *nalu);

Parses the headers of an AVC coded NAL unit from `data` and puts the result into `nalu` .

#### Parameters

nalparser | a GstH264NalParser |
data | The data to parse, containing an AVC coded NAL unit |
offset | the offset in `data` from which to parse the NAL unit |
size | the size of `data` |
nal_length_size | the size in bytes of the AVC nal length prefix. |
nalu | The GstH264NalUnit to store the identified NAL unit in |

#### Returns

a GstH264ParserResult

### gst_h264_parser_parse_nal ()

    GstH264ParserResult
    gst_h264_parser_parse_nal (GstH264NalParser *nalparser,
                               GstH264NalUnit *nalu);

This function should be called in the case one doesn't need to parse a specific structure. It is necessary to do so to make sure `nalparser` is up to date.

#### Parameters

nalparser | a GstH264NalParser |
nalu | The GstH264NalUnit to parse |

#### Returns

a GstH264ParserResult

### gst_h264_parser_parse_slice_hdr ()

    GstH264ParserResult
    gst_h264_parser_parse_slice_hdr (GstH264NalParser *nalparser,
                                     GstH264NalUnit *nalu,
                                     GstH264SliceHdr *slice,
                                     gboolean parse_pred_weight_table,
                                     gboolean parse_dec_ref_pic_marking);

Parses `nalu` containing a coded slice, and fills `slice` .

#### Parameters

nalparser | a GstH264NalParser |
nalu | The GST_H264_NAL_SLICE to GST_H264_NAL_SLICE_IDR GstH264NalUnit to parse |
slice | The GstH264SliceHdr to fill. |
parse_pred_weight_table | Whether to parse the pred_weight_table or not |
parse_dec_ref_pic_marking | Whether to parse the dec_ref_pic_marking or not |

#### Returns

a GstH264ParserResult

### gst_h264_parser_parse_sps ()

    GstH264ParserResult
    gst_h264_parser_parse_sps (GstH264NalParser *nalparser,
                               GstH264NalUnit *nalu,
                               GstH264SPS *sps,
                               gboolean parse_vui_params);

Parses `nalu` containing a Sequence Parameter Set, and fills `sps` .

#### Parameters

nalparser | a GstH264NalParser |
nalu | The GST_H264_NAL_SPS GstH264NalUnit to parse |
sps | The GstH264SPS to fill. |
parse_vui_params | Whether to parse the vui_params or not |

#### Returns

a GstH264ParserResult

### gst_h264_parser_parse_pps ()

    GstH264ParserResult
    gst_h264_parser_parse_pps (GstH264NalParser *nalparser,
                               GstH264NalUnit *nalu,
                               GstH264PPS *pps);

Parses `nalu` containing a Picture Parameter Set, and fills `pps` .

The resulting `pps` data structure must be deallocated by the caller using `gst_h264_pps_clear()`.

#### Parameters

nalparser | a GstH264NalParser |
nalu | The GST_H264_NAL_PPS GstH264NalUnit to parse |
pps | The GstH264PPS to fill. |

#### Returns

a GstH264ParserResult

### gst_h264_parser_parse_sei ()

    GstH264ParserResult
    gst_h264_parser_parse_sei (GstH264NalParser *nalparser,
                               GstH264NalUnit *nalu,
                               GArray **messages);

Parses `nalu` containing one or more Supplementary Enhancement Information messages, and allocates and fills the `messages` array.

#### Parameters

nalparser | a GstH264NalParser |
nalu | The GST_H264_NAL_SEI GstH264NalUnit to parse |
messages | The GArray of GstH264SEIMessage to fill. The caller must free it when done. |

#### Returns

a GstH264ParserResult

### gst_h264_nal_parser_new ()

    GstH264NalParser *
    gst_h264_nal_parser_new (void);

Creates a new GstH264NalParser. It should be freed with gst_h264_nal_parser_free after use.

#### Returns

a new GstH264NalParser

### gst_h264_nal_parser_free ()

    void
    gst_h264_nal_parser_free (GstH264NalParser *nalparser);

Frees `nalparser` and sets it to `NULL`

#### Parameters

nalparser | the GstH264NalParser to free |

### gst_h264_parse_sps ()

    GstH264ParserResult
    gst_h264_parse_sps (GstH264NalUnit *nalu,
                        GstH264SPS *sps,
                        gboolean parse_vui_params);

Parses `data` , and fills the `sps` structure.

#### Parameters

nalu | The GST_H264_NAL_SPS GstH264NalUnit to parse |
sps | The GstH264SPS to fill. |
parse_vui_params | Whether to parse the vui_params or not |

#### Returns

a GstH264ParserResult

### gst_h264_parse_pps ()

    GstH264ParserResult
    gst_h264_parse_pps (GstH264NalParser *nalparser,
                        GstH264NalUnit *nalu,
                        GstH264PPS *pps);

Parses `data` , and fills the `pps` structure.

The resulting `pps` data structure shall be deallocated with the `gst_h264_pps_clear()` function when it is no longer needed, or prior to parsing a new PPS NAL unit.

#### Parameters

nalparser | a GstH264NalParser |
nalu | The GST_H264_NAL_PPS GstH264NalUnit to parse |
pps | The GstH264PPS to fill. |

#### Returns

a GstH264ParserResult

### gst_h264_pps_clear ()

    void
    gst_h264_pps_clear (GstH264PPS *pps);

Clears all `pps` internal resources.

#### Parameters

pps | The GstH264PPS to free |

Since: 1.4

### gst_h264_quant_matrix_8x8_get_zigzag_from_raster ()

    void
    gst_h264_quant_matrix_8x8_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.4

### gst_h264_quant_matrix_8x8_get_raster_from_zigzag ()

    void
    gst_h264_quant_matrix_8x8_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.4

### gst_h264_quant_matrix_4x4_get_zigzag_from_raster ()

    void
    gst_h264_quant_matrix_4x4_get_zigzag_from_raster
                                   (guint8 out_quant[16],
                                    const guint8 quant[16]);

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.4

### gst_h264_quant_matrix_4x4_get_raster_from_zigzag ()

    void
    gst_h264_quant_matrix_4x4_get_raster_from_zigzag
                                   (guint8 out_quant[16],
                                    const guint8 quant[16]);

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.4

### gst_h264_video_calculate_framerate ()

    void
    gst_h264_video_calculate_framerate (const GstH264SPS *sps,
                                        guint field_pic_flag,
                                        guint pic_struct,
                                        gint *fps_num,
                                        gint *fps_den);

Calculate framerate of a video sequence using `sps` VUI information, `field_pic_flag` from a slice header and `pic_struct` from GstH264PicTiming SEI message.

If framerate is variable or can't be determined, `fps_num` will be set to 0 and `fps_den` to 1.

#### Parameters

sps | Current Sequence Parameter Set |
field_pic_flag | Current `field_pic_flag` , obtained from latest slice header |
pic_struct | `pic_struct` value if available, 0 otherwise |
fps_num | The resulting fps numerator. | [out]
fps_den | The resulting fps denominator. | [out]

## Types and Values

### GST_H264_MAX_SPS_COUNT

    #define GST_H264_MAX_SPS_COUNT   32

### GST_H264_MAX_PPS_COUNT

    #define GST_H264_MAX_PPS_COUNT   256

### enum GstH264NalUnitType

Indicates the type of H264 Nal Units

#### Members

GST_H264_NAL_UNKNOWN | Unknown nal type |
GST_H264_NAL_SLICE | Slice nal |
GST_H264_NAL_SLICE_DPA | DPA slice nal |
GST_H264_NAL_SLICE_DPB | DPB slice nal |
GST_H264_NAL_SLICE_DPC | DPC slice nal |
GST_H264_NAL_SLICE_IDR | DPR slice nal |
GST_H264_NAL_SEI | Supplemental enhancement information (SEI) nal unit |
GST_H264_NAL_SPS | Sequence parameter set (SPS) nal unit |
GST_H264_NAL_PPS | Picture parameter set (PPS) nal unit |
GST_H264_NAL_AU_DELIMITER | Access unit (AU) delimiter nal unit |
GST_H264_NAL_SEQ_END | End of sequence nal unit |
GST_H264_NAL_STREAM_END | End of stream nal unit |
GST_H264_NAL_FILLER_DATA | Filler data nal lunit |
GST_H264_NAL_SPS_EXT | Sequence parameter set (SPS) extension NAL unit |
GST_H264_NAL_PREFIX_UNIT | Prefix NAL unit |
GST_H264_NAL_SUBSET_SPS | Subset sequence parameter set (SSPS) NAL unit |
GST_H264_NAL_DEPTH_SPS | Depth parameter set (DPS) NAL unit |
GST_H264_NAL_SLICE_AUX | Auxiliary coded picture without partitioning NAL unit |
GST_H264_NAL_SLICE_EXT | Coded slice extension NAL unit |
GST_H264_NAL_SLICE_DEPTH | Coded slice extension for depth or 3D-AVC texture view |

### enum GstH264ParserResult

The result of parsing H264 data.

#### Members

GST_H264_PARSER_OK | The parsing succeeded |
GST_H264_PARSER_BROKEN_DATA | The data to parse is broken |
GST_H264_PARSER_BROKEN_LINK | The link to structure needed for the parsing couldn't be found |
GST_H264_PARSER_ERROR | An error occurred when parsing |
GST_H264_PARSER_NO_NAL | No NAL unit found during the parsing |
GST_H264_PARSER_NO_NAL_END | Start of the NAL unit found, but not the end. This will be returned if no start/sync marker for the next NAL unit was found. In this case the parser will assume that the end of the data is also the end of the NAL unit. Whether this assumption is correct or not depends on the context, which only the caller can know, which is why a special result value is returned in this case. If the data is NAL-aligned then GST_H264_PARSER_NO_NAL_END can be treated just like GST_H264_PARSER_OK. If the data is not guaranteed to be NAL-aligned, then the caller probably wants to collect more data until there's another sync marker or the end of the stream has been reached. |

### enum GstH264SEIPayloadType

The type of SEI message.

#### Members

GST_H264_SEI_BUF_PERIOD | Buffering Period SEI Message |
GST_H264_SEI_PIC_TIMING | Picture Timing SEI Message |
GST_H264_SEI_REGISTERED_USER_DATA | Registered user data (D.2.5) |
GST_H264_SEI_RECOVERY_POINT | Recovery Point SEI Message (D.2.7) |
GST_H264_SEI_STEREO_VIDEO_INFO | stereo video info SEI message (Since: 1.6) |
GST_H264_SEI_FRAME_PACKING | Frame Packing Arrangement (FPA) message that contains the 3D arrangement for stereoscopic 3D video (Since: 1.6) ... |

### enum GstH264SEIPicStructType

SEI pic_struct type

#### Members

GST_H264_SEI_PIC_STRUCT_FRAME | Picture is a frame |
GST_H264_SEI_PIC_STRUCT_TOP_FIELD | Top field of frame |
GST_H264_SEI_PIC_STRUCT_BOTTOM_FIELD | Bottom field of frame |
GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM | Top bottom field of frame |
GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP | bottom top field of frame |
GST_H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP | top bottom top field of frame |
GST_H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM | bottom top bottom field of frame |
GST_H264_SEI_PIC_STRUCT_FRAME_DOUBLING | indicates that the frame should be displayed two times consecutively |
GST_H264_SEI_PIC_STRUCT_FRAME_TRIPLING | indicates that the frame should be displayed three times consecutively |

### enum GstH264SliceType

Type of Picture slice

#### Members

GST_H264_P_SLICE |  |
GST_H264_B_SLICE |  |
GST_H264_I_SLICE |  |
GST_H264_SP_SLICE |  |
GST_H264_SI_SLICE |  |
GST_H264_S_P_SLICE |  |
GST_H264_S_B_SLICE |  |
GST_H264_S_I_SLICE |  |
GST_H264_S_SP_SLICE |  |
GST_H264_S_SI_SLICE |  |

### struct GstH264NalParser

    struct GstH264NalParser {
    };

H264 NAL Parser (opaque structure).

### struct GstH264NalUnit

    struct GstH264NalUnit {
      guint16 ref_idc;
      guint16 type;

      /* calculated values */
      guint8 idr_pic_flag;
      guint size;
      guint offset;
      guint sc_offset;
      gboolean valid;

      guint8 *data;

      guint8 header_bytes;
      guint8 extension_type;
      union {
        GstH264NalUnitExtensionMVC mvc;
      } extension;
    };

Structure defining the NAL unit headers

#### Members

guint16 `ref_idc`; | not equal to 0 specifies that the content of the NAL unit contains a sequence parameter set, a sequence parameter set extension, a subset sequence parameter set, a picture parameter set, a slice of a reference picture, a slice data partition of a reference picture, or a prefix NAL unit preceding a slice of a reference picture. |
guint16 `type`; | A GstH264NalUnitType |
guint8 `idr_pic_flag`; | calculated idr_pic_flag |
guint `size`; | The size of the NAL unit starting from `offset` , thus including the header bytes. e.g. `type` (nal_unit_type) |
guint `offset`; | The offset of the actual start of the NAL unit, thus including the header bytes |
guint `sc_offset`; | The offset of the start code of the NAL unit |
gboolean `valid`; | If the NAL unit is valid, which means it has already been parsed |
guint8 *`data`; | The data from which the NAL unit has been parsed |
guint8 `header_bytes`; | The size of the NALU header in bytes (Since: 1.6) |
guint8 `extension_type`; | the extension type (Since: 1.6) |

### struct GstH264SPS

    struct GstH264SPS {
      gint id;

      guint8 profile_idc;
      guint8 constraint_set0_flag;
      guint8 constraint_set1_flag;
      guint8 constraint_set2_flag;
      guint8 constraint_set3_flag;
      guint8 constraint_set4_flag;
      guint8 constraint_set5_flag;
      guint8 level_idc;

      guint8 chroma_format_idc;
      guint8 separate_colour_plane_flag;
      guint8 bit_depth_luma_minus8;
      guint8 bit_depth_chroma_minus8;
      guint8 qpprime_y_zero_transform_bypass_flag;

      guint8 scaling_matrix_present_flag;
      guint8 scaling_lists_4x4[6][16];
      guint8 scaling_lists_8x8[6][64];

      guint8 log2_max_frame_num_minus4;
      guint8 pic_order_cnt_type;

      /* if pic_order_cnt_type == 0 */
      guint8 log2_max_pic_order_cnt_lsb_minus4;

      /* else if pic_order_cnt_type == 1 */
      guint8 delta_pic_order_always_zero_flag;
      gint32 offset_for_non_ref_pic;
      gint32 offset_for_top_to_bottom_field;
      guint8 num_ref_frames_in_pic_order_cnt_cycle;
      gint32 offset_for_ref_frame[255];

      guint32 num_ref_frames;
      guint8 gaps_in_frame_num_value_allowed_flag;
      guint32 pic_width_in_mbs_minus1;
      guint32 pic_height_in_map_units_minus1;
      guint8 frame_mbs_only_flag;

      guint8 mb_adaptive_frame_field_flag;

      guint8 direct_8x8_inference_flag;

      guint8 frame_cropping_flag;

      /* if frame_cropping_flag */
      guint32 frame_crop_left_offset;
      guint32 frame_crop_right_offset;
      guint32 frame_crop_top_offset;
      guint32 frame_crop_bottom_offset;

      guint8 vui_parameters_present_flag;
      /* if vui_parameters_present_flag */
      GstH264VUIParams vui_parameters;

      /* calculated values */
      guint8 chroma_array_type;
      guint32 max_frame_num;
      gint width, height;
      gint crop_rect_width, crop_rect_height;
      gint crop_rect_x, crop_rect_y;
      gint fps_num_removed, fps_den_removed; /* FIXME: remove */
      gboolean valid;

      /* Subset SPS extensions */
      guint8 extension_type;
      union {
        GstH264SPSExtMVC mvc;
      } extension;
    };

H264 Sequence Parameter Set (SPS)

#### Members

gint `id`; | The ID of the sequence parameter set |
guint8 `profile_idc`; | indicate the profile to which the coded video sequence conforms |
guint8 `constraint_set0_flag`; |  |
guint8 `constraint_set1_flag`; |  |
guint8 `constraint_set2_flag`; |  |
guint8 `constraint_set3_flag`; |  |
guint8 `constraint_set4_flag`; |  |
guint8 `constraint_set5_flag`; |  |
guint8 `level_idc`; |  |
guint8 `chroma_format_idc`; |  |
guint8 `separate_colour_plane_flag`; |  |
guint8 `bit_depth_luma_minus8`; |  |
guint8 `bit_depth_chroma_minus8`; |  |
guint8 `qpprime_y_zero_transform_bypass_flag`; |  |
guint8 `scaling_matrix_present_flag`; |  |
guint8 `scaling_lists_4x4`[6][16]; |  |
guint8 `scaling_lists_8x8`[6][64]; |  |
guint8 `log2_max_frame_num_minus4`; |  |
guint8 `pic_order_cnt_type`; |  |
guint8 `log2_max_pic_order_cnt_lsb_minus4`; |  |
guint8 `delta_pic_order_always_zero_flag`; |  |
gint32 `offset_for_non_ref_pic`; |  |
gint32 `offset_for_top_to_bottom_field`; |  |
guint8 `num_ref_frames_in_pic_order_cnt_cycle`; |  |
gint32 `offset_for_ref_frame`[255]; |  |
guint32 `num_ref_frames`; |  |
guint8 `gaps_in_frame_num_value_allowed_flag`; |  |
guint32 `pic_width_in_mbs_minus1`; |  |
guint32 `pic_height_in_map_units_minus1`; |  |
guint8 `frame_mbs_only_flag`; |  |
guint8 `mb_adaptive_frame_field_flag`; |  |
guint8 `direct_8x8_inference_flag`; |  |
guint8 `frame_cropping_flag`; |  |
guint32 `frame_crop_left_offset`; |  |
guint32 `frame_crop_right_offset`; |  |
guint32 `frame_crop_top_offset`; |  |
guint32 `frame_crop_bottom_offset`; |  |
guint8 `vui_parameters_present_flag`; |  |
GstH264VUIParams `vui_parameters`; |  |
guint8 `chroma_array_type`; |  |
guint32 `max_frame_num`; |  |
gint `width`; |  |
gint `height`; |  |
gint `crop_rect_width`; |  |
gint `crop_rect_height`; |  |
gint `crop_rect_x`; |  |
gint `crop_rect_y`; |  |
gint `fps_num_removed`; |  |
gint `fps_den_removed`; |  |
gboolean `valid`; |  |
guint8 `extension_type`; |  |

### struct GstH264PPS

    struct GstH264PPS {
      gint id;

      GstH264SPS *sequence;

      guint8 entropy_coding_mode_flag;
      guint8 pic_order_present_flag;

      guint32 num_slice_groups_minus1;

      /* if num_slice_groups_minus1 > 0 */
      guint8 slice_group_map_type;
      /* and if slice_group_map_type == 0 */
      guint32 run_length_minus1[8];
      /* or if slice_group_map_type == 2 */
      guint32 top_left[8];
      guint32 bottom_right[8];
      /* or if slice_group_map_type == (3, 4, 5) */
      guint8 slice_group_change_direction_flag;
      guint32 slice_group_change_rate_minus1;
      /* or if slice_group_map_type == 6 */
      guint32 pic_size_in_map_units_minus1;
      guint8 *slice_group_id;

      guint8 num_ref_idx_l0_active_minus1;
      guint8 num_ref_idx_l1_active_minus1;
      guint8 weighted_pred_flag;
      guint8 weighted_bipred_idc;
      gint8 pic_init_qp_minus26;
      gint8 pic_init_qs_minus26;
      gint8 chroma_qp_index_offset;
      guint8 deblocking_filter_control_present_flag;
      guint8 constrained_intra_pred_flag;
      guint8 redundant_pic_cnt_present_flag;

      guint8 transform_8x8_mode_flag;

      guint8 scaling_lists_4x4[6][16];
      guint8 scaling_lists_8x8[6][64];

      guint8 second_chroma_qp_index_offset;

      gboolean valid;
    };

H264 Picture Parameter Set

### struct GstH264HRDParams

    struct GstH264HRDParams {
      guint8 cpb_cnt_minus1;
      guint8 bit_rate_scale;
      guint8 cpb_size_scale;

      guint32 bit_rate_value_minus1[32];
      guint32 cpb_size_value_minus1[32];
      guint8 cbr_flag[32];

      guint8 initial_cpb_removal_delay_length_minus1;
      guint8 cpb_removal_delay_length_minus1;
      guint8 dpb_output_delay_length_minus1;
      guint8 time_offset_length;
    };

Defines the HRD parameters

#### Members

guint8 `cpb_cnt_minus1`; | plus 1 specifies the number of alternative CPB specifications in the bitstream |
guint8 `bit_rate_scale`; | specifies the maximum input bit rate of the SchedSelIdx-th CPB |
guint8 `cpb_size_scale`; | specifies the CPB size of the SchedSelIdx-th CPB |
guint32 `bit_rate_value_minus1`[32]; |  |
guint32 `cpb_size_value_minus1`[32]; | is used together with cpb_size_scale to specify the SchedSelIdx-th CPB size |
guint8 `cbr_flag`[32]; | Specifies if running in constant or intermittent bit rate mode |
guint8 `initial_cpb_removal_delay_length_minus1`; | specifies the length in bits of the cpb_removal_delay syntax element |
guint8 `cpb_removal_delay_length_minus1`; | specifies the length in bits of the dpb_output_delay syntax element |
guint8 `dpb_output_delay_length_minus1`; | 0 specifies the length in bits of the time_offset syntax element. =0 specifies that the time_offset syntax element is not present |
guint8 `time_offset_length`; | Length of the time offset |

### struct GstH264VUIParams

    struct GstH264VUIParams {
      guint8 aspect_ratio_info_present_flag;
      guint8 aspect_ratio_idc;
      /* if aspect_ratio_idc == 255 */
      guint16 sar_width;
      guint16 sar_height;

      guint8 overscan_info_present_flag;
      /* if overscan_info_present_flag */
      guint8 overscan_appropriate_flag;

      guint8 video_signal_type_present_flag;
      guint8 video_format;
      guint8 video_full_range_flag;
      guint8 colour_description_present_flag;
      guint8 colour_primaries;
      guint8 transfer_characteristics;
      guint8 matrix_coefficients;

      guint8 chroma_loc_info_present_flag;
      guint8 chroma_sample_loc_type_top_field;
      guint8 chroma_sample_loc_type_bottom_field;

      guint8 timing_info_present_flag;
      /* if timing_info_present_flag */
      guint32 num_units_in_tick;
      guint32 time_scale;
      guint8 fixed_frame_rate_flag;

      guint8 nal_hrd_parameters_present_flag;
      /* if nal_hrd_parameters_present_flag */
      GstH264HRDParams nal_hrd_parameters;

      guint8 vcl_hrd_parameters_present_flag;
      /* if vcl_hrd_parameters_present_flag */
      GstH264HRDParams vcl_hrd_parameters;

      guint8 low_delay_hrd_flag;
      guint8 pic_struct_present_flag;

      guint8 bitstream_restriction_flag;
      /*  if bitstream_restriction_flag */
      guint8 motion_vectors_over_pic_boundaries_flag;
      guint32 max_bytes_per_pic_denom;
      guint32 max_bits_per_mb_denom;
      guint32 log2_max_mv_length_horizontal;
      guint32 log2_max_mv_length_vertical;
      guint32 num_reorder_frames;
      guint32 max_dec_frame_buffering;

      /* calculated values */
      guint par_n;
      guint par_d;
    };

The structure representing the VUI parameters.

#### Members

guint8 `aspect_ratio_info_present_flag`; | `TRUE` specifies that aspect_ratio_idc is present. `FALSE` specifies that aspect_ratio_idc is not present `aspect_ratio_idc` specifies the value of the sample aspect ratio of the luma samples `sar_width` indicates the horizontal size of the sample aspect ratio `sar_height` indicates the vertical size of the sample aspect ratio |
guint8 `aspect_ratio_idc`; |  |
guint16 `sar_width`; |  |
guint16 `sar_height`; |  |
guint8 `overscan_info_present_flag`; | `TRUE` overscan_appropriate_flag is present `FALSE` otherwise |
guint8 `overscan_appropriate_flag`; | `TRUE` indicates that the cropped decoded pictures output are suitable for display using overscan. `FALSE` the cropped decoded pictures output contain visually important information |
guint8 `video_signal_type_present_flag`; | `TRUE` specifies that video_format, video_full_range_flag and colour_description_present_flag are present. |
guint8 `video_format`; | indicates the representation of the picture |
guint8 `video_full_range_flag`; | indicates the black level and range of the luma and chroma signals |
guint8 `colour_description_present_flag`; | `TRUE` specifies that colour_primaries, transfer_characteristics and matrix_coefficients are present |
guint8 `colour_primaries`; | indicates the chromaticity coordinates of the source primaries |
guint8 `transfer_characteristics`; | indicates the opto-electronic transfer characteristic |
guint8 `matrix_coefficients`; | describes the matrix coefficients used in deriving luma and chroma signals |
guint8 `chroma_loc_info_present_flag`; | `TRUE` specifies that chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present, `FALSE` otherwise |
guint8 `chroma_sample_loc_type_top_field`; | specify the location of chroma for top field `chroma_sample_loc_type_bottom_field` specify the location of chroma for bottom field |
guint8 `chroma_sample_loc_type_bottom_field`; |  |
guint8 `timing_info_present_flag`; | `TRUE` specifies that num_units_in_tick, time_scale and fixed_frame_rate_flag are present in the bitstream |
guint32 `num_units_in_tick`; | is the number of time units of a clock operating at the frequency time_scale Hz time_scale: is the number of time units that pass in one second |
guint32 `time_scale`; |  |
guint8 `fixed_frame_rate_flag`; | `TRUE` indicates that the temporal distance between the HRD output times of any two consecutive pictures in output order is constrained as specified in the spec, `FALSE` otherwise. |
guint8 `nal_hrd_parameters_present_flag`; | `TRUE` if NAL HRD parameters exist in the bitstream |
GstH264HRDParams `nal_hrd_parameters`; |  |
guint8 `vcl_hrd_parameters_present_flag`; | `TRUE` if VCL HRD parameters exist in the bitstream |
GstH264HRDParams `vcl_hrd_parameters`; |  |
guint8 `low_delay_hrd_flag`; | specifies the HRD operational mode |
guint8 `pic_struct_present_flag`; | `TRUE` specifies that picture timing SEI messages are present or not |
guint8 `bitstream_restriction_flag`; | `TRUE` specifies that the following coded video sequence bitstream restriction parameters are present |
guint8 `motion_vectors_over_pic_boundaries_flag`; | `FALSE` indicates that no sample outside the picture boundaries and no sample at a fractional sample position, `TRUE` indicates that one or more samples outside picture boundaries may be used in inter prediction |
guint32 `max_bytes_per_pic_denom`; | indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture in the coded video sequence. |
guint32 `max_bits_per_mb_denom`; | indicates the maximum number of coded bits of macroblock_layer |
guint32 `log2_max_mv_length_horizontal`; | indicate the maximum absolute value of a decoded horizontal motion vector component |
guint32 `log2_max_mv_length_vertical`; | indicate the maximum absolute value of a decoded vertical motion vector component |
guint32 `num_reorder_frames`; | indicates the maximum number of frames, complementary field pairs, or non-paired fields that precede any frame, |
guint32 `max_dec_frame_buffering`; | specifies the required size of the HRD decoded picture buffer in units of frame buffers. |
guint `par_n`; |  |
guint `par_d`; |  |

### struct GstH264DecRefPicMarking

    struct GstH264DecRefPicMarking {
      /* if slice->nal_unit.IdrPicFlag */
      guint8 no_output_of_prior_pics_flag;
      guint8 long_term_reference_flag;

      guint8 adaptive_ref_pic_marking_mode_flag;
      GstH264RefPicMarking ref_pic_marking[10];
      guint8 n_ref_pic_marking;
    };

### struct GstH264RefPicMarking

    struct GstH264RefPicMarking {
      guint8 memory_management_control_operation;

      guint32 difference_of_pic_nums_minus1;
      guint32 long_term_pic_num;
      guint32 long_term_frame_idx;
      guint32 max_long_term_frame_idx_plus1;
    };

### struct GstH264PredWeightTable

    struct GstH264PredWeightTable {
      guint8 luma_log2_weight_denom;
      guint8 chroma_log2_weight_denom;

      gint16 luma_weight_l0[32];
      gint8 luma_offset_l0[32];

      /* if seq->ChromaArrayType != 0 */
      gint16 chroma_weight_l0[32][2];
      gint8 chroma_offset_l0[32][2];

      /* if slice->slice_type % 5 == 1 */
      gint16 luma_weight_l1[32];
      gint8 luma_offset_l1[32];

      /* and if seq->ChromaArrayType != 0 */
      gint16 chroma_weight_l1[32][2];
      gint8 chroma_offset_l1[32][2];
    };

### struct GstH264SliceHdr

    struct GstH264SliceHdr {
      guint32 first_mb_in_slice;
      guint32 type;
      GstH264PPS *pps;

      /* if seq->separate_colour_plane_flag */
      guint8 colour_plane_id;

      guint16 frame_num;

      guint8 field_pic_flag;
      guint8 bottom_field_flag;

      /* if nal_unit.type == 5 */
      guint16 idr_pic_id;

      /* if seq->pic_order_cnt_type == 0 */
      guint16 pic_order_cnt_lsb;
      /* if seq->pic_order_present_flag && !field_pic_flag */
      gint32 delta_pic_order_cnt_bottom;

      gint32 delta_pic_order_cnt[2];
      guint8 redundant_pic_cnt;

      /* if slice_type == B_SLICE */
      guint8 direct_spatial_mv_pred_flag;

      guint8 num_ref_idx_l0_active_minus1;
      guint8 num_ref_idx_l1_active_minus1;

      guint8 ref_pic_list_modification_flag_l0;
      guint8 n_ref_pic_list_modification_l0;
      GstH264RefPicListModification ref_pic_list_modification_l0[32];
      guint8 ref_pic_list_modification_flag_l1;
      guint8 n_ref_pic_list_modification_l1;
      GstH264RefPicListModification ref_pic_list_modification_l1[32];

      GstH264PredWeightTable pred_weight_table;
      /* if nal_unit.ref_idc != 0 */
      GstH264DecRefPicMarking dec_ref_pic_marking;

      guint8 cabac_init_idc;
      gint8 slice_qp_delta;
      gint8 slice_qs_delta;

      guint8 disable_deblocking_filter_idc;
      gint8 slice_alpha_c0_offset_div2;
      gint8 slice_beta_offset_div2;

      guint16 slice_group_change_cycle;

      /* calculated values */
      guint32 max_pic_num;
      gboolean valid;

      /* Size of the slice_header() in bits */
      guint header_size;

      /* Number of emulation prevention bytes (EPB) in this slice_header() */
      guint n_emulation_prevention_bytes;
    };

### struct GstH264ClockTimestamp

    struct GstH264ClockTimestamp {
      guint8 ct_type;
      guint8 nuit_field_based_flag;
      guint8 counting_type;
      guint8 discontinuity_flag;
      guint8 cnt_dropped_flag;
      guint8 n_frames;

      guint8 seconds_flag;
      guint8 seconds_value;

      guint8 minutes_flag;
      guint8 minutes_value;

      guint8 hours_flag;
      guint8 hours_value;

      guint32 time_offset;
    };

### struct GstH264PicTiming

    struct GstH264PicTiming {
      guint32 cpb_removal_delay;
      guint32 dpb_output_delay;

      guint8 pic_struct_present_flag;
      /* if pic_struct_present_flag */
      guint8 pic_struct;

      guint8 clock_timestamp_flag[3];
      GstH264ClockTimestamp clock_timestamp[3];
    };

### struct GstH264BufferingPeriod

    struct GstH264BufferingPeriod {
      GstH264SPS *sps;

      /* seq->vui_parameters->nal_hrd_parameters_present_flag */
      guint32 nal_initial_cpb_removal_delay[32];
      guint32 nal_initial_cpb_removal_delay_offset[32];

      /* seq->vui_parameters->vcl_hrd_parameters_present_flag */
      guint32 vcl_initial_cpb_removal_delay[32];
      guint32 vcl_initial_cpb_removal_delay_offset[32];
    };

### struct GstH264SEIMessage

    struct GstH264SEIMessage {
      GstH264SEIPayloadType payloadType;

      union {
        GstH264BufferingPeriod buffering_period;
        GstH264PicTiming pic_timing;
        GstH264RegisteredUserData registered_user_data;
        GstH264RecoveryPoint recovery_point;
        GstH264StereoVideoInfo stereo_video_info;
        GstH264FramePacking frame_packing;
        /* ... could implement more */
      } payload;
    };