[FFmpeg-cvslog] oggtheora: Port changes from oggvorbis timestamp handling.

Michael Niedermayer git at videolan.org
Sat May 5 00:01:37 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri May  4 22:54:35 2012 +0200| [b18c9f1eb024abd239c16636f1ef3a9a02d6f262] | committer: Michael Niedermayer

oggtheora: Port changes from oggvorbis timestamp handling.

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

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

 libavformat/oggparsetheora.c |   29 ++++++++++++-----------------
 1 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index 3b7e853..d646efc 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -162,26 +162,21 @@ static int theora_packet(AVFormatContext *s, int idx)
        the total duration to the page granule to find the encoder delay and
        set the first timestamp */
 
-    if (!os->lastpts) {
+    if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
         int seg;
-        uint8_t *last_pkt = os->buf + os->pstart;
-        uint8_t *next_pkt = last_pkt;
-        int first_duration = 0;
-
-        duration = 0;
-        for (seg = 0; seg < os->nsegs; seg++) {
-            if (os->segments[seg] < 255) {
-                if (!duration)
-                    first_duration = 1;
-                duration++;
-                last_pkt = next_pkt + os->segments[seg];
-            }
-            next_pkt += os->segments[seg];
+
+        duration = 1;
+        for (seg = os->segp; seg < os->nsegs; seg++) {
+            if (os->segments[seg] < 255)
+                duration ++;
         }
+
         os->lastpts = os->lastdts   = theora_gptopts(s, idx, os->granule, NULL) - duration;
-        s->streams[idx]->start_time = os->lastpts + first_duration;
-        if (s->streams[idx]->duration)
-            s->streams[idx]->duration -= s->streams[idx]->start_time;
+        if(s->streams[idx]->start_time == AV_NOPTS_VALUE) {
+            s->streams[idx]->start_time = os->lastpts;
+            if (s->streams[idx]->duration)
+                s->streams[idx]->duration -= s->streams[idx]->start_time;
+        }
     }
 
     /* parse packet duration */



More information about the ffmpeg-cvslog mailing list