ref: 9901cb9e822e726defa919ab71d07f90ea8ff093
parent: 948dabc7da65ed77df8fd72c762be9ce2758d38d
author: Jean-Marc Valin <[email protected]>
date: Fri Mar 21 07:13:51 EDT 2008
fixed-point: defined celt_maxabs16() as basic operator
--- a/libcelt/fixed_c5x.h
+++ b/libcelt/fixed_c5x.h
@@ -64,8 +64,10 @@
#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),(b)),15))
-
#define celt_ilog2(x) (30 - _lnorm(x))
#define OVERRIDE_CELT_ILOG2
+
+#define celt_maxabs16(x) MAX16(maxval((DATA *)x, len),-minval((DATA *)x, len))
+#define OVERRIDE_CELT_MAXABS16
#endif /* FIXED_C5X_H */
--- a/libcelt/mathops.h
+++ b/libcelt/mathops.h
@@ -64,6 +64,16 @@
}
#endif
+#ifndef OVERRIDE_CELT_MAXABS16
+static inline celt_word16_t celt_maxabs16(celt_word16_t *x, int len)
+{
+ int i;
+ celt_word16_t maxval = 0;
+ for (i=0;i<len;i++)
+ maxval = MAX16(maxval, ABS16(x[i]));
+ return maxval;
+}
+#endif
/** Integer log in base2. Defined for zero, but not for negative numbers */
static inline celt_int16_t celt_zlog2(celt_word32_t x)
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -63,9 +63,8 @@
static void normalise16(celt_word16_t *x, int len, celt_word16_t val)
{
int i;
- celt_word16_t maxval = 0;
- for (i=0;i<len;i++)
- maxval = MAX16(maxval, ABS16(x[i]));
+ celt_word16_t maxval;
+ maxval = celt_maxabs16(x,len);
if (maxval > val)
{
int shift = 0;