]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/mp3: fix skipping zeros
authorwm4 <nfxjfg@googlemail.com>
Wed, 30 Sep 2015 12:53:35 +0000 (14:53 +0200)
committerwm4 <nfxjfg@googlemail.com>
Wed, 30 Sep 2015 13:57:41 +0000 (15:57 +0200)
Commits 43bc5cf9 and c5371f77 add code for skipping initial zeros in mp3
packets. This code forgot to report to the user that data was skipped at
all.

Since audio codecs allow partial packet decoding, the user application
has to rely on the return value. It will remove the data reported as
consumed by the decoder, and feed it to the decoder again. This resulted
in the mp3 frame after the zero region to be decoded over and over
again, until the zero region was finally skipped by the application.

Fix this by including the amount of skipped bytes to the number of
consumed bytes returned by the decode call.

Fixes trac ticket #4890.

libavcodec/mpegaudiodec_template.c

index b7b9dbdfee05dc4cc1772493fe3adfc1241b2ab9..0f32ac7b515d194c14b7d6a0e2026262e0d86c8e 100644 (file)
@@ -1657,9 +1657,11 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
     uint32_t header;
     int ret;
 
+    int skipped = 0;
     while(buf_size && !*buf){
         buf++;
         buf_size--;
+        skipped++;
     }
 
     if (buf_size < HEADER_SIZE)
@@ -1714,7 +1716,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
             return ret;
     }
     s->frame_size = 0;
-    return buf_size;
+    return buf_size + skipped;
 }
 
 static void mp_flush(MPADecodeContext *ctx)