[FFmpeg-cvslog] r20886 - in trunk/libavformat: Makefile tta.c

jai_menon subversion
Wed Dec 16 20:18:48 CET 2009


Author: jai_menon
Date: Wed Dec 16 20:18:48 2009
New Revision: 20886

Log:
Parse ID3v[12] metadata from TTA files.
As a side-effect, this commit also fixes issue 1310.

Modified:
   trunk/libavformat/Makefile
   trunk/libavformat/tta.c

Modified: trunk/libavformat/Makefile
==============================================================================
--- trunk/libavformat/Makefile	Wed Dec 16 18:15:57 2009	(r20885)
+++ trunk/libavformat/Makefile	Wed Dec 16 20:18:48 2009	(r20886)
@@ -228,7 +228,7 @@ OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER)       
 OBJS-$(CONFIG_TMV_DEMUXER)               += tmv.o
 OBJS-$(CONFIG_TRUEHD_DEMUXER)            += raw.o id3v2.o
 OBJS-$(CONFIG_TRUEHD_MUXER)              += raw.o
-OBJS-$(CONFIG_TTA_DEMUXER)               += tta.o
+OBJS-$(CONFIG_TTA_DEMUXER)               += tta.o id3v1.o id3v2.o
 OBJS-$(CONFIG_TXD_DEMUXER)               += txd.o
 OBJS-$(CONFIG_VC1_DEMUXER)               += raw.o
 OBJS-$(CONFIG_VC1T_DEMUXER)              += vc1test.o

Modified: trunk/libavformat/tta.c
==============================================================================
--- trunk/libavformat/tta.c	Wed Dec 16 18:15:57 2009	(r20885)
+++ trunk/libavformat/tta.c	Wed Dec 16 20:18:48 2009	(r20886)
@@ -21,6 +21,8 @@
 
 #include "libavcodec/get_bits.h"
 #include "avformat.h"
+#include "id3v2.h"
+#include "id3v1.h"
 
 typedef struct {
     int totalframes, currentframe;
@@ -29,6 +31,10 @@ typedef struct {
 static int tta_probe(AVProbeData *p)
 {
     const uint8_t *d = p->buf;
+
+    if (ff_id3v2_match(d))
+        d += ff_id3v2_tag_len(d);
+
     if (d[0] == 'T' && d[1] == 'T' && d[2] == 'A' && d[3] == '1')
         return 80;
     return 0;
@@ -39,8 +45,13 @@ static int tta_read_header(AVFormatConte
     TTAContext *c = s->priv_data;
     AVStream *st;
     int i, channels, bps, samplerate, datalen, framelen;
-    uint64_t framepos;
+    uint64_t framepos, start_offset;
 
+    ff_id3v2_read(s);
+    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
 
@@ -93,14 +104,14 @@ static int tta_read_header(AVFormatConte
     st->codec->sample_rate = samplerate;
     st->codec->bits_per_coded_sample = bps;
 
-    st->codec->extradata_size = url_ftell(s->pb);
+    st->codec->extradata_size = url_ftell(s->pb) - start_offset;
     if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
         //this check is redundant as get_buffer should fail
         av_log(s, AV_LOG_ERROR, "extradata_size too large\n");
         return -1;
     }
     st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
-    url_fseek(s->pb, 0, SEEK_SET);
+    url_fseek(s->pb, start_offset, SEEK_SET);
     get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size);
 
     return 0;



More information about the ffmpeg-cvslog mailing list