diff matroska.c @ 1914:511723932287 libavformat

calculate pts for laced packets
author aurel
date Tue, 13 Mar 2007 00:10:52 +0000
parents 1c1df2f4090b
children b3a5ffd3bc99
line wrap: on
line diff
--- a/matroska.c	Tue Mar 13 00:02:55 2007 +0000
+++ b/matroska.c	Tue Mar 13 00:10:52 2007 +0000
@@ -2427,7 +2427,7 @@
 
 static int
 matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size,
-                     int64_t pos, uint64_t cluster_time,
+                     int64_t pos, uint64_t cluster_time, uint64_t duration,
                      int is_keyframe, int is_bframe,
                      int *ptrack, AVPacket **ppkt)
 {
@@ -2462,6 +2462,8 @@
         av_free(origdata);
         return res;
     }
+    if (duration == AV_NOPTS_VALUE)
+        duration = matroska->tracks[track]->default_duration;
 
     /* block_time (relative to cluster time) */
     block_time = (data[0] << 8) | data[1];
@@ -2597,7 +2599,8 @@
                 else
                     matroska_queue_packet(matroska, pkt);
 
-                timecode = AV_NOPTS_VALUE;
+                if (timecode != AV_NOPTS_VALUE)
+                    timecode = duration ? timecode + duration : AV_NOPTS_VALUE;
             }
             data += lace_size[n];
         }
@@ -2686,7 +2689,8 @@
 
     if (size > 0)
         res = matroska_parse_block(matroska, data, size, pos, cluster_time,
-                                   is_keyframe, is_bframe, &track, &pkt);
+                                   duration, is_keyframe, is_bframe,
+                                   &track, &pkt);
 
     if (pkt)
     {
@@ -2743,7 +2747,8 @@
                 res = ebml_read_binary(matroska, &id, &data, &size);
                 if (res == 0)
                     res = matroska_parse_block(matroska, data, size, pos,
-                                               cluster_time, -1,0, NULL, NULL);
+                                               cluster_time, AV_NOPTS_VALUE,
+                                               -1, 0, NULL, NULL);
                 break;
 
             default: