From cd2ffb67ad9e9fec1766c501ad33e85dc934eeed Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 20 Mar 2012 11:20:54 -0400 Subject: xa: fix timestamp calculation The packet duration is always 28 samples. --- libavformat/xa.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'libavformat/xa.c') diff --git a/libavformat/xa.c b/libavformat/xa.c index c5e5cf5864..82b703f8c5 100644 --- a/libavformat/xa.c +++ b/libavformat/xa.c @@ -38,7 +38,6 @@ typedef struct MaxisXADemuxContext { uint32_t out_size; uint32_t sent_bytes; - uint32_t audio_frame_counter; } MaxisXADemuxContext; static int xa_probe(AVProbeData *p) @@ -87,6 +86,7 @@ static int xa_read_header(AVFormatContext *s) st->codec->bits_per_coded_sample = avio_rl16(pb); avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); + st->start_time = 0; return 0; } @@ -111,9 +111,7 @@ static int xa_read_packet(AVFormatContext *s, pkt->stream_index = st->index; xa->sent_bytes += packet_size; - pkt->pts = xa->audio_frame_counter; - /* 14 bytes Samples per channel with 2 samples per byte */ - xa->audio_frame_counter += 28 * st->codec->channels; + pkt->duration = 28; return ret; } -- cgit v1.2.3 From 64de57f64515001225ec8d8d6b3a7d567fc9cdcd Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 20 Mar 2012 11:53:56 -0400 Subject: xa: fix end-of-file handling Do not output an extra packet when out_size is reached. Also return AVERROR_EOF instead of AVERROR(EIO). --- libavformat/xa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libavformat/xa.c') diff --git a/libavformat/xa.c b/libavformat/xa.c index 82b703f8c5..aacdd2b62d 100644 --- a/libavformat/xa.c +++ b/libavformat/xa.c @@ -100,8 +100,8 @@ static int xa_read_packet(AVFormatContext *s, unsigned int packet_size; int ret; - if(xa->sent_bytes > xa->out_size) - return AVERROR(EIO); + if (xa->sent_bytes >= xa->out_size) + return AVERROR_EOF; /* 1 byte header and 14 bytes worth of samples * number channels per block */ packet_size = 15*st->codec->channels; -- cgit v1.2.3 From a54bc52265b9b42e0735507f3b28cfb49a9d3c62 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 20 Mar 2012 12:00:00 -0400 Subject: xa: do not set bit_rate, block_align, or bits_per_coded_sample The values in the header refer to decoded data, not compressed data. --- libavformat/xa.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libavformat/xa.c') diff --git a/libavformat/xa.c b/libavformat/xa.c index aacdd2b62d..4cec2dae88 100644 --- a/libavformat/xa.c +++ b/libavformat/xa.c @@ -80,10 +80,9 @@ static int xa_read_header(AVFormatContext *s) avio_skip(pb, 2); /* Skip the tag */ st->codec->channels = avio_rl16(pb); st->codec->sample_rate = avio_rl32(pb); - /* Value in file is average byte rate*/ - st->codec->bit_rate = avio_rl32(pb) * 8; - st->codec->block_align = avio_rl16(pb); - st->codec->bits_per_coded_sample = avio_rl16(pb); + avio_skip(pb, 4); /* Skip average byte rate */ + avio_skip(pb, 2); /* Skip block align */ + avio_skip(pb, 2); /* Skip bits-per-sample */ avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); st->start_time = 0; -- cgit v1.2.3 From 777365fe8602d4b92e2664647d0e5fe2418d4bf6 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 20 Mar 2012 12:13:15 -0400 Subject: xa: set correct bit rate Also fixes stream duration calculation. --- libavformat/xa.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libavformat/xa.c') diff --git a/libavformat/xa.c b/libavformat/xa.c index 4cec2dae88..09ef17ff35 100644 --- a/libavformat/xa.c +++ b/libavformat/xa.c @@ -84,6 +84,9 @@ static int xa_read_header(AVFormatContext *s) avio_skip(pb, 2); /* Skip block align */ avio_skip(pb, 2); /* Skip bits-per-sample */ + st->codec->bit_rate = av_clip(15LL * st->codec->channels * 8 * + st->codec->sample_rate / 28, 0, INT_MAX); + avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); st->start_time = 0; -- cgit v1.2.3