[FFmpeg-cvslog] tta: remove pointless code

Paul B Mahol git at videolan.org
Thu May 30 22:25:48 CEST 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu May 30 19:57:47 2013 +0000| [c4e0e314248865830ec073e5a3ef08e0a40aabf2] | committer: Paul B Mahol

tta: remove pointless code

Checking seek table crc in decoder is pointless, as seek table is not used in
decoder anyway, so also stop storing seek table into extradata.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c4e0e314248865830ec073e5a3ef08e0a40aabf2
---

 libavcodec/tta.c      |   15 ++-------------
 libavformat/tta.c     |   24 ++++++++++--------------
 libavformat/version.h |    2 +-
 3 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index fd796d9..0de3fe9 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -203,8 +203,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
 
     s->avctx = avctx;
 
-    // 30bytes includes a seektable with one frame
-    if (avctx->extradata_size < 30)
+    // 30bytes includes TTA1 header
+    if (avctx->extradata_size < 22)
         return AVERROR_INVALIDDATA;
 
     init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8);
@@ -278,17 +278,6 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
         av_log(avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n",
             s->data_length, s->frame_length, s->last_frame_length, total_frames);
 
-        // FIXME: seek table
-        if (avctx->extradata_size <= 26 || total_frames > INT_MAX / 4 ||
-            avctx->extradata_size - 26 < total_frames * 4)
-            av_log(avctx, AV_LOG_WARNING, "Seek table missing or too small\n");
-        else if (avctx->err_recognition & AV_EF_CRCCHECK) {
-            if (tta_check_crc(s, avctx->extradata + 22, total_frames * 4))
-                return AVERROR_INVALIDDATA;
-        }
-        skip_bits_long(&s->gb, 32 * total_frames);
-        skip_bits_long(&s->gb, 32); // CRC32 of seektable
-
         if(s->frame_length >= UINT_MAX / (s->channels * sizeof(int32_t))){
             av_log(avctx, AV_LOG_ERROR, "frame_length too large\n");
             return AVERROR_INVALIDDATA;
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 656f914..cb04ff4 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -96,6 +96,16 @@ static int tta_read_header(AVFormatContext *s)
 
     framepos = avio_tell(s->pb) + 4*c->totalframes + 4;
 
+    st->codec->extradata_size = avio_tell(s->pb) - start_offset;
+    st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+    if (!st->codec->extradata) {
+        st->codec->extradata_size = 0;
+        return AVERROR(ENOMEM);
+    }
+
+    avio_seek(s->pb, start_offset, SEEK_SET);
+    avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
+
     for (i = 0; i < c->totalframes; i++) {
         uint32_t size = avio_rl32(s->pb);
         av_add_index_entry(st, framepos, i * c->frame_size, size, 0,
@@ -110,20 +120,6 @@ static int tta_read_header(AVFormatContext *s)
     st->codec->sample_rate = samplerate;
     st->codec->bits_per_coded_sample = bps;
 
-    st->codec->extradata_size = avio_tell(s->pb) - start_offset;
-    if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
-        //this check is redundant as avio_read 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);
-    if (!st->codec->extradata) {
-        st->codec->extradata_size = 0;
-        return AVERROR(ENOMEM);
-    }
-    avio_seek(s->pb, start_offset, SEEK_SET);
-    avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
-
     return 0;
 }
 
diff --git a/libavformat/version.h b/libavformat/version.h
index 3c0afbb..8517fb1 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 55
 #define LIBAVFORMAT_VERSION_MINOR  8
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list