From 622d86de977922a6714cb771c735f2f2a25c0d78 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 1 Feb 2011 16:19:17 +0000 Subject: some ladspa optimization git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2029 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Effect/ladspa/ladspahost.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src') 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 * * Copyright (C) 2005 Giacomo Lozito * - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2011 by Ilya Kotov * * * * 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; -- cgit v1.2.3-13-gbd6f