diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-01-15 16:26:42 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-01-15 16:26:42 +0000 |
commit | 462b26202bc167c52159bcf409c0955bfa37134b (patch) | |
tree | 6228da63627bf35c05ea01ae7efe7938bf4c0728 /libavformat/wav.c | |
parent | 13184036a6b1b1d4b61c91118c0896e9ad4634c3 (diff) | |
download | ffmpeg-462b26202bc167c52159bcf409c0955bfa37134b.tar.gz |
Set duration for wav files from sample size and data size or the wf64 sample value.
This should improve duration accuracy slightly and avoids a warning about its
inaccuracy when accurate values are available. Idea by Frank Barchard
Originally committed as revision 26366 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/wav.c')
-rw-r--r-- | libavformat/wav.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/wav.c b/libavformat/wav.c index ca687a3adb..903bc72747 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -183,6 +183,7 @@ static int wav_read_header(AVFormatContext *s, AVFormatParameters *ap) { int64_t size, av_uninit(data_size); + int64_t sample_count=0; int rf64; unsigned int tag; ByteIOContext *pb = s->pb; @@ -208,6 +209,7 @@ static int wav_read_header(AVFormatContext *s, return -1; get_le64(pb); /* RIFF size */ data_size = get_le64(pb); + sample_count = get_le64(pb); url_fskip(pb, size - 16); /* skip rest of ds64 chunk */ } @@ -233,6 +235,11 @@ static int wav_read_header(AVFormatContext *s, wav->data_end = INT64_MAX; } else wav->data_end= url_ftell(pb) + size; + + if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id)) + sample_count = (size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id)); + if (sample_count) + st->duration = sample_count; return 0; } |