diff options
author | John Stebbins <[email protected]> | 2019-12-22 13:08:36 -0800 |
---|---|---|
committer | John Stebbins <[email protected]> | 2019-12-22 13:08:36 -0800 |
commit | efeaeb4c7d20980a57ff8a872d51748a8b396ee4 (patch) | |
tree | 79f1a235ff2ee2a8ea9c167f9797406c6bebb22e /libhb/bd.c | |
parent | 948f1b7b8840a6fe85e1d75cfcc85a0fd9dc97d9 (diff) |
bd: add processing of "secondary" audio tracks
There are actually 2 types. One "secondary" audio type is designated
by a distinct stream id. The other "secondary" audio type is disignated
by being in a separate "secondary" audio list.
Maybe fixes https://github.com/HandBrake/HandBrake/issues/2501
Diffstat (limited to 'libhb/bd.c')
-rw-r--r-- | libhb/bd.c | 121 |
1 files changed, 110 insertions, 11 deletions
diff --git a/libhb/bd.c b/libhb/bd.c index ea0707bac..2e3c03a2c 100644 --- a/libhb/bd.c +++ b/libhb/bd.c @@ -130,7 +130,7 @@ static void add_subtitle(int track, hb_list_t *list_subtitle, BLURAY_STREAM_INFO return; } -static void add_audio(int track, hb_list_t *list_audio, BLURAY_STREAM_INFO *bdaudio, int substream_type, uint32_t codec, uint32_t codec_param) +static void add_audio(int track, hb_list_t *list_audio, BLURAY_STREAM_INFO *bdaudio, int substream_type, uint32_t codec, uint32_t codec_param, int attributes) { const char * codec_name; hb_audio_t * audio; @@ -195,7 +195,7 @@ static void add_audio(int track, hb_list_t *list_audio, BLURAY_STREAM_INFO *bdau lang = lang_for_code2( (char*)bdaudio->lang ); - audio->config.lang.attributes = HB_AUDIO_ATTR_NONE; + audio->config.lang.attributes = attributes; snprintf( audio->config.lang.simple, sizeof( audio->config.lang.simple ), "%s", @@ -474,47 +474,146 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) case BLURAY_STREAM_TYPE_AUDIO_TRUHD: // Add 2 audio tracks. One for TrueHD and one for AC-3 add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_AC3, - HB_ACODEC_AC3, AV_CODEC_ID_AC3); + HB_ACODEC_AC3, AV_CODEC_ID_AC3, HB_AUDIO_ATTR_NONE); add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_TRUEHD, - HB_ACODEC_FFTRUEHD, AV_CODEC_ID_TRUEHD); + HB_ACODEC_FFTRUEHD, AV_CODEC_ID_TRUEHD, + HB_AUDIO_ATTR_NONE); break; case BLURAY_STREAM_TYPE_AUDIO_DTS: add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_DCA, AV_CODEC_ID_DTS); + HB_ACODEC_DCA, AV_CODEC_ID_DTS, HB_AUDIO_ATTR_NONE); break; case BLURAY_STREAM_TYPE_AUDIO_MPEG2: case BLURAY_STREAM_TYPE_AUDIO_MPEG1: add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_FFMPEG, AV_CODEC_ID_MP2); + HB_ACODEC_FFMPEG, AV_CODEC_ID_MP2, + HB_AUDIO_ATTR_NONE); break; case BLURAY_STREAM_TYPE_AUDIO_AC3PLUS: add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_FFEAC3, AV_CODEC_ID_EAC3); + HB_ACODEC_FFEAC3, AV_CODEC_ID_EAC3, + HB_AUDIO_ATTR_NONE); + break; + + case BLURAY_STREAM_TYPE_AUDIO_AC3PLUS_SECONDARY: + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_FFEAC3, AV_CODEC_ID_EAC3, + HB_AUDIO_ATTR_NONE); break; case BLURAY_STREAM_TYPE_AUDIO_LPCM: add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_FFMPEG, AV_CODEC_ID_PCM_BLURAY); + HB_ACODEC_FFMPEG, AV_CODEC_ID_PCM_BLURAY, + HB_AUDIO_ATTR_NONE); break; case BLURAY_STREAM_TYPE_AUDIO_AC3: add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_AC3, AV_CODEC_ID_AC3); + HB_ACODEC_AC3, AV_CODEC_ID_AC3, HB_AUDIO_ATTR_NONE); break; case BLURAY_STREAM_TYPE_AUDIO_DTSHD_MASTER: case BLURAY_STREAM_TYPE_AUDIO_DTSHD: // Add 2 audio tracks. One for DTS-HD and one for DTS add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_DTS, - HB_ACODEC_DCA, AV_CODEC_ID_DTS); + HB_ACODEC_DCA, AV_CODEC_ID_DTS, HB_AUDIO_ATTR_NONE); // DTS-HD is special. The substreams must be concatinated // DTS-core followed by DTS-hd-extensions. Setting // a substream id of 0 says use all substreams. add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_DCA_HD, AV_CODEC_ID_DTS); + HB_ACODEC_DCA_HD, AV_CODEC_ID_DTS, + HB_AUDIO_ATTR_NONE); + break; + + case BLURAY_STREAM_TYPE_AUDIO_DTSHD_SECONDARY: + // BD "DTSHD_SECONDARY" is DTS Express which has no + // DTS core + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_DCA_HD, AV_CODEC_ID_DTS, + HB_AUDIO_ATTR_NONE); + break; + + default: + hb_log("scan: unknown audio pid 0x%x codec 0x%x", bdaudio->pid, + bdaudio->coding_type); + break; + } + } + + // Add all the secondary audios found in the above clip. + for (jj = 0; jj < ti->clips[audio_clip_index].sec_audio_stream_count; jj++, ii++) + { + BLURAY_STREAM_INFO * bdaudio; + + bdaudio = &ti->clips[audio_clip_index].sec_audio_streams[jj]; + + switch (bdaudio->coding_type) + { + case BLURAY_STREAM_TYPE_AUDIO_TRUHD: + // Add 2 audio tracks. One for TrueHD and one for AC-3 + add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_AC3, + HB_ACODEC_AC3, AV_CODEC_ID_AC3, + HB_AUDIO_ATTR_SECONDARY); + add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_TRUEHD, + HB_ACODEC_FFTRUEHD, AV_CODEC_ID_TRUEHD, + HB_AUDIO_ATTR_SECONDARY); + break; + + case BLURAY_STREAM_TYPE_AUDIO_DTS: + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_DCA, AV_CODEC_ID_DTS, + HB_AUDIO_ATTR_SECONDARY); + break; + + case BLURAY_STREAM_TYPE_AUDIO_MPEG2: + case BLURAY_STREAM_TYPE_AUDIO_MPEG1: + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_FFMPEG, AV_CODEC_ID_MP2, + HB_AUDIO_ATTR_SECONDARY); + break; + + case BLURAY_STREAM_TYPE_AUDIO_AC3PLUS: + case BLURAY_STREAM_TYPE_AUDIO_AC3PLUS_SECONDARY: + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_FFEAC3, AV_CODEC_ID_EAC3, + HB_AUDIO_ATTR_SECONDARY); + break; + + case BLURAY_STREAM_TYPE_AUDIO_LPCM: + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_FFMPEG, AV_CODEC_ID_PCM_BLURAY, + HB_AUDIO_ATTR_SECONDARY); + break; + + case BLURAY_STREAM_TYPE_AUDIO_AC3: + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_AC3, AV_CODEC_ID_AC3, + HB_AUDIO_ATTR_SECONDARY); + break; + + case BLURAY_STREAM_TYPE_AUDIO_DTSHD_MASTER: + case BLURAY_STREAM_TYPE_AUDIO_DTSHD: + // Add 2 audio tracks. One for DTS-HD and one for DTS + add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_DTS, + HB_ACODEC_DCA, AV_CODEC_ID_DTS, + HB_AUDIO_ATTR_SECONDARY); + // DTS-HD is special. The substreams must be concatinated + // DTS-core followed by DTS-hd-extensions. Setting + // a substream id of 0 says use all substreams. + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_DCA_HD, AV_CODEC_ID_DTS, + HB_AUDIO_ATTR_SECONDARY); + break; + + case BLURAY_STREAM_TYPE_AUDIO_DTSHD_SECONDARY: + // BD "DTSHD_SECONDARY" is DTS Express which has no + // DTS core + add_audio(ii, title->list_audio, bdaudio, 0, + HB_ACODEC_DCA_HD, AV_CODEC_ID_DTS, + HB_AUDIO_ATTR_SECONDARY); break; default: |