diff options
author | Anuradha Suraparaju <anuradha@rd.bbc.co.uk> | 2008-08-13 23:29:35 +0400 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2008-08-13 23:29:35 +0400 |
commit | f4bba2015adbeeede8246d5004a4b5318a8c1fa3 (patch) | |
tree | 8c8be9807b3503131eba6e4de569eb3325e839ee /libavformat/mpegtsenc.c | |
parent | ce15710f554ef3520f968c8b4284a0f576611c95 (diff) |
Dirac encapsulation in MPEG-TS
patch by Anuradha Suraparaju, anuradha rd.bbc.co uk
Originally committed as revision 14734 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mpegtsenc.c')
-rw-r--r-- | libavformat/mpegtsenc.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 4a70a15f74..6a43ce4c32 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -220,6 +220,9 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) case CODEC_ID_H264: stream_type = STREAM_TYPE_VIDEO_H264; break; + case CODEC_ID_DIRAC: + stream_type = STREAM_TYPE_VIDEO_DIRAC; + break; case CODEC_ID_MP2: case CODEC_ID_MP3: stream_type = STREAM_TYPE_AUDIO_MPEG1; @@ -267,6 +270,16 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) put16(&q, 1); /* ancillary page id */ } break; + case CODEC_TYPE_VIDEO: + if (stream_type == STREAM_TYPE_VIDEO_DIRAC) { + *q++ = 0x05; /*MPEG-2 registration descriptor*/ + *q++ = 4; + *q++ = 'd'; + *q++ = 'r'; + *q++ = 'a'; + *q++ = 'c'; + } + break; } val = 0xf000 | (q - desc_length_ptr - 2); @@ -527,13 +540,17 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, *q++ = 0; } if (is_start) { + int pes_extension = 0; /* write PES header */ *q++ = 0x00; *q++ = 0x00; *q++ = 0x01; private_code = 0; if (st->codec->codec_type == CODEC_TYPE_VIDEO) { - *q++ = 0xe0; + if (st->codec->codec_id == CODEC_ID_DIRAC) { + *q++ = 0xfd; + } else + *q++ = 0xe0; } else if (st->codec->codec_type == CODEC_TYPE_AUDIO && (st->codec->codec_id == CODEC_ID_MP2 || st->codec->codec_id == CODEC_ID_MP3)) { @@ -554,6 +571,19 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, header_len += 5; flags |= 0x40; } + if (st->codec->codec_type == CODEC_TYPE_VIDEO && + st->codec->codec_id == CODEC_ID_DIRAC) { + /* set PES_extension_flag */ + pes_extension = 1; + flags |= 0x01; + + /* + * One byte for PES2 extension flag + + * one byte for extension length + + * one byte for extension id + */ + header_len += 3; + } len = payload_size + header_len + 3; if (private_code != 0) len++; @@ -574,6 +604,16 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, write_pts(q, 1, dts); q += 5; } + if (pes_extension && st->codec->codec_id == CODEC_ID_DIRAC) { + flags = 0x01; /* set PES_extension_flag_2 */ + *q++ = flags; + *q++ = 0x80 | 0x01; /* marker bit + extension length */ + /* + * Set the stream id extension flag bit to 0 and + * write the extended stream id + */ + *q++ = 0x00 | 0x60; + } if (private_code != 0) *q++ = private_code; is_start = 0; |