From 736851264b7998c0e390f208a2438a1493bdf994 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 9 Oct 2013 21:43:06 +0200 Subject: [PATCH] avformat/wavdec: Dont trust the fact chunk for PCM Fixes Ticket3033 Signed-off-by: Michael Niedermayer (cherry picked from commit 83fc6c822b06688e572333299927d93eb3c6c426) --- libavformat/wavdec.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 23c3b9e555..64dd8678b1 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -396,11 +396,15 @@ break_loop: avio_seek(pb, data_ofs, SEEK_SET); - 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 || av_get_exact_bits_per_sample(st->codec->codec_id) > 0) + if ( st->codec->channels + && data_size + && 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;