[FFmpeg-devel] Support TrueHD for MPEG Transport Stream format
刘 岐
lingjiujianke at gmail.com
Mon Oct 21 16:34:37 CEST 2013
Support TrueHD for MPEG Transport Stream format
Before patch: output_before.log
After patch: output_after.log
-------------- next part --------------
A non-text attachment was scrubbed...
Name: output_before.log
Type: application/octet-stream
Size: 24078 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131021/f00efbcc/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: output_after.log
Type: application/octet-stream
Size: 8620 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131021/f00efbcc/attachment-0001.obj>
-------------- next part --------------
Signed-off-by: Steven Liu <lingjiujianke at gmail.com>
---
libavformat/mpeg.h | 1 +
libavformat/mpegts.c | 1 +
libavformat/mpegts.h | 1 +
libavformat/mpegtsenc.c | 10 ++++++++--
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index cf10d6a..4661c4b 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -57,6 +57,7 @@
#define STREAM_TYPE_VIDEO_CAVS 0x42
#define STREAM_TYPE_AUDIO_AC3 0x81
+#define STREAM_TYPE_AUDIO_TRUEHD 0x83
#define STREAM_TYPE_AUDIO_DTS 0x8a
static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 5f2dfe9..44819bd 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -623,6 +623,7 @@ static const StreamType HDMV_types[] = {
/* ATSC ? */
static const StreamType MISC_types[] = {
{ 0x81, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AC3 },
+ { 0x83, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_TRUEHD },
{ 0x8a, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS },
{ 0 },
};
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 269c23b..a5b5270 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -57,6 +57,7 @@
#define STREAM_TYPE_VIDEO_DIRAC 0xd1
#define STREAM_TYPE_AUDIO_AC3 0x81
+#define STREAM_TYPE_AUDIO_TRUEHD 0x83
#define STREAM_TYPE_AUDIO_DTS 0x8a
typedef struct MpegTSContext MpegTSContext;
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 1d51b97..cd1ecc1 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -311,6 +311,9 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
case AV_CODEC_ID_AC3:
stream_type = STREAM_TYPE_AUDIO_AC3;
break;
+ case AV_CODEC_ID_TRUEHD:
+ stream_type = STREAM_TYPE_AUDIO_TRUEHD;
+ break;
default:
stream_type = STREAM_TYPE_PRIVATE_DATA;
break;
@@ -940,6 +943,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
*q++ = 0xc0;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
st->codec->codec_id == AV_CODEC_ID_AC3 &&
+ st->codec->codec_id == AV_CODEC_ID_TRUEHD &&
ts->m2ts_mode) {
*q++ = 0xfd;
} else {
@@ -976,7 +980,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
*/
if (ts->m2ts_mode &&
st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
- st->codec->codec_id == AV_CODEC_ID_AC3) {
+ (st->codec->codec_id == AV_CODEC_ID_AC3 ||
+ st->codec->codec_id == AV_CODEC_ID_TRUEHD)) {
/* set PES_extension_flag */
pes_extension = 1;
flags |= 0x01;
@@ -1017,7 +1022,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
/* For Blu-ray AC3 Audio Setting extended flags */
if (ts->m2ts_mode &&
pes_extension &&
- st->codec->codec_id == AV_CODEC_ID_AC3) {
+ (st->codec->codec_id == AV_CODEC_ID_AC3 ||
+ st->codec->codec_id == AV_CODEC_ID_TRUEHD)) {
flags = 0x01; /* set PES_extension_flag_2 */
*q++ = flags;
*q++ = 0x80 | 0x01; /* marker bit + extension length */
--
1.7.12.4 (Apple Git-37)
More information about the ffmpeg-devel
mailing list