Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/rnnoise.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/pitch.c')
-rw-r--r--src/pitch.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pitch.c b/src/pitch.c
index bd101a6..9b0271b 100644
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -43,6 +43,10 @@
#include "celt_lpc.h"
#include "math.h"
+#ifdef USE_MALLOC
+#include <stdlib.h>
+#endif
+
static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len,
int max_pitch, int *best_pitch
#ifdef FIXED_POINT
@@ -297,9 +301,15 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y,
celt_assert(max_pitch>0);
lag = len+max_pitch;
+#ifdef USE_MALLOC
+ opus_val16 *x_lp4 = malloc(sizeof(*x_lp4) * len>>2);
+ opus_val16 *y_lp4 = malloc(sizeof(*y_lp4) * lag>>2);
+ opus_val32 *xcorr = malloc(sizeof(*xcorr) * max_pitch>>1);
+#else
opus_val16 x_lp4[len>>2];
opus_val16 y_lp4[lag>>2];
opus_val32 xcorr[max_pitch>>1];
+#endif
/* Downsample by 2 again */
for (j=0;j<len>>2;j++)
@@ -382,6 +392,12 @@ void pitch_search(const opus_val16 *x_lp, opus_val16 *y,
offset = 0;
}
*pitch = 2*best_pitch[0]-offset;
+
+#ifdef USE_MALLOC
+ free(x_lp4);
+ free(y_lp4);
+ free(xcorr);
+#endif
}
#ifdef FIXED_POINT
@@ -427,7 +443,11 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
opus_val16 g, g0;
opus_val16 pg;
opus_val32 xy,xx,yy,xy2;
+#ifdef USE_MALLOC
+ opus_val32 *xcorr = malloc(sizeof(*xcorr) * 3);
+#else
opus_val32 xcorr[3];
+#endif
opus_val32 best_xy, best_yy;
int offset;
int minperiod0;
@@ -443,7 +463,11 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
*T0_=maxperiod-1;
T = T0 = *T0_;
+#ifdef USE_MALLOC
+ opus_val16 *yy_lookup = malloc(sizeof(*yy_lookup) * (maxperiod+1));
+#else
opus_val32 yy_lookup[maxperiod+1];
+#endif
dual_inner_prod(x, x, x-T0, N, &xx, &xy);
yy_lookup[0] = xx;
yy=xx;
@@ -522,5 +546,11 @@ opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
if (*T0_<minperiod0)
*T0_=minperiod0;
+
+#ifdef USE_MALLOC
+ free(xcorr);
+ free(yy_lookup);
+#endif
+
return pg;
}