diff options
author | steve <steve@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-12-09 18:54:54 +0000 |
---|---|---|
committer | steve <steve@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-12-09 18:54:54 +0000 |
commit | 80a081bc44d4e6dbfd501330d24fa768624aa597 (patch) | |
tree | 26487096cef8f289a938d38c3f86e94c60d09362 /libao2 | |
parent | 1351fb412acc17847bd5ba0d70c95e1448db7d0a (diff) | |
download | mpv-80a081bc44d4e6dbfd501330d24fa768624aa597.tar.bz2 mpv-80a081bc44d4e6dbfd501330d24fa768624aa597.tar.xz |
still fiddling with surround levels
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3411 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r-- | libao2/pl_surround.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/libao2/pl_surround.c b/libao2/pl_surround.c index 8735004096..b7b811209d 100644 --- a/libao2/pl_surround.c +++ b/libao2/pl_surround.c @@ -156,19 +156,21 @@ static int play(){ out = pl_surround.databuf; in = (int16_t *)ao_plugin_data.data; for (i=0; i<samples; i++) { - // About the .707 here and the /2 for surround: + // About volume balancing... // Surround encoding does the following: // Lt=L+.707*C+.707*S, Rt=R+.707*C-.707*S - // So S needs to be extracted as: - // .707*(L-R) - // But L-R could still be as much as 32767-(-32768), way off scale - // for signed 16 bits, so to avoid running out of bits, whilst still - // keeping levels in balance, we scale L and R down by 3dB (*.707), - // and scale the surround down by 6dB (.707*.707=.5) + // So S should to be extracted as: + // .707*(Lt-Rt) + // But we are splitting the S to two output channels, so we + // must take another 3dB off as we split it: + // Ls=Rs=.707*.707*(Lt-Rt) + // = .5*(Lt-Rt) + // This result is handy as it is also sure not to clip, even + // though L could be full scale +ve, R full scale -ve // front left and right - out[0] = in[0]*.707; - out[1] = in[1]*.707; + out[0] = in[0]; + out[1] = in[1]; // surround - from 15msec ago out[2] = pl_surround.delaybuf[pl_surround.delaybuf_ptr]; out[3] = -out[2]; @@ -184,6 +186,3 @@ static int play(){ ao_plugin_data.len=samples*sizeof(int16_t)*4; return 1; } - - - |