]> git.sesse.net Git - ffmpeg/commitdiff
workaround some broken mpeg-ps timestamps
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 15 Dec 2004 02:36:03 +0000 (02:36 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 15 Dec 2004 02:36:03 +0000 (02:36 +0000)
Originally committed as revision 3755 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/utils.c

index c25ca08a2efbf7440110e3eec29588a2ff774b7f..da5348644f88d0c5fcf9d371115b61cab16593ce 100644 (file)
@@ -741,6 +741,14 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
         /* cannot compute PTS if not present (we can compute it only
            by knowing the futur */
     } else {
+        if(pkt->pts != AV_NOPTS_VALUE && pkt->duration){
+            int64_t old_diff= ABS(st->cur_dts - pkt->duration - pkt->pts);
+            int64_t new_diff= ABS(st->cur_dts - pkt->pts);
+            if(old_diff < new_diff && old_diff < (pkt->duration>>3)){
+                pkt->pts += pkt->duration;
+            }
+        }
+    
         /* presentation is not delayed : PTS and DTS are the same */
         if (pkt->pts == AV_NOPTS_VALUE) {
             if (pkt->dts == AV_NOPTS_VALUE) {