From 6fa9843b4baf93a95be5ce7c6ad5c041992504bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jind=C5=99ich=20Makovi=C4=8Dka?= Date: Mon, 19 Dec 2011 20:03:24 +0100 Subject: [PATCH] mpegts: properly output large audio packets MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Do not assume the audio packets being always smaller than DEFAULT_PES_PAYLOAD_SIZE. Signed-off-by: Jindřich Makovička Signed-off-by: Anton Khirnov --- libavformat/mpegtsenc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 57cfe45..48b1617 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -1007,10 +1007,18 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) } if (ts_st->payload_size + size > DEFAULT_PES_PAYLOAD_SIZE) { - 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) { + 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 (size > DEFAULT_PES_PAYLOAD_SIZE) { + mpegts_write_pes(s, st, buf, size, pts, dts, + pkt->flags & AV_PKT_FLAG_KEY); + av_free(data); + return 0; + } } if (!ts_st->payload_size) { -- 2.7.4