summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaurj <[email protected]>2007-05-04 17:23:47 +0000
committermaurj <[email protected]>2007-05-04 17:23:47 +0000
commita38b87188264278d18a38c82c5cedfa5fbdbe991 (patch)
treecb40098bd8a46d1e23bedd5202499530f3daa7b6
parentacc0fbfcbf1a3dc278e82166ca304586a916350c (diff)
Enabled DTS channel mixdowns by moving to a more generic input channel layout set of constants. Updated Controller.mm to use these generic input layout constants when deciding which mixdowns to offer.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@565 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/common.h30
-rw-r--r--libhb/scan.c161
-rw-r--r--libhb/work.c309
-rw-r--r--macosx/Controller.mm38
4 files changed, 206 insertions, 332 deletions
diff --git a/libhb/common.h b/libhb/common.h
index fd77999fc..151b25b0e 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -295,6 +295,36 @@ struct hb_audio_s
/* dcaflags is only set when the source audio format is HB_ACODEC_DCA */
int dcaflags;
+/* define some masks, used to extract the various information from the HB_AMIXDOWN_XXXX values */
+#define HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK 0xF0000
+#define HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK 0x0F000
+#define HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK 0x00F00
+#define HB_INPUT_CH_LAYOUT_ENCODED_FRONT_MASK 0x000F0
+#define HB_INPUT_CH_LAYOUT_ENCODED_REAR_MASK 0x0000F
+
+/* define the input channel layouts used to describe the channel layout of this audio */
+#define HB_INPUT_CH_LAYOUT_MONO 0x0110010
+#define HB_INPUT_CH_LAYOUT_STEREO 0x0220020
+#define HB_INPUT_CH_LAYOUT_DOLBY 0x0320031
+#define HB_INPUT_CH_LAYOUT_3F 0x0430030
+#define HB_INPUT_CH_LAYOUT_2F1R 0x0521021
+#define HB_INPUT_CH_LAYOUT_3F1R 0x0631031
+#define HB_INPUT_CH_LAYOUT_2F2R 0x0722022
+#define HB_INPUT_CH_LAYOUT_3F2R 0x0832032
+#define HB_INPUT_CH_LAYOUT_3F2RLFE 0x0A32132
+#define HB_INPUT_CH_LAYOUT_4F2R 0x0942042
+
+/* define some macros to extract the various information from the HB_AMIXDOWN_XXXX values */
+#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_FRONT_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK ) >> 16 )
+#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK ) >> 12 )
+#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_LFE_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK ) >> 8 )
+#define HB_INPUT_CH_LAYOUT_GET_ENCODED_FRONT_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_ENCODED_FRONT_MASK ) >> 4 )
+#define HB_INPUT_CH_LAYOUT_GET_ENCODED_REAR_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_ENCODED_REAR_MASK ) )
+
+ /* input_channel_layout is the channel layout of this audio */
+ /* this is used to provide a common way of describing the source audio */
+ int input_channel_layout;
+
#ifdef __LIBHB__
/* Internal data */
hb_fifo_t * fifo_in; /* AC3/MPEG/LPCM ES */
diff --git a/libhb/scan.c b/libhb/scan.c
index 9d229b6cf..a93d3015a 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -159,6 +159,18 @@ static void ScanFunc( void * _data )
free( title );
continue;
}
+
+ /* set a default input channel layout of stereo for LPCM or MPEG2 audio */
+ /* AC3 and DCA will already have had their layout set via DecodePreviews above, */
+ /* which calls LookForAC3AndDCA */
+ for( j = 0; j < hb_list_count( title->list_audio ); j++ )
+ {
+ audio = hb_list_item( title->list_audio, j );
+ if( audio->codec == HB_ACODEC_LPCM || audio->codec == HB_ACODEC_MPGA )
+ {
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
+ }
+ }
i++;
}
@@ -441,6 +453,7 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b )
for( i = 0; i < hb_list_count( title->list_audio ); i++ )
{
audio = hb_list_item( title->list_audio, i );
+ /* check if we have an AC3 or DCA which we recognise */
if( ( audio->codec == HB_ACODEC_AC3 || audio->codec == HB_ACODEC_DCA ) &&
audio->id == b->id )
{
@@ -476,65 +489,48 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b )
audio->bitrate = bitrate;
switch( flags & A52_CHANNEL_MASK )
{
+ /* mono sources */
case A52_MONO:
case A52_CHANNEL1:
case A52_CHANNEL2:
- audio->src_discrete_front_channels = 1;
- audio->src_discrete_rear_channels = 0;
- audio->src_encoded_front_channels = 1;
- audio->src_encoded_rear_channels = 0;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_MONO;
break;
- case A52_STEREO:
+ /* stereo input */
case A52_CHANNEL:
- audio->src_discrete_front_channels = 2;
- audio->src_discrete_rear_channels = 0;
- audio->src_encoded_front_channels = 2;
- audio->src_encoded_rear_channels = 0;
+ case A52_STEREO:
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
break;
+ /* dolby (DPL1 aka Dolby Surround = 4.0 matrix-encoded) input */
case A52_DOLBY:
- audio->src_discrete_front_channels = 2;
- audio->src_discrete_rear_channels = 0;
- audio->src_encoded_front_channels = 3;
- audio->src_encoded_rear_channels = 1;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_DOLBY;
+ break;
+ /* 3F/2R input */
+ case A52_3F2R:
+ if (flags & A52_LFE) {
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F2RLFE;
+ } else {
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F2R;
+ }
break;
+ /* 3F/1R input */
+ case A52_3F1R:
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F1R;
+ break;
+ /* other inputs */
case A52_3F:
- audio->src_discrete_front_channels = 3;
- audio->src_discrete_rear_channels = 0;
- audio->src_encoded_front_channels = 3;
- audio->src_encoded_rear_channels = 0;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F;
break;
case A52_2F1R:
- audio->src_discrete_front_channels = 2;
- audio->src_discrete_rear_channels = 1;
- audio->src_encoded_front_channels = 2;
- audio->src_encoded_rear_channels = 1;
- break;
- case A52_3F1R:
- audio->src_discrete_front_channels = 3;
- audio->src_discrete_rear_channels = 1;
- audio->src_encoded_front_channels = 3;
- audio->src_encoded_rear_channels = 1;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_2F1R;
break;
case A52_2F2R:
- audio->src_discrete_front_channels = 2;
- audio->src_discrete_rear_channels = 2;
- audio->src_encoded_front_channels = 2;
- audio->src_encoded_rear_channels = 2;
- break;
- case A52_3F2R:
- audio->src_discrete_front_channels = 3;
- audio->src_discrete_rear_channels = 2;
- audio->src_encoded_front_channels = 3;
- audio->src_encoded_rear_channels = 2;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_2F2R;
break;
+ /* unknown */
+ default:
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
}
- if (flags & A52_LFE) {
- audio->src_discrete_lfe_channels = 1;
- } else {
- audio->src_discrete_lfe_channels = 0;
- }
-
/* store the AC3 flags for future reference
This enables us to find out if we had a stereo or Dolby source later on */
audio->config.a52.ac3flags = flags;
@@ -549,7 +545,9 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b )
} else {
sprintf( audio->lang + strlen( audio->lang ),
" (%d.%d ch)",
- audio->src_discrete_front_channels + audio->src_discrete_rear_channels, audio->src_discrete_lfe_channels );
+ HB_INPUT_CH_LAYOUT_GET_DISCRETE_FRONT_COUNT(audio->input_channel_layout) +
+ HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT(audio->input_channel_layout),
+ HB_INPUT_CH_LAYOUT_GET_DISCRETE_LFE_COUNT(audio->input_channel_layout));
}
break;
@@ -571,71 +569,47 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b )
audio->bitrate = bitrate;
switch( flags & DCA_CHANNEL_MASK )
{
+ /* mono sources */
case DCA_MONO:
- audio->src_discrete_front_channels = 1;
- audio->src_discrete_rear_channels = 0;
- audio->src_encoded_front_channels = 1;
- audio->src_encoded_rear_channels = 0;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_MONO;
break;
+ /* stereo input */
case DCA_CHANNEL:
case DCA_STEREO:
case DCA_STEREO_SUMDIFF:
case DCA_STEREO_TOTAL:
- audio->src_discrete_front_channels = 2;
- audio->src_discrete_rear_channels = 0;
- audio->src_encoded_front_channels = 2;
- audio->src_encoded_rear_channels = 0;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
break;
- case DCA_DOLBY:
- audio->src_discrete_front_channels = 2;
- audio->src_discrete_rear_channels = 0;
- audio->src_encoded_front_channels = 3;
- audio->src_encoded_rear_channels = 1;
+ /* 3F/2R input */
+ case DCA_3F2R:
+ if (flags & DCA_LFE) {
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F2RLFE;
+ } else {
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F2R;
+ }
+ break;
+ /* 3F/1R input */
+ case DCA_3F1R:
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F1R;
break;
+ /* other inputs */
case DCA_3F:
- audio->src_discrete_front_channels = 3;
- audio->src_discrete_rear_channels = 0;
- audio->src_encoded_front_channels = 3;
- audio->src_encoded_rear_channels = 0;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F;
break;
case DCA_2F1R:
- audio->src_discrete_front_channels = 2;
- audio->src_discrete_rear_channels = 1;
- audio->src_encoded_front_channels = 2;
- audio->src_encoded_rear_channels = 1;
- break;
- case DCA_3F1R:
- audio->src_discrete_front_channels = 3;
- audio->src_discrete_rear_channels = 1;
- audio->src_encoded_front_channels = 3;
- audio->src_encoded_rear_channels = 1;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_2F1R;
break;
case DCA_2F2R:
- audio->src_discrete_front_channels = 2;
- audio->src_discrete_rear_channels = 2;
- audio->src_encoded_front_channels = 2;
- audio->src_encoded_rear_channels = 2;
- break;
- case DCA_3F2R:
- audio->src_discrete_front_channels = 3;
- audio->src_discrete_rear_channels = 2;
- audio->src_encoded_front_channels = 3;
- audio->src_encoded_rear_channels = 2;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_2F2R;
break;
case DCA_4F2R:
- audio->src_discrete_front_channels = 4;
- audio->src_discrete_rear_channels = 2;
- audio->src_encoded_front_channels = 4;
- audio->src_encoded_rear_channels = 2;
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_4F2R;
break;
+ /* unknown */
+ default:
+ audio->input_channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
}
- if (flags & DCA_LFE) {
- audio->src_discrete_lfe_channels = 1;
- } else {
- audio->src_discrete_lfe_channels = 0;
- }
-
/* store the DCA flags for future reference
This enables us to find out if we had a stereo or Dolby source later on */
audio->config.dca.dcaflags = flags;
@@ -650,13 +624,16 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b )
} else {
sprintf( audio->lang + strlen( audio->lang ),
" (%d.%d ch)",
- audio->src_discrete_front_channels + audio->src_discrete_rear_channels, audio->src_discrete_lfe_channels );
+ HB_INPUT_CH_LAYOUT_GET_DISCRETE_FRONT_COUNT(audio->input_channel_layout) +
+ HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT(audio->input_channel_layout),
+ HB_INPUT_CH_LAYOUT_GET_DISCRETE_LFE_COUNT(audio->input_channel_layout));
}
break;
}
}
}
+
}
static int AllAC3AndDCAOK( hb_title_t * title )
diff --git a/libhb/work.c b/libhb/work.c
index 8f3c1d03c..e45ee7bab 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -220,7 +220,7 @@ static void do_job( hb_job_t * job, int cpu_count )
{
audio = hb_list_item( title->list_audio, i );
hb_log( " + %x, %s", audio->id, audio->lang );
-
+
/* sense-check the current mixdown options */
/* log the requested mixdown */
@@ -231,227 +231,108 @@ static void do_job( hb_job_t * job, int cpu_count )
}
}
- if (audio->codec == HB_ACODEC_AC3)
- {
+ /* sense-check the requested mixdown */
- /* sense-check the AC3 mixdown */
-
- /* audioCodecSupportsMono and audioCodecSupports6Ch are the same for now,
- but this may change in the future, so they are separated for flexibility */
- int audioCodecSupportsMono = (job->acodec == HB_ACODEC_FAAC);
- int audioCodecSupports6Ch = (job->acodec == HB_ACODEC_FAAC);
-
- /* find out what the format of our source AC3 audio is */
- switch (audio->config.a52.ac3flags & A52_CHANNEL_MASK) {
-
- /* mono sources */
- case A52_MONO:
- case A52_CHANNEL1:
- case A52_CHANNEL2:
- /* regardless of what stereo mixdown we've requested, a mono source always get mixed down
- to mono if we can, and mixed up to stereo if we can't */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 1) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_MONO;
- } else {
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
- }
- break;
-
- /* stereo input */
- case A52_CHANNEL:
- case A52_STEREO:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- /* use stereo if not supported */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
- /* otherwise, preserve stereo regardless of if we requested something higher */
- } else if (job->audio_mixdowns[i] > HB_AMIXDOWN_STEREO) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
- }
- break;
-
- /* dolby (DPL1 aka Dolby Surround = 4.0 matrix-encoded) input */
- /* the A52 flags don't allow for a way to distinguish between DPL1 and DPL2 on a DVD,
- so we always assume a DPL1 source for A52_DOLBY */
- case A52_DOLBY:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- /* preserve dolby if not supported */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
- /* otherwise, preserve dolby even if we requested something higher */
- /* a stereo mixdown will still be honoured here */
- } else if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBY) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
- }
- break;
-
- /* 3F/2R input */
- case A52_3F2R:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- /* use dpl2 if not supported */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
- } else {
- /* check if we have 3F2R input and also have an LFE - i.e. we have a 5.1 source) */
- if (audio->config.a52.ac3flags & A52_LFE) {
- /* we have a 5.1 source */
- /* if we requested 6ch, but our audio format doesn't support it, then mix to DPLII instead */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_6CH && audioCodecSupports6Ch == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
- }
- } else {
- /* we have a 5.0 source, so we can't do 6ch conversion
- default to DPL II instead */
- if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBYPLII) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
- }
- }
- }
- /* all other mixdowns will have been preserved here */
- break;
-
- /* 3F/1R input */
- case A52_3F1R:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- /* use dpl1 if not supported */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
- } else {
- /* we have a 4.0 or 4.1 source, so we can't do DPLII or 6ch conversion
- default to DPL I instead */
- if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBY) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
- }
- }
- /* all other mixdowns will have been preserved here */
- break;
-
- default:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 1) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_MONO;
- /* mix everything else down to stereo */
- } else {
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
- }
+ /* audioCodecsSupportMono and audioCodecsSupport6Ch are the same for now,
+ but this may change in the future, so they are separated for flexibility */
+ int audioCodecsSupportMono = ((audio->codec == HB_ACODEC_AC3 ||
+ audio->codec == HB_ACODEC_DCA) && job->acodec == HB_ACODEC_FAAC);
+ int audioCodecsSupport6Ch = ((audio->codec == HB_ACODEC_AC3 ||
+ audio->codec == HB_ACODEC_DCA) && job->acodec == HB_ACODEC_FAAC);
+ /* find out what the format of our source audio is */
+ switch (audio->input_channel_layout) {
+
+ /* mono sources */
+ case HB_INPUT_CH_LAYOUT_MONO:
+ /* regardless of what stereo mixdown we've requested, a mono source always get mixed down
+ to mono if we can, and mixed up to stereo if we can't */
+ if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecsSupportMono == 1) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_MONO;
+ } else {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
}
+ break;
- }
- else if (audio->codec == HB_ACODEC_DCA)
- {
+ /* stereo input */
+ case HB_INPUT_CH_LAYOUT_STEREO:
+ /* if we've requested a mono mixdown, and it is supported, then do the mix */
+ /* use stereo if not supported */
+ if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecsSupportMono == 0) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
+ /* otherwise, preserve stereo regardless of if we requested something higher */
+ } else if (job->audio_mixdowns[i] > HB_AMIXDOWN_STEREO) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
+ }
+ break;
- /* sense-check the DCA mixdown */
-
- /* audioCodecSupportsMono and audioCodecSupports6Ch are the same for now,
- but this may change in the future, so they are separated for flexibility */
- int audioCodecSupportsMono = (job->acodec == HB_ACODEC_FAAC);
- int audioCodecSupports6Ch = (job->acodec == HB_ACODEC_FAAC);
-
- /* find out what the format of our source DCA audio is */
- switch (audio->config.dca.dcaflags & DCA_CHANNEL_MASK) {
-
- /* mono sources */
- case DCA_MONO:
- /* regardless of what stereo mixdown we've requested, a mono source always get mixed down
- to mono if we can, and mixed up to stereo if we can't */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 1) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_MONO;
- } else {
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
- }
- break;
-
- /* stereo input */
- case DCA_CHANNEL:
- case DCA_STEREO:
- case DCA_STEREO_SUMDIFF:
- case DCA_STEREO_TOTAL:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- /* use stereo if not supported */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
- /* otherwise, preserve stereo regardless of if we requested something higher */
- } else if (job->audio_mixdowns[i] > HB_AMIXDOWN_STEREO) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
- }
- break;
-
- /* dolby (DPL1 aka Dolby Surround = 4.0 matrix-encoded) input */
- /* the A52 flags don't allow for a way to distinguish between DPL1 and DPL2 on a DVD,
- so we always assume a DPL1 source for A52_DOLBY */
- case DCA_DOLBY:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- /* preserve dolby if not supported */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
- /* otherwise, preserve dolby even if we requested something higher */
- /* a stereo mixdown will still be honoured here */
- } else if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBY) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
- }
- break;
-
- /* 3F/2R input */
- case DCA_3F2R:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- /* use dpl2 if not supported */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
- } else {
- /* check if we have 3F2R input and also have an LFE - i.e. we have a 5.1 source) */
- if (audio->config.dca.dcaflags & DCA_LFE) {
- /* we have a 5.1 source */
- /* if we requested 6ch, but our audio format doesn't support it, then mix to DPLII instead */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_6CH && audioCodecSupports6Ch == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
- }
- } else {
- /* we have a 5.0 source, so we can't do 6ch conversion
- default to DPL II instead */
- if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBYPLII) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
- }
- }
- }
- /* all other mixdowns will have been preserved here */
- break;
-
- /* 3F/1R input */
- case DCA_3F1R:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- /* use dpl1 if not supported */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 0) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
- } else {
- /* we have a 4.0 or 4.1 source, so we can't do DPLII or 6ch conversion
- default to DPL I instead */
- if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBY) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
- }
- }
- /* all other mixdowns will have been preserved here */
- break;
-
- default:
- /* if we've requested a mono mixdown, and it is supported, then do the mix */
- if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecSupportsMono == 1) {
- job->audio_mixdowns[i] = HB_AMIXDOWN_MONO;
- /* mix everything else down to stereo */
- } else {
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
- }
- }
+ /* dolby (DPL1 aka Dolby Surround = 4.0 matrix-encoded) input */
+ /* the A52 flags don't allow for a way to distinguish between DPL1 and DPL2 on a DVD,
+ so we always assume a DPL1 source for A52_DOLBY */
+ case HB_INPUT_CH_LAYOUT_DOLBY:
+ /* if we've requested a mono mixdown, and it is supported, then do the mix */
+ /* preserve dolby if not supported */
+ if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecsSupportMono == 0) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
+ /* otherwise, preserve dolby even if we requested something higher */
+ /* a stereo mixdown will still be honoured here */
+ } else if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBY) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
+ }
+ break;
- }
- else
- {
+ /* 3F/2R input */
+ case HB_INPUT_CH_LAYOUT_3F2R:
+ case HB_INPUT_CH_LAYOUT_3F2RLFE:
+ /* if we've requested a mono mixdown, and it is supported, then do the mix */
+ /* use dpl2 if not supported */
+ if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecsSupportMono == 0) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
+ } else {
+ /* check if we have 3F2R input and also have an LFE - i.e. we have a 5.1 source) */
+ if (audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2RLFE) {
+ /* we have a 5.1 source */
+ /* if we requested 6ch, but our audio format doesn't support it, then mix to DPLII instead */
+ if (job->audio_mixdowns[i] == HB_AMIXDOWN_6CH && audioCodecsSupport6Ch == 0) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
+ }
+ } else {
+ /* we have a 5.0 source, so we can't do 6ch conversion
+ default to DPL II instead */
+ if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBYPLII) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBYPLII;
+ }
+ }
+ }
+ /* all other mixdowns will have been preserved here */
+ break;
+
+ /* 3F/1R input */
+ case HB_INPUT_CH_LAYOUT_3F1R:
+ /* if we've requested a mono mixdown, and it is supported, then do the mix */
+ /* use dpl1 if not supported */
+ if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecsSupportMono == 0) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
+ } else {
+ /* we have a 4.0 or 4.1 source, so we can't do DPLII or 6ch conversion
+ default to DPL I instead */
+ if (job->audio_mixdowns[i] > HB_AMIXDOWN_DOLBY) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_DOLBY;
+ }
+ }
+ /* all other mixdowns will have been preserved here */
+ break;
- /* assume a stereo input and output for non-AC3/DCA audio input (LPCM, MP2),
- regardless of the mixdown passed to us */
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
+ default:
+ /* if we've requested a mono mixdown, and it is supported, then do the mix */
+ if (job->audio_mixdowns[i] == HB_AMIXDOWN_MONO && audioCodecsSupportMono == 1) {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_MONO;
+ /* mix everything else down to stereo */
+ } else {
+ job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
+ }
- }
+ }
/* log the output mixdown */
for (j = 0; j < hb_audio_mixdowns_count; j++) {
diff --git a/macosx/Controller.mm b/macosx/Controller.mm
index be6ad82f0..c8311f4e3 100644
--- a/macosx/Controller.mm
+++ b/macosx/Controller.mm
@@ -1528,12 +1528,14 @@ return registrationDictionary;
{
/* find out if our selected output audio codec supports mono and / or 6ch */
- /* we also check for an input codec of AC3,
- as it is the only library able to do the mixdown to mono / conversion to 6-ch */
+ /* we also check for an input codec of AC3 or DCA,
+ as they are the only libraries able to do the mixdown to mono / conversion to 6-ch */
/* audioCodecsSupportMono and audioCodecsSupport6Ch are the same for now,
but this may change in the future, so they are separated for flexibility */
- int audioCodecsSupportMono = (audio->codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_FAAC);
- int audioCodecsSupport6Ch = (audio->codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_FAAC);
+ int audioCodecsSupportMono = ((audio->codec == HB_ACODEC_AC3 ||
+ audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
+ int audioCodecsSupport6Ch = ((audio->codec == HB_ACODEC_AC3 ||
+ audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
/* check for AC-3 passthru */
if (audio->codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3)
@@ -1545,23 +1547,6 @@ return registrationDictionary;
else
{
- /* find out the audio channel layout for our input audio */
- /* we'll cheat and use the liba52 layouts, even if the source isn't AC3 */
- int channel_layout;
- int audio_has_lfe;
- if (audio->codec == HB_ACODEC_AC3)
- {
- channel_layout = (audio->ac3flags & A52_CHANNEL_MASK);
- audio_has_lfe = (audio->ac3flags & A52_LFE);
- }
- else
- {
- /* assume a stereo input for all other input codecs */
- /* we're cheating and using liba52's A52_STEREO layout here, even though the source isn't AC3 */
- channel_layout = A52_STEREO;
- audio_has_lfe = 0;
- }
-
/* add the appropriate audio mixdown menuitems to the popupbutton */
/* in each case, we set the new menuitem's tag to be the amixdown value for that mixdown,
so that we can reference the mixdown later */
@@ -1583,8 +1568,8 @@ return registrationDictionary;
/* do we want to add a stereo option? */
/* offer stereo if we have a mono source and non-mono-supporting codecs, as otherwise we won't have a mixdown at all */
/* also offer stereo if we have a stereo-or-better source */
- if (((channel_layout == A52_MONO || channel_layout == A52_CHANNEL1 || channel_layout == A52_CHANNEL2) && audioCodecsSupportMono == 0) ||
- (channel_layout >= A52_STEREO && channel_layout != A52_CHANNEL1 && channel_layout != A52_CHANNEL2)) {
+ if ((audio->input_channel_layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) ||
+ audio->input_channel_layout >= HB_INPUT_CH_LAYOUT_STEREO) {
id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
[NSString stringWithCString: hb_audio_mixdowns[1].human_readable_name]
action: NULL keyEquivalent: @""];
@@ -1594,7 +1579,8 @@ return registrationDictionary;
}
/* do we want to add a dolby surround (DPL1) option? */
- if (channel_layout == A52_3F1R || channel_layout == A52_3F2R || channel_layout == A52_DOLBY) {
+ if (audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F1R || audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2R ||
+ audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2RLFE || audio->input_channel_layout == HB_INPUT_CH_LAYOUT_DOLBY) {
id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
[NSString stringWithCString: hb_audio_mixdowns[2].human_readable_name]
action: NULL keyEquivalent: @""];
@@ -1604,7 +1590,7 @@ return registrationDictionary;
}
/* do we want to add a dolby pro logic 2 (DPL2) option? */
- if (channel_layout == A52_3F2R) {
+ if (audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2R || audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2RLFE) {
id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
[NSString stringWithCString: hb_audio_mixdowns[3].human_readable_name]
action: NULL keyEquivalent: @""];
@@ -1614,7 +1600,7 @@ return registrationDictionary;
}
/* do we want to add a 6-channel discrete option? */
- if (audioCodecsSupport6Ch == 1 && channel_layout == A52_3F2R && audio_has_lfe == A52_LFE) {
+ if (audioCodecsSupport6Ch == 1 && audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2RLFE) {
id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
[NSString stringWithCString: hb_audio_mixdowns[4].human_readable_name]
action: NULL keyEquivalent: @""];