diff options
-rw-r--r-- | gtk/src/hb-backend.c | 23 | ||||
-rw-r--r-- | gtk/src/presets.c | 3 | ||||
-rw-r--r-- | libhb/bd.c | 12 | ||||
-rw-r--r-- | libhb/common.c | 2 | ||||
-rw-r--r-- | libhb/common.h | 19 | ||||
-rw-r--r-- | libhb/decavcodec.c | 83 | ||||
-rw-r--r-- | libhb/dvd.c | 4 | ||||
-rw-r--r-- | libhb/dvdnav.c | 4 | ||||
-rw-r--r-- | libhb/muxmkv.c | 2 | ||||
-rw-r--r-- | libhb/stream.c | 64 | ||||
-rw-r--r-- | libhb/sync.c | 6 | ||||
-rw-r--r-- | libhb/work.c | 36 | ||||
-rw-r--r-- | macosx/HBAudio.m | 15 | ||||
-rw-r--r-- | macosx/HBAudioController.m | 2 | ||||
-rw-r--r-- | test/test.c | 6 |
15 files changed, 170 insertions, 111 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index e98330155..a55897ab8 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -251,14 +251,15 @@ combo_opts_t vcodec_opts = static options_map_t d_acodec_opts[] = { - {"AAC (faac)", "faac", HB_ACODEC_FAAC, "faac"}, - {"AAC (ffmpeg)", "ffaac", HB_ACODEC_FFAAC, "ffaac"}, - {"MP3 (lame)", "lame", HB_ACODEC_LAME, "lame"}, - {"Vorbis", "vorbis", HB_ACODEC_VORBIS, "vorbis"}, - {"AC3 (ffmpeg)", "ac3", HB_ACODEC_AC3, "ac3"}, - {"AC3 (pass-thru)", "ac3pass", HB_ACODEC_AC3_PASS, "ac3pass"}, - {"DTS (pass-thru)", "dtspass", HB_ACODEC_DCA_PASS, "dtspass"}, - {"Choose For Me", "auto", HB_ACODEC_ANY, "auto"}, + {"AAC (faac)", "faac", HB_ACODEC_FAAC, "faac"}, + {"AAC (ffmpeg)", "ffaac", HB_ACODEC_FFAAC, "ffaac"}, + {"MP3 (lame)", "lame", HB_ACODEC_LAME, "lame"}, + {"Vorbis", "vorbis", HB_ACODEC_VORBIS, "vorbis"}, + {"AC3 (ffmpeg)", "ac3", HB_ACODEC_AC3, "ac3"}, + {"AC3 (pass-thru)", "ac3pass", HB_ACODEC_AC3_PASS, "ac3pass"}, + {"DTS (pass-thru)", "dtspass", HB_ACODEC_DCA_PASS, "dtspass"}, + {"DTS-HD (pass-thru)", "dtshdpass", HB_ACODEC_DCA_HD_PASS, "dtshdpass"}, + {"Choose For Me", "auto", HB_ACODEC_ANY, "auto"}, }; combo_opts_t acodec_opts = { @@ -1568,10 +1569,12 @@ ghb_grey_combo_options(GtkBuilder *builder) if (allow_dca) { grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_PASS, FALSE); + grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, FALSE); } else { grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE); + grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, TRUE); } if (aconfig && aconfig->in.codec != HB_ACODEC_AC3) @@ -1582,6 +1585,10 @@ ghb_grey_combo_options(GtkBuilder *builder) { grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE); } + if (aconfig && aconfig->in.codec != HB_ACODEC_DCA_HD) + { + grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, TRUE); + } grey_combo_box_item(builder, "VideoEncoder", HB_VCODEC_THEORA, FALSE); widget = GHB_WIDGET (builder, "AudioEncoder"); diff --git a/gtk/src/presets.c b/gtk/src/presets.c index b3815f032..39d86be9b 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -2001,6 +2001,7 @@ static value_map_t acodec_xlat[] = {"AAC (CoreAudio)", "faac"}, {"AC3 Passthru", "ac3pass"}, {"DTS Passthru", "dtspass"}, + {"DTS-HD Passthru", "dtshdpass"}, {"MP3 (lame)", "lame"}, {"Vorbis (vorbis)", "vorbis"}, {NULL,NULL} @@ -2049,6 +2050,8 @@ value_map_t mix_xlat[] = {"Dolby Pro Logic II", "dpl2"}, {"6-channel discrete", "6ch"}, {"AC3 Passthru", "none"}, + {"DTS Passthru", "none"}, + {"DTS-HD Passthru", "none"}, {NULL, NULL} }; diff --git a/libhb/bd.c b/libhb/bd.c index 536769307..9231436f6 100644 --- a/libhb/bd.c +++ b/libhb/bd.c @@ -103,7 +103,7 @@ static void add_audio(int track, hb_list_t *list_audio, BLURAY_STREAM_INFO *bdau strlen(lang->native_name) ? lang->native_name : lang->eng_name, audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" : ( audio->config.in.codec == HB_ACODEC_DCA ? "DTS" : - ( audio->config.in.codec == HB_ACODEC_MPGA ? + ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) ? ( stream_type == BLURAY_STREAM_TYPE_AUDIO_LPCM ? "BD LPCM" : ( stream_type == BLURAY_STREAM_TYPE_AUDIO_AC3PLUS ? "E-AC3" : ( stream_type == BLURAY_STREAM_TYPE_AUDIO_TRUHD ? "TrueHD" : @@ -352,7 +352,7 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) add_audio(ii, title->list_audio, bdaudio, HB_SUBSTREAM_BD_AC3, HB_ACODEC_AC3, 0); add_audio(ii, title->list_audio, bdaudio, - HB_SUBSTREAM_BD_TRUEHD, HB_ACODEC_MPGA, CODEC_ID_TRUEHD); + HB_SUBSTREAM_BD_TRUEHD, HB_ACODEC_FFMPEG, CODEC_ID_TRUEHD); break; case BLURAY_STREAM_TYPE_AUDIO_DTS: @@ -362,17 +362,17 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) case BLURAY_STREAM_TYPE_AUDIO_MPEG2: case BLURAY_STREAM_TYPE_AUDIO_MPEG1: add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_MPGA, CODEC_ID_MP2); + HB_ACODEC_FFMPEG, CODEC_ID_MP2); break; case BLURAY_STREAM_TYPE_AUDIO_AC3PLUS: add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_MPGA, CODEC_ID_EAC3); + HB_ACODEC_FFMPEG, CODEC_ID_EAC3); break; case BLURAY_STREAM_TYPE_AUDIO_LPCM: add_audio(ii, title->list_audio, bdaudio, 0, - HB_ACODEC_MPGA, CODEC_ID_PCM_BLURAY); + HB_ACODEC_FFMPEG, CODEC_ID_PCM_BLURAY); break; case BLURAY_STREAM_TYPE_AUDIO_AC3: @@ -388,7 +388,7 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) // 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_MPGA, CODEC_ID_DTS); + HB_ACODEC_DCA_HD, CODEC_ID_DTS); break; default: diff --git a/libhb/common.c b/libhb/common.c index 2d5963d76..5f3ce49f8 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -1226,7 +1226,7 @@ int hb_audio_add(const hb_job_t * job, const hb_audio_config_t * audiocfg) */ audio->config.out.track = hb_list_count(job->list_audio) + 1; audio->config.out.codec = audiocfg->out.codec; - if( (audiocfg->out.codec & HB_ACODEC_MASK) == audio->config.in.codec && + if( (audiocfg->out.codec & HB_ACODEC_MASK) == (audio->config.in.codec & HB_ACODEC_MASK) && (audiocfg->out.codec & HB_ACODEC_PASS_FLAG ) ) { /* Pass-through, copy from input. */ diff --git a/libhb/common.h b/libhb/common.h index 492e39750..d350a6bf1 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -316,17 +316,20 @@ struct hb_job_s #define HB_ACODEC_LAME 0x00000200 #define HB_ACODEC_VORBIS 0x00000400 #define HB_ACODEC_AC3 0x00000800 -#define HB_ACODEC_MPGA 0x00001000 -#define HB_ACODEC_LPCM 0x00002000 -#define HB_ACODEC_DCA 0x00004000 -#define HB_ACODEC_FFMPEG 0x00008000 -#define HB_ACODEC_CA_AAC 0x00010000 -#define HB_ACODEC_CA_HAAC 0x00020000 -#define HB_ACODEC_FFAAC 0x00040000 +#define HB_ACODEC_LPCM 0x00001000 +#define HB_ACODEC_DCA 0x00002000 +#define HB_ACODEC_CA_AAC 0x00004000 +#define HB_ACODEC_CA_HAAC 0x00008000 +#define HB_ACODEC_FFAAC 0x00010000 +#define HB_ACODEC_FFMPEG 0x00020000 +#define HB_ACODEC_DCA_HD 0x00040000 +#define HB_ACODEC_FF_MASK 0x00060000 +#define HB_ACODEC_FF_I_FLAG 0x80000000 #define HB_ACODEC_PASS_FLAG 0x40000000 -#define HB_ACODEC_PASS_MASK (HB_ACODEC_AC3 | HB_ACODEC_DCA) +#define HB_ACODEC_PASS_MASK (HB_ACODEC_DCA_HD | HB_ACODEC_AC3 | HB_ACODEC_DCA) #define HB_ACODEC_AC3_PASS (HB_ACODEC_AC3 | HB_ACODEC_PASS_FLAG) #define HB_ACODEC_DCA_PASS (HB_ACODEC_DCA | HB_ACODEC_PASS_FLAG) +#define HB_ACODEC_DCA_HD_PASS (HB_ACODEC_DCA_HD | HB_ACODEC_PASS_FLAG) #define HB_ACODEC_ANY (HB_ACODEC_MASK | HB_ACODEC_PASS_FLAG) #define HB_SUBSTREAM_BD_TRUEHD 0x72 diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 610ec1120..63b1c6dff 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -74,7 +74,7 @@ static int decavcodecBSInfo( hb_work_object_t *, const hb_buffer_t *, hb_work_in hb_work_object_t hb_decavcodec = { WORK_DECAVCODEC, - "MPGA decoder (libavcodec)", + "Audio decoder (libavcodec)", decavcodecInit, decavcodecWork, decavcodecClose, @@ -1327,23 +1327,6 @@ static void init_ffmpeg_context( hb_work_object_t *w ) pv->brokenByMicrosoft = 1; } -static void prepare_ffmpeg_buffer( hb_buffer_t * in ) -{ - // ffmpeg requires an extra 8 bytes of zero at the end of the buffer and - // will seg fault in odd, data dependent ways if it's not there. (my guess - // is this is a case of a local performance optimization creating a global - // performance degradation since all the time wasted by extraneous data - // copies & memory zeroing has to be huge compared to the minor reduction - // in inner-loop instructions this affords - modern cpus bottleneck on - // memory bandwidth not instruction bandwidth). - if ( in->size + FF_INPUT_BUFFER_PADDING_SIZE > in->alloc ) - { - // have to realloc to add the padding - hb_buffer_realloc( in, in->size + FF_INPUT_BUFFER_PADDING_SIZE ); - } - memset( in->data + in->size, 0, FF_INPUT_BUFFER_PADDING_SIZE ); -} - static int decavcodecviInit( hb_work_object_t * w, hb_job_t * job ) { @@ -1429,7 +1412,6 @@ static int decavcodecviWork( hb_work_object_t * w, hb_buffer_t ** buf_in, pv->new_chap = in->new_chap; pv->chap_time = pts >= 0? pts : pv->pts_next; } - prepare_ffmpeg_buffer( in ); decodeFrame( pv, in->data, in->size, in->sequence, in->start, in->renderOffset ); hb_buffer_close( &in ); *buf_out = link_buf_list( pv ); @@ -1475,7 +1457,7 @@ static hb_buffer_t * downmixAudio( else { buf = hb_buffer_init( nsamples * sizeof(float) ); - memcpy(buf->data, buffer, nsamples * sizeof(float) ); + memcpy( buf->data, buffer, nsamples * sizeof(float) ); } return buf; @@ -1524,7 +1506,34 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat pos += len; if( out_size > 0 ) { - // We require signed 16-bit ints for the output format. If + int isamp = av_get_bytes_per_sample( context->sample_fmt ); + nsamples = out_size / isamp; + double pts_next = pv->pts_next + nsamples * pv->duration; + + // DTS-HD can be passed through to mkv + if( audio->config.out.codec & HB_ACODEC_PASS_FLAG ) + { + // Note that even though we are doing passthru, we had + // to decode so that we know the stop time and the + // pts of the next audio packet. + hb_buffer_t * buf; + + buf = hb_buffer_init( avp.size ); + memcpy( buf->data, avp.data, len ); + buf->start = pv->pts_next; + buf->stop = pts_next; + hb_list_add( pv->list, buf ); + + if ( hb_list_count( audio->priv.ff_audio_list ) == 0 ) + { + pv->pts_next = pts_next; + continue; + } + // Fall through and process the list of other audio + // pipelines that use this ffmpeg audio stream. + } + + // We require signed floats for the output format. If // we got something different convert it. if ( context->sample_fmt != AV_SAMPLE_FMT_FLT ) { @@ -1535,16 +1544,13 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat // anything more complicated than a one-for-one format // conversion we'd probably want to cache the converter // context in the pv. - int isamp; AVAudioConvert *ctx; - isamp = av_get_bytes_per_sample( context->sample_fmt ); ctx = av_audio_convert_alloc( AV_SAMPLE_FMT_FLT, 1, context->sample_fmt, 1, NULL, 0 ); // get output buffer size then malloc a buffer - nsamples = out_size / isamp; buffer = av_malloc( nsamples * sizeof(hb_sample_t) ); // we're doing straight sample format conversion which @@ -1557,16 +1563,11 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat av_audio_convert( ctx, obuf, ostride, ibuf, istride, nsamples ); av_audio_convert_free( ctx ); } - else - { - nsamples = out_size / sizeof(hb_sample_t); - } - hb_buffer_t * buf; - double pts_next = pv->pts_next + nsamples * pv->duration; - buf = downmixAudio( audio, pv, buffer, context->channels, nsamples ); - if ( buf ) + if ( !( audio->config.out.codec & HB_ACODEC_PASS_FLAG ) ) { + hb_buffer_t * buf; + buf = downmixAudio( audio, pv, buffer, context->channels, nsamples ); buf->start = pv->pts_next; buf->stop = pts_next; hb_list_add( pv->list, buf ); @@ -1579,13 +1580,20 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat hb_work_private_t *ff_pv = hb_list_item( pv->ff_audio_list, i ); if ( ff_pv ) { - buf = downmixAudio( ff_audio, ff_pv, buffer, context->channels, nsamples ); - if ( buf ) + hb_buffer_t * buf; + + if ( !( ff_audio->config.out.codec & HB_ACODEC_PASS_FLAG ) ) + { + buf = downmixAudio( ff_audio, ff_pv, buffer, context->channels, nsamples ); + } + else { - buf->start = pv->pts_next; - buf->stop = pts_next; - hb_list_add( ff_pv->list, buf ); + buf = hb_buffer_init( avp.size ); + memcpy( buf->data, avp.data, len ); } + buf->start = pv->pts_next; + buf->stop = pts_next; + hb_list_add( ff_pv->list, buf ); } } pv->pts_next = pts_next; @@ -1639,7 +1647,6 @@ static int decavcodecaiWork( hb_work_object_t *w, hb_buffer_t **buf_in, { pv->pts_next = in->start; } - prepare_ffmpeg_buffer( in ); decodeAudio( w->audio, pv, in->data, in->size, pv->pts_next ); writeAudioFifos( w ); *buf_out = link_buf_list( pv ); diff --git a/libhb/dvd.c b/libhb/dvd.c index c5c052223..2a36eb4f2 100644 --- a/libhb/dvd.c +++ b/libhb/dvd.c @@ -360,7 +360,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur case 0x02: case 0x03: audio->id = 0xc0 + position; - audio->config.in.codec = HB_ACODEC_MPGA; + audio->config.in.codec = HB_ACODEC_FFMPEG; break; case 0x04: @@ -411,7 +411,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur strlen(lang->native_name) ? lang->native_name : lang->eng_name, audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" : ( audio->config.in.codec == HB_ACODEC_DCA ? "DTS" : ( audio->config.in.codec == - HB_ACODEC_MPGA ? "MPEG" : "LPCM" ) ) ); + HB_ACODEC_FFMPEG ? "MPEG" : "LPCM" ) ) ); snprintf( audio->config.lang.simple, sizeof( audio->config.lang.simple ), "%s", strlen(lang->native_name) ? lang->native_name : lang->eng_name ); snprintf( audio->config.lang.iso639_2, sizeof( audio->config.lang.iso639_2 ), "%s", diff --git a/libhb/dvdnav.c b/libhb/dvdnav.c index d65b6abbb..eda1988bc 100644 --- a/libhb/dvdnav.c +++ b/libhb/dvdnav.c @@ -508,7 +508,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura case 0x02: case 0x03: audio->id = 0xc0 + position; - audio->config.in.codec = HB_ACODEC_MPGA; + audio->config.in.codec = HB_ACODEC_FFMPEG; break; case 0x04: @@ -559,7 +559,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura strlen(lang->native_name) ? lang->native_name : lang->eng_name, audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" : ( audio->config.in.codec == HB_ACODEC_DCA ? "DTS" : ( audio->config.in.codec == - HB_ACODEC_MPGA ? "MPEG" : "LPCM" ) ) ); + HB_ACODEC_FFMPEG ? "MPEG" : "LPCM" ) ) ); snprintf( audio->config.lang.simple, sizeof( audio->config.lang.simple ), "%s", strlen(lang->native_name) ? lang->native_name : lang->eng_name ); snprintf( audio->config.lang.iso639_2, sizeof( audio->config.lang.iso639_2 ), "%s", diff --git a/libhb/muxmkv.c b/libhb/muxmkv.c index 654c51bc0..f73139b98 100644 --- a/libhb/muxmkv.c +++ b/libhb/muxmkv.c @@ -191,6 +191,8 @@ static int MKVInit( hb_mux_object_t * m ) { case HB_ACODEC_DCA: case HB_ACODEC_DCA_PASS: + case HB_ACODEC_DCA_HD: + case HB_ACODEC_DCA_HD_PASS: track->codecPrivate = NULL; track->codecPrivateSize = 0; track->codecID = MK_ACODEC_DTS; diff --git a/libhb/stream.c b/libhb/stream.c index fdfc8b6a7..ddf20602b 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -45,8 +45,8 @@ typedef struct { static const stream2codec_t st2codec[256] = { st(0x01, V, WORK_DECMPEG2, 0, "MPEG1"), st(0x02, V, WORK_DECMPEG2, 0, "MPEG2"), - st(0x03, A, HB_ACODEC_MPGA, CODEC_ID_MP2, "MPEG1"), - st(0x04, A, HB_ACODEC_MPGA, CODEC_ID_MP2, "MPEG2"), + st(0x03, A, HB_ACODEC_FFMPEG, CODEC_ID_MP2, "MPEG1"), + st(0x04, A, HB_ACODEC_FFMPEG, CODEC_ID_MP2, "MPEG2"), st(0x05, N, 0, 0, "ISO 13818-1 private section"), st(0x06, U, 0, 0, "ISO 13818-1 PES private data"), st(0x07, N, 0, 0, "ISO 13522 MHEG"), @@ -57,23 +57,23 @@ static const stream2codec_t st2codec[256] = { st(0x0c, N, 0, 0, "ISO 13818-6 Stream descriptors"), st(0x0d, N, 0, 0, "ISO 13818-6 Sections"), st(0x0e, N, 0, 0, "ISO 13818-1 auxiliary"), - st(0x0f, A, HB_ACODEC_MPGA, CODEC_ID_AAC, "AAC"), + st(0x0f, A, HB_ACODEC_FFMPEG, CODEC_ID_AAC, "AAC"), st(0x10, V, WORK_DECAVCODECV, CODEC_ID_MPEG4, "MPEG4"), - st(0x11, A, HB_ACODEC_MPGA, CODEC_ID_AAC_LATM, "LATM AAC"), + st(0x11, A, HB_ACODEC_FFMPEG, CODEC_ID_AAC_LATM, "LATM AAC"), st(0x12, U, 0, 0, "MPEG4 generic"), st(0x14, N, 0, 0, "ISO 13818-6 DSM-CC download"), st(0x1b, V, WORK_DECAVCODECV, CODEC_ID_H264, "H.264"), - st(0x80, N, HB_ACODEC_MPGA, CODEC_ID_PCM_BLURAY, "Digicipher II Video"), + st(0x80, N, HB_ACODEC_FFMPEG, CODEC_ID_PCM_BLURAY, "Digicipher II Video"), st(0x81, A, HB_ACODEC_AC3, 0, "AC3"), st(0x82, A, HB_ACODEC_DCA, 0, "DTS"), st(0x83, A, HB_ACODEC_LPCM, 0, "LPCM"), st(0x84, U, 0, 0, "SDDS"), st(0x85, U, 0, 0, "ATSC Program ID"), st(0x86, A, HB_ACODEC_DCA, 0, "DTS-HD MA"), - st(0x87, A, HB_ACODEC_MPGA, CODEC_ID_EAC3, "E-AC3"), + st(0x87, A, HB_ACODEC_FFMPEG, CODEC_ID_EAC3, "E-AC3"), st(0x8a, A, HB_ACODEC_DCA, 0, "DTS"), @@ -1705,7 +1705,8 @@ static void set_ts_audio_description( hb_audio_t *audio, iso639_lang_t *lang ) // For streams demuxed and decoded by ffmpeg, we have a cached context. // Use it to get the name and profile information. Obtaining // the profile requires that ffmpeg has already probed the stream. - else if ( audio->config.in.codec == HB_ACODEC_FFMPEG && + else if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) && + ( audio->config.in.codec & HB_ACODEC_FF_I_FLAG ) && ( cc = hb_ffmpeg_context( audio->config.in.codec_param ) ) && avcodec_find_decoder( cc->codec_id ) ) { @@ -1726,7 +1727,8 @@ static void set_ts_audio_description( hb_audio_t *audio, iso639_lang_t *lang ) } // For streams demuxed by us and decoded by ffmpeg, we can lookup the // decoder name. - else if ( audio->config.in.codec == HB_ACODEC_MPGA && + else if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) && + !( audio->config.in.codec & HB_ACODEC_FF_I_FLAG ) && avcodec_find_decoder( audio->config.in.codec_param ) ) { codec_name = avcodec_find_decoder( audio->config.in.codec_param )->name; @@ -1735,9 +1737,9 @@ static void set_ts_audio_description( hb_audio_t *audio, iso639_lang_t *lang ) { codec_name = audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" : audio->config.in.codec == HB_ACODEC_DCA ? "DTS" : - audio->config.in.codec == HB_ACODEC_MPGA ? "MPEG" : + audio->config.in.codec == HB_ACODEC_DCA_HD ? "DTS-HD" : audio->config.in.codec == HB_ACODEC_LPCM ? "LPCM" : - audio->config.in.codec == HB_ACODEC_FFMPEG ? "FFmpeg" : + (audio->config.in.codec & HB_ACODEC_FF_MASK) ? "FFmpeg" : "Unknown"; } snprintf( audio->config.lang.description, @@ -1745,7 +1747,8 @@ static void set_ts_audio_description( hb_audio_t *audio, iso639_lang_t *lang ) strlen(lang->native_name) ? lang->native_name : lang->eng_name, codec_name ); - if (audio->config.in.codec == HB_ACODEC_FFMPEG) + if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK) && + ( audio->config.in.codec & HB_ACODEC_FF_I_FLAG ) ) { int layout = audio->config.in.channel_layout; char *desc = audio->config.lang.description + @@ -1776,7 +1779,8 @@ static void set_audio_description( hb_audio_t *audio, iso639_lang_t *lang ) // For streams demuxed and decoded by ffmpeg, we have a cached context. // Use it to get the name and profile information. Obtaining // the profile requires that ffmpeg has already probed the stream. - if ( audio->config.in.codec == HB_ACODEC_FFMPEG && + if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) && + ( audio->config.in.codec & HB_ACODEC_FF_I_FLAG ) && ( cc = hb_ffmpeg_context( audio->config.in.codec_param ) ) && avcodec_find_decoder( cc->codec_id ) ) { @@ -1792,7 +1796,8 @@ static void set_audio_description( hb_audio_t *audio, iso639_lang_t *lang ) } // For streams demuxed by us and decoded by ffmpeg, we can lookup the // decoder name. - else if ( audio->config.in.codec == HB_ACODEC_MPGA && + else if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) && + !( audio->config.in.codec & HB_ACODEC_FF_I_FLAG ) && avcodec_find_decoder( audio->config.in.codec_param ) ) { codec_name = avcodec_find_decoder( audio->config.in.codec_param )->name; @@ -1801,9 +1806,8 @@ static void set_audio_description( hb_audio_t *audio, iso639_lang_t *lang ) { codec_name = audio->config.in.codec == HB_ACODEC_AC3 ? "AC3" : audio->config.in.codec == HB_ACODEC_DCA ? "DTS" : - audio->config.in.codec == HB_ACODEC_MPGA ? "MPEG" : audio->config.in.codec == HB_ACODEC_LPCM ? "LPCM" : - audio->config.in.codec == HB_ACODEC_FFMPEG ? "FFmpeg" : + (audio->config.in.codec & HB_ACODEC_FF_MASK) ? "FFmpeg" : "Unknown"; } snprintf( audio->config.lang.description, @@ -1811,7 +1815,8 @@ static void set_audio_description( hb_audio_t *audio, iso639_lang_t *lang ) strlen(lang->native_name) ? lang->native_name : lang->eng_name, codec_name ); - if (audio->config.in.codec == HB_ACODEC_FFMPEG) + if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK) && + ( audio->config.in.codec & HB_ACODEC_FF_I_FLAG ) ) { int layout = audio->config.in.channel_layout; char *desc = audio->config.lang.description + @@ -1875,7 +1880,7 @@ static void hb_ts_stream_set_audio_list( // To distinguish, Bluray streams have a reg_desc of HDMV stream->ts[i].stream_kind = A; add_audio(i, list_audio, stream, 0, - HB_ACODEC_MPGA, CODEC_ID_PCM_BLURAY ); + HB_ACODEC_FFMPEG, CODEC_ID_PCM_BLURAY ); continue; } @@ -1896,7 +1901,7 @@ static void hb_ts_stream_set_audio_list( HB_ACODEC_AC3, 0 ); stream->ts[i].substream_type[1] = HB_SUBSTREAM_BD_TRUEHD; add_audio(i, list_audio, stream, HB_SUBSTREAM_BD_TRUEHD, - HB_ACODEC_MPGA, CODEC_ID_TRUEHD ); + HB_ACODEC_FFMPEG, CODEC_ID_TRUEHD ); stream->ts[i].number_substreams = 2; continue; } @@ -1910,7 +1915,7 @@ static void hb_ts_stream_set_audio_list( add_audio(i, list_audio, stream, HB_SUBSTREAM_BD_DTS, HB_ACODEC_DCA, 0 ); stream->ts[i].substream_type[1] = 0; - add_audio(i, list_audio, stream, 0, HB_ACODEC_MPGA, CODEC_ID_DTS ); + add_audio(i, list_audio, stream, 0, HB_ACODEC_DCA_HD, CODEC_ID_DTS ); stream->ts[i].number_substreams = 2; continue; } @@ -1927,7 +1932,7 @@ static void hb_ts_stream_set_audio_list( add_audio(i, list_audio, stream, HB_SUBSTREAM_BD_DTS, HB_ACODEC_DCA, 0 ); stream->ts[i].substream_type[1] = 0; - add_audio(i, list_audio, stream, 0, HB_ACODEC_MPGA, CODEC_ID_DTS ); + add_audio(i, list_audio, stream, 0, HB_ACODEC_DCA_HD, CODEC_ID_DTS ); stream->ts[i].number_substreams = 2; continue; } @@ -1938,7 +1943,7 @@ static void hb_ts_stream_set_audio_list( // which conflicts with SDDS // To distinguish, Bluray streams have a reg_desc of HDMV stream->ts[i].stream_kind = A; - add_audio(i, list_audio, stream, 0, HB_ACODEC_MPGA, CODEC_ID_EAC3 ); + add_audio(i, list_audio, stream, 0, HB_ACODEC_FFMPEG, CODEC_ID_EAC3 ); continue; } @@ -1982,7 +1987,7 @@ static void hb_ts_stream_set_audio_list( // 0xC0 - 0xCF are the normal containers for ISO-standard // media (mpeg2 audio and mpeg4 AAC). add_audio(i, list_audio, stream, 0, - HB_ACODEC_MPGA, CODEC_ID_MP2 ); + HB_ACODEC_FFMPEG, CODEC_ID_MP2 ); } else { @@ -2010,7 +2015,7 @@ static void add_audio_to_title(hb_title_t *title, int id) switch ( id >> 12 ) { case 0x0: - audio->config.in.codec = HB_ACODEC_MPGA; + audio->config.in.codec = HB_ACODEC_FFMPEG; hb_log("add_audio_to_title: added MPEG audio stream 0x%x", id); break; case 0x2: @@ -3189,7 +3194,7 @@ static void ffmpeg_remap_stream( hb_stream_t *stream, hb_title_t *title ) hb_audio_t *audio; for ( i = 0; ( audio = hb_list_item( title->list_audio, i ) ); ++i ) { - if ( audio->config.in.codec == HB_ACODEC_FFMPEG ) + if ( audio->config.in.codec & HB_ACODEC_FF_MASK ) { ffmpeg_add_codec( stream, audio->config.in.codec_param >> ffmpeg_sl_bits ); @@ -3330,7 +3335,16 @@ static void add_ffmpeg_audio( hb_title_t *title, hb_stream_t *stream, int id ) } else { - audio->config.in.codec = HB_ACODEC_FFMPEG; + if ( codec->codec_id == CODEC_ID_DTS && + ( codec->profile == FF_PROFILE_DTS_HD_MA || + codec->profile == FF_PROFILE_DTS_HD_HRA ) ) + { + audio->config.in.codec = HB_ACODEC_DCA_HD | HB_ACODEC_FF_I_FLAG; + } + else + { + audio->config.in.codec = HB_ACODEC_FFMPEG | HB_ACODEC_FF_I_FLAG; + } audio->config.in.codec_param = ffmpeg_codec_param( stream, id ); audio->config.in.bitrate = codec->bit_rate? codec->bit_rate : 1; diff --git a/libhb/sync.c b/libhb/sync.c index 09e88538c..b754a54cc 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -1033,7 +1033,8 @@ static int syncAudioWork( hb_work_object_t * w, hb_buffer_t ** buf_in, * Or in the case of DCA, skip some frames from the * other streams. */ - if( w->audio->config.out.codec == HB_ACODEC_DCA_PASS ) + if( w->audio->config.out.codec == HB_ACODEC_DCA_PASS || + w->audio->config.out.codec == HB_ACODEC_DCA_HD_PASS ) { hb_log( "sync: audio gap %d ms. Skipping frames. Audio 0x%x" " start %"PRId64", next %"PRId64, @@ -1093,8 +1094,7 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i ) w->audio = hb_list_item( title->list_audio, i ); w->fifo_in = w->audio->priv.fifo_raw; - if( w->audio->config.out.codec == HB_ACODEC_AC3_PASS || - w->audio->config.out.codec == HB_ACODEC_DCA_PASS ) + if ( w->audio->config.out.codec & HB_ACODEC_PASS_FLAG ) { w->fifo_out = w->audio->priv.fifo_out; } diff --git a/libhb/work.c b/libhb/work.c index f0a81fa75..90209dbd2 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -112,9 +112,16 @@ hb_work_object_t * hb_codec_decoder( int codec ) { case HB_ACODEC_AC3: return hb_get_work( WORK_DECA52 ); case HB_ACODEC_DCA: return hb_get_work( WORK_DECDCA ); - case HB_ACODEC_MPGA: return hb_get_work( WORK_DECAVCODEC ); case HB_ACODEC_LPCM: return hb_get_work( WORK_DECLPCM ); - case HB_ACODEC_FFMPEG: return hb_get_work( WORK_DECAVCODECAI ); + default: + if ( codec & HB_ACODEC_FF_MASK ) + { + if ( codec & HB_ACODEC_FF_I_FLAG ) + return hb_get_work( WORK_DECAVCODECAI ); + else + return hb_get_work( WORK_DECAVCODEC ); + } + break; } return NULL; } @@ -351,7 +358,7 @@ void hb_display_job_info( hb_job_t * job ) hb_log( " + bitrate: %d kbps, samplerate: %d Hz", audio->config.in.bitrate / 1000, audio->config.in.samplerate ); } - if( (audio->config.out.codec != HB_ACODEC_AC3_PASS) && (audio->config.out.codec != HB_ACODEC_DCA_PASS) ) + if( !(audio->config.out.codec & HB_ACODEC_PASS_FLAG) ) { for (j = 0; j < hb_audio_mixdowns_count; j++) { @@ -371,10 +378,12 @@ void hb_display_job_info( hb_job_t * job ) hb_log(" + dynamic range compression: %f", audio->config.out.dynamic_range_compression); } - if( (audio->config.out.codec == HB_ACODEC_AC3_PASS) || (audio->config.out.codec == HB_ACODEC_DCA_PASS) ) + if( audio->config.out.codec & HB_ACODEC_PASS_FLAG ) { - hb_log( " + %s passthrough", (audio->config.out.codec == HB_ACODEC_AC3_PASS) ? - "AC3" : "DCA" ); + hb_log( " + %s passthrough", + (audio->config.out.codec == HB_ACODEC_AC3_PASS) ? "AC3" : + (audio->config.out.codec == HB_ACODEC_DCA_PASS) ? "DTS" : + "DTS-HD"); } else { @@ -416,7 +425,7 @@ static int check_ff_audio( hb_list_t *list_audio, hb_audio_t *ff_audio ) if ( audio == ff_audio ) break; - if ( audio->config.in.codec == HB_ACODEC_FFMPEG && + if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) && audio->id == ff_audio->id ) { hb_list_add( audio->priv.ff_audio_list, ff_audio ); @@ -547,8 +556,9 @@ static void do_job( hb_job_t * job ) for( i = 0; i < hb_list_count( title->list_audio ); ) { audio = hb_list_item( title->list_audio, i ); - if( ( ( audio->config.out.codec == HB_ACODEC_AC3_PASS ) && ( audio->config.in.codec != HB_ACODEC_AC3 ) ) || - ( ( audio->config.out.codec == HB_ACODEC_DCA_PASS ) && ( audio->config.in.codec != HB_ACODEC_DCA ) ) ) + if( ( audio->config.out.codec & HB_ACODEC_PASS_FLAG ) && + !( audio->config.in.codec & audio->config.out.codec & + HB_ACODEC_PASS_MASK ) ) { hb_log( "Passthru requested and input codec is not the same as output codec for track %d", audio->config.out.track ); @@ -556,8 +566,7 @@ static void do_job( hb_job_t * job ) free( audio ); continue; } - if( audio->config.out.codec != HB_ACODEC_AC3_PASS && - audio->config.out.codec != HB_ACODEC_DCA_PASS && + if( !(audio->config.out.codec & HB_ACODEC_PASS_FLAG) && audio->config.out.samplerate > 48000 ) { hb_log( "Sample rate %d not supported. Down-sampling to 48kHz.", @@ -712,7 +721,7 @@ static void do_job( hb_job_t * job ) audio->priv.fifo_out = hb_fifo_init( FIFO_LARGE, FIFO_LARGE_WAKE ); audio->priv.ff_audio_list = hb_list_init(); - if ( audio->config.in.codec == HB_ACODEC_FFMPEG ) + if ( audio->config.in.codec & HB_ACODEC_FF_MASK ) { if ( !check_ff_audio( title->list_audio, audio ) ) { @@ -939,8 +948,7 @@ static void do_job( hb_job_t * job ) /* * Audio Encoder Thread */ - if( audio->config.out.codec != HB_ACODEC_AC3_PASS && - audio->config.out.codec != HB_ACODEC_DCA_PASS ) + if ( !(audio->config.out.codec & HB_ACODEC_PASS_FLAG ) ) { /* * Add the encoder thread if not doing AC-3 pass through diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m index 194d4dd16..920cd13ae 100644 --- a/macosx/HBAudio.m +++ b/macosx/HBAudio.m @@ -135,6 +135,13 @@ static NSMutableArray *masterBitRateArray = nil; [NSNumber numberWithInt: HB_ACODEC_DCA], keyAudioMustMatchTrack, nil]]; [masterCodecArray addObject: [NSDictionary dictionaryWithObjectsAndKeys: + NSLocalizedString(@"DTS-HD Passthru", @"DTS-HD Passthru"), keyAudioCodecName, + [NSNumber numberWithInt: HB_ACODEC_DCA_HD_PASS], keyAudioCodec, + [NSNumber numberWithBool: NO], keyAudioMP4, + [NSNumber numberWithBool: YES], keyAudioMKV, + [NSNumber numberWithInt: HB_ACODEC_DCA_HD], keyAudioMustMatchTrack, + nil]]; + [masterCodecArray addObject: [NSDictionary dictionaryWithObjectsAndKeys: NSLocalizedString(@"Vorbis (vorbis)", @"Vorbis (vorbis)"), keyAudioCodecName, [NSNumber numberWithInt: HB_ACODEC_VORBIS], keyAudioCodec, [NSNumber numberWithBool: NO], keyAudioMP4, @@ -151,6 +158,10 @@ static NSMutableArray *masterBitRateArray = nil; NSLocalizedString(@"DTS Passthru", @"DTS Passthru"), keyAudioMixdownName, [NSNumber numberWithInt: HB_ACODEC_DCA_PASS], keyAudioMixdown, nil]]; + [masterMixdownArray addObject: [NSDictionary dictionaryWithObjectsAndKeys: + NSLocalizedString(@"DTS-HD Passthru", @"DTS-HD Passthru"), keyAudioMixdownName, + [NSNumber numberWithInt: HB_ACODEC_DCA_HD_PASS], keyAudioMixdown, + nil]]; for (i = 0; i < hb_audio_mixdowns_count; i++) { [masterMixdownArray addObject: [NSDictionary dictionaryWithObjectsAndKeys: @@ -639,7 +650,7 @@ static NSMutableArray *masterBitRateArray = nil; if (YES == retval) { int myMixdown = [[[self mixdown] objectForKey: keyAudioMixdown] intValue]; - if (HB_ACODEC_AC3_PASS == myMixdown || HB_ACODEC_DCA_PASS == myMixdown) + if (myMixdown & HB_ACODEC_PASS_FLAG) { retval = NO; } @@ -672,7 +683,7 @@ static NSMutableArray *masterBitRateArray = nil; if (YES == retval) { int myCodecCodec = [[[self codec] objectForKey: keyAudioCodec] intValue]; - if (HB_ACODEC_AC3_PASS == myCodecCodec || HB_ACODEC_DCA_PASS == myCodecCodec) + if (myCodecCodec & HB_ACODEC_PASS_FLAG) { retval = NO; } diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index b604fcc87..be7df4507 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -105,7 +105,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [aDict setObject: [[anAudio bitRate] objectForKey: keyAudioBitrateName] forKey: [prefix stringByAppendingString: @"Bitrate"]]; // output is not passthru so apply gain - if (HB_ACODEC_AC3_PASS != [[[anAudio codec] objectForKey: keyAudioCodec] intValue] && HB_ACODEC_DCA_PASS != [[[anAudio codec] objectForKey: keyAudioCodec] intValue]) + if (!([[[anAudio codec] objectForKey: keyAudioCodec] intValue] & HB_ACODEC_PASS_FLAG)) { [aDict setObject: [anAudio gain] forKey: [prefix stringByAppendingString: @"TrackGainSlider"]]; } diff --git a/test/test.c b/test/test.c index 4305c3625..4bb5f80d6 100644 --- a/test/test.c +++ b/test/test.c @@ -3565,7 +3565,7 @@ static int get_acodec_for_string( char *codec ) } else if( !strcasecmp( codec, "copy" ) ) { - return HB_ACODEC_AC3_PASS | HB_ACODEC_DCA_PASS; + return HB_ACODEC_AC3_PASS | HB_ACODEC_DCA_PASS | HB_ACODEC_DCA_HD_PASS; } else if( !strcasecmp( codec, "copy:ac3" ) ) { @@ -3575,6 +3575,10 @@ static int get_acodec_for_string( char *codec ) { return HB_ACODEC_DCA_PASS; } + else if( !strcasecmp( codec, "copy:dtshd" ) ) + { + return HB_ACODEC_DCA_HD_PASS; + } else if( !strcasecmp( codec, "lame" ) ) { return HB_ACODEC_LAME; |