summaryrefslogtreecommitdiff
path: root/libavformat/tta.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-04 02:03:25 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-04 04:26:04 +0100
commit15c6be8c7da7b94b5e131396e9a82ab6fe4a6b64 (patch)
tree84db7f4851faba26561f846b4f112ef64d01b3ad /libavformat/tta.c
parentf972193a15026a99eb2b08e7913a03f2123663da (diff)
parentb7beabab4b78cc253d06c0a33f15b8ff79866e85 (diff)
downloadffmpeg-15c6be8c7da7b94b5e131396e9a82ab6fe4a6b64.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: tiertexseq: set correct block_align for audio tiertexseq: set audio stream start time to 0 voc/avs: Do not change the sample rate mid-stream. segafilm: use the sample rate as the time base for audio streams ea: fix audio pts psx-str: fix audio pts vqf: set packet duration tta demuxer: set packet duration mpegaudio_parser: do not ignore information from the first parsed frame mpegaudio_parser: be less picky about the start position thp: set audio packet durations avcodec: add a Vorbis parser to get packet duration vorbisdec: read the previous window flag for long windows lavc: free the output packet when encoding failed or produced no output. lavc: preserve avpkt->destruct in ff_alloc_packet(). lavc: clarify the meaning of AVCodecContext.frame_number. mpegts: Pad the packet buffer in handle_packet(). mpegts: Do not call read_sl_header() when no bytes remain in the buffer. Conflicts: libavcodec/mpegaudio_parser.c libavcodec/version.h libavformat/mpegts.c tests/ref/fate/pva-demux Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/tta.c')
-rw-r--r--libavformat/tta.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libavformat/tta.c b/libavformat/tta.c
index c2f0902535..9c31432b7b 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -27,6 +27,8 @@
typedef struct {
int totalframes, currentframe;
+ int frame_size;
+ int last_frame_size;
} TTAContext;
static int tta_probe(AVProbeData *p)
@@ -42,7 +44,7 @@ static int tta_read_header(AVFormatContext *s)
{
TTAContext *c = s->priv_data;
AVStream *st;
- int i, channels, bps, samplerate, datalen, framelen;
+ int i, channels, bps, samplerate, datalen;
uint64_t framepos, start_offset;
if (!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX))
@@ -69,8 +71,11 @@ static int tta_read_header(AVFormatContext *s)
avio_skip(s->pb, 4); // header crc
- framelen = samplerate*256/245;
- c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0);
+ c->frame_size = samplerate * 256 / 245;
+ c->last_frame_size = datalen % c->frame_size;
+ if (!c->last_frame_size)
+ c->last_frame_size = c->frame_size;
+ c->totalframes = datalen / c->frame_size + (c->last_frame_size < c->frame_size);
c->currentframe = 0;
if(c->totalframes >= UINT_MAX/sizeof(uint32_t) || c->totalframes <= 0){
@@ -90,7 +95,8 @@ static int tta_read_header(AVFormatContext *s)
for (i = 0; i < c->totalframes; i++) {
uint32_t size = avio_rl32(s->pb);
- av_add_index_entry(st, framepos, i*framelen, size, 0, AVINDEX_KEYFRAME);
+ av_add_index_entry(st, framepos, i * c->frame_size, size, 0,
+ AVINDEX_KEYFRAME);
framepos += size;
}
avio_skip(s->pb, 4); // seektable crc
@@ -132,6 +138,8 @@ static int tta_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(s->pb, pkt, size);
pkt->dts = st->index_entries[c->currentframe++].timestamp;
+ pkt->duration = c->currentframe == c->totalframes ? c->last_frame_size :
+ c->frame_size;
return ret;
}