diff options
author | maurj <[email protected]> | 2007-05-06 21:32:01 +0000 |
---|---|---|
committer | maurj <[email protected]> | 2007-05-06 21:32:01 +0000 |
commit | 1b1c0f9ceaa8b712d5b43056276d7d2f83ca395b (patch) | |
tree | c8a8828362ee7b8d595b41007683b5540163d161 /libhb | |
parent | 51f567d40d8706914b4bfca9670f2a8e609aebea (diff) |
Updated the input channel layouts to store the source LFE information as well as the non-LFE layout. This is so muxavi.c can output the correct channel count for AC3 passthru for all AC3 sources. Updated Controller.mm, scan.c and work.c to use these revised layouts.
Added a new property to the work object, to remember the source audio codec for audio work objects. This enables encfaac to detect an 6-channel AC3 source to apply the QuickTime 6-channel audio mapping (as opposed to a DTS source, which doesn't need it).
Fixed the Dolby Pro Logic I/II downmix mappings in libdca and updated the libdca patch. Uploaded a new set of pre-built darwin contribs (0014) with this patch applied.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@570 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.h | 26 | ||||
-rw-r--r-- | libhb/encfaac.c | 24 | ||||
-rw-r--r-- | libhb/muxavi.c | 4 | ||||
-rw-r--r-- | libhb/scan.c | 24 | ||||
-rw-r--r-- | libhb/work.c | 23 |
5 files changed, 51 insertions, 50 deletions
diff --git a/libhb/common.h b/libhb/common.h index 151b25b0e..8b09c85c9 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -278,16 +278,6 @@ struct hb_audio_s int codec; int rate; int bitrate; - /* src_discrete_front_channels: The # of discrete front channels in the source audio - src_discrete_rear_channels: The # of discrete rear channels in the source audio - src_discrete_lfe_channels: The # of discrete lfe channels in the source audio - src_encoded_front_channels: The # of front channels encoded into the source audio - src_encoded_rear_channels: The # of rear channels encoded into the source audio */ - int src_discrete_front_channels; - int src_discrete_rear_channels; - int src_discrete_lfe_channels; - int src_encoded_front_channels; - int src_encoded_rear_channels; /* ac3flags is only set when the source audio format is HB_ACODEC_AC3 */ int ac3flags; @@ -296,11 +286,12 @@ struct hb_audio_s 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 HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK 0x00F0000 +#define HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK 0x000F000 +#define HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK 0x0000F00 +#define HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK 0xFFFF0FF +#define HB_INPUT_CH_LAYOUT_ENCODED_FRONT_MASK 0x00000F0 +#define HB_INPUT_CH_LAYOUT_ENCODED_REAR_MASK 0x000000F /* define the input channel layouts used to describe the channel layout of this audio */ #define HB_INPUT_CH_LAYOUT_MONO 0x0110010 @@ -311,13 +302,14 @@ struct hb_audio_s #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 HB_INPUT_CH_LAYOUT_HAS_LFE 0x0000100 /* 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_DISCRETE_COUNT( a ) ( ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK ) >> 16 ) + ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK ) >> 12 ) + ( ( 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 ) ) @@ -481,6 +473,8 @@ struct hb_work_object_s /* amixdown is the mixdown format to be used if the work object is an audio track */ int amixdown; + /* source_acodec is the source audio codec if the work object is an audio track */ + int source_acodec; hb_work_private_t * private_data; diff --git a/libhb/encfaac.c b/libhb/encfaac.c index 95a047ac6..5545f9ebf 100644 --- a/libhb/encfaac.c +++ b/libhb/encfaac.c @@ -79,17 +79,19 @@ int encfaacInit( hb_work_object_t * w, hb_job_t * job ) cfg->outputFormat = 0; cfg->inputFormat = FAAC_INPUT_FLOAT; - if (pv->out_discrete_channels == 6) { - /* we are preserving 5.1 audio into 6-channel AAC, and need to - re-map the output of deca52 into our own mapping - the mapping - below is the default mapping expected by QuickTime */ - /* This doesn't seem to be correct for VLC on Linux */ - cfg->channel_map[0] = 2; - cfg->channel_map[1] = 1; - cfg->channel_map[2] = 3; - cfg->channel_map[3] = 4; - cfg->channel_map[4] = 5; - cfg->channel_map[5] = 0; + if (w->amixdown == HB_AMIXDOWN_6CH && w->source_acodec == HB_ACODEC_AC3) + { + /* we are preserving 5.1 AC-3 audio into 6-channel AAC, and need to + re-map the output of deca52 into our own mapping - the mapping + below is the default mapping expected by QuickTime */ + /* DTS output from libdca is already in the right mapping for QuickTime */ + /* This doesn't seem to be correct for VLC on Linux */ + cfg->channel_map[0] = 2; + cfg->channel_map[1] = 1; + cfg->channel_map[2] = 3; + cfg->channel_map[3] = 4; + cfg->channel_map[4] = 5; + cfg->channel_map[5] = 0; } if( !faacEncSetConfiguration( pv->faac, cfg ) ) diff --git a/libhb/muxavi.c b/libhb/muxavi.c index 214393d68..de377f692 100644 --- a/libhb/muxavi.c +++ b/libhb/muxavi.c @@ -369,7 +369,7 @@ static int AVIInit( hb_mux_object_t * m ) { f.BytesCount = sizeof( hb_wave_formatex_t ) - 8; f.FormatTag = 0x2000; - f.Channels = 2; + f.Channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(audio->input_channel_layout); f.SamplesPerSec = audio->rate; } else @@ -377,7 +377,7 @@ static int AVIInit( hb_mux_object_t * m ) f.BytesCount = sizeof( hb_wave_formatex_t ) + sizeof( hb_wave_mp3_t ) - 8; f.FormatTag = 0x55; - f.Channels = 2; + f.Channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(job->audio_mixdowns[i]); f.SamplesPerSec = job->arate; } f.AvgBytesPerSec = h.Rate; diff --git a/libhb/scan.c b/libhb/scan.c index a93d3015a..45da1b7d1 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -506,11 +506,7 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b ) 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; - } + audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F2R; break; /* 3F/1R input */ case A52_3F1R: @@ -530,6 +526,12 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b ) default: audio->input_channel_layout = HB_INPUT_CH_LAYOUT_STEREO; } + + /* add in our own LFE flag if the source has LFE */ + if (flags & A52_LFE) + { + audio->input_channel_layout = audio->input_channel_layout | HB_INPUT_CH_LAYOUT_HAS_LFE; + } /* store the AC3 flags for future reference This enables us to find out if we had a stereo or Dolby source later on */ @@ -582,11 +584,7 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b ) break; /* 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; - } + audio->input_channel_layout = HB_INPUT_CH_LAYOUT_3F2R; break; /* 3F/1R input */ case DCA_3F1R: @@ -610,6 +608,12 @@ static void LookForAC3AndDCA( hb_title_t * title, hb_buffer_t * b ) audio->input_channel_layout = HB_INPUT_CH_LAYOUT_STEREO; } + /* add in our own LFE flag if the source has LFE */ + if (flags & DCA_LFE) + { + audio->input_channel_layout = audio->input_channel_layout | HB_INPUT_CH_LAYOUT_HAS_LFE; + } + /* 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; diff --git a/libhb/work.c b/libhb/work.c index 7cdb09fcc..aa7709719 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -255,7 +255,7 @@ static void do_job( hb_job_t * job, int cpu_count ) 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) { + switch (audio->input_channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK) { /* mono sources */ case HB_INPUT_CH_LAYOUT_MONO: @@ -297,14 +297,13 @@ static void do_job( hb_job_t * job, int cpu_count ) /* 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) { + if (audio->input_channel_layout & HB_INPUT_CH_LAYOUT_HAS_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 && audioCodecsSupport6Ch == 0) { @@ -383,10 +382,11 @@ static void do_job( hb_job_t * job, int cpu_count ) w = getWork( WORK_DECLPCM ); break; } - w->fifo_in = audio->fifo_in; - w->fifo_out = audio->fifo_raw; - w->config = &audio->config; - w->amixdown = audio->amixdown; + w->fifo_in = audio->fifo_in; + w->fifo_out = audio->fifo_raw; + w->config = &audio->config; + w->amixdown = audio->amixdown; + w->source_acodec = audio->codec; /* FIXME: This feels really hackish, anything better? */ audio_w = calloc( sizeof( hb_work_object_t ), 1 ); @@ -409,10 +409,11 @@ static void do_job( hb_job_t * job, int cpu_count ) if( job->acodec != HB_ACODEC_AC3 ) { - w->fifo_in = audio->fifo_sync; - w->fifo_out = audio->fifo_out; - w->config = &audio->config; - w->amixdown = audio->amixdown; + w->fifo_in = audio->fifo_sync; + w->fifo_out = audio->fifo_out; + w->config = &audio->config; + w->amixdown = audio->amixdown; + w->source_acodec = audio->codec; /* FIXME: This feels really hackish, anything better? */ audio_w = calloc( sizeof( hb_work_object_t ), 1 ); |