~ubuntu-branches/ubuntu/wily/sflphone/wily-proposed

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.2.1/third_party/speex/libspeex/arch.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 Jean-Marc Valin */
 
2
/**
 
3
   @file arch.h
 
4
   @brief Various architecture definitions Speex
 
5
*/
 
6
/*
 
7
   Redistribution and use in source and binary forms, with or without
 
8
   modification, are permitted provided that the following conditions
 
9
   are met:
 
10
   
 
11
   - Redistributions of source code must retain the above copyright
 
12
   notice, this list of conditions and the following disclaimer.
 
13
   
 
14
   - Redistributions in binary form must reproduce the above copyright
 
15
   notice, this list of conditions and the following disclaimer in the
 
16
   documentation and/or other materials provided with the distribution.
 
17
   
 
18
   - Neither the name of the Xiph.org Foundation nor the names of its
 
19
   contributors may be used to endorse or promote products derived from
 
20
   this software without specific prior written permission.
 
21
   
 
22
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
23
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
24
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
25
   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
 
26
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
27
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
28
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
29
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
30
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
31
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
32
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
33
*/
 
34
 
 
35
#ifndef ARCH_H
 
36
#define ARCH_H
 
37
 
 
38
#ifndef SPEEX_VERSION
 
39
#define SPEEX_MAJOR_VERSION 1         /**< Major Speex version. */
 
40
#define SPEEX_MINOR_VERSION 1         /**< Minor Speex version. */
 
41
#define SPEEX_MICRO_VERSION 15        /**< Micro Speex version. */
 
42
#define SPEEX_EXTRA_VERSION ""        /**< Extra Speex version. */
 
43
#define SPEEX_VERSION "speex-1.2beta3"  /**< Speex version string. */
 
44
#endif
 
45
 
 
46
/* A couple test to catch stupid option combinations */
 
47
#ifdef FIXED_POINT
 
48
 
 
49
#ifdef FLOATING_POINT
 
50
#error You cannot compile as floating point and fixed point at the same time
 
51
#endif
 
52
#ifdef _USE_SSE
 
53
#error SSE is only for floating-point
 
54
#endif
 
55
#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
 
56
#error Make up your mind. What CPU do you have?
 
57
#endif
 
58
#ifdef VORBIS_PSYCHO
 
59
#error Vorbis-psy model currently not implemented in fixed-point
 
60
#endif
 
61
 
 
62
#else
 
63
 
 
64
#ifndef FLOATING_POINT
 
65
#error You now need to define either FIXED_POINT or FLOATING_POINT
 
66
#endif
 
67
#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
 
68
#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
 
69
#endif
 
70
#ifdef FIXED_POINT_DEBUG
 
71
#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"
 
72
#endif
 
73
 
 
74
 
 
75
#endif
 
76
 
 
77
#ifndef OUTSIDE_SPEEX
 
78
#include "speex/speex_types.h"
 
79
#endif
 
80
 
 
81
#define ABS(x) ((x) < 0 ? (-(x)) : (x))      /**< Absolute integer value. */
 
82
#define ABS16(x) ((x) < 0 ? (-(x)) : (x))    /**< Absolute 16-bit value.  */
 
83
#define MIN16(a,b) ((a) < (b) ? (a) : (b))   /**< Maximum 16-bit value.   */
 
84
#define MAX16(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 16-bit value.   */
 
85
#define ABS32(x) ((x) < 0 ? (-(x)) : (x))    /**< Absolute 32-bit value.  */
 
86
#define MIN32(a,b) ((a) < (b) ? (a) : (b))   /**< Maximum 32-bit value.   */
 
87
#define MAX32(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 32-bit value.   */
 
88
 
 
89
#ifdef FIXED_POINT
 
90
 
 
91
typedef spx_int16_t spx_word16_t;
 
92
typedef spx_int32_t   spx_word32_t;
 
93
typedef spx_word32_t spx_mem_t;
 
94
typedef spx_word16_t spx_coef_t;
 
95
typedef spx_word16_t spx_lsp_t;
 
96
typedef spx_word32_t spx_sig_t;
 
97
 
 
98
#define Q15ONE 32767
 
99
 
 
100
#define LPC_SCALING  8192
 
101
#define SIG_SCALING  16384
 
102
#define LSP_SCALING  8192.
 
103
#define GAMMA_SCALING 32768.
 
104
#define GAIN_SCALING 64
 
105
#define GAIN_SCALING_1 0.015625
 
106
 
 
107
#define LPC_SHIFT    13
 
108
#define LSP_SHIFT    13
 
109
#define SIG_SHIFT    14
 
110
#define GAIN_SHIFT   6
 
111
 
 
112
#define VERY_SMALL 0
 
113
#define VERY_LARGE32 ((spx_word32_t)2147483647)
 
114
#define VERY_LARGE16 ((spx_word16_t)32767)
 
115
#define Q15_ONE ((spx_word16_t)32767)
 
116
 
 
117
 
 
118
#ifdef FIXED_DEBUG
 
119
#include "fixed_debug.h"
 
120
#else
 
121
 
 
122
#include "fixed_generic.h"
 
123
 
 
124
#ifdef ARM5E_ASM
 
125
#include "fixed_arm5e.h"
 
126
#elif defined (ARM4_ASM)
 
127
#include "fixed_arm4.h"
 
128
#elif defined (BFIN_ASM)
 
129
#include "fixed_bfin.h"
 
130
#endif
 
131
 
 
132
#endif
 
133
 
 
134
 
 
135
#else
 
136
 
 
137
typedef float spx_mem_t;
 
138
typedef float spx_coef_t;
 
139
typedef float spx_lsp_t;
 
140
typedef float spx_sig_t;
 
141
typedef float spx_word16_t;
 
142
typedef float spx_word32_t;
 
143
 
 
144
#define Q15ONE 1.0f
 
145
#define LPC_SCALING  1.f
 
146
#define SIG_SCALING  1.f
 
147
#define LSP_SCALING  1.f
 
148
#define GAMMA_SCALING 1.f
 
149
#define GAIN_SCALING 1.f
 
150
#define GAIN_SCALING_1 1.f
 
151
 
 
152
 
 
153
#define VERY_SMALL 1e-15f
 
154
#define VERY_LARGE32 1e15f
 
155
#define VERY_LARGE16 1e15f
 
156
#define Q15_ONE ((spx_word16_t)1.f)
 
157
 
 
158
#define QCONST16(x,bits) (x)
 
159
#define QCONST32(x,bits) (x)
 
160
 
 
161
#define NEG16(x) (-(x))
 
162
#define NEG32(x) (-(x))
 
163
#define EXTRACT16(x) (x)
 
164
#define EXTEND32(x) (x)
 
165
#define SHR16(a,shift) (a)
 
166
#define SHL16(a,shift) (a)
 
167
#define SHR32(a,shift) (a)
 
168
#define SHL32(a,shift) (a)
 
169
#define PSHR16(a,shift) (a)
 
170
#define PSHR32(a,shift) (a)
 
171
#define VSHR32(a,shift) (a)
 
172
#define SATURATE16(x,a) (x)
 
173
#define SATURATE32(x,a) (x)
 
174
 
 
175
#define PSHR(a,shift)       (a)
 
176
#define SHR(a,shift)       (a)
 
177
#define SHL(a,shift)       (a)
 
178
#define SATURATE(x,a) (x)
 
179
 
 
180
#define ADD16(a,b) ((a)+(b))
 
181
#define SUB16(a,b) ((a)-(b))
 
182
#define ADD32(a,b) ((a)+(b))
 
183
#define SUB32(a,b) ((a)-(b))
 
184
#define MULT16_16_16(a,b)     ((a)*(b))
 
185
#define MULT16_16(a,b)     ((spx_word32_t)(a)*(spx_word32_t)(b))
 
186
#define MAC16_16(c,a,b)     ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
 
187
 
 
188
#define MULT16_32_Q11(a,b)     ((a)*(b))
 
189
#define MULT16_32_Q13(a,b)     ((a)*(b))
 
190
#define MULT16_32_Q14(a,b)     ((a)*(b))
 
191
#define MULT16_32_Q15(a,b)     ((a)*(b))
 
192
#define MULT16_32_P15(a,b)     ((a)*(b))
 
193
 
 
194
#define MAC16_32_Q11(c,a,b)     ((c)+(a)*(b))
 
195
#define MAC16_32_Q15(c,a,b)     ((c)+(a)*(b))
 
196
 
 
197
#define MAC16_16_Q11(c,a,b)     ((c)+(a)*(b))
 
198
#define MAC16_16_Q13(c,a,b)     ((c)+(a)*(b))
 
199
#define MAC16_16_P13(c,a,b)     ((c)+(a)*(b))
 
200
#define MULT16_16_Q11_32(a,b)     ((a)*(b))
 
201
#define MULT16_16_Q13(a,b)     ((a)*(b))
 
202
#define MULT16_16_Q14(a,b)     ((a)*(b))
 
203
#define MULT16_16_Q15(a,b)     ((a)*(b))
 
204
#define MULT16_16_P15(a,b)     ((a)*(b))
 
205
#define MULT16_16_P13(a,b)     ((a)*(b))
 
206
#define MULT16_16_P14(a,b)     ((a)*(b))
 
207
 
 
208
#define DIV32_16(a,b)     (((spx_word32_t)(a))/(spx_word16_t)(b))
 
209
#define PDIV32_16(a,b)     (((spx_word32_t)(a))/(spx_word16_t)(b))
 
210
#define DIV32(a,b)     (((spx_word32_t)(a))/(spx_word32_t)(b))
 
211
#define PDIV32(a,b)     (((spx_word32_t)(a))/(spx_word32_t)(b))
 
212
 
 
213
 
 
214
#endif
 
215
 
 
216
 
 
217
#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
 
218
 
 
219
/* 2 on TI C5x DSP */
 
220
#define BYTES_PER_CHAR 2 
 
221
#define BITS_PER_CHAR 16
 
222
#define LOG2_BITS_PER_CHAR 4
 
223
 
 
224
#else 
 
225
 
 
226
#define BYTES_PER_CHAR 1
 
227
#define BITS_PER_CHAR 8
 
228
#define LOG2_BITS_PER_CHAR 3
 
229
 
 
230
#endif
 
231
 
 
232
 
 
233
 
 
234
#ifdef FIXED_DEBUG
 
235
extern long long spx_mips;
 
236
#endif
 
237
 
 
238
 
 
239
#endif