Jean-Marc Valin | 8b2ff0d | 2009-10-17 21:40:10 -0400 | [diff] [blame] | 1 | /* Copyright (c) 2003-2008 Jean-Marc Valin |
| 2 | Copyright (c) 2007-2008 CSIRO |
| 3 | Copyright (c) 2007-2009 Xiph.Org Foundation |
| 4 | Written by Jean-Marc Valin */ |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 5 | /** |
| 6 | @file arch.h |
Jean-Marc Valin | c7e0b76 | 2008-03-16 07:55:29 +1100 | [diff] [blame] | 7 | @brief Various architecture definitions for CELT |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 8 | */ |
| 9 | /* |
| 10 | Redistribution and use in source and binary forms, with or without |
| 11 | modification, are permitted provided that the following conditions |
| 12 | are met: |
Gregory Maxwell | 71d39ad | 2011-07-30 00:00:29 -0400 | [diff] [blame] | 13 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 14 | - Redistributions of source code must retain the above copyright |
| 15 | notice, this list of conditions and the following disclaimer. |
Gregory Maxwell | 71d39ad | 2011-07-30 00:00:29 -0400 | [diff] [blame] | 16 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 17 | - Redistributions in binary form must reproduce the above copyright |
| 18 | notice, this list of conditions and the following disclaimer in the |
| 19 | documentation and/or other materials provided with the distribution. |
Gregory Maxwell | 71d39ad | 2011-07-30 00:00:29 -0400 | [diff] [blame] | 20 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
Jean-Marc Valin | cb05e7c | 2012-04-20 16:40:24 -0400 | [diff] [blame] | 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| 25 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | */ |
| 33 | |
| 34 | #ifndef ARCH_H |
| 35 | #define ARCH_H |
| 36 | |
Jean-Marc Valin | d77d6a5 | 2011-07-29 17:33:06 -0400 | [diff] [blame] | 37 | #include "opus_types.h" |
Gregory Maxwell | 7830cf1 | 2013-10-17 15:56:52 -0700 | [diff] [blame] | 38 | #include "opus_defines.h" |
Jean-Marc Valin | c7e0b76 | 2008-03-16 07:55:29 +1100 | [diff] [blame] | 39 | |
Timothy B. Terriberry | 1a45886 | 2011-05-04 15:03:30 -0700 | [diff] [blame] | 40 | # if !defined(__GNUC_PREREQ) |
| 41 | # if defined(__GNUC__)&&defined(__GNUC_MINOR__) |
| 42 | # define __GNUC_PREREQ(_maj,_min) \ |
| 43 | ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) |
| 44 | # else |
| 45 | # define __GNUC_PREREQ(_maj,_min) 0 |
| 46 | # endif |
| 47 | # endif |
| 48 | |
Jean-Marc Valin | c7bbc3e | 2016-08-06 01:01:13 -0400 | [diff] [blame] | 49 | #if OPUS_GNUC_PREREQ(3, 0) |
| 50 | #define opus_likely(x) (__builtin_expect(!!(x), 1)) |
| 51 | #define opus_unlikely(x) (__builtin_expect(!!(x), 0)) |
| 52 | #else |
| 53 | #define opus_likely(x) (!!(x)) |
| 54 | #define opus_unlikely(x) (!!(x)) |
| 55 | #endif |
| 56 | |
Jean-Marc Valin | 628c025 | 2010-04-16 20:57:56 -0400 | [diff] [blame] | 57 | #define CELT_SIG_SCALE 32768.f |
Jean-Marc Valin | c7e0b76 | 2008-03-16 07:55:29 +1100 | [diff] [blame] | 58 | |
Jean-Marc Valin | ef20313 | 2018-03-22 17:40:35 -0400 | [diff] [blame^] | 59 | #define CELT_FATAL(str) celt_fatal(str, __FILE__, __LINE__); |
| 60 | |
| 61 | #if defined(ENABLE_ASSERTIONS) || defined(ENABLE_HARDENING) |
| 62 | #ifdef __GNUC__ |
| 63 | __attribute__((noreturn)) |
| 64 | #endif |
| 65 | void celt_fatal(const char *str, const char *file, int line); |
| 66 | |
| 67 | #if defined(CELT_C) && !defined(OVERRIDE_celt_fatal) |
Jean-Marc Valin | 6d3829f | 2010-08-27 17:52:38 -0400 | [diff] [blame] | 68 | #include <stdio.h> |
| 69 | #include <stdlib.h> |
Gregory Maxwell | 5d5875a | 2011-10-03 21:07:39 -0400 | [diff] [blame] | 70 | #ifdef __GNUC__ |
| 71 | __attribute__((noreturn)) |
| 72 | #endif |
Jean-Marc Valin | ef20313 | 2018-03-22 17:40:35 -0400 | [diff] [blame^] | 73 | void celt_fatal(const char *str, const char *file, int line) |
Jean-Marc Valin | 6d3829f | 2010-08-27 17:52:38 -0400 | [diff] [blame] | 74 | { |
| 75 | fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); |
| 76 | abort(); |
| 77 | } |
Jean-Marc Valin | ef20313 | 2018-03-22 17:40:35 -0400 | [diff] [blame^] | 78 | #endif |
| 79 | |
| 80 | #define celt_assert(cond) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond);}} |
| 81 | #define celt_assert2(cond, message) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond "\n" message);}} |
Jean-Marc Valin | c7e0b76 | 2008-03-16 07:55:29 +1100 | [diff] [blame] | 82 | #else |
| 83 | #define celt_assert(cond) |
| 84 | #define celt_assert2(cond, message) |
| 85 | #endif |
| 86 | |
Jean-Marc Valin | ef20313 | 2018-03-22 17:40:35 -0400 | [diff] [blame^] | 87 | #if defined(ENABLE_ASSERTIONS) |
| 88 | #define celt_sig_assert(cond) {if (!(cond)) {CELT_FATAL("signal assertion failed: " #cond);}} |
| 89 | #else |
| 90 | #define celt_sig_assert(cond) |
| 91 | #endif |
| 92 | |
Jean-Marc Valin | 821945d | 2008-04-10 13:24:48 +1000 | [diff] [blame] | 93 | #define IMUL32(a,b) ((a)*(b)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 94 | |
Gregory Maxwell | 8842fde | 2009-05-04 15:58:40 -0400 | [diff] [blame] | 95 | #define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 96 | #define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ |
Gregory Maxwell | 8842fde | 2009-05-04 15:58:40 -0400 | [diff] [blame] | 97 | #define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 98 | #define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ |
Gregory Maxwell | 8842fde | 2009-05-04 15:58:40 -0400 | [diff] [blame] | 99 | #define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ |
Jean-Marc Valin | c24b518 | 2008-09-19 16:49:26 -0400 | [diff] [blame] | 100 | #define IMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */ |
Jean-Marc Valin | 453ccd8 | 2008-09-12 20:52:27 -0400 | [diff] [blame] | 101 | #define UADD32(a,b) ((a)+(b)) |
| 102 | #define USUB32(a,b) ((a)-(b)) |
| 103 | |
Jonathan Lennox | 8da4f84 | 2015-11-20 23:03:52 -0500 | [diff] [blame] | 104 | /* Set this if opus_int64 is a native type of the CPU. */ |
| 105 | /* Assume that all LP64 architectures have fast 64-bit types; also x86_64 |
| 106 | (which can be ILP32 for x32) and Win64 (which is LLP64). */ |
| 107 | #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) |
| 108 | #define OPUS_FAST_INT64 1 |
| 109 | #else |
| 110 | #define OPUS_FAST_INT64 0 |
| 111 | #endif |
| 112 | |
Jean-Marc Valin | 453ccd8 | 2008-09-12 20:52:27 -0400 | [diff] [blame] | 113 | #define PRINT_MIPS(file) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 114 | |
| 115 | #ifdef FIXED_POINT |
| 116 | |
Jean-Marc Valin | ff5f722 | 2011-07-29 18:59:12 -0400 | [diff] [blame] | 117 | typedef opus_int16 opus_val16; |
| 118 | typedef opus_int32 opus_val32; |
Jean-Marc Valin | cf9409f | 2016-12-16 17:52:15 -0500 | [diff] [blame] | 119 | typedef opus_int64 opus_val64; |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 120 | |
Jean-Marc Valin | ff5f722 | 2011-07-29 18:59:12 -0400 | [diff] [blame] | 121 | typedef opus_val32 celt_sig; |
| 122 | typedef opus_val16 celt_norm; |
| 123 | typedef opus_val32 celt_ener; |
Jean-Marc Valin | 49ca99e | 2008-02-25 14:05:10 +1100 | [diff] [blame] | 124 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 125 | #define Q15ONE 32767 |
| 126 | |
Jean-Marc Valin | 5c3bc67 | 2008-08-28 23:34:24 -0400 | [diff] [blame] | 127 | #define SIG_SHIFT 12 |
Jean-Marc Valin | 382ab79 | 2016-07-21 19:48:55 -0400 | [diff] [blame] | 128 | /* Safe saturation value for 32-bit signals. Should be less than |
| 129 | 2^31*(1-0.85) to avoid blowing up on DC at deemphasis.*/ |
| 130 | #define SIG_SAT (300000000) |
Jean-Marc Valin | 4207438 | 2008-02-27 11:08:53 +1100 | [diff] [blame] | 131 | |
Jean-Marc Valin | 03892c1 | 2008-03-07 17:25:47 +1100 | [diff] [blame] | 132 | #define NORM_SCALING 16384 |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 133 | |
Jean-Marc Valin | bd0610d | 2010-03-13 10:04:19 -0500 | [diff] [blame] | 134 | #define DB_SHIFT 10 |
Jean-Marc Valin | 5d56183 | 2008-02-27 11:59:05 +1100 | [diff] [blame] | 135 | |
Jean-Marc Valin | ff74e39 | 2008-02-27 15:35:43 +1100 | [diff] [blame] | 136 | #define EPSILON 1 |
Jean-Marc Valin | 260474f | 2013-07-12 01:22:09 -0400 | [diff] [blame] | 137 | #define VERY_SMALL 0 |
Jean-Marc Valin | ff5f722 | 2011-07-29 18:59:12 -0400 | [diff] [blame] | 138 | #define VERY_LARGE16 ((opus_val16)32767) |
| 139 | #define Q15_ONE ((opus_val16)32767) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 140 | |
Ralph Giles | da025d5 | 2011-10-26 20:24:49 -0700 | [diff] [blame] | 141 | #define SCALEIN(a) (a) |
| 142 | #define SCALEOUT(a) (a) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 143 | |
Jean-Marc Valin | 0f869cb | 2013-12-08 03:54:18 -0500 | [diff] [blame] | 144 | #define ABS16(x) ((x) < 0 ? (-(x)) : (x)) |
| 145 | #define ABS32(x) ((x) < 0 ? (-(x)) : (x)) |
| 146 | |
Jean-Marc Valin | 4d07b13 | 2014-01-06 17:43:20 -0500 | [diff] [blame] | 147 | static OPUS_INLINE opus_int16 SAT16(opus_int32 x) { |
| 148 | return x > 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; |
| 149 | } |
| 150 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 151 | #ifdef FIXED_DEBUG |
| 152 | #include "fixed_debug.h" |
| 153 | #else |
| 154 | |
| 155 | #include "fixed_generic.h" |
| 156 | |
Jonathan Lennox | 05d3e79 | 2015-11-20 23:03:59 -0500 | [diff] [blame] | 157 | #ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR |
| 158 | #include "arm/fixed_arm64.h" |
| 159 | #elif OPUS_ARM_INLINE_EDSP |
Timothy B. Terriberry | e095c3e | 2013-05-21 12:53:33 -0700 | [diff] [blame] | 160 | #include "arm/fixed_armv5e.h" |
Timothy B. Terriberry | 39386e0 | 2013-11-18 13:30:13 -0500 | [diff] [blame] | 161 | #elif defined (OPUS_ARM_INLINE_ASM) |
Timothy B. Terriberry | e095c3e | 2013-05-21 12:53:33 -0700 | [diff] [blame] | 162 | #include "arm/fixed_armv4.h" |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 163 | #elif defined (BFIN_ASM) |
| 164 | #include "fixed_bfin.h" |
Jean-Marc Valin | 72e8003 | 2008-03-12 10:16:26 +1100 | [diff] [blame] | 165 | #elif defined (TI_C5X_ASM) |
| 166 | #include "fixed_c5x.h" |
Jean-Marc Valin | eac9970 | 2008-04-15 21:31:42 +1000 | [diff] [blame] | 167 | #elif defined (TI_C6X_ASM) |
| 168 | #include "fixed_c6x.h" |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 169 | #endif |
| 170 | |
| 171 | #endif |
| 172 | |
Jean-Marc Valin | 18ddc02 | 2008-02-22 14:24:50 +1100 | [diff] [blame] | 173 | #else /* FIXED_POINT */ |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 174 | |
Jean-Marc Valin | ff5f722 | 2011-07-29 18:59:12 -0400 | [diff] [blame] | 175 | typedef float opus_val16; |
| 176 | typedef float opus_val32; |
Jean-Marc Valin | cf9409f | 2016-12-16 17:52:15 -0500 | [diff] [blame] | 177 | typedef float opus_val64; |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 178 | |
Jean-Marc Valin | 234969c | 2009-10-17 22:12:42 -0400 | [diff] [blame] | 179 | typedef float celt_sig; |
| 180 | typedef float celt_norm; |
| 181 | typedef float celt_ener; |
Jean-Marc Valin | 18ddc02 | 2008-02-22 14:24:50 +1100 | [diff] [blame] | 182 | |
Jean-Marc Valin | 15edb78 | 2013-12-09 21:56:21 -0500 | [diff] [blame] | 183 | #ifdef FLOAT_APPROX |
| 184 | /* This code should reliably detect NaN/inf even when -ffast-math is used. |
| 185 | Assumes IEEE 754 format. */ |
Jean-Marc Valin | 122971b | 2013-12-10 13:55:35 -0500 | [diff] [blame] | 186 | static OPUS_INLINE int celt_isnan(float x) |
Jean-Marc Valin | 15edb78 | 2013-12-09 21:56:21 -0500 | [diff] [blame] | 187 | { |
| 188 | union {float f; opus_uint32 i;} in; |
| 189 | in.f = x; |
| 190 | return ((in.i>>23)&0xFF)==0xFF && (in.i&0x007FFFFF)!=0; |
| 191 | } |
| 192 | #else |
| 193 | #ifdef __FAST_MATH__ |
| 194 | #error Cannot build libopus with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input |
| 195 | #endif |
| 196 | #define celt_isnan(x) ((x)!=(x)) |
| 197 | #endif |
| 198 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 199 | #define Q15ONE 1.0f |
Jean-Marc Valin | b60340f | 2008-02-26 15:41:51 +1100 | [diff] [blame] | 200 | |
Jean-Marc Valin | b4dfce4 | 2008-02-25 17:41:30 +1100 | [diff] [blame] | 201 | #define NORM_SCALING 1.f |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 202 | |
Jean-Marc Valin | d9584db | 2008-03-26 00:00:18 +1100 | [diff] [blame] | 203 | #define EPSILON 1e-15f |
Jean-Marc Valin | 260474f | 2013-07-12 01:22:09 -0400 | [diff] [blame] | 204 | #define VERY_SMALL 1e-30f |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 205 | #define VERY_LARGE16 1e15f |
Jean-Marc Valin | ff5f722 | 2011-07-29 18:59:12 -0400 | [diff] [blame] | 206 | #define Q15_ONE ((opus_val16)1.f) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 207 | |
Jean-Marc Valin | 0f869cb | 2013-12-08 03:54:18 -0500 | [diff] [blame] | 208 | /* This appears to be the same speed as C99's fabsf() but it's more portable. */ |
| 209 | #define ABS16(x) ((float)fabs(x)) |
| 210 | #define ABS32(x) ((float)fabs(x)) |
| 211 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 212 | #define QCONST16(x,bits) (x) |
| 213 | #define QCONST32(x,bits) (x) |
| 214 | |
| 215 | #define NEG16(x) (-(x)) |
| 216 | #define NEG32(x) (-(x)) |
Jean-Marc Valin | 2739064 | 2016-07-21 19:40:23 -0400 | [diff] [blame] | 217 | #define NEG32_ovflw(x) (-(x)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 218 | #define EXTRACT16(x) (x) |
| 219 | #define EXTEND32(x) (x) |
| 220 | #define SHR16(a,shift) (a) |
| 221 | #define SHL16(a,shift) (a) |
| 222 | #define SHR32(a,shift) (a) |
| 223 | #define SHL32(a,shift) (a) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 224 | #define PSHR32(a,shift) (a) |
| 225 | #define VSHR32(a,shift) (a) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 226 | |
Jean-Marc Valin | c209c34 | 2008-03-07 17:50:45 +1100 | [diff] [blame] | 227 | #define PSHR(a,shift) (a) |
| 228 | #define SHR(a,shift) (a) |
| 229 | #define SHL(a,shift) (a) |
| 230 | #define SATURATE(x,a) (x) |
Jean-Marc Valin | 02fed47 | 2013-08-29 15:29:02 -0400 | [diff] [blame] | 231 | #define SATURATE16(x) (x) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 232 | |
Jean-Marc Valin | f5b0587 | 2008-03-21 10:46:17 +1100 | [diff] [blame] | 233 | #define ROUND16(a,shift) (a) |
Jean-Marc Valin | a0bd7d3 | 2016-07-22 09:13:00 -0400 | [diff] [blame] | 234 | #define SROUND16(a,shift) (a) |
Jean-Marc Valin | 21b1134 | 2011-05-13 17:41:33 -0400 | [diff] [blame] | 235 | #define HALF16(x) (.5f*(x)) |
Jean-Marc Valin | c209c34 | 2008-03-07 17:50:45 +1100 | [diff] [blame] | 236 | #define HALF32(x) (.5f*(x)) |
Jean-Marc Valin | a02ca1e | 2008-02-28 11:33:22 +1100 | [diff] [blame] | 237 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 238 | #define ADD16(a,b) ((a)+(b)) |
| 239 | #define SUB16(a,b) ((a)-(b)) |
| 240 | #define ADD32(a,b) ((a)+(b)) |
| 241 | #define SUB32(a,b) ((a)-(b)) |
Jean-Marc Valin | 2739064 | 2016-07-21 19:40:23 -0400 | [diff] [blame] | 242 | #define ADD32_ovflw(a,b) ((a)+(b)) |
| 243 | #define SUB32_ovflw(a,b) ((a)-(b)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 244 | #define MULT16_16_16(a,b) ((a)*(b)) |
Jean-Marc Valin | ff5f722 | 2011-07-29 18:59:12 -0400 | [diff] [blame] | 245 | #define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) |
| 246 | #define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 247 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 248 | #define MULT16_32_Q15(a,b) ((a)*(b)) |
Jean-Marc Valin | ef0d5f1 | 2008-04-22 09:49:22 +1000 | [diff] [blame] | 249 | #define MULT16_32_Q16(a,b) ((a)*(b)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 250 | |
Jean-Marc Valin | d857ac4 | 2008-03-12 13:26:37 +1100 | [diff] [blame] | 251 | #define MULT32_32_Q31(a,b) ((a)*(b)) |
| 252 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 253 | #define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) |
Jean-Marc Valin | 17b1978 | 2014-01-21 11:07:57 -0500 | [diff] [blame] | 254 | #define MAC16_32_Q16(c,a,b) ((c)+(a)*(b)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 255 | |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 256 | #define MULT16_16_Q11_32(a,b) ((a)*(b)) |
Jean-Marc Valin | 3ab03e0 | 2013-09-06 16:00:39 -0400 | [diff] [blame] | 257 | #define MULT16_16_Q11(a,b) ((a)*(b)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 258 | #define MULT16_16_Q13(a,b) ((a)*(b)) |
| 259 | #define MULT16_16_Q14(a,b) ((a)*(b)) |
| 260 | #define MULT16_16_Q15(a,b) ((a)*(b)) |
| 261 | #define MULT16_16_P15(a,b) ((a)*(b)) |
| 262 | #define MULT16_16_P13(a,b) ((a)*(b)) |
| 263 | #define MULT16_16_P14(a,b) ((a)*(b)) |
Gregory Maxwell | 28b41ae | 2012-07-11 00:04:24 -0400 | [diff] [blame] | 264 | #define MULT16_32_P16(a,b) ((a)*(b)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 265 | |
Jean-Marc Valin | ff5f722 | 2011-07-29 18:59:12 -0400 | [diff] [blame] | 266 | #define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) |
Jean-Marc Valin | ff5f722 | 2011-07-29 18:59:12 -0400 | [diff] [blame] | 267 | #define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 268 | |
Ralph Giles | da025d5 | 2011-10-26 20:24:49 -0700 | [diff] [blame] | 269 | #define SCALEIN(a) ((a)*CELT_SIG_SCALE) |
| 270 | #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 271 | |
Jean-Marc Valin | 2e6876c | 2014-01-22 19:22:05 -0500 | [diff] [blame] | 272 | #define SIG2WORD16(x) (x) |
| 273 | |
Jean-Marc Valin | 18ddc02 | 2008-02-22 14:24:50 +1100 | [diff] [blame] | 274 | #endif /* !FIXED_POINT */ |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 275 | |
Gregory Maxwell | 71d39ad | 2011-07-30 00:00:29 -0400 | [diff] [blame] | 276 | #ifndef GLOBAL_STACK_SIZE |
Gregory Maxwell | 242eee3 | 2009-02-03 16:07:01 -0500 | [diff] [blame] | 277 | #ifdef FIXED_POINT |
Jean-Marc Valin | 3c9b4d6 | 2017-02-15 17:34:24 -0500 | [diff] [blame] | 278 | #define GLOBAL_STACK_SIZE 120000 |
Gregory Maxwell | 242eee3 | 2009-02-03 16:07:01 -0500 | [diff] [blame] | 279 | #else |
Jean-Marc Valin | 3c9b4d6 | 2017-02-15 17:34:24 -0500 | [diff] [blame] | 280 | #define GLOBAL_STACK_SIZE 120000 |
Gregory Maxwell | 242eee3 | 2009-02-03 16:07:01 -0500 | [diff] [blame] | 281 | #endif |
Gregory Maxwell | 71d39ad | 2011-07-30 00:00:29 -0400 | [diff] [blame] | 282 | #endif |
Jean-Marc Valin | 6359089 | 2007-11-29 17:01:16 +1100 | [diff] [blame] | 283 | |
Jean-Marc Valin | 18ddc02 | 2008-02-22 14:24:50 +1100 | [diff] [blame] | 284 | #endif /* ARCH_H */ |