Commit d59d39e1 authored by James Almer's avatar James Almer Committed by Paul B Mahol

wavdec: fix duration calculation for files with invalid data size

Some wav files report a data size that is bigger than the actual file size.
Fall back to estimation from bitrate in such cases.

Fixes ticket #2065.
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 981baf74
......@@ -365,7 +365,7 @@ break_loop:
avio_seek(pb, data_ofs, SEEK_SET);
if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id))
if (!sample_count && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id) && wav->data_end <= avio_size(pb))
sample_count = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
if (sample_count)
st->duration = sample_count;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment