Skip to content

Commit d9dddeb

Browse files
committed
Some memory optimizations
1 parent 9b0bb81 commit d9dddeb

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

include/lsp-plug.in/dsp/common/pcomplex.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,32 @@ LSP_DSP_LIB_SYMBOL(void, pcomplex_c2r, float *dst, const float *src, size_t coun
119119

120120
/** Get module for complex numbers: mod = sqrt(re*re + im*im)
121121
*
122-
* @param dst_mod array to sore module
122+
* @param dst_mod array to store module
123123
* @param src packed complex number data
124124
* @param count count number of elements to process
125125
*/
126126
LSP_DSP_LIB_SYMBOL(void, pcomplex_mod, float *dst_mod, const float *src, size_t count);
127127

128+
/**
129+
* Get module for complex numbers and add to destination:
130+
* dst[i] = dst[i] + sqrt(re[i]*re[i] + im[i]*im[i])
131+
*
132+
* @param dst array to add module
133+
* @param src packed complex number data
134+
* @param count count number of elements to process
135+
*/
136+
LSP_DSP_LIB_SYMBOL(void, pcomplex_mod_add2, float *dst, const float *src, size_t count);
137+
138+
/**
139+
* Get module for complex numbers and add to destination:
140+
* dst[i] = src1[i] + sqrt(re[i]*re[i] + im[i]*im[i])
141+
*
142+
* @param dst array to add module
143+
* @param src packed complex number data
144+
* @param count count number of elements to process
145+
*/
146+
LSP_DSP_LIB_SYMBOL(void, pcomplex_mod_add3, float *dst, const float *src, const float *reim, size_t count);
147+
128148
/** Convert packed complex number to polar form
129149
*
130150
* @param mod module of the complex number

include/private/dsp/arch/generic/pcomplex.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,33 @@ namespace lsp
205205
}
206206
}
207207

208+
void pcomplex_mod_add2(float *dst, const float *src, size_t count)
209+
{
210+
while (count--)
211+
{
212+
float re = src[0];
213+
float im = src[1];
214+
*dst += sqrtf(re*re + im*im);
215+
216+
src += 2;
217+
++dst;
218+
}
219+
}
220+
221+
void pcomplex_mod_add3(float *dst, const float * src, const float *reim, size_t count)
222+
{
223+
while (count--)
224+
{
225+
float re = reim[0];
226+
float im = reim[1];
227+
*dst = *src + sqrtf(re*re + im*im);
228+
229+
reim += 2;
230+
++dst;
231+
++src;
232+
}
233+
}
234+
208235
void pcomplex_arg(float *dst, const float *src, size_t count)
209236
{
210237
for (; count > 0; --count, src += 2)

src/main/generic/generic.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ namespace lsp
354354
EXPORT1(pcomplex_r2c);
355355
EXPORT1(pcomplex_c2r);
356356
EXPORT1(pcomplex_mod);
357+
EXPORT1(pcomplex_mod_add2);
358+
EXPORT1(pcomplex_mod_add3);
357359
EXPORT1(pcomplex_arg);
358360
EXPORT1(pcomplex_modarg);
359361
EXPORT1(pcomplex_corr);

0 commit comments

Comments
 (0)