From 2d7b76c96066be19af9dc75af443d520457b698f Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 23 Dec 2001 19:10:00 +0000 Subject: [PATCH] surround channels can now be decoded in stereoish git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3682 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/pl_surround.c | 70 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/libao2/pl_surround.c b/libao2/pl_surround.c index c2872de7a5..1d2fdeaccb 100644 --- a/libao2/pl_surround.c +++ b/libao2/pl_surround.c @@ -21,11 +21,21 @@ */ /* The principle: Make rear channels by extracting anti-phase data - from the front channels, delay by 15msec and feed to rear in anti-phase - www.dolby.com has the background + from the front channels, delay by 20msec and feed to rear in anti-phase */ +// SPLITREAR: Define to decode two distinct rear channels - +// this doesn't work so well in practice because +// separation in a passive matrix is not high. +// C (dialogue) to Ls and Rs 14dB or so - +// so dialogue leaks to the rear. +// Still - give it a try and send feedback. +// comment this define for old behaviour of a single +// surround sent to rear in anti-phase +#define SPLITREAR + + #include #include #include @@ -65,7 +75,7 @@ typedef struct pl_surround_s } pl_surround_t; -static pl_surround_t pl_surround={0,15,NULL,NULL,NULL,0,0,NULL,0,0,0}; +static pl_surround_t pl_surround={0,20,NULL,NULL,NULL,0,0,NULL,0,0,0}; // to set/get/query special features/parameters static int control(int cmd,int arg){ @@ -153,13 +163,21 @@ static void reset() memset(pl_surround.Rs_delaybuf, 0, sizeof(int16_t)*pl_surround.delaybuf_len); } +// The beginnings of an active matrix... +static double steering_matrix[][12] = { +// LL RL LR RR LS RS LLs RLs LRs RRs LC RC + {.707, .0, .0, .707, .5, -.5, .5878, -.3928, .3928, -.5878, .5, .5}, +}; + +// Experimental moving average dominances +static int amp_L = 0, amp_R = 0, amp_C = 0, amp_S = 0; // processes 'ao_plugin_data.len' bytes of 'data' // called for every block of data static int play(){ int16_t *in, *out; int i, samples; - int surround; + double *matrix = steering_matrix[0]; // later we'll index based on detected dominance if (pl_surround.passthrough) return 1; @@ -168,12 +186,18 @@ static int play(){ samples = ao_plugin_data.len / sizeof(int16_t) / pl_surround.input_channels; out = pl_surround.databuf; in = (int16_t *)ao_plugin_data.data; - // Testing - place a 1kHz tone in the front channels in anti-phase + // Testing - place a 1kHz tone on Lt and Rt in anti-phase: should decode in S //sinewave(in, samples, pl_surround.input_channels, 1000, 0.0, pl_surround.rate); //sinewave(&in[1], samples, pl_surround.input_channels, 1000, PI, pl_surround.rate); for (i=0; i