changeset 3892:8f1928b41f45 libavformat

matroska: subtitle display duration must be stored in pkt->convergence_duration
author aurel
date Thu, 04 Sep 2008 23:08:19 +0000
parents fbe8704f513a
children 8e7b2616e1ad
files matroskadec.c matroskaenc.c
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/matroskadec.c	Thu Sep 04 22:35:05 2008 +0000
+++ b/matroskadec.c	Thu Sep 04 23:08:19 2008 +0000
@@ -1583,7 +1583,10 @@
 
                 pkt->pts = timecode;
                 pkt->pos = pos;
-                pkt->duration = duration;
+                if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE)
+                    pkt->convergence_duration = duration;
+                else
+                    pkt->duration = duration;
 
                 dynarray_add(&matroska->packets, &matroska->num_packets, pkt);
             }
--- a/matroskaenc.c	Thu Sep 04 22:35:05 2008 +0000
+++ b/matroskaenc.c	Thu Sep 04 23:08:19 2008 +0000
@@ -749,6 +749,7 @@
     ByteIOContext *pb = s->pb;
     AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
     int keyframe = !!(pkt->flags & PKT_FLAG_KEY);
+    int duration = pkt->duration;
     int ret;
 
     // start a new cluster every 5 MB or 5 sec
@@ -781,8 +782,9 @@
         mkv_write_block(s, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe << 7);
     } else {
         ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(pkt));
+        duration = pkt->convergence_duration;
         mkv_write_block(s, MATROSKA_ID_BLOCK, pkt, 0);
-        put_ebml_uint(pb, MATROSKA_ID_DURATION, pkt->duration);
+        put_ebml_uint(pb, MATROSKA_ID_DURATION, duration);
         end_ebml_master(pb, blockgroup);
     }
 
@@ -791,7 +793,7 @@
         if (ret < 0) return ret;
     }
 
-    mkv->duration = FFMAX(mkv->duration, pkt->pts + pkt->duration);
+    mkv->duration = FFMAX(mkv->duration, pkt->pts + duration);
     return 0;
 }