Mercurial > mplayer.hg
comparison libao2/pl_surround.c @ 3373:e5b881ac961e
Corrected front:surround levels
author | steve |
---|---|
date | Fri, 07 Dec 2001 22:36:33 +0000 |
parents | 614b4525d275 |
children | 3eb15016e454 |
comparison
equal
deleted
inserted
replaced
3372:0704cb60a223 | 3373:e5b881ac961e |
---|---|
153 | 153 |
154 samples = ao_plugin_data.len / sizeof(int16_t) / pl_surround.input_channels; | 154 samples = ao_plugin_data.len / sizeof(int16_t) / pl_surround.input_channels; |
155 | 155 |
156 out = pl_surround.databuf; in = (int16_t *)ao_plugin_data.data; | 156 out = pl_surround.databuf; in = (int16_t *)ao_plugin_data.data; |
157 for (i=0; i<samples; i++) { | 157 for (i=0; i<samples; i++) { |
158 | |
159 // About the .707 here and the /2 for surround: | |
160 // Surround encoding does the following: | |
161 // Lt=L+.707*C+.707*S, Rt=R+.707*C-.707*S | |
162 // So S needs to be extracted as: | |
163 // .707*(L-R) | |
164 // But L-R could still be as much as 32767-(-32768), way off scale | |
165 // for signed 16 bits, so to avoid running out of bits, whilst still | |
166 // keeping levels in balance, we scale L and R down by 3dB (*.707), | |
167 // and scale the surround down by 6dB (.707*.707=.5) | |
168 | |
158 // front left and right | 169 // front left and right |
159 out[0] = in[0]; | 170 out[0] = in[0]*.707; |
160 out[1] = in[1]; | 171 out[1] = in[1]*.707; |
161 // surround - from 15msec ago | 172 // surround - from 15msec ago |
162 out[2] = pl_surround.delaybuf[pl_surround.delaybuf_ptr]; | 173 out[2] = pl_surround.delaybuf[pl_surround.delaybuf_ptr]; |
163 out[3] = -out[2]; | 174 out[3] = -out[2]; |
164 // calculate and save surround for 15msecs time | 175 // calculate and save surround for 15msecs time |
165 pl_surround.delaybuf[pl_surround.delaybuf_ptr++] = (in[0]/2 - in[1]/2); | 176 pl_surround.delaybuf[pl_surround.delaybuf_ptr++] = (in[0]/2 - in[1]/2); |