[FFmpeg-cvslog] avcodec/mp3: fix skipping zeros

wm4 git at videolan.org
Fri Oct 9 22:50:04 CEST 2015


ffmpeg | branch: release/2.3 | wm4 <nfxjfg at googlemail.com> | Wed Sep 30 14:53:35 2015 +0200| [f57a595024d679427946ba92c0c70e65ae2d4342] | committer: Carl Eugen Hoyos

avcodec/mp3: fix skipping zeros

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.
(cherry picked from commit cb1da9fb8d71bb611a7b0028914c97afc3f5711d)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f57a595024d679427946ba92c0c70e65ae2d4342
---

 libavcodec/mpegaudiodec_template.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
index 05237070..90543aa 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -1642,9 +1642,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)
@@ -1699,7 +1701,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)



More information about the ffmpeg-cvslog mailing list