[FFmpeg-cvslog] mp3dec: replace avpriv_mpa_decode_header with avpriv_mpegaudio_decode_header

Anton Khirnov git at videolan.org
Fri Jan 1 16:58:06 CET 2016


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Jan  2 09:49:20 2015 +0100| [72d658766e6ccf198317dffd6499c5e288847a1c] | committer: Anton Khirnov

mp3dec: replace avpriv_mpa_decode_header with avpriv_mpegaudio_decode_header

The latter does not require a full AVCodecContext and still provides all
the functionality needed here.

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

 libavformat/mp3dec.c |   17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 8904797..fd2c695 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -53,13 +53,9 @@ typedef struct MP3DecContext {
 static int mp3_read_probe(AVProbeData *p)
 {
     int max_frames, first_frames = 0;
-    int fsize, frames, sample_rate;
+    int frames, ret;
     uint32_t header;
     uint8_t *buf, *buf0, *buf2, *end;
-    AVCodecContext *avctx = avcodec_alloc_context3(NULL);
-
-    if (!avctx)
-        return AVERROR(ENOMEM);
 
     buf0 = p->buf;
     end = p->buf + p->buf_size - sizeof(uint32_t);
@@ -73,19 +69,18 @@ static int mp3_read_probe(AVProbeData *p)
         buf2 = buf;
 
         for(frames = 0; buf2 < end; frames++) {
+            MPADecodeHeader h;
+
             header = AV_RB32(buf2);
-            fsize = avpriv_mpa_decode_header(avctx, header, &sample_rate,
-                                             &sample_rate, &sample_rate,
-                                             &sample_rate);
-            if(fsize < 0)
+            ret = avpriv_mpegaudio_decode_header(&h, header);
+            if (ret != 0)
                 break;
-            buf2 += fsize;
+            buf2 += h.frame_size;
         }
         max_frames = FFMAX(max_frames, frames);
         if(buf == buf0)
             first_frames= frames;
     }
-    avcodec_free_context(&avctx);
     // keep this in sync with ac3 probe, both need to avoid
     // issues with MPEG-files!
     if (first_frames >= 10)



More information about the ffmpeg-cvslog mailing list