ref: 2e6876c07a2771462eff862bc6fcc423f2cd95af
parent: 9b3a3ad7ff3db7f43640be02faa0f869ecff5b99
author: Jean-Marc Valin <[email protected]>
date: Wed Jan 22 14:22:05 EST 2014
Using SSAT in SIG2WORD16() on ARMv6
--- a/celt/arch.h
+++ b/celt/arch.h
@@ -226,6 +226,8 @@
#define SCALEIN(a) ((a)*CELT_SIG_SCALE)
#define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE))
+#define SIG2WORD16(x) (x)
+
#endif /* !FIXED_POINT */
#ifndef GLOBAL_STACK_SIZE
--- a/celt/arm/fixed_armv5e.h
+++ b/celt/arm/fixed_armv5e.h
@@ -130,4 +130,22 @@
}
#define MULT16_16(a, b) (MULT16_16_armv5e(a, b))
+#ifdef OPUS_ARM_INLINE_MEDIA
+
+#undef SIG2WORD16
+static OPUS_INLINE opus_val16 SIG2WORD16_armv6(opus_val32 x)
+{
+ celt_sig res;
+ __asm__(
+ "#SIG2WORD16\n\t"
+ "ssat %0, #16, %1, ASR #12\n\t"
+ : "=r"(res)
+ : "r"(x+2048)
+ );
+ return EXTRACT16(res);
+}
+#define SIG2WORD16(x) (SIG2WORD16_armv6(x))
+
+#endif /* OPUS_ARM_INLINE_MEDIA */
+
#endif
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -178,17 +178,6 @@
}
#endif /* CUSTOM_MODES */
-static OPUS_INLINE opus_val16 SIG2WORD16(celt_sig x)
-{
-#ifdef FIXED_POINT
- x = PSHR32(x, SIG_SHIFT);
- x = MAX32(x, -32768);
- x = MIN32(x, 32767);
- return EXTRACT16(x);
-#else
- return (opus_val16)x;
-#endif
-}
#ifndef RESYNTH
static
--- a/celt/fixed_generic.h
+++ b/celt/fixed_generic.h
@@ -135,4 +135,13 @@
/** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */
#define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b)))
+static OPUS_INLINE opus_val16 SIG2WORD16_generic(celt_sig x)
+{
+ x = PSHR32(x, SIG_SHIFT);
+ x = MAX32(x, -32768);
+ x = MIN32(x, 32767);
+ return EXTRACT16(x);
+}
+#define SIG2WORD16(x) (SIG2WORD16_generic(x))
+
#endif