[FFmpeg-cvslog] wavdec: fix duration calculation for files with invalid data size

James Almer git at videolan.org
Sat Dec 29 18:49:23 CET 2012


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Dec 27 19:30:40 2012 -0300| [d59d39e1642569b68249c922ae01a59bfe52747b] | committer: 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: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d59d39e1642569b68249c922ae01a59bfe52747b
---

 libavformat/wavdec.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 62bf263..9d09865 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -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;



More information about the ffmpeg-cvslog mailing list