~ubuntu-branches/ubuntu/vivid/linphone/vivid

« back to all changes in this revision

Viewing changes to speex/libspeex/fixed_arm.h

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2006-11-15 10:34:50 UTC
  • mfrom: (1.2.1 upstream) (2.1.8 feisty)
  • Revision ID: james.westby@ubuntu.com-20061115103450-qgafwcks2lkhctlj
* New upstream release.
* Enable video support.
* Fix mismatched #endif in mscommon.h, closes: #398307.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2003 Jean-Marc Valin */
2
 
/**
3
 
   @file fixed_generic.h
4
 
   @brief ARM-tuned fixed-point operations
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 FIXED_ARM_H
36
 
#define FIXED_ARM_H
37
 
 
38
 
#define SHR(a,shift) ((a) >> (shift))
39
 
#define SHL(a,shift) ((a) << (shift))
40
 
 
41
 
#define SATURATE(x,a) ((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))
42
 
 
43
 
 
44
 
#define ADD16(a,b) ((short)((short)(a)+(short)(b)))
45
 
#define SUB16(a,b) ((a)-(b))
46
 
#define ADD32(a,b) ((a)+(b))
47
 
#define SUB32(a,b) ((a)-(b))
48
 
#define ADD64(a,b) ((a)+(b))
49
 
 
50
 
#define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift))
51
 
 
52
 
/* result fits in 16 bits */
53
 
#define MULT16_16_16(a,b)     (((short)(a))*((short)(b)))
54
 
 
55
 
static inline spx_word32_t MULT16_16(spx_word16_t x, spx_word16_t y) {
56
 
  int res;
57
 
  asm ("smulbb  %0,%1,%2;\n"
58
 
              : "=&r"(res)
59
 
              : "%r"(x),"r"(y));
60
 
  return(res);
61
 
}
62
 
 
63
 
static inline spx_word32_t MAC16_16(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
64
 
  int res;
65
 
  asm ("smlabb  %0,%1,%2,%3;\n"
66
 
              : "=&r"(res)
67
 
               : "%r"(x),"r"(y),"r"(a));
68
 
  return(res);
69
 
}
70
 
 
71
 
#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
72
 
#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
73
 
#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))
74
 
 
75
 
static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
76
 
  int res;
77
 
  asm ("smulwb  %0,%1,%2;\n"
78
 
              : "=&r"(res)
79
 
               : "%r"(y<<1),"r"(x));
80
 
  return(res);
81
 
}
82
 
static inline spx_word32_t MAC16_32_Q15(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
83
 
  int res;
84
 
  asm ("smlawb  %0,%1,%2,%3;\n"
85
 
              : "=&r"(res)
86
 
               : "%r"(y<<1),"r"(x),"r"(a));
87
 
  return(res);
88
 
}
89
 
static inline spx_word32_t MULT16_32_Q11(spx_word16_t x, spx_word32_t y) {
90
 
  int res;
91
 
  asm ("smulwb  %0,%1,%2;\n"
92
 
              : "=&r"(res)
93
 
               : "%r"(y<<5),"r"(x));
94
 
  return(res);
95
 
}
96
 
static inline spx_word32_t MAC16_32_Q11(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
97
 
  int res;
98
 
  asm ("smlawb  %0,%1,%2,%3;\n"
99
 
              : "=&r"(res)
100
 
               : "%r"(y<<5),"r"(x),"r"(a));
101
 
  return(res);
102
 
}
103
 
 
104
 
#define MAC16_16_Q11(c,a,b)     (ADD32((c),SHR(MULT16_16((a),(b)),11)))
105
 
 
106
 
#define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11))
107
 
#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
108
 
#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
109
 
#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
110
 
 
111
 
#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
112
 
#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
113
 
#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))
114
 
 
115
 
#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))
116
 
 
117
 
 
118
 
 
119
 
#define DIV32_16(a,b) ((short)(((signed int)(a))/((short)(b))))
120
 
#define DIV32(a,b) (((signed int)(a))/((signed int)(b)))
121
 
 
122
 
 
123
 
 
124
 
#endif