Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit e31c5ebe1146d98d17a5121312c5444432c81904)
Conflicts:
libavformat/mpegtsenc.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -23,6 +23,7 @@ |
23 | 23 |
#include "libavutil/crc.h" |
24 | 24 |
#include "libavutil/dict.h" |
25 | 25 |
#include "libavutil/opt.h" |
26 |
+#include "libavutil/avassert.h" |
|
26 | 27 |
#include "libavcodec/mpegvideo.h" |
27 | 28 |
#include "avformat.h" |
28 | 29 |
#include "internal.h" |
... | ... |
@@ -947,19 +948,20 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) |
947 | 947 |
} |
948 | 948 |
} |
949 | 949 |
|
950 |
- if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) { |
|
950 |
+ if (ts_st->payload_index && ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) { |
|
951 |
+ mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, |
|
952 |
+ ts_st->payload_pts, ts_st->payload_dts); |
|
953 |
+ ts_st->payload_index = 0; |
|
954 |
+ } |
|
955 |
+ |
|
956 |
+ if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > DEFAULT_PES_PAYLOAD_SIZE) { |
|
957 |
+ av_assert0(!ts_st->payload_index); |
|
951 | 958 |
// for video and subtitle, write a single pes packet |
952 | 959 |
mpegts_write_pes(s, st, buf, size, pts, dts); |
953 | 960 |
av_free(data); |
954 | 961 |
return 0; |
955 | 962 |
} |
956 | 963 |
|
957 |
- if (ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) { |
|
958 |
- mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, |
|
959 |
- ts_st->payload_pts, ts_st->payload_dts); |
|
960 |
- ts_st->payload_index = 0; |
|
961 |
- } |
|
962 |
- |
|
963 | 964 |
if (!ts_st->payload_index) { |
964 | 965 |
ts_st->payload_pts = pts; |
965 | 966 |
ts_st->payload_dts = dts; |