ref: 17ad401c2c0e01dc7a6b0ba105d71903bdaf0e3f
parent: c2decd39a63edb2bab2a21f66471108033236bcf
author: Jean-Marc Valin <[email protected]>
date: Sun Mar 23 04:06:29 EDT 2008
defined find_max16 and overrode it for C55x
--- a/libcelt/fixed_c5x.h
+++ b/libcelt/fixed_c5x.h
@@ -70,4 +70,13 @@
#define celt_maxabs16(x, len) MAX16(maxval((DATA *)x, len),-minval((DATA *)x, len))
#define OVERRIDE_CELT_MAXABS16
+#define OVERRIDE_FIND_MAX16
+static inline int find_max16(celt_word16_t *x, int len)
+{
+ DATA max_corr16 = -VERY_LARGE16;
+ DATA pitch16 = 0;
+ maxvec((DATA *)x, len, &max_corr16, &pitch16);
+ return pitch16;
+}
+
#endif /* FIXED_C5X_H */
--- a/libcelt/mathops.h
+++ b/libcelt/mathops.h
@@ -37,6 +37,24 @@
#include "arch.h"
+#ifndef OVERRIDE_FIND_MAX16
+static inline int find_max16(celt_word16_t *x, int len)
+{
+ celt_word16_t max_corr=-VERY_LARGE16;
+ int i, id = 0;
+ for (i=0;i<len;i++)
+ {
+ if (x[i] > max_corr)
+ {
+ id = i;
+ max_corr = x[i];
+ }
+ }
+ return id;
+}
+#endif
+
+
#ifndef FIXED_POINT
#define celt_sqrt sqrt
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -102,7 +102,6 @@
void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const celt_sig_t * restrict x, const celt_sig_t * restrict y, const celt_word16_t * restrict window, int overlap, int lag, int len, int C, int *pitch)
{
int c, i;
- celt_word32_t max_corr;
VARDECL(celt_word16_t, X);
VARDECL(celt_word16_t, Y);
VARDECL(celt_mask_t, curve);
@@ -179,16 +178,6 @@
real16_ifft(fft, X, Y, lag);
/* The peak in the correlation gives us the pitch */
- max_corr=-VERY_LARGE32;
- *pitch = 0;
- for (i=0;i<lag-len;i++)
- {
- /*printf ("%f ", xx[i]);*/
- if (Y[i] > max_corr)
- {
- *pitch = i;
- max_corr = Y[i];
- }
- }
+ *pitch = find_max16(Y, lag-len);
RESTORE_STACK;
}