summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libopus/celt/arch.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/arch.h')
-rw-r--r--lib/rbcodec/codecs/libopus/celt/arch.h66
1 files changed, 55 insertions, 11 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/arch.h b/lib/rbcodec/codecs/libopus/celt/arch.h
index 035b92ff29..08b07db598 100644
--- a/lib/rbcodec/codecs/libopus/celt/arch.h
+++ b/lib/rbcodec/codecs/libopus/celt/arch.h
@@ -46,30 +46,54 @@
46# endif 46# endif
47# endif 47# endif
48 48
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
49#define CELT_SIG_SCALE 32768.f 57#define CELT_SIG_SCALE 32768.f
50 58
51#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__); 59#define CELT_FATAL(str) celt_fatal(str, __FILE__, __LINE__);
52#ifdef ENABLE_ASSERTIONS 60
61#if defined(ENABLE_ASSERTIONS) || defined(ENABLE_HARDENING)
62#ifdef __GNUC__
63__attribute__((noreturn))
64#endif
65void celt_fatal(const char *str, const char *file, int line);
66
67#if defined(CELT_C) && !defined(OVERRIDE_celt_fatal)
53#include <stdio.h> 68#include <stdio.h>
54#include <stdlib.h> 69#include <stdlib.h>
55#ifdef __GNUC__ 70#ifdef __GNUC__
56__attribute__((noreturn)) 71__attribute__((noreturn))
57#endif 72#endif
58static OPUS_INLINE void _celt_fatal(const char *str, const char *file, int line) 73void celt_fatal(const char *str, const char *file, int line)
59{ 74{
60 fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); 75 fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
61 abort(); 76 abort();
62} 77}
63#define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);}} 78#endif
64#define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed: " #cond "\n" message);}} 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);}}
82#define MUST_SUCCEED(call) celt_assert((call) == OPUS_OK)
65#else 83#else
66#define celt_assert(cond) 84#define celt_assert(cond)
67#define celt_assert2(cond, message) 85#define celt_assert2(cond, message)
86#define MUST_SUCCEED(call) do {if((call) != OPUS_OK) {RESTORE_STACK; return OPUS_INTERNAL_ERROR;} } while (0)
87#endif
88
89#if defined(ENABLE_ASSERTIONS)
90#define celt_sig_assert(cond) {if (!(cond)) {CELT_FATAL("signal assertion failed: " #cond);}}
91#else
92#define celt_sig_assert(cond)
68#endif 93#endif
69 94
70#define IMUL32(a,b) ((a)*(b)) 95#define IMUL32(a,b) ((a)*(b))
71 96
72#define ABS(x) ((x) < 0 ? (-(x)) : (x))
73#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ 97#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */
74#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ 98#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */
75#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ 99#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */
@@ -79,20 +103,35 @@ static OPUS_INLINE void _celt_fatal(const char *str, const char *file, int line)
79#define UADD32(a,b) ((a)+(b)) 103#define UADD32(a,b) ((a)+(b))
80#define USUB32(a,b) ((a)-(b)) 104#define USUB32(a,b) ((a)-(b))
81 105
106/* Set this if opus_int64 is a native type of the CPU. */
107/* Assume that all LP64 architectures have fast 64-bit types; also x86_64
108 (which can be ILP32 for x32) and Win64 (which is LLP64). */
109#if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64)
110#define OPUS_FAST_INT64 1
111#else
112#define OPUS_FAST_INT64 0
113#endif
114
82#define PRINT_MIPS(file) 115#define PRINT_MIPS(file)
83 116
84#ifdef FIXED_POINT 117#ifdef FIXED_POINT
85 118
86typedef opus_int16 opus_val16; 119typedef opus_int16 opus_val16;
87typedef opus_int32 opus_val32; 120typedef opus_int32 opus_val32;
121typedef opus_int64 opus_val64;
88 122
89typedef opus_val32 celt_sig; 123typedef opus_val32 celt_sig;
90typedef opus_val16 celt_norm; 124typedef opus_val16 celt_norm;
91typedef opus_val32 celt_ener; 125typedef opus_val32 celt_ener;
92 126
127#define celt_isnan(x) 0
128
93#define Q15ONE 32767 129#define Q15ONE 32767
94 130
95#define SIG_SHIFT 12 131#define SIG_SHIFT 12
132/* Safe saturation value for 32-bit signals. Should be less than
133 2^31*(1-0.85) to avoid blowing up on DC at deemphasis.*/
134#define SIG_SAT (300000000)
96 135
97#define NORM_SCALING 16384 136#define NORM_SCALING 16384
98 137
@@ -119,7 +158,9 @@ static OPUS_INLINE opus_int16 SAT16(opus_int32 x) {
119 158
120#include "fixed_generic.h" 159#include "fixed_generic.h"
121 160
122#ifdef OPUS_ARM_INLINE_EDSP 161#ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR
162#include "arm/fixed_arm64.h"
163#elif defined (OPUS_ARM_INLINE_EDSP)
123#include "arm/fixed_armv5e.h" 164#include "arm/fixed_armv5e.h"
124#elif defined (OPUS_ARM_INLINE_ASM) 165#elif defined (OPUS_ARM_INLINE_ASM)
125#include "arm/fixed_armv4.h" 166#include "arm/fixed_armv4.h"
@@ -129,8 +170,6 @@ static OPUS_INLINE opus_int16 SAT16(opus_int32 x) {
129#include "fixed_c5x.h" 170#include "fixed_c5x.h"
130#elif defined (TI_C6X_ASM) 171#elif defined (TI_C6X_ASM)
131#include "fixed_c6x.h" 172#include "fixed_c6x.h"
132#elif defined (OPUS_CF_INLINE_ASM)
133#include "cf/fixed_cf.h"
134#endif 173#endif
135 174
136#endif 175#endif
@@ -139,6 +178,7 @@ static OPUS_INLINE opus_int16 SAT16(opus_int32 x) {
139 178
140typedef float opus_val16; 179typedef float opus_val16;
141typedef float opus_val32; 180typedef float opus_val32;
181typedef float opus_val64;
142 182
143typedef float celt_sig; 183typedef float celt_sig;
144typedef float celt_norm; 184typedef float celt_norm;
@@ -178,6 +218,7 @@ static OPUS_INLINE int celt_isnan(float x)
178 218
179#define NEG16(x) (-(x)) 219#define NEG16(x) (-(x))
180#define NEG32(x) (-(x)) 220#define NEG32(x) (-(x))
221#define NEG32_ovflw(x) (-(x))
181#define EXTRACT16(x) (x) 222#define EXTRACT16(x) (x)
182#define EXTEND32(x) (x) 223#define EXTEND32(x) (x)
183#define SHR16(a,shift) (a) 224#define SHR16(a,shift) (a)
@@ -194,6 +235,7 @@ static OPUS_INLINE int celt_isnan(float x)
194#define SATURATE16(x) (x) 235#define SATURATE16(x) (x)
195 236
196#define ROUND16(a,shift) (a) 237#define ROUND16(a,shift) (a)
238#define SROUND16(a,shift) (a)
197#define HALF16(x) (.5f*(x)) 239#define HALF16(x) (.5f*(x))
198#define HALF32(x) (.5f*(x)) 240#define HALF32(x) (.5f*(x))
199 241
@@ -201,6 +243,8 @@ static OPUS_INLINE int celt_isnan(float x)
201#define SUB16(a,b) ((a)-(b)) 243#define SUB16(a,b) ((a)-(b))
202#define ADD32(a,b) ((a)+(b)) 244#define ADD32(a,b) ((a)+(b))
203#define SUB32(a,b) ((a)-(b)) 245#define SUB32(a,b) ((a)-(b))
246#define ADD32_ovflw(a,b) ((a)+(b))
247#define SUB32_ovflw(a,b) ((a)-(b))
204#define MULT16_16_16(a,b) ((a)*(b)) 248#define MULT16_16_16(a,b) ((a)*(b))
205#define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) 249#define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b))
206#define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) 250#define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b))
@@ -235,9 +279,9 @@ static OPUS_INLINE int celt_isnan(float x)
235 279
236#ifndef GLOBAL_STACK_SIZE 280#ifndef GLOBAL_STACK_SIZE
237#ifdef FIXED_POINT 281#ifdef FIXED_POINT
238#define GLOBAL_STACK_SIZE 100000 282#define GLOBAL_STACK_SIZE 120000
239#else 283#else
240#define GLOBAL_STACK_SIZE 100000 284#define GLOBAL_STACK_SIZE 120000
241#endif 285#endif
242#endif 286#endif
243 287