[FFmpeg-devel] Support TrueHD for MPEG Transport Stream format
Timothy Gu
timothygu99 at gmail.com
Mon Oct 21 18:07:13 CEST 2013
On Oct 21, 2013 7:34 AM, "刘 岐" <lingjiujianke at gmail.com> wrote:
>
> Support TrueHD for MPEG Transport Stream format
>
> Before patch: output_before.log
> After patch: output_after.log
>
>
>
> 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) {
Shouldn't this be
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
As a stream cannot be AC3 and TrueHD at the same time? (The same as the
next hunk) Of course I might be wrong.
> *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)
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list