summaryrefslogtreecommitdiffstats
path: root/libhb/decdca.c
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-05-27 13:38:41 +0000
committerRodeo <[email protected]>2012-05-27 13:38:41 +0000
commitf2ffde5fff6540a84bca511a67ad7468c25aab81 (patch)
tree1026ba45c33da4d752b50fa9a11d4eff4269e46a /libhb/decdca.c
parentc906e05b28bae440471dd2a816627b9852eed3e8 (diff)
decdca: attempt to fix Dolby Surround and Pro Logic II mixdown. We were doing it wrong in some cases.
This means Dolby Pro Logic II is now only available for sources with at least L, R, C, Ls, Rs channels (as well as any additional channels), due to some libdca limitations. This will eventually go away when we use our own downmixing for all sources. Further cleanup to follow. Also cleans up usage of audio->config.in.flags (was audio->config.flags.*). git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4705 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/decdca.c')
-rw-r--r--libhb/decdca.c72
1 files changed, 60 insertions, 12 deletions
diff --git a/libhb/decdca.c b/libhb/decdca.c
index 49fb3ecae..a459dcd23 100644
--- a/libhb/decdca.c
+++ b/libhb/decdca.c
@@ -76,17 +76,66 @@ static int decdcaInit( hb_work_object_t * w, hb_job_t * job )
pv->list = hb_list_init();
pv->state = dca_init( 0 );
+ pv->level = 1.0;
+
+ /* Decide what format we want out of libdca;
+ * work.c has already done some of this deduction for us in do_job().
+ * Dolby Surround and Pro Logic II are a bit tricky. */
+ int layout = ( audio->config.in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK );
+ switch( audio->config.out.mixdown )
+ {
+ case HB_AMIXDOWN_DOLBYPLII:
+ {
+ if( layout == HB_INPUT_CH_LAYOUT_3F2R )
+ {
+ // Dolby Pro Logic II output is supported
+ pv->flags_out = ( DCA_3F2R | DCA_OUT_DPLII );
+ }
+ else if( layout == HB_INPUT_CH_LAYOUT_3F1R )
+ {
+ // Dolby Surround output and DCA_3F1R downmix are supported
+ pv->flags_out = ( DCA_3F1R | DCA_OUT_DPLI );
+ }
+ else if( layout > HB_INPUT_CH_LAYOUT_DOLBY )
+ {
+ // Dolby Surround output is supported, but DCA_3F1R downmix isn't
+ pv->flags_out = DCA_DOLBY;
+ }
+ else
+ {
+ // Dolby Surround output not supported OR
+ // Dolby Surround input just gets passed through as is
+ pv->flags_out = DCA_STEREO;
+ }
+ } break;
- /* Decide what format we want out of libdca
- work.c has already done some of this deduction for us in do_job() */
+ case HB_AMIXDOWN_DOLBY:
+ {
+ if( layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_3F1R )
+ {
+ // Dolby Surround output and DCA_3F1R downmix are supported
+ pv->flags_out = ( DCA_3F1R | DCA_OUT_DPLI );
+ }
+ else if( layout > HB_INPUT_CH_LAYOUT_DOLBY )
+ {
+ // Dolby Surround output is supported, but DCA_3F1R downmix isn't
+ pv->flags_out = DCA_DOLBY;
+ }
+ else
+ {
+ // Dolby Surround output not supported OR
+ // Dolby Surround input just gets passed through as is
+ pv->flags_out = DCA_STEREO;
+ }
+ } break;
- pv->flags_out = HB_AMIXDOWN_GET_DCA_FORMAT(audio->config.out.mixdown);
+ default:
+ pv->flags_out = HB_AMIXDOWN_GET_DCA_FORMAT( audio->config.out.mixdown );
+ break;
+ }
/* pass the number of channels used into the private work data */
- /* will only be actually used if we're not doing AC3 passthru */
- pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown);
-
- pv->level = 1.0;
+ pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT( audio->config.out.mixdown );
return 0;
}
@@ -315,11 +364,6 @@ static int decdcaBSInfo( hb_work_object_t *w, const hb_buffer_t *b,
info->flags = flags;
info->samples_per_frame = frame_length;
- if ( ( flags & DCA_CHANNEL_MASK) == DCA_DOLBY )
- {
- info->flags |= AUDIO_F_DOLBY;
- }
-
switch( flags & DCA_CHANNEL_MASK )
{
/* mono sources */
@@ -333,6 +377,10 @@ static int decdcaBSInfo( hb_work_object_t *w, const hb_buffer_t *b,
case DCA_STEREO_TOTAL:
info->channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
break;
+ /* Dolby Pro Logic (a.k.a. Dolby Surround), 4.0 channels (matrix-encoded) */
+ case DCA_DOLBY:
+ info->channel_layout = HB_INPUT_CH_LAYOUT_DOLBY;
+ break;
/* 3F/2R input */
case DCA_3F2R:
info->channel_layout = HB_INPUT_CH_LAYOUT_3F2R;