summaryrefslogtreecommitdiffstats
path: root/libhb/deca52.c
diff options
context:
space:
mode:
authormaurj <[email protected]>2007-04-11 15:23:57 +0000
committermaurj <[email protected]>2007-04-11 15:23:57 +0000
commitddc7ac09960746920ae8e48ac6f38a61c9f56d47 (patch)
tree0ad40c6da4ff1ef22f33f6b6543171f346643029 /libhb/deca52.c
parent1ce785c8d342834c33ee09e63315c5997782f919 (diff)
Added libhb and CLI support for Dolby Pro Logic II 5.0 matrix encoding. *NOT YET ADDED TO THE GUI*. Handbrake now uses a more general "audio mixdown" concept. For each audio track to be converted you specify a mixdown. These are defined in common.h.
This checkin only allows you to specify one mixdown for all tracks in the CLI, although everything is in place internally to specify a different mixdown per track. In the CLI, the "-6 --surround" option has been repurposed as a "-6 --mixdown" option, with a string parameter of mono/stereo/dpl1/dpl2/6ch. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@494 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/deca52.c')
-rw-r--r--libhb/deca52.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/libhb/deca52.c b/libhb/deca52.c
index 0664584c9..5b5f080bc 100644
--- a/libhb/deca52.c
+++ b/libhb/deca52.c
@@ -29,7 +29,7 @@ struct hb_work_private_s
hb_list_t * list;
- int channelsused;
+ int out_discrete_channels;
};
@@ -69,27 +69,11 @@ int deca52Init( hb_work_object_t * w, hb_job_t * job )
/* Decide what format we want out of a52dec
work.c has already done some of this deduction for us in do_job() */
- if (w->config->a52.channelsused == 6) {
- /* we're going to be encoding to a 6ch-supporting format,
- and have turned on the "preserve 5.1" flag */
- pv->flags_out = A52_3F2R | A52_LFE;
- } else if (w->config->a52.channelsused == 1) {
- /* we're going to be encoding to a 1ch-supporting format,
- so mix down to a mono track */
- pv->flags_out = A52_MONO;
- } else if (w->config->a52.channelsused == 2 && w->config->a52.channels == 5 && w->config->a52.lfechannels == 1) {
- /* we are mixing a 5.1 source down to stereo, so use dolby surround */
- pv->flags_out = A52_DOLBY;
- } else if (w->config->a52.channelsused == 2 && ((w->config->a52.ac3flags & A52_CHANNEL_MASK) == A52_DOLBY)) {
- /* we have a dolby stereo surround source, so preserve it */
- pv->flags_out = A52_DOLBY;
- } else {
- /* mix everything else down to plain stereo */
- pv->flags_out = A52_STEREO;
- }
+ pv->flags_out = HB_AMIXDOWN_GET_A52_FORMAT(w->amixdown);
/* pass the number of channels used into the private work data */
- pv->channelsused = w->config->a52.channelsused;
+ /* will only be actually used if we're not doing AC3 passthru */
+ pv->out_discrete_channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(w->amixdown);
pv->level = 32768.0;
@@ -206,7 +190,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
a52_frame( pv->state, pv->frame, &pv->flags_out, &pv->level, 0 );
/* 6 blocks per frame, 256 samples per block, channelsused channels */
- buf = hb_buffer_init( 6 * 256 * pv->channelsused * sizeof( float ) );
+ buf = hb_buffer_init( 6 * 256 * pv->out_discrete_channels * sizeof( float ) );
buf->start = pts + ( pos / pv->size ) * 6 * 256 * 90000 / pv->rate;
buf->stop = buf->start + 6 * 256 * 90000 / pv->rate;
@@ -217,14 +201,14 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
a52_block( pv->state );
samples_in = a52_samples( pv->state );
- samples_out = ((float *) buf->data) + 256 * pv->channelsused * i;
+ samples_out = ((float *) buf->data) + 256 * pv->out_discrete_channels * i;
/* Interleave */
for( j = 0; j < 256; j++ )
{
- for ( k = 0; k < pv->channelsused; k++ )
+ for ( k = 0; k < pv->out_discrete_channels; k++ )
{
- samples_out[(pv->channelsused*j)+k] = samples_in[(256*k)+j]; // DJA
+ samples_out[(pv->out_discrete_channels*j)+k] = samples_in[(256*k)+j]; // DJA
}
}
}