summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.h30
-rw-r--r--libhb/scan.c161
-rw-r--r--libhb/work.c309
3 files changed, 194 insertions, 306 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++) {