]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/oggparseopus.c
Merge commit 'fe80fa53bc4977ef6e8e749a9df8ca5590a09307'
[ffmpeg] / libavformat / oggparseopus.c
index aafefbbe65bac6ce31df70599bd4cde7c077d084..553ddb0b0388df3b8f4895c092090304549b9fbd 100644 (file)
@@ -130,16 +130,13 @@ static int opus_packet(AVFormatContext *avf, int idx)
         duration += d;
         last_pkt = next_pkt =  next_pkt + os->psize;
         for (; seg < os->nsegs; seg++) {
-            if (os->segments[seg] < 255) {
-                int d = opus_duration(last_pkt, os->segments[seg]);
-                if (d < 0) {
-                    duration = os->granule;
-                    break;
-                }
-                duration += d;
-                last_pkt  = next_pkt + os->segments[seg];
-            }
             next_pkt += os->segments[seg];
+            if (os->segments[seg] < 255 && next_pkt != last_pkt) {
+                int d = opus_duration(last_pkt, next_pkt - last_pkt);
+                if (d > 0)
+                    duration += d;
+                last_pkt = next_pkt;
+            }
         }
         os->lastpts                 =
         os->lastdts                 = os->granule - duration;