* TTA demuxer
* Copyright (c) 2006 Alex Beregszaszi
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
-#define ALT_BITSREAM_READER_LE
#include "bitstream.h"
typedef struct {
static int tta_probe(AVProbeData *p)
{
const uint8_t *d = p->buf;
- if (p->buf_size < 4)
- return 0;
if (d[0] == 'T' && d[1] == 'T' && d[2] == 'A' && d[3] == '1')
return 80;
return 0;
{
TTAContext *c = s->priv_data;
AVStream *st;
- int i, channels, bps, samplerate, datalen, framelen, start;
-
- start = url_ftell(&s->pb);
+ int i, channels, bps, samplerate, datalen, framelen;
if (get_le32(&s->pb) != ff_get_fourcc("TTA1"))
return -1; // not tta file
url_fskip(&s->pb, 4); // header crc
- framelen = 1.04489795918367346939 * samplerate;
+ framelen = samplerate*256/245;
c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0);
c->currentframe = 0;
return AVERROR_NOMEM;
for (i = 0; i < c->totalframes; i++)
- c->seektable[i] = get_le32(&s->pb);
+ c->seektable[i] = get_le32(&s->pb);
url_fskip(&s->pb, 4); // seektable crc
st = av_new_stream(s, 0);
st->codec->sample_rate = samplerate;
st->codec->bits_per_sample = bps;
- st->codec->extradata_size = url_ftell(&s->pb) - start;
+ st->codec->extradata_size = url_ftell(&s->pb);
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, start, SEEK_SET); // or SEEK_CUR and -size ? :)
+ url_fseek(&s->pb, 0, SEEK_SET);
get_buffer(&s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;