From: Arun Raghavan Date: Tue, 8 Feb 2011 18:20:13 +0000 (+0530) Subject: mpegaudioparse: Post CBR bitrate as nominal bitrate X-Git-Tag: RELEASE-0.10.29~264 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7f4a61b56c8e6cf0b9fa0600adf6adb4cba67838;p=platform%2Fupstream%2Fgst-plugins-good.git 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 --- diff --git a/gst/audioparsers/gstmpegaudioparse.c b/gst/audioparsers/gstmpegaudioparse.c index d95f8ae..b9ad66a 100644 --- a/gst/audioparsers/gstmpegaudioparse.c +++ b/gst/audioparsers/gstmpegaudioparse.c @@ -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); diff --git a/gst/audioparsers/gstmpegaudioparse.h b/gst/audioparsers/gstmpegaudioparse.h index 0b4dad7..cf5fd37 100644 --- a/gst/audioparsers/gstmpegaudioparse.h +++ b/gst/audioparsers/gstmpegaudioparse.h @@ -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;