aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-02-01 16:19:17 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-02-01 16:19:17 +0000
commit622d86de977922a6714cb771c735f2f2a25c0d78 (patch)
treede3643bafd9805e7ce4994d149be5d9c72a96995
parent4c1497f040f0ed2b2e0e602e246625dc06041b8f (diff)
downloadqmmp-622d86de977922a6714cb771c735f2f2a25c0d78.tar.gz
qmmp-622d86de977922a6714cb771c735f2f2a25c0d78.tar.bz2
qmmp-622d86de977922a6714cb771c735f2f2a25c0d78.zip
some ladspa optimization
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2029 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/plugins/Effect/ladspa/ladspahost.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/plugins/Effect/ladspa/ladspahost.cpp b/src/plugins/Effect/ladspa/ladspahost.cpp
index f18b9312b..4dcbd8440 100644
--- a/src/plugins/Effect/ladspa/ladspahost.cpp
+++ b/src/plugins/Effect/ladspa/ladspahost.cpp
@@ -1,7 +1,7 @@
/***************************************************************************
* Copyright (C) 2002-2003 Nick Lamb <njl195@zepler.org.uk> *
* Copyright (C) 2005 Giacomo Lozito <city_hunter@users.sf.net> *
- * Copyright (C) 2009 by Ilya Kotov <forkotov02@hotmail.ru> *
+ * Copyright (C) 2009-2011 by Ilya Kotov <forkotov02@hotmail.ru> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -35,9 +35,6 @@
#define PATH_MAX 4096
#endif
-#undef CLAMP
-#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
-
LADSPAHost *LADSPAHost::m_instance = 0;
LADSPAHost::LADSPAHost(QObject *parent) : QObject(parent)
@@ -253,35 +250,34 @@ int LADSPAHost::applyEffect(qint16 *d, int length)
if (m_chan == 1)
{
- for (k = 0; k < length / 2; ++k)
- m_left[k] = ((LADSPA_Data) raw16[k]) * (1.0f / 32768.0f);
+ for (k = 0; k < length >> 1; ++k)
+ m_left[k] = (LADSPA_Data) raw16[k] / 32768.0f;
foreach(instance, m_effects)
{
if (instance->handle)
- instance->descriptor->run(instance->handle, length / 2);
+ instance->descriptor->run(instance->handle, length >> 1);
}
- for (k = 0; k < length / 2; ++k)
- raw16[k] = CLAMP((int)(m_left[k] * 32768.0f), -32768, 32767);
+ for (k = 0; k < length >> 1; ++k)
+ raw16[k] = qBound((int)(m_left[k] * 32768.0f), -32768, 32767);
}
else
{
- for (k = 0; k < length / 2; k += 2)
+ for (k = 0; k < length >> 1; k += 2)
{
- m_left[k/2] = ((LADSPA_Data) raw16[k]) * (1.0f / 32768.0f);
- m_right[(k+1)/2] = ((LADSPA_Data) raw16[k+1]) * (1.0f / 32768.0f);
+ m_left[k >> 1] = (LADSPA_Data) raw16[k] / 32768.0f;
+ m_right[k >> 1] = (LADSPA_Data) raw16[k+1] / 32768.0f;
}
foreach(instance, m_effects)
{
if (instance->handle)
- instance->descriptor->run(instance->handle, length/4);
+ instance->descriptor->run(instance->handle, length >> 2);
if (instance->handle2)
- instance->descriptor->run(instance->handle2, length/4);
+ instance->descriptor->run(instance->handle2, length >> 2);
}
- for (k = 0; k < length / 2; k += 2)
+ for (k = 0; k < length >> 1; k += 2)
{
- raw16[k] = CLAMP((int)(m_left[k/2] * 32768.0f), -32768, 32767);
- raw16[k+1] = CLAMP((int)(m_right[(k+1)/2] * 32768.0f), -32768, 32767);
-
+ raw16[k] = qBound((int)(m_left[k >> 1] * 32768.0f), -32768, 32767);
+ raw16[k+1] = qBound((int)(m_right[k >> 1] * 32768.0f), -32768, 32767);
}
}
return length;