changeset 4285:d8803d0a4274 libavformat

Handle ID3v2 tags in raw FLAC streams by skipping them. Patch by David DeHaven (dave sagetv com)
author jbr
date Sun, 25 Jan 2009 00:16:27 +0000
parents 40c9bef5b4e2
children 2af9d6b4db07
files raw.c
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/raw.c	Sat Jan 24 14:52:46 2009 +0000
+++ b/raw.c	Sun Jan 25 00:16:27 2009 +0000
@@ -289,6 +289,18 @@
     st->codec->codec_id = s->iformat->value;
     st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
+
+    if(st->codec->codec_id == CODEC_ID_FLAC) {
+        /* skip ID3v2 header if found */
+        uint8_t buf[ID3v2_HEADER_SIZE];
+        int ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
+        if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf)) {
+            int len = ff_id3v2_tag_len(buf);
+            url_fseek(s->pb, len - ID3v2_HEADER_SIZE, SEEK_CUR);
+        } else {
+            url_fseek(s->pb, 0, SEEK_SET);
+        }
+    }
     return 0;
 }
 
@@ -573,7 +585,12 @@
 #if CONFIG_FLAC_DEMUXER
 static int flac_probe(AVProbeData *p)
 {
-    if(memcmp(p->buf, "fLaC", 4)) return 0;
+    uint8_t *bufptr = p->buf;
+
+    if(ff_id3v2_match(bufptr))
+        bufptr += ff_id3v2_tag_len(bufptr);
+
+    if(memcmp(bufptr, "fLaC", 4)) return 0;
     else                          return AVPROBE_SCORE_MAX / 2;
 }
 #endif