]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugins-ugly0-10.git/commitdiff
mp3parse: be more conservative when changing layer/rate/etc.
authorMichael Smith <msmith@songbirdnest.com>
Fri, 6 Mar 2009 20:30:36 +0000 (12:30 -0800)
committerMichael Smith <msmith@songbirdnest.com>
Fri, 6 Mar 2009 21:21:36 +0000 (13:21 -0800)
Don't allow a change in sample rate/channels/layer/version unless we can
see another frame at the correct offset. Prevents accidently flipping
due to simple single-bit corruption.

gst/mpegaudioparse/gstmpegaudioparse.c

index 1747f6082ec144bf4f8528e0b0bb6afae4a012fb..0974eda417d92297a89f31ba6b3f41af0b1b6af7 100644 (file)
@@ -1225,15 +1225,22 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
     if (head_check (mp3parse, header)) {
       guint bitrate = 0, layer = 0, rate = 0, channels = 0, version = 0, mode =
           0, crc = 0;
+      gboolean caps_change = FALSE;
 
       if (!(bpf = mp3_type_frame_length_from_header (mp3parse, header,
                   &version, &layer, &channels, &bitrate, &rate, &mode, &crc)))
         goto header_error;
 
+      if (channels != mp3parse->channels ||
+          rate != mp3parse->rate || layer != mp3parse->layer ||
+          version != mp3parse->version)
+        caps_change = TRUE;
+
       /*************************************************************************
       * robust seek support
       * - This performs additional frame validation if the resyncing flag is set
-      *   (indicating a discontinuous stream).
+      *   (indicating a discontinuous stream), or if the caps are changing 
+      *   (different sample rate, channels, layer, version)
       * - The current frame header is not accepted as valid unless the NEXT 
       *   frame header has the same values for most fields.  This significantly
       *   increases the probability that we aren't processing random data.
@@ -1242,7 +1249,7 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
       *   bitrate from previous frames.  In this case, seeking may be more 
       *   complicated because the frames are not independently coded.
       *************************************************************************/
-      if (mp3parse->resyncing) {
+      if (mp3parse->resyncing || caps_change) {
         guint32 header2;
         const guint8 *data2;
 
@@ -1284,9 +1291,7 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
         break;
       }
 
-      if (channels != mp3parse->channels ||
-          rate != mp3parse->rate || layer != mp3parse->layer ||
-          version != mp3parse->version) {
+      if (caps_change) {
         GstCaps *caps;
 
         caps = mp3_caps_create (version, layer, channels, rate);