[Mplayer-cvslog] CVS: main/libao2 pl_surround.c,1.2,1.3

Stephen Davies steve at mplayer.dev.hu
Fri Dec 7 23:36:43 CET 2001


Update of /cvsroot/mplayer/main/libao2
In directory mplayer:/var/tmp.root/cvs-serv15942/libao2

Modified Files:
	pl_surround.c 
Log Message:
Corrected front:surround levels

Index: pl_surround.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_surround.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pl_surround.c	4 Dec 2001 15:49:26 -0000	1.2
+++ pl_surround.c	7 Dec 2001 22:36:33 -0000	1.3
@@ -155,9 +155,20 @@
 
   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:
+    //   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)
+
     // front left and right
-    out[0] = in[0];
-    out[1] = in[1];
+    out[0] = in[0]*.707;
+    out[1] = in[1]*.707;
     // surround - from 15msec ago
     out[2] = pl_surround.delaybuf[pl_surround.delaybuf_ptr];
     out[3] = -out[2];




More information about the MPlayer-cvslog mailing list