changeset 4212:3aaa3da02aea libavformat

use delay to avoid negative dts
author bcoudurier
date Wed, 14 Jan 2009 22:14:35 +0000
parents 5e5654752973
children 461f23728a14
files mpegtsenc.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mpegtsenc.c	Wed Jan 14 21:57:10 2009 +0000
+++ b/mpegtsenc.c	Wed Jan 14 22:14:35 2009 +0000
@@ -672,6 +672,7 @@
     MpegTSWriteStream *ts_st = st->priv_data;
     int len, max_payload_size;
     const uint8_t *access_unit_index = NULL;
+    const uint64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
 
     if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
         /* for subtitle, a single PES packet must be generated */
@@ -717,8 +718,8 @@
         if (access_unit_index && access_unit_index < buf &&
             ts_st->payload_pts == AV_NOPTS_VALUE &&
             ts_st->payload_dts == AV_NOPTS_VALUE) {
-            ts_st->payload_dts = pkt->dts;
-            ts_st->payload_pts = pkt->pts;
+            ts_st->payload_dts = pkt->dts + delay;
+            ts_st->payload_pts = pkt->pts + delay;
         }
         if (ts_st->payload_index >= max_payload_size) {
             mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,