545 files changed, 230976 insertions, 0 deletions
diff --git a/audio_codec/libraac/assembly.h b/audio_codec/libraac/assembly.h new file mode 100644 index 0000000..aeee62b --- a/dev/null +++ b/audio_codec/libraac/assembly.h @@ -0,0 +1,147 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Source last modified: $Id: assembly.h,v 1.7 2005/11/10 00:04:40 margotm Exp $ + * + * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. + * + * The contents of this file, and the files included with this file, + * are subject to the current version of the RealNetworks Public + * Source License (the "RPSL") available at + * http://www.helixcommunity.org/content/rpsl unless you have licensed + * the file under the current version of the RealNetworks Community + * Source License (the "RCSL") available at + * http://www.helixcommunity.org/content/rcsl, in which case the RCSL + * will apply. You may also obtain the license terms directly from + * RealNetworks. You may not use this file except in compliance with + * the RPSL or, if you have a valid RCSL with RealNetworks applicable + * to this file, the RCSL. Please see the applicable RPSL or RCSL for + * the rights, obligations and limitations governing use of the + * contents of the file. + * + * This file is part of the Helix DNA Technology. RealNetworks is the + * developer of the Original Code and owns the copyrights in the + * portions it created. + * + * This file, and the files included with this file, is distributed + * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY + * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS + * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET + * ENJOYMENT OR NON-INFRINGEMENT. + * + * Technology Compatibility Kit Test Suite(s) Location: + * http://www.helixcommunity.org/content/tck + * + * Contributor(s): + * + * ***** END LICENSE BLOCK ***** */ + +/************************************************************************************** + * Fixed-point HE-AAC decoder + * Jon Recker (jrecker@real.com) + * February 2005 + * + * assembly.h - inline assembly language functions and prototypes + * + * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y), + * returns top 32-bits of 64-bit result + * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short, + * clipping to [-32768, 32767] + * FASTABS(x) branchless absolute value of signed integer x + * CLZ(x) count leading zeros on signed integer x + * MADD64(sum64, x, y) 64-bit multiply accumulate: sum64 += (x*y) + **************************************************************************************/ + +#ifndef _ASSEMBLY_H +#define _ASSEMBLY_H + +/* toolchain: ARM gcc + * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier) + */ + +#if defined(__aarch64__) +static __inline__ int MULSHIFT32(int x, int y) +{ + long c; + c = (long)x * y; + return (int)c; +} +#else +static __inline__ int MULSHIFT32(int x, int y) +{ + int zlow; + __asm__ volatile("smull %0,%1,%2,%3" : "=&r"(zlow), "=r"(y) : "r"(x), "1"(y) : "cc"); + return y; +} +#endif +static __inline__ short CLIPTOSHORT(int x) +{ + int sign; + + /* clip to [-32768, 32767] */ + sign = x >> 31; + if (sign != (x >> 15)) { + x = sign ^((1 << 15) - 1); + } + + return (short)x; +} + +static __inline__ int FASTABS(int x) +{ + int sign; + + sign = x >> (sizeof(int) * 8 - 1); + x ^= sign; + x -= sign; + + return x; +} + +static __inline__ int CLZ(int x) +{ + int numZeros; + + if (!x) { + return (sizeof(int) * 8); + } + + numZeros = 0; + while (!(x & 0x80000000)) { + numZeros++; + x <<= 1; + } + + return numZeros; +} + +typedef long long Word64; + +typedef union _U64 { + Word64 w64; + struct { + /* ARM ADS = little endian */ + unsigned int lo32; + signed int hi32; + } r; +} U64; + +#if defined(__aarch64__) +static __inline__ Word64 MADD64(Word64 sum64, int x, int y) +{ + sum64 += (long)x * y; + + return sum64; +} +#else +static __inline__ Word64 MADD64(Word64 sum64, int x, int y) +{ + U64 u; + u.w64 = sum64; + + __asm__ volatile("smlal %0,%1,%2,%3" : "+&r"(u.r.lo32), "+&r"(u.r.hi32) : "r"(x), "r"(y) : "cc"); + + return u.w64; +} +#endif + +#endif /* _ASSEMBLY_H */ |