CI13LC SDK API手册  2.1.1
本手册用于描述CI13LC SDK各个组件和驱动API
mp3assembly.h
浏览该文件的文档.
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: RCSL 1.0/RPSL 1.0
3  *
4  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
5  *
6  * The contents of this file, and the files included with this file, are
7  * subject to the current version of the RealNetworks Public Source License
8  * Version 1.0 (the "RPSL") available at
9  * http://www.helixcommunity.org/content/rpsl unless you have licensed
10  * the file under the RealNetworks Community Source License Version 1.0
11  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
12  * in which case the RCSL will apply. You may also obtain the license terms
13  * directly from RealNetworks. You may not use this file except in
14  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
15  * applicable to this file, the RCSL. Please see the applicable RPSL or
16  * RCSL for the rights, obligations and limitations governing use of the
17  * contents of the file.
18  *
19  * This file is part of the Helix DNA Technology. RealNetworks is the
20  * developer of the Original Code and owns the copyrights in the portions
21  * it created.
22  *
23  * This file, and the files included with this file, is distributed and made
24  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
25  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
26  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
27  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
28  *
29  * Technology Compatibility Kit Test Suite(s) Location:
30  * http://www.helixcommunity.org/content/tck
31  *
32  * Contributor(s):
33  *
34  * ***** END LICENSE BLOCK ***** */
35 
36 /**************************************************************************************
37  * Fixed-point MP3 decoder
38  * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
39  * June 2003
40  *
41  * mp3assembly.h - assembly language functions and prototypes for supported platforms
42  *
43  * - inline rountines with access to 64-bit multiply results
44  * - x86 (_WIN32) and ARM (ARM_ADS, _WIN32_WCE) versions included
45  * - some inline functions are mix of asm and C for speed
46  * - some functions are in native asm files, so only the prototype is given here
47  *
48  * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y), returns top 32 bits of 64-bit result
49  * FASTABS(x) branchless absolute value of signed integer x
50  * CLZ(x) count leading zeros in x
51  * MADD64(sum, x, y) (Windows only) sum [64-bit] += x [32-bit] * y [32-bit]
52  * SHL64(sum, x, y) (Windows only) 64-bit left shift using __int64
53  * SAR64(sum, x, y) (Windows only) 64-bit right shift using __int64
54  */
55 
56 #ifndef _ASSEMBLY_H
57 #define _ASSEMBLY_H
58 
59 #include "mp3dec.h"
60 
61 /* toolchain: ARM gcc
62  * target architecture: ARM v7-m
63  */
64 #if defined(__GNUC__) && (defined(ARM) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__))
65 
66 typedef long long Word64;
67 
68 typedef union _U64
69 {
70  Word64 w64;
71  struct
72  {
73  unsigned int lo32;
74  signed int hi32;
75  }r;
76 } U64;
77 
78 #define MULSHIFT32 xmp3_MULSHIFT32
79 extern int MULSHIFT32(int x, int y);
80 
81 #define FASTABS xmp3_FASTABS
82 extern int FASTABS(int x);
83 
84 static inline Word64 MADD64(Word64 sum64, int x, int y)
85 {
86  U64 u;
87  u.w64 = sum64;
88  __asm__ volatile ("smlal %0,%1,%2,%3" : "+&r" (u.r.lo32), "+&r" (u.r.hi32) : "r" (x), "r" (y) : "cc");
89  return u.w64;
90 }
91 
92 static inline long long SAR64(long long x, int n)
93 {
94  long long ret = x;
95  ret = ret>>n;
96  return ret;
97 }
98 
99 #define CLZ(x) __CLZ(x)
100 
101 #define CLIPTO30(x) __SSAT(x,30)
102 
103 
104 /* toolchain: iar iccarm
105  * target architecture: ARM v7-m
106  */
107 #elif defined(__ICCARM__)
108 
109 typedef long long Word64;
110 
111 #define MULSHIFT32 xmp3_MULSHIFT32
112 extern int MULSHIFT32(int x, int y);
113 
114 #define FASTABS xmp3_FASTABS
115 extern int FASTABS(int x);
116 
117 static inline long long MADD64(long long sum, int x, int y)
118 {
119  return (sum +(long long)x * y);
120 }
121 
122 static inline long long SAR64(long long x, int n)
123 {
124  long long ret = x;
125  ret = ret>>n;
126  return ret;
127 }
128 
129 #define CLZ(x) __CLZ(x)
130 
131 #define CLIPTO30(x) __SSAT(x,30)
132 
133 #else
134 
135 typedef long long Word64;
136 
137 _XIF_ static inline int MULSHIFT32(int x, int y)
138 {
139  int z;
140  z = (Word64)x * (Word64)y >> 32;
141  return z;
142 }
143 
144 _XIF_ static inline int FASTABS(int x)
145 {
146  int sign;
147  sign = x >> (sizeof(int) * 8 -1);
148  x ^= sign;
149  x -= sign;
150  return x;
151 }
152 
153 _XIF_ static inline long long MADD64(long long sum, int x, int y)
154 {
155  return (sum +(long long)x * y);
156 }
157 
158 _XIF_ static inline long long SAR64(long long x, int n)
159 {
160  long long ret = x;
161  ret = ret>>n;
162  return ret;
163 }
164 
165 _XIF_ static inline int CLZ(int x)
166 {
167  int numZeros;
168 
169  if(!x)
170  return 32;
171 
172  numZeros = 1;
173  if(!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16;}
174  if(!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8;}
175  if(!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4;}
176  if(!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2;}
177 
178  numZeros -= ((unsigned int)x >> 31);
179 
180  return numZeros;
181 }
182 
183 _XIF_ static inline int CLIPTO30(int x)
184 {
185  int sign;
186 
187  sign = x>>31;
188  if(sign != (x >> 30))
189  x = sign ^ ((1 << 30)-1);
190 
191  return x;
192 }
193 
194 #endif /* platforms */
195 
196 #endif /* _ASSEMBLY_H */
static _XIF_ int MULSHIFT32(int x, int y)
Definition: mp3assembly.h:137
long long Word64
Definition: mp3assembly.h:135
static _XIF_ int FASTABS(int x)
Definition: mp3assembly.h:144
static _XIF_ int CLIPTO30(int x)
Definition: mp3assembly.h:183
static _XIF_ int CLZ(int x)
Definition: mp3assembly.h:165
static _XIF_ long long MADD64(long long sum, int x, int y)
Definition: mp3assembly.h:153
static _XIF_ long long SAR64(long long x, int n)
Definition: mp3assembly.h:158
#define U64
Definition: Global.h:78