[FFmpeg-devel] [PATCH] Move ID3v1 skip from decoder to demuxer

Clément Bœsch ubitux
Fri Jan 21 22:22:21 CET 2011


Hi,

Skipping id3v1 tag in the decoder seems not the appropriate place (beside
the inappropriate libavformat include). This patch moves the code to the
demuxer (and slightly improve the header comparison)

BTW, everything goes fine by running fate locally.

Regards,

-- 
Cl?ment B.
-------------- next part --------------
>From 7dac4b3fc1eede620c54ed8218588ed8b4e902d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Fri, 21 Jan 2011 20:40:22 +0100
Subject: [PATCH] mp3: move ID3v1 skip from decoder to demuxer

---
 libavcodec/mpegaudiodec.c |    8 --------
 libavformat/mp3dec.c      |    8 ++++++++
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index 76fdffb..769be89 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -27,7 +27,6 @@
 #include "avcodec.h"
 #include "get_bits.h"
 #include "dsputil.h"
-#include "libavformat/id3v1.h"
 
 /*
  * TODO:
@@ -2044,13 +2043,6 @@ static int decode_frame(AVCodecContext * avctx,
 
     header = AV_RB32(buf);
     if(ff_mpa_check_header(header) < 0){
-
-        if (buf_size == ID3v1_TAG_SIZE
-            && buf[0] == 'T' && buf[1] == 'A' && buf[2] == 'G') {
-            *data_size = 0;
-            return ID3v1_TAG_SIZE;
-        }
-
         av_log(avctx, AV_LOG_ERROR, "Header missing\n");
         return -1;
     }
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index ab6aabe..225716c 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -174,6 +174,14 @@ static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
     if (ret <= 0) {
         return AVERROR(EIO);
     }
+
+    if (ret > ID3v1_TAG_SIZE) {
+        uint8_t *buf = &pkt->data[ret - ID3v1_TAG_SIZE];
+        uint32_t v = AV_RB24(buf);
+        if (v == MKBETAG(0, 'T', 'A', 'G'))
+            ret -= ID3v1_TAG_SIZE;
+    }
+
     /* note: we need to modify the packet size here to handle the last
        packet */
     pkt->size = ret;
-- 
1.7.3.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110121/a1b856d9/attachment.pgp>



More information about the ffmpeg-devel mailing list