mpegvideoparse: Parse bitrate and emit as tag

This patch picks up the bitrate for the stream from the MPEG sequence
header and emits it as a tag on the source pad.

Fixes #599298.
This commit is contained in:
Arun Raghavan 2010-02-02 15:49:29 +05:30 committed by Tim-Philipp Müller
parent 203b284bab
commit 8144fee47c
3 changed files with 19 additions and 0 deletions

View file

@ -562,6 +562,15 @@ mpeg_util_parse_sequence_hdr (MPEGSeqHdr * hdr, guint8 * data, guint8 * end)
fps_idx = code & 0xf;
set_fps_from_code (hdr, fps_idx);
hdr->bitrate = ((data[6] >> 6) | (data[5] << 2) | (data[4] << 10));
if (hdr->bitrate == 0x3ffff) {
/* VBR stream */
hdr->bitrate = 0;
} else {
/* Value in header is in units of 400 bps */
hdr->bitrate *= 400;
}
constrained_flag = (data[7] >> 2) & 0x01;
load_intra_flag = (data[7] >> 1) & 0x01;
if (load_intra_flag) {

View file

@ -76,6 +76,8 @@ struct MPEGSeqHdr
gint width, height;
/* Framerate */
gint fps_n, fps_d;
/* Bitrate */
guint bitrate;
gboolean progressive;
};

View file

@ -275,6 +275,14 @@ mpegvideoparse_handle_sequence (MpegVideoParse * mpegvideoparse,
}
gst_caps_unref (caps);
if (new_hdr.bitrate > 0) {
GstTagList *taglist;
taglist = gst_tag_list_new_full (GST_TAG_BITRATE, new_hdr.bitrate, NULL);
gst_element_found_tags_for_pad (GST_ELEMENT_CAST (mpegvideoparse),
mpegvideoparse->srcpad, taglist);
}
/* And update the new_hdr into our stored version */
mpegvideoparse->seq_hdr = new_hdr;
}