aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/wav.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2003-11-10 18:44:27 +0000
committerFabrice Bellard <fabrice@bellard.org>2003-11-10 18:44:27 +0000
commitf9b5459e7925d2bf04aabb1bae93d94b01662e44 (patch)
tree55ec6a39785225f0692d1c78b784bc5be3d89d84 /libavformat/wav.c
parent8e38ff0c07752ad6343b2c64197f7cc990f1869b (diff)
downloadffmpeg-f9b5459e7925d2bf04aabb1bae93d94b01662e44.tar.gz
seeking support - fixed some ADPCM decoding cases
Originally committed as revision 2500 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/wav.c')
-rw-r--r--libavformat/wav.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/libavformat/wav.c b/libavformat/wav.c
index 41bae1205d..22e605fb48 100644
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -132,7 +132,7 @@ void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size)
}else
codec->bits_per_sample = get_le16(pb);
codec->codec_id = wav_codec_get_id(id, codec->bits_per_sample);
-
+
if (size > 16) { /* We're obviously dealing with WAVEFORMATEX */
codec->extradata_size = get_le16(pb);
if (codec->extradata_size > 0) {
@@ -285,6 +285,7 @@ static int wav_read_header(AVFormatContext *s,
return AVERROR_NOMEM;
get_wav_header(pb, &st->codec, size);
+ st->need_parsing = 1;
size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
if (size < 0)
@@ -297,11 +298,20 @@ static int wav_read_header(AVFormatContext *s,
static int wav_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
- int ret;
+ int ret, size;
+ AVStream *st;
if (url_feof(&s->pb))
return -EIO;
- if (av_new_packet(pkt, MAX_SIZE))
+ st = s->streams[0];
+
+ size = MAX_SIZE;
+ if (st->codec.block_align > 1) {
+ if (size < st->codec.block_align)
+ size = st->codec.block_align;
+ size = (size / st->codec.block_align) * st->codec.block_align;
+ }
+ if (av_new_packet(pkt, size))
return -EIO;
pkt->stream_index = 0;
@@ -319,6 +329,25 @@ static int wav_read_close(AVFormatContext *s)
return 0;
}
+static int wav_read_seek(AVFormatContext *s,
+ int stream_index, int64_t timestamp)
+{
+ AVStream *st;
+
+ st = s->streams[0];
+ switch(st->codec.codec_id) {
+ case CODEC_ID_MP2:
+ case CODEC_ID_MP3:
+ case CODEC_ID_AC3:
+ /* use generic seeking with dynamically generated indexes */
+ return -1;
+ default:
+ break;
+ }
+ return pcm_read_seek(s, stream_index, timestamp);
+}
+
+
static AVInputFormat wav_iformat = {
"wav",
"wav format",
@@ -327,6 +356,7 @@ static AVInputFormat wav_iformat = {
wav_read_header,
wav_read_packet,
wav_read_close,
+ wav_read_seek,
};
#ifdef CONFIG_ENCODERS