[FFmpeg-cvslog] oggdec: simplify start time calculation code.

Reimar Döffinger git at videolan.org
Tue Aug 7 13:45:28 CEST 2012


ffmpeg | branch: release/0.11 | Reimar Döffinger <Reimar.Doeffinger at gmx.de> | Sun Aug  5 09:41:20 2012 +0200| [5231a35559c8c791716fea67db936b7456314f03] | committer: Michael Niedermayer

oggdec: simplify start time calculation code.

Also slightly more correct behaviour in case streams_left for
some reason is 0 from the start.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
(cherry picked from commit a4163b2d6583396845e06b1b976c3a981eb8cb1c)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/oggdec.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 6df4831..5fb13ad 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -525,9 +525,10 @@ static int ogg_get_length(AVFormatContext *s)
     avio_seek (s->pb, s->data_offset, SEEK_SET);
     ogg_reset(s);
     i = -1;
-    while (!ogg_packet(s, &i, NULL, NULL, NULL)) {
-        if(i>=0) {
-        int64_t pts = ogg_calc_pts(s, i, NULL);
+    while (streams_left > 0 && !ogg_packet(s, &i, NULL, NULL, NULL)) {
+        int64_t pts;
+        if (i < 0) continue;
+        pts = ogg_calc_pts(s, i, NULL);
         if (pts != AV_NOPTS_VALUE && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){
             s->streams[i]->duration -= pts;
             ogg->streams[i].got_start= 1;
@@ -536,9 +537,6 @@ static int ogg_get_length(AVFormatContext *s)
             ogg->streams[i].got_start= 1;
             streams_left--;
         }
-        }
-            if(streams_left<=0)
-                break;
     }
     ogg_restore (s, 0);
 



More information about the ffmpeg-cvslog mailing list