diff mov.c @ 2083:2c3887f02739 libavformat

fix ctts index computation when seeking, check must be done against next ctts sample, thanks to Uoti
author bcoudurier
date Sat, 12 May 2007 22:02:27 +0000
parents dc74a26ea890
children f5671ebda7cd
line wrap: on
line diff
--- a/mov.c	Fri May 11 19:07:40 2007 +0000
+++ b/mov.c	Sat May 12 22:02:27 2007 +0000
@@ -1525,12 +1525,13 @@
     if (sc->ctts_data) {
         time_sample = 0;
         for (i = 0; i < sc->ctts_count; i++) {
-            time_sample += sc->ctts_data[i].count;
-            if (time_sample >= sc->current_sample) {
+            int next = time_sample + sc->ctts_data[i].count;
+            if (next > sc->current_sample) {
                 sc->sample_to_ctime_index = i;
-                sc->sample_to_ctime_sample = time_sample - sc->current_sample;
+                sc->sample_to_ctime_sample = sc->current_sample - time_sample;
                 break;
             }
+            time_sample = next;
         }
     }
     return sample;