summaryrefslogtreecommitdiffstats
path: root/libhb/work.c
diff options
context:
space:
mode:
authormaurj <[email protected]>2007-05-02 15:56:39 +0000
committermaurj <[email protected]>2007-05-02 15:56:39 +0000
commit7800f22f054d4a96731c94bc71310c09a2b8235f (patch)
treeccee5caab83f8bda1057985f71145ef83bbfb0be /libhb/work.c
parent3a55755f5bd2fb02d5e87f100b83f81e61f7bf82 (diff)
Added support for DTS audio. DTS audio streams (of 5.1 audio and below) will be detected and decoded. This requires a new library - libdca (and patch) - which is included (in patched form) in a new version of the pre-built UB Darwin contribs (0012). These have been uploaded to download.m0k.org/handbrake/contrib/ .
I haven't yet added any code to Controller.mm to recognise the DTS streams as supporting mono / 6ch DPL1 / DPL2 downmixes. Note: running Jam on the new library required me to update some tools on Mac OS X - possibly libtool, autoconf, automake. Not sure which made the difference, but these were the ones I updated. it won't jam successfully without this. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@559 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/work.c')
-rw-r--r--libhb/work.c131
1 files changed, 123 insertions, 8 deletions
diff --git a/libhb/work.c b/libhb/work.c
index 3e5ec4a78..8f3c1d03c 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -6,6 +6,7 @@
#include "hb.h"
#include "a52dec/a52.h"
+#include "dca.h"
typedef struct
{
@@ -230,13 +231,8 @@ static void do_job( hb_job_t * job, int cpu_count )
}
}
- if(audio->codec != HB_ACODEC_AC3) {
-
- /* assume a stereo input and output for non-AC3 audio input (LPCM, MP2),
- regardless of the mixdown passed to us */
- job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
-
- } else {
+ if (audio->codec == HB_ACODEC_AC3)
+ {
/* sense-check the AC3 mixdown */
@@ -339,7 +335,122 @@ static void do_job( hb_job_t * job, int cpu_count )
job->audio_mixdowns[i] = HB_AMIXDOWN_STEREO;
}
- }
+ }
+
+ }
+ else if (audio->codec == HB_ACODEC_DCA)
+ {
+
+ /* 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;
+ }
+ }
+
+ }
+ else
+ {
+
+ /* 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;
+
}
/* log the output mixdown */
@@ -367,6 +478,9 @@ static void do_job( hb_job_t * job, int cpu_count )
case HB_ACODEC_AC3:
w = getWork( WORK_DECA52 );
break;
+ case HB_ACODEC_DCA:
+ w = getWork( WORK_DECDCA );
+ break;
case HB_ACODEC_MPGA:
w = getWork( WORK_DECAVCODEC );
break;
@@ -466,6 +580,7 @@ static void do_job( hb_job_t * job, int cpu_count )
/* FIXME: This feels really hackish, anything better? */
if ( w->id == WORK_DECA52 ||
+ w->id == WORK_DECDCA ||
w->id == WORK_DECLPCM ||
w->id == WORK_ENCFAAC ||
w->id == WORK_ENCLAME ||