[FFmpeg-devel] [PATCH] wavdec: do not use invalid data_size to calculate duration

Paul B Mahol onemda at gmail.com
Wed Dec 26 17:04:53 CET 2012


Fixes #2065. Regression since 462b262.

Signed-off-by: Paul B Mahol <onemda at gmail.com>
---

What is wrong with bitrate approach?
---
 libavformat/wavdec.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 62bf263..c25772f 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -220,7 +220,7 @@ static const AVMetadataConv wav_metadata_conv[] = {
 /* wav input */
 static int wav_read_header(AVFormatContext *s)
 {
-    int64_t size, av_uninit(data_size);
+    int64_t size, data_size = 0;
     int64_t sample_count=0;
     int rf64;
     uint32_t tag;
@@ -289,7 +289,8 @@ static int wav_read_header(AVFormatContext *s)
             if (rf64) {
                 next_tag_ofs = wav->data_end = avio_tell(pb) + data_size;
             } else {
-                data_size = size;
+                if (size != 0xFFFFFFFFu)
+                    data_size = size;
                 next_tag_ofs = wav->data_end = size ? next_tag_ofs : INT64_MAX;
             }
 
@@ -365,7 +366,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 && data_size && st->codec->channels && av_get_bits_per_sample(st->codec->codec_id))
         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.7.11.4



More information about the ffmpeg-devel mailing list