From: nu774 <[email protected]>

14496-3 suggests packing main_data of MP3 that is usually scatttered into
multiple frames due to bit reservoir.
However, after packing main_data into a access unit, bitrate index in the
MPEG audio frame header doesn't match with actual frame size.
In order to accept this, this patch removes unnecessary frame size checking
on mp3 decoder.
Also, mov demuxer was changed to use MP3 parser only on special cases
(QT MOV with specific sample description) to avoid re-packetizing.

Signed-off-by: Luca Barbato <[email protected]>
---

Eventually got around uploading the updated file to fate, patch eventually
merged in a while.

 libavcodec/mpegaudiodec_template.c |  7 -------
 libavformat/mov.c                  | 10 +++++++++-
 tests/fate/mp3.mak                 |  2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mpegaudiodec_template.c 
b/libavcodec/mpegaudiodec_template.c
index 08dd18b..293316b 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -1647,13 +1647,6 @@ static int decode_frame(AVCodecContext * avctx, void 
*data, int *got_frame_ptr,
     if (!avctx->bit_rate)
         avctx->bit_rate = s->bit_rate;

-    if (s->frame_size <= 0 || s->frame_size > buf_size) {
-        av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
-        return AVERROR_INVALIDDATA;
-    } else if (s->frame_size < buf_size) {
-        buf_size= s->frame_size;
-    }
-
     s->frame = data;

     ret = mp_decode_frame(s, NULL, buf, buf_size);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index f603446..b922579 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1519,6 +1519,15 @@ static void mov_parse_stsd_audio(MOVContext *c, 
AVIOContext *pb,
                     ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample,
                                              flags);
         }
+        if (version == 0 || (version == 1 && sc->audio_cid != -2)) {
+            /* can't correctly handle variable sized packet as audio unit */
+            switch (st->codec->codec_id) {
+            case AV_CODEC_ID_MP2:
+            case AV_CODEC_ID_MP3:
+                st->need_parsing = AVSTREAM_PARSE_FULL;
+                break;
+            }
+        }
     }

     switch (st->codec->codec_id) {
@@ -1695,7 +1704,6 @@ static int mov_finalize_stsd_codec(MOVContext *c, 
AVIOContext *pb,
     case AV_CODEC_ID_MP3:
         /* force type after stsd for m1a hdlr */
         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-        st->need_parsing      = AVSTREAM_PARSE_FULL;
         break;
     case AV_CODEC_ID_GSM:
     case AV_CODEC_ID_ADPCM_MS:
diff --git a/tests/fate/mp3.mak b/tests/fate/mp3.mak
index fe6a0e1..3442ce1 100644
--- a/tests/fate/mp3.mak
+++ b/tests/fate/mp3.mak
@@ -1,6 +1,6 @@
 FATE_MP3 += fate-mp3-float-conf-compl
 fate-mp3-float-conf-compl: CMD = pcm -acodec mp3float -i 
$(TARGET_SAMPLES)/mp3-conformance/compl.bit
-fate-mp3-float-conf-compl: REF = $(SAMPLES)/mp3-conformance/compl.pcm
+fate-mp3-float-conf-compl: REF = $(SAMPLES)/mp3-conformance/compl_2.pcm

 FATE_MP3 += fate-mp3-float-conf-he_32khz
 fate-mp3-float-conf-he_32khz: CMD = pcm -acodec mp3float -i 
$(TARGET_SAMPLES)/mp3-conformance/he_32khz.bit -fs 343296
--
1.9.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to