[FFmpeg-devel] [PATCH 1/2] lavf: try reading id3v1 header for all formats

Anton Khirnov anton
Mon Nov 29 09:41:51 CET 2010


similarly to id3v2 case, id3v1 headers can be found on anything, so it
makes sense to check for their presence if the file is seekable and no
other metadata was found.
---
 libavformat/aacdec.c |    3 ---
 libavformat/mp3.c    |    3 ---
 libavformat/tta.c    |    4 ----
 libavformat/utils.c  |    8 ++++++++
 libavformat/wv.c     |    3 ---
 5 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index 64ac3d1..a712e20 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -23,7 +23,6 @@
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "rawdec.h"
-#include "id3v1.h"
 
 
 static int adts_aac_probe(AVProbeData *p)
@@ -73,8 +72,6 @@ static int adts_aac_read_header(AVFormatContext *s,
     st->codec->codec_id = s->iformat->value;
     st->need_parsing = AVSTREAM_PARSE_FULL;
 
-    ff_id3v1_read(s);
-
     //LCM of all possible ADTS sample rates
     av_set_pts_info(st, 64, 1, 28224000);
 
diff --git a/libavformat/mp3.c b/libavformat/mp3.c
index ceba2ce..61a04b1 100644
--- a/libavformat/mp3.c
+++ b/libavformat/mp3.c
@@ -155,9 +155,6 @@ static int mp3_read_header(AVFormatContext *s,
 
     off = url_ftell(s->pb);
 
-    if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
-        ff_id3v1_read(s);
-
     if (mp3_parse_vbr_tags(s, st, off) < 0)
         url_fseek(s->pb, off, SEEK_SET);
 
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 64ed4d8..b4fe684 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -21,7 +21,6 @@
 
 #include "libavcodec/get_bits.h"
 #include "avformat.h"
-#include "id3v1.h"
 
 typedef struct {
     int totalframes, currentframe;
@@ -43,9 +42,6 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
     int i, channels, bps, samplerate, datalen, framelen;
     uint64_t framepos, start_offset;
 
-    if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
-        ff_id3v1_read(s);
-
     start_offset = url_ftell(s->pb);
     if (get_le32(s->pb) != AV_RL32("TTA1"))
         return -1; // not tta file
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 44d1c62..77c98b8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -24,6 +24,7 @@
 #include "libavutil/opt.h"
 #include "metadata.h"
 #include "id3v2.h"
+#include "id3v1.h"
 #include "libavutil/avstring.h"
 #include "riff.h"
 #include "audiointerleave.h"
@@ -487,6 +488,13 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
             goto fail;
     }
 
+    if (pb && !url_is_streamed(pb) && !av_metadata_get(ic->metadata, "", NULL,
+                                                       AV_METADATA_IGNORE_SUFFIX)) {
+        int64_t off = url_ftell(pb);
+        ff_id3v1_read(ic);
+        url_fseek(pb, off, SEEK_SET);
+    }
+
     if (pb && !ic->data_offset)
         ic->data_offset = url_ftell(ic->pb);
 
diff --git a/libavformat/wv.c b/libavformat/wv.c
index 03b864b..08c91cd 100644
--- a/libavformat/wv.c
+++ b/libavformat/wv.c
@@ -22,7 +22,6 @@
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "apetag.h"
-#include "id3v1.h"
 
 // specs say that maximum block size is 1Mb
 #define WV_BLOCK_LIMIT 1047576
@@ -174,8 +173,6 @@ static int wv_read_header(AVFormatContext *s,
     if(!url_is_streamed(s->pb)) {
         int64_t cur = url_ftell(s->pb);
         ff_ape_parse_tag(s);
-        if(!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX))
-            ff_id3v1_read(s);
         url_fseek(s->pb, cur, SEEK_SET);
     }
 
-- 
1.7.2.3




More information about the ffmpeg-devel mailing list