From 8aed3176ce65a1963d1b2bea8b9ed110714ca4e2 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Tue, 6 Jul 2010 13:21:19 +0530 Subject: [PATCH] qtdemux: Fix order of bitrates in 'btrt' atom There seems to be a bug in libmp4v2 that generates a MPEG4BitRateBox as (bufferSizeDB, avgBitrate, maxBitrate) instead of (bufferSizeDB, maxBitrate, avgBitrate), according to the spec. I used the mp4file output while writing this code, so the order is wrong. This patches fixes that. https://bugzilla.gnome.org/show_bug.cgi?id=623654 --- gst/qtdemux/qtdemux.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index b9626ed2dd..979497d4b5 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -5385,12 +5385,21 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) if (size < 12) break; - max_bitrate = QT_UINT32 (avc_data + 0xc); - avg_bitrate = QT_UINT32 (avc_data + 0x10); + max_bitrate = QT_UINT32 (avc_data + 0x10); + avg_bitrate = QT_UINT32 (avc_data + 0xc); if (!max_bitrate && !avg_bitrate) break; + /* Some muxers seem to swap the average and maximum bitrates + * (I'm looking at you, YouTube), so we swap for sanity. */ + if (max_bitrate > 0 && max_bitrate < avg_bitrate) { + guint temp = avg_bitrate; + + avg_bitrate = max_bitrate; + max_bitrate = temp; + } + if (!list) list = gst_tag_list_new ();