Mercurial > libavformat.hg
comparison tta.c @ 1969:f7b57a2fa7ca libavformat
argh, who commited this trash
start must be 0 ...
author | michael |
---|---|
date | Fri, 30 Mar 2007 22:10:25 +0000 |
parents | 170e151f1d9e |
children | 363dcd1e64e0 |
comparison
equal
deleted
inserted
replaced
1968:170e151f1d9e | 1969:f7b57a2fa7ca |
---|---|
38 | 38 |
39 static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) | 39 static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) |
40 { | 40 { |
41 TTAContext *c = s->priv_data; | 41 TTAContext *c = s->priv_data; |
42 AVStream *st; | 42 AVStream *st; |
43 int i, channels, bps, samplerate, datalen, framelen, start; | 43 int i, channels, bps, samplerate, datalen, framelen; |
44 | |
45 start = url_ftell(&s->pb); | |
46 | 44 |
47 if (get_le32(&s->pb) != ff_get_fourcc("TTA1")) | 45 if (get_le32(&s->pb) != ff_get_fourcc("TTA1")) |
48 return -1; // not tta file | 46 return -1; // not tta file |
49 | 47 |
50 url_fskip(&s->pb, 2); // FIXME: flags | 48 url_fskip(&s->pb, 2); // FIXME: flags |
88 st->codec->codec_id = CODEC_ID_TTA; | 86 st->codec->codec_id = CODEC_ID_TTA; |
89 st->codec->channels = channels; | 87 st->codec->channels = channels; |
90 st->codec->sample_rate = samplerate; | 88 st->codec->sample_rate = samplerate; |
91 st->codec->bits_per_sample = bps; | 89 st->codec->bits_per_sample = bps; |
92 | 90 |
93 st->codec->extradata_size = url_ftell(&s->pb) - start; | 91 st->codec->extradata_size = url_ftell(&s->pb); |
94 if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ | 92 if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ |
95 //this check is redundant as get_buffer should fail | 93 //this check is redundant as get_buffer should fail |
96 av_log(s, AV_LOG_ERROR, "extradata_size too large\n"); | 94 av_log(s, AV_LOG_ERROR, "extradata_size too large\n"); |
97 return -1; | 95 return -1; |
98 } | 96 } |
99 st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); | 97 st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); |
100 url_fseek(&s->pb, start, SEEK_SET); // or SEEK_CUR and -size ? :) | 98 url_fseek(&s->pb, 0, SEEK_SET); |
101 get_buffer(&s->pb, st->codec->extradata, st->codec->extradata_size); | 99 get_buffer(&s->pb, st->codec->extradata, st->codec->extradata_size); |
102 | 100 |
103 return 0; | 101 return 0; |
104 } | 102 } |
105 | 103 |