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