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.
This commit is contained in:
Paul B Mahol 2013-05-30 19:57:47 +00:00
parent 2886e8065e
commit c4e0e31424
3 changed files with 13 additions and 28 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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, \