aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mpegtsenc.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-05-11 02:30:29 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-05-11 02:30:29 +0000
commite4358e70f8509e0cbdfa968236a3665ed7be15a2 (patch)
treea725eb090280bd7b3c73e7ca55d45aba36ac3d64 /libavformat/mpegtsenc.c
parent61a4fd8e641f4c86d43bcd7f03be28c86b074acd (diff)
downloadffmpeg-e4358e70f8509e0cbdfa968236a3665ed7be15a2.tar.gz
write a single pes for video frames, some proprietary player needs it
Originally committed as revision 18792 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mpegtsenc.c')
-rw-r--r--libavformat/mpegtsenc.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index b3d973e1a4..82fbd9abe8 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -619,6 +619,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
len = payload_size + header_len + 3;
if (private_code != 0)
len++;
+ if (len > 0xffff)
+ len = 0;
*q++ = len >> 8;
*q++ = len;
val = 0x80;
@@ -709,31 +711,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
}
ts_st->first_pts_check = 0;
- if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
- /* for subtitle, a single PES packet must be generated */
- mpegts_write_pes(s, st, buf, size, pts, AV_NOPTS_VALUE);
- return 0;
- }
-
- if (st->codec->codec_id == CODEC_ID_DIRAC) {
- /* for Dirac, a single PES packet must be generated */
- mpegts_write_pes(s, st, buf, size, pts, dts);
- return 0;
- }
-
- if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO ||
- st->codec->codec_id == CODEC_ID_MPEG1VIDEO) {
- const uint8_t *p = pkt->data;
- const uint8_t *end = pkt->data+pkt->size;
- uint32_t state = -1;
- while (p < end) {
- p = ff_find_start_code(p, end, &state);
- if (state == PICTURE_START_CODE) {
- access_unit_index = p - 4;
- break;
- }
- }
- } if (st->codec->codec_id == CODEC_ID_H264) {
+ if (st->codec->codec_id == CODEC_ID_H264) {
if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
av_log(s, AV_LOG_ERROR, "h264 bitstream malformated\n");
return -1;
@@ -759,6 +737,14 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
return -1;
}
+ if (st->codec->codec_type == CODEC_TYPE_SUBTITLE ||
+ st->codec->codec_type == CODEC_TYPE_VIDEO) {
+ // for video and subtitle, write a single pes packet
+ mpegts_write_pes(s, st, buf, size, pts, dts);
+ return 0;
+ }
+
+ // audio
while (size > 0) {
len = DEFAULT_PES_PAYLOAD_SIZE - ts_st->payload_index;
if (len > size)