aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-19 22:57:36 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-19 23:04:31 +0200
commite31c5ebe1146d98d17a5121312c5444432c81904 (patch)
treed3ddd8ec55d3acbffd37ca6c70b0486558b0980c
parent057161d39bc5bc97a60c2c5b49d1f96cfcbcc386 (diff)
downloadffmpeg-e31c5ebe1146d98d17a5121312c5444432c81904.tar.gz
mpegtsenc: fix handling of large audio packets
(sorry i have no sample, just a user report) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/mpegtsenc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 1b00251b1c..cf636fe99e 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -24,6 +24,7 @@
#include "libavutil/dict.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
+#include "libavutil/avassert.h"
#include "libavcodec/mpegvideo.h"
#include "avformat.h"
#include "internal.h"
@@ -1022,20 +1023,21 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
}
}
- if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
- // for video and subtitle, write a single pes packet
- mpegts_write_pes(s, st, buf, size, pts, dts, pkt->flags & AV_PKT_FLAG_KEY);
- av_free(data);
- return 0;
- }
-
- if (ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) {
+ if (ts_st->payload_index && ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
ts_st->payload_index = 0;
}
+ if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > DEFAULT_PES_PAYLOAD_SIZE) {
+ av_assert0(!ts_st->payload_index);
+ // for video and subtitle, write a single pes packet
+ mpegts_write_pes(s, st, buf, size, pts, dts, pkt->flags & AV_PKT_FLAG_KEY);
+ av_free(data);
+ return 0;
+ }
+
if (!ts_st->payload_index) {
ts_st->payload_pts = pts;
ts_st->payload_dts = dts;