summaryrefslogtreecommitdiffstats
path: root/libao2
diff options
context:
space:
mode:
authoratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-06-16 01:44:33 +0000
committeratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-06-16 01:44:33 +0000
commita5737c25ee7a00b75ba58fb78c27b37fbc14cc4f (patch)
tree3f7861bdab1d931c65c6fb8a44dbe8e6b395de17 /libao2
parent56d5ebb2fc8fe00ce2261fa8bc6a50fee7fff223 (diff)
downloadmpv-a5737c25ee7a00b75ba58fb78c27b37fbc14cc4f.tar.bz2
mpv-a5737c25ee7a00b75ba58fb78c27b37fbc14cc4f.tar.xz
Fixed lround replacement, hopefully fast enough.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6440 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r--libao2/pl_eq.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libao2/pl_eq.c b/libao2/pl_eq.c
index 2588b383d1..eb9234a297 100644
--- a/libao2/pl_eq.c
+++ b/libao2/pl_eq.c
@@ -89,16 +89,21 @@ static int control(int cmd,int arg){
return CONTROL_UNKNOWN;
}
+// return rounded 16bit int
+static inline int16_t lround16(double n){
+ return (int16_t)((n)>=0.0?(n)+0.5:(n)-0.5);
+}
+
// 2nd order Band-pass Filter design
void bp2(int16_t* a, int16_t* b, float fc, float q){
double th=2*3.141592654*fc;
double C=(1 - tan(th*q/2))/(1 + tan(th*q/2));
- a[0] = (int16_t)( 16383.0 * (1 + C) * cos(th) + 0.5);
- a[1] = (int16_t)(-16383.0 * C + 0.5);
+ a[0] = lround16( 16383.0 * (1 + C) * cos(th));
+ a[1] = lround16(-16383.0 * C);
- b[0] = (int16_t)(-16383.0 * (C - 1)/2 + 0.5);
- b[1] = (int16_t)(-16383.0 * 1.0050 + 0.5);
+ b[0] = lround16(-16383.0 * (C - 1)/2);
+ b[1] = lround16(-16383.0 * 1.0050);
}
// empty buffers