mpegaudioparse: Post CBR bitrate as nominal bitrate

Even if VBR headers are missing, we can't guarantee that a stream is in
fact a CBR stream, so it's safer to let baseparse calculate the average
bitrate rather than assume a CBR stream. However, in order to make
/some/ metadata available before the requisite number of frames have
been parsed, this posts the bitrate from the non-VBR headers as the
nominal bitrate.

https://bugzilla.gnome.org/show_bug.cgi?id=641858
This commit is contained in:
Arun Raghavan 2011-02-08 23:50:13 +05:30 committed by Tim-Philipp Müller
parent cc1b5ded6d
commit 7f4a61b56c
2 changed files with 14 additions and 0 deletions

View file

@ -189,6 +189,8 @@ gst_mpeg_audio_parse_reset (GstMpegAudioParse * mp3parse)
mp3parse->last_posted_crc = CRC_UNKNOWN;
mp3parse->last_posted_channel_mode = MPEG_AUDIO_CHANNEL_MODE_UNKNOWN;
mp3parse->hdr_bitrate = 0;
mp3parse->xing_flags = 0;
mp3parse->xing_bitrate = 0;
mp3parse->xing_frames = 0;
@ -958,6 +960,8 @@ gst_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
(version == 1) ? 10 : 30, 2);
}
mp3parse->hdr_bitrate = bitrate;
/* For first frame; check for seek tables and output a codec tag */
gst_mpeg_audio_parse_handle_first_frame (mp3parse, buf);
@ -1148,6 +1152,13 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse,
taglist = gst_tag_list_new ();
gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_AUDIO_CODEC, codec, NULL);
if (mp3parse->hdr_bitrate > 0 && mp3parse->xing_bitrate == 0 &&
mp3parse->vbri_bitrate == 0) {
/* We don't have a VBR bitrate, so post the available bitrate as
* nominal and let baseparse calculate the real bitrate */
gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_NOMINAL_BITRATE, mp3parse->hdr_bitrate, NULL);
}
gst_element_found_tags_for_pad (GST_ELEMENT (mp3parse),
GST_BASE_PARSE_SRC_PAD (mp3parse), taglist);
g_free (codec);

View file

@ -65,6 +65,9 @@ struct _GstMpegAudioParse {
gint last_posted_crc, last_crc;
guint last_posted_channel_mode, last_mode;
/* Bitrate from non-vbr headers */
guint32 hdr_bitrate;
/* Xing info */
guint32 xing_flags;
guint32 xing_frames;