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 | |
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
-rw-r--r-- | libhb/bd.c | 121 | ||||
-rw-r--r-- | libhb/scan.c | 6 | ||||
-rw-r--r-- | libhb/stream.c | 17 |
3 files changed, 127 insertions, 17 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: diff --git a/libhb/scan.c b/libhb/scan.c index 7060402d9..23b80b6d6 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -1334,6 +1334,12 @@ static void LookForAudio(hb_scan_t *scan, hb_title_t * title, hb_buffer_t * b) sizeof(audio->config.lang.description) - strlen(audio->config.lang.description) - 1); } + if (audio->config.lang.attributes & HB_AUDIO_ATTR_SECONDARY) + { + strncat(audio->config.lang.description, " (Secondary)", + sizeof(audio->config.lang.description) - + strlen(audio->config.lang.description) - 1); + } if (audio->config.in.channel_layout) { diff --git a/libhb/stream.c b/libhb/stream.c index f7e5ac854..b2d816517 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -95,7 +95,7 @@ static const stream2codec_t st2codec[256] = { // BD E-AC3 Secondary audio st(0xa1, U, 0, 0, "E-AC3"), // BD DTS-HD Secondary audio - st(0xa2, U, 0, 0, "DTS-HD LBR"), + st(0xa2, U, HB_ACODEC_DCA_HD, AV_CODEC_ID_DTS, "DTS-HD LBR"), st(0xea, V, WORK_DECAVCODECV, AV_CODEC_ID_VC1, "VC-1"), }; @@ -4288,11 +4288,16 @@ static void hb_ts_resolve_pid_types(hb_stream_t *stream) stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_EAC3; continue; } - // 0xa2 is DTS-HD LBR used in HD-DVD and bluray for - // secondary audio streams. FFmpeg can not decode yet. - // Having it in the audio list causes delays during scan - // while we try to get stream parameters. So skip - // this type for now. + if ( stype == 0xa2 && + stream->reg_desc == STR4_TO_UINT32("HDMV") ) + { + // Blueray DTS-HD LBR audio + // This is no interleaved DTS core + update_ts_streams( stream, pid, 0, stype, A, &pes_idx ); + stream->pes.list[pes_idx].codec = HB_ACODEC_DCA_HD; + stream->pes.list[pes_idx].codec_param = AV_CODEC_ID_DTS; + continue; + } if ( stype == 0x85 && stream->reg_desc == STR4_TO_UINT32("HDMV") ) { |