[FFmpeg-cvslog] mpegtsenc: check max_delay in write_packet_internal().

Michael Niedermayer git at videolan.org
Fri May 11 14:03:31 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri May 11 13:41:06 2012 +0200| [3700f655c55e2001b57215210b957b169d66b50f] | committer: Michael Niedermayer

mpegtsenc: check max_delay in write_packet_internal().

Checking it during PES writing is too late.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3700f655c55e2001b57215210b957b169d66b50f
---

 libavformat/mpegtsenc.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 8d38d01..25ca1b0 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1070,6 +1070,21 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
         }
     }
 
+    if (pkt->dts != AV_NOPTS_VALUE) {
+        int i;
+        for(i=0; i<s->nb_streams; i++){
+            AVStream *st2 = s->streams[i];
+            MpegTSWriteStream *ts_st2 = st2->priv_data;
+            if(   ts_st2->payload_size
+               && ts_st2->payload_dts == AV_NOPTS_VALUE || dts - ts_st2->payload_dts > delay/2){
+                mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
+                                ts_st->payload_pts, ts_st->payload_dts,
+                                ts_st->payload_flags & AV_PKT_FLAG_KEY);
+                ts_st->payload_size = 0;
+            }
+        }
+    }
+
     if (ts_st->payload_size && ts_st->payload_size + size > ts->pes_payload_size) {
         mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
                          ts_st->payload_pts, ts_st->payload_dts,



More information about the ffmpeg-cvslog mailing list