[FFmpeg-devel] [PATCH] wavdec: Fix duration calculation for files with invalid data size
James Almer
jamrial at gmail.com
Thu Dec 27 23:40:36 CET 2012
Hello.
The attached patch fixes ticket #2065 for me.
Regards.
-------------- next part --------------
>From dbe48876602fcc68e03604a8ff128a0a96617f72 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial at gmail.com>
Date: Thu, 27 Dec 2012 19:30:40 -0300
Subject: [PATCH] wavdec: Fix duration calculation for files with invalid data size
Fixes ticket #2065
Some wav files report a data size that is bigger than the actual file size.
Fall back to estimation from bitrate in such cases.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/wavdec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 62bf263..2ba60d6 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -365,7 +365,8 @@ 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;
--
1.8.0.msysgit.0
More information about the ffmpeg-devel
mailing list