[FFmpeg-devel] [PATCH 2/3] Round the duration calculation in the aiff demuxer

Benjamin Larsson benjamin
Wed Mar 2 18:28:00 CET 2011


---
 libavformat/aiffdec.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 7b3d1e7..942fb08 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -174,7 +174,7 @@ static int aiff_read_header(AVFormatContext *s,
                             AVFormatParameters *ap)
 {
     int size, filesize;
-    int64_t offset = 0;
+    int64_t offset = 0, rduration;
     uint32_t tag;
     unsigned version = AIFF_C_VERSION1;
     AVIOContext *pb = s->pb;
@@ -272,8 +272,10 @@ got_sound:
 
     av_set_pts_info(st, 64, 1, st->codec->sample_rate);
     st->start_time = 0;
-    st->duration = st->codec->frame_size ?
+    rduration = st->codec->frame_size ?
         st->nb_frames * st->codec->frame_size : st->nb_frames;
+    st->duration = av_rescale_rnd(rduration, 1000, st->codec->sample_rate,
+                                  AV_ROUND_UP) * st->codec->sample_rate/1000;
 
     /* Position the stream at the first block */
     url_fseek(pb, offset, SEEK_SET);
-- 
1.7.1




More information about the ffmpeg-devel mailing list