diff options
-rw-r--r-- | MacOsXContribBinariesVersion.txt | 2 | ||||
-rw-r--r-- | contrib/patch-libdca.patch | 81 | ||||
-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 | ||||
-rw-r--r-- | macosx/Controller.mm | 13 |
8 files changed, 112 insertions, 85 deletions
diff --git a/MacOsXContribBinariesVersion.txt b/MacOsXContribBinariesVersion.txt index f582134f6..1ca31086b 100644 --- a/MacOsXContribBinariesVersion.txt +++ b/MacOsXContribBinariesVersion.txt @@ -1 +1 @@ -0013 +0014 diff --git a/contrib/patch-libdca.patch b/contrib/patch-libdca.patch index 92f2cfe2f..cab8db266 100644 --- a/contrib/patch-libdca.patch +++ b/contrib/patch-libdca.patch @@ -341,7 +341,7 @@ diff -Naur libdca/libdca/dca_internal.h libdca_patched/libdca/dca_internal.h #define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30)) diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c --- libdca/libdca/downmix.c 2007-05-02 10:05:05.000000000 +0100 -+++ libdca_patched/libdca/downmix.c 2007-05-02 10:09:34.000000000 +0100 ++++ libdca_patched/libdca/downmix.c 2007-05-06 19:45:54.000000000 +0100 @@ -33,8 +33,8 @@ #define CONVERT(acmod,output) (((output) << DCA_CHANNEL_BITS) + (acmod)) @@ -470,21 +470,39 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c for (i = 0; i < 256; i++) { common = BIAS (samples[i] + samples[i + 768]); -@@ -426,10 +429,10 @@ +@@ -426,23 +429,32 @@ } } -static void mix31toS (sample_t * samples, sample_t bias) +static void mix31toS (dca_sample_t * samples, dca_sample_t bias) { - int i; +- int i; - sample_t common, surround; -+ dca_sample_t common, surround; - for (i = 0; i < 256; i++) { - common = BIAS (samples[i]); -@@ -439,10 +442,10 @@ - } +- for (i = 0; i < 256; i++) { +- common = BIAS (samples[i]); +- surround = samples[i + 768]; +- samples[i] = samples[i + 256] + common - surround; +- samples[i + 256] = samples[i + 512] + common + surround; +- } ++ int i; ++ dca_sample_t cc, surround, Lt, Rt; ++ ++ for (i = 0; i < 256; i++) { ++ ++ cc = samples[i] * LEVEL_3DB; ++ ++ surround = samples[i + 768]; ++ ++ Lt = samples[i + 256] + cc; ++ Rt = samples[i + 512] + cc; ++ ++ samples[i] = Lt - surround; ++ samples[i + 256] = Rt + surround; ++ ++ } ++ } -static void mix22toS (sample_t * samples, sample_t bias) @@ -496,7 +514,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c for (i = 0; i < 256; i++) { surround = samples[i + 512] + samples[i + 768]; -@@ -451,10 +454,10 @@ +@@ -451,10 +463,10 @@ } } @@ -509,7 +527,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c for (i = 0; i < 256; i++) { common = BIAS (samples[i]); -@@ -463,20 +466,48 @@ +@@ -463,20 +475,55 @@ } } @@ -527,15 +545,16 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c - } -} + if (use_dpl2 == 1) { -+ + +-static void move2to1 (sample_t * src, sample_t * dest, sample_t bias) + int i; + dca_sample_t cc, Lt, Rt, Ls, Rs, Lss, Rss; + + for (i = 0; i < 256; i++) { + -+ cc = samples[i + 256] * LEVEL_3DB; ++ cc = samples[i] * LEVEL_3DB; + -+ Lt = samples[i] + cc; ++ Lt = samples[i + 256] + cc; + Rt = samples[i + 512] + cc; + + Ls = samples[i + 768]; @@ -552,16 +571,22 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c + } else { + + int i; -+ dca_sample_t common, surround; ++ dca_sample_t cc, surround, Lt, Rt; + + for (i = 0; i < 256; i++) { -+ common = samples[i + 256] + bias; -+ surround = samples[i + 768] + samples[i + 1024]; -+ samples[i] += common - surround; -+ samples[i + 256] = samples[i + 512] + common + surround; ++ ++ cc = samples[i] * LEVEL_3DB; ++ ++ surround = samples[i + 768] + samples[i + 1024]; ++ ++ Lt = samples[i + 256] + cc; ++ Rt = samples[i + 512] + cc; ++ ++ samples[i] = Lt - surround; ++ samples[i + 256] = Rt + surround; ++ + } - --static void move2to1 (sample_t * src, sample_t * dest, sample_t bias) ++ + } + +} @@ -569,7 +594,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c { int i; -@@ -484,7 +515,7 @@ +@@ -484,7 +531,7 @@ dest[i] = BIAS (src[i] + src[i + 256]); } @@ -578,7 +603,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c { int i; -@@ -492,8 +523,8 @@ +@@ -492,8 +539,8 @@ samples[i] = 0; } @@ -589,7 +614,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c { (void)clev; -@@ -529,7 +560,7 @@ +@@ -529,7 +576,7 @@ break; case CONVERT (DCA_MONO, DCA_DOLBY): @@ -598,7 +623,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c break; case CONVERT (DCA_3F, DCA_STEREO): -@@ -576,7 +607,7 @@ +@@ -576,7 +623,7 @@ break; case CONVERT (DCA_3F2R, DCA_DOLBY): @@ -607,7 +632,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c break; case CONVERT (DCA_3F1R, DCA_3F): -@@ -594,7 +625,7 @@ +@@ -594,7 +641,7 @@ case CONVERT (DCA_3F1R, DCA_2F1R): mix3to2 (samples, bias); @@ -616,7 +641,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c break; case CONVERT (DCA_2F2R, DCA_2F1R): -@@ -608,30 +639,52 @@ +@@ -608,30 +655,52 @@ case CONVERT (DCA_3F2R, DCA_3F1R): mix2to1 (samples + 768, samples + 1024, bias); @@ -675,7 +700,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c { switch (CONVERT (acmod, output & DCA_CHANNEL_MASK)) { -@@ -657,7 +710,7 @@ +@@ -657,7 +726,7 @@ case CONVERT (DCA_3F, DCA_STEREO): case CONVERT (DCA_3F, DCA_DOLBY): mix_3to2: @@ -684,7 +709,7 @@ diff -Naur libdca/libdca/downmix.c libdca_patched/libdca/downmix.c zero (samples + 256); break; -@@ -684,11 +737,11 @@ +@@ -684,11 +753,11 @@ zero (samples + 1024); case CONVERT (DCA_3F1R, DCA_2F1R): mix_31to21: 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 ); diff --git a/macosx/Controller.mm b/macosx/Controller.mm index c8311f4e3..871dfae31 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -1554,6 +1554,9 @@ return registrationDictionary; /* keep a track of the min and max mixdowns we used, so we can select the best match later */ int minMixdownUsed = 0; int maxMixdownUsed = 0; + + /* get the input channel layout without any lfe channels */ + int layout = audio->input_channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK; /* do we want to add a mono option? */ if (audioCodecsSupportMono == 1) { @@ -1568,8 +1571,7 @@ 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 ((audio->input_channel_layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) || - audio->input_channel_layout >= HB_INPUT_CH_LAYOUT_STEREO) { + if ((layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) || layout >= HB_INPUT_CH_LAYOUT_STEREO) { id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle: [NSString stringWithCString: hb_audio_mixdowns[1].human_readable_name] action: NULL keyEquivalent: @""]; @@ -1579,8 +1581,7 @@ return registrationDictionary; } /* do we want to add a dolby surround (DPL1) option? */ - 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) { + if (layout == HB_INPUT_CH_LAYOUT_3F1R || layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_DOLBY) { id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle: [NSString stringWithCString: hb_audio_mixdowns[2].human_readable_name] action: NULL keyEquivalent: @""]; @@ -1590,7 +1591,7 @@ return registrationDictionary; } /* do we want to add a dolby pro logic 2 (DPL2) option? */ - if (audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2R || audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2RLFE) { + if (layout == HB_INPUT_CH_LAYOUT_3F2R) { id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle: [NSString stringWithCString: hb_audio_mixdowns[3].human_readable_name] action: NULL keyEquivalent: @""]; @@ -1600,7 +1601,7 @@ return registrationDictionary; } /* do we want to add a 6-channel discrete option? */ - if (audioCodecsSupport6Ch == 1 && audio->input_channel_layout == HB_INPUT_CH_LAYOUT_3F2RLFE) { + if (audioCodecsSupport6Ch == 1 && layout == HB_INPUT_CH_LAYOUT_3F2R && (audio->input_channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE)) { id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle: [NSString stringWithCString: hb_audio_mixdowns[4].human_readable_name] action: NULL keyEquivalent: @""]; |