[opus] [[RFC PATCH v2]: Ne10 fft fixed and previous 7/8] armv7, armv8: Extend fixed fft NE10 optimizations to mdct

Viswanath Puttagunta
Fri, 08 May 2015 16:52:58 -0000

Extends usage of Neon optimized fixed point fft optimizations
in libNE10 to clt_mdct_forward and clt_mdct_backward.

Signed-off-by: Viswanath Puttagunta <viswanath.puttagunta at linaro.org>
---
 celt/arm/arm_celt_map.c   | 48 ++++++++++++++++++++++++-----------------------
 celt/arm/celt_ne10_mdct.c | 23 ++++++++++-------------
 celt/arm/mdct_arm.h       | 32 +++++++++++++++++--------------
 celt/mdct.h               |  5 ++---
 4 files changed, 55 insertions(+), 53 deletions(-)

diff --git a/celt/arm/arm_celt_map.c b/celt/arm/arm_celt_map.c
index af54b9d..41b18b1 100644
--- a/celt/arm/arm_celt_map.c
+++ b/celt/arm/arm_celt_map.c
@@ -69,27 +69,7 @@ void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state
*cfg,
    opus_ifft_c,                   /* Media */
    opus_ifft_neon                 /* Neon with NE10 */
 };
-#endif
-
-# if defined(FIXED_POINT)
-opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
-    const opus_val16 *, opus_val32 *, int , int) = {
-  celt_pitch_xcorr_c,               /* ARMv4 */
-  MAY_HAVE_EDSP(celt_pitch_xcorr),  /* EDSP */
-  MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */
-  MAY_HAVE_NEON(celt_pitch_xcorr)   /* NEON */
-};
-# else /* !FIXED_POINT */
-#  if defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
-void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
-    const opus_val16 *, opus_val32 *, int, int) = {
-  celt_pitch_xcorr_c,              /* ARMv4 */
-  celt_pitch_xcorr_c,              /* EDSP */
-  celt_pitch_xcorr_c,              /* Media */
-  celt_pitch_xcorr_float_neon      /* Neon */
-};

-#if defined(HAVE_ARM_NE10)
 void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
                                                      kiss_fft_scalar *in,
                                                      kiss_fft_scalar *
OPUS_RESTRICT out,
@@ -99,7 +79,11 @@ void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const
mdct_lookup *l,
    clt_mdct_forward_c,           /* ARMv4 */
    clt_mdct_forward_c,           /* EDSP */
    clt_mdct_forward_c,           /* Media */
-   clt_mdct_forward_float_neon   /* Neon with NE10 */
+#if defined(FIXED_POINT)
+   clt_mdct_forward_c,           /* Debugging issues with NE10 library for
fixed point */
+#else
+   clt_mdct_forward_neon         /* Neon with NE10 */
+#endif
 };

 void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
@@ -111,10 +95,28 @@ void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const
mdct_lookup *l,
    clt_mdct_backward_c,           /* ARMv4 */
    clt_mdct_backward_c,           /* EDSP */
    clt_mdct_backward_c,           /* Media */
-   clt_mdct_backward_float_neon   /* Neon with NE10 */
+   clt_mdct_backward_neon,        /* Neon with NE10 */
 };

-#endif /* HAVE_ARM_NE10 */
+#endif
+
+# if defined(FIXED_POINT)
+opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
+    const opus_val16 *, opus_val32 *, int , int) = {
+  celt_pitch_xcorr_c,               /* ARMv4 */
+  MAY_HAVE_EDSP(celt_pitch_xcorr),  /* EDSP */
+  MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */
+  MAY_HAVE_NEON(celt_pitch_xcorr)   /* NEON */
+};
+# else /* !FIXED_POINT */
+#  if defined(OPUS_ARM_MAY_HAVE_NEON_INTR)
+void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
+    const opus_val16 *, opus_val32 *, int, int) = {
+  celt_pitch_xcorr_c,              /* ARMv4 */
+  celt_pitch_xcorr_c,              /* EDSP */
+  celt_pitch_xcorr_c,              /* Media */
+  celt_pitch_xcorr_float_neon      /* Neon */
+};
 #  endif /* OPUS_ARM_MAY_HAVE_NEON_INTR */
 # endif /* FIXED_POINT */

diff --git a/celt/arm/celt_ne10_mdct.c b/celt/arm/celt_ne10_mdct.c
index 938fc93..a445088 100644
--- a/celt/arm/celt_ne10_mdct.c
+++ b/celt/arm/celt_ne10_mdct.c
@@ -43,13 +43,11 @@
 #include "os_support.h"
 #include "stack_alloc.h"

-#if !defined(FIXED_POINT)
-
-void clt_mdct_forward_float_neon(const mdct_lookup *l,
-                                 kiss_fft_scalar *in,
-                                 kiss_fft_scalar * OPUS_RESTRICT out,
-                                 const opus_val16 *window,
-                                 int overlap, int shift, int stride, int arch)
+void clt_mdct_forward_neon(const mdct_lookup *l,
+                           kiss_fft_scalar *in,
+                           kiss_fft_scalar * OPUS_RESTRICT out,
+                           const opus_val16 *window,
+                           int overlap, int shift, int stride, int arch)
 {
    int i;
    int N, N2, N4;
@@ -159,11 +157,11 @@ void clt_mdct_forward_float_neon(const mdct_lookup *l,
    RESTORE_STACK;
 }

-void clt_mdct_backward_float_neon(const mdct_lookup *l,
-                                  kiss_fft_scalar *in,
-                                  kiss_fft_scalar * OPUS_RESTRICT out,
-                                  const opus_val16 * OPUS_RESTRICT window,
-                                  int overlap, int shift, int stride, int arch)
+void clt_mdct_backward_neon(const mdct_lookup *l,
+                            kiss_fft_scalar *in,
+                            kiss_fft_scalar * OPUS_RESTRICT out,
+                            const opus_val16 * OPUS_RESTRICT window,
+                            int overlap, int shift, int stride, int arch)
 {
    int i;
    int N, N2, N4;
@@ -260,4 +258,3 @@ void clt_mdct_backward_float_neon(const mdct_lookup *l,
    }
    RESTORE_STACK;
 }
-#endif /* !defined(FIXED_POINT) */
diff --git a/celt/arm/mdct_arm.h b/celt/arm/mdct_arm.h
index db32efe..f43c28c 100644
--- a/celt/arm/mdct_arm.h
+++ b/celt/arm/mdct_arm.h
@@ -36,25 +36,29 @@
 #include "config.h"
 #include "mdct.h"

-#if !defined(FIXED_POINT) && defined(HAVE_ARM_NE10)
+#if defined(HAVE_ARM_NE10)
 /** Compute a forward MDCT and scale by 4/N, trashes the input array */
-void clt_mdct_forward_float_neon(const mdct_lookup *l, kiss_fft_scalar *in,
-                                 kiss_fft_scalar * OPUS_RESTRICT out,
-                                 const opus_val16 *window, int overlap,
-                                 int shift, int stride, int arch);
-
-void clt_mdct_backward_float_neon(const mdct_lookup *l, kiss_fft_scalar *in,
-                                  kiss_fft_scalar * OPUS_RESTRICT out,
-                                  const opus_val16 *window, int overlap,
-                                  int shift, int stride, int arch);
-
+void clt_mdct_forward_neon(const mdct_lookup *l, kiss_fft_scalar *in,
+                           kiss_fft_scalar * OPUS_RESTRICT out,
+                           const opus_val16 *window, int overlap,
+                           int shift, int stride, int arch);
+void clt_mdct_backward_neon(const mdct_lookup *l, kiss_fft_scalar *in,
+                            kiss_fft_scalar * OPUS_RESTRICT out,
+                            const opus_val16 *window, int overlap,
+                            int shift, int stride, int arch);
 #if !defined(OPUS_HAVE_RTCD)
 #define OVERRIDE_OPUS_MDCT (1)
+#if defined(FIXED_POINT)
+/* Debugging corner cases in mdct forward issues with NE10 library */
 #define clt_mdct_forward(_l, _in, _out, _window, _int, _shift, _stride, _arch)
\
-      clt_mdct_forward_float_neon(_l, _in, _out, _window, _int, _shift,
_stride, _arch)
+      clt_mdct_forward_c(_l, _in, _out, _window, _int, _shift, _stride, _arch)
+#else
+#define clt_mdct_forward(_l, _in, _out, _window, _int, _shift, _stride, _arch)
\
+      clt_mdct_forward_neon(_l, _in, _out, _window, _int, _shift, _stride,
_arch)
+#endif
 #define clt_mdct_backward(_l, _in, _out, _window, _int, _shift, _stride, _arch)
\
-      clt_mdct_backward_float_neon(_l, _in, _out, _window, _int, _shift,
_stride, _arch)
+      clt_mdct_backward_neon(_l, _in, _out, _window, _int, _shift, _stride,
_arch)
 #endif /* OPUS_HAVE_RTCD */
-#endif /* !defined(FIXED_POINT) && defined(HAVE_ARM_NE10) */
+#endif /* defined(HAVE_ARM_NE10) */

 #endif
diff --git a/celt/mdct.h b/celt/mdct.h
index 3ced019..df8bcd2 100644
--- a/celt/mdct.h
+++ b/celt/mdct.h
@@ -53,7 +53,7 @@ typedef struct {
    const kiss_twiddle_scalar * OPUS_RESTRICT trig;
 } mdct_lookup;

-#if !defined(FIXED_POINT) && defined(HAVE_ARM_NE10)
+#if defined(HAVE_ARM_NE10)
 #include "arm/mdct_arm.h"
 #endif

@@ -76,8 +76,7 @@ void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar
*in,

 #if !defined(OVERRIDE_OPUS_MDCT)
 /* Is run-time CPU detection enabled on this platform? */
-#if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) &&
!defined(FIXED_POINT)
-
+#if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10)
 void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
                                                      kiss_fft_scalar *in,
                                                      kiss_fft_scalar *
OPUS_RESTRICT out,
--
1.9.1