media/libopus/celt/arch.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libopus/celt/arch.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,214 @@
     1.4 +/* Copyright (c) 2003-2008 Jean-Marc Valin
     1.5 +   Copyright (c) 2007-2008 CSIRO
     1.6 +   Copyright (c) 2007-2009 Xiph.Org Foundation
     1.7 +   Written by Jean-Marc Valin */
     1.8 +/**
     1.9 +   @file arch.h
    1.10 +   @brief Various architecture definitions for CELT
    1.11 +*/
    1.12 +/*
    1.13 +   Redistribution and use in source and binary forms, with or without
    1.14 +   modification, are permitted provided that the following conditions
    1.15 +   are met:
    1.16 +
    1.17 +   - Redistributions of source code must retain the above copyright
    1.18 +   notice, this list of conditions and the following disclaimer.
    1.19 +
    1.20 +   - Redistributions in binary form must reproduce the above copyright
    1.21 +   notice, this list of conditions and the following disclaimer in the
    1.22 +   documentation and/or other materials provided with the distribution.
    1.23 +
    1.24 +   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.25 +   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.26 +   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.27 +   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
    1.28 +   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    1.29 +   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    1.30 +   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    1.31 +   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    1.32 +   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    1.33 +   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    1.34 +   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.35 +*/
    1.36 +
    1.37 +#ifndef ARCH_H
    1.38 +#define ARCH_H
    1.39 +
    1.40 +#include "opus_types.h"
    1.41 +#include "opus_defines.h"
    1.42 +
    1.43 +# if !defined(__GNUC_PREREQ)
    1.44 +#  if defined(__GNUC__)&&defined(__GNUC_MINOR__)
    1.45 +#   define __GNUC_PREREQ(_maj,_min) \
    1.46 + ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
    1.47 +#  else
    1.48 +#   define __GNUC_PREREQ(_maj,_min) 0
    1.49 +#  endif
    1.50 +# endif
    1.51 +
    1.52 +#define CELT_SIG_SCALE 32768.f
    1.53 +
    1.54 +#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
    1.55 +#ifdef ENABLE_ASSERTIONS
    1.56 +#include <stdio.h>
    1.57 +#include <stdlib.h>
    1.58 +#ifdef __GNUC__
    1.59 +__attribute__((noreturn))
    1.60 +#endif
    1.61 +static OPUS_INLINE void _celt_fatal(const char *str, const char *file, int line)
    1.62 +{
    1.63 +   fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
    1.64 +   abort();
    1.65 +}
    1.66 +#define celt_assert(cond) {if (!(cond)) {celt_fatal("assertion failed: " #cond);}}
    1.67 +#define celt_assert2(cond, message) {if (!(cond)) {celt_fatal("assertion failed: " #cond "\n" message);}}
    1.68 +#else
    1.69 +#define celt_assert(cond)
    1.70 +#define celt_assert2(cond, message)
    1.71 +#endif
    1.72 +
    1.73 +#define IMUL32(a,b) ((a)*(b))
    1.74 +
    1.75 +#define ABS(x) ((x) < 0 ? (-(x)) : (x))      /**< Absolute integer value. */
    1.76 +#define ABS16(x) ((x) < 0 ? (-(x)) : (x))    /**< Absolute 16-bit value.  */
    1.77 +#define MIN16(a,b) ((a) < (b) ? (a) : (b))   /**< Minimum 16-bit value.   */
    1.78 +#define MAX16(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 16-bit value.   */
    1.79 +#define ABS32(x) ((x) < 0 ? (-(x)) : (x))    /**< Absolute 32-bit value.  */
    1.80 +#define MIN32(a,b) ((a) < (b) ? (a) : (b))   /**< Minimum 32-bit value.   */
    1.81 +#define MAX32(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 32-bit value.   */
    1.82 +#define IMIN(a,b) ((a) < (b) ? (a) : (b))   /**< Minimum int value.   */
    1.83 +#define IMAX(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum int value.   */
    1.84 +#define UADD32(a,b) ((a)+(b))
    1.85 +#define USUB32(a,b) ((a)-(b))
    1.86 +
    1.87 +#define PRINT_MIPS(file)
    1.88 +
    1.89 +#ifdef FIXED_POINT
    1.90 +
    1.91 +typedef opus_int16 opus_val16;
    1.92 +typedef opus_int32 opus_val32;
    1.93 +
    1.94 +typedef opus_val32 celt_sig;
    1.95 +typedef opus_val16 celt_norm;
    1.96 +typedef opus_val32 celt_ener;
    1.97 +
    1.98 +#define Q15ONE 32767
    1.99 +
   1.100 +#define SIG_SHIFT 12
   1.101 +
   1.102 +#define NORM_SCALING 16384
   1.103 +
   1.104 +#define DB_SHIFT 10
   1.105 +
   1.106 +#define EPSILON 1
   1.107 +#define VERY_SMALL 0
   1.108 +#define VERY_LARGE16 ((opus_val16)32767)
   1.109 +#define Q15_ONE ((opus_val16)32767)
   1.110 +
   1.111 +#define SCALEIN(a)      (a)
   1.112 +#define SCALEOUT(a)     (a)
   1.113 +
   1.114 +#ifdef FIXED_DEBUG
   1.115 +#include "fixed_debug.h"
   1.116 +#else
   1.117 +
   1.118 +#include "fixed_generic.h"
   1.119 +
   1.120 +#ifdef OPUS_ARM_INLINE_EDSP
   1.121 +#include "arm/fixed_armv5e.h"
   1.122 +#elif defined (OPUS_ARM_INLINE_ASM)
   1.123 +#include "arm/fixed_armv4.h"
   1.124 +#elif defined (BFIN_ASM)
   1.125 +#include "fixed_bfin.h"
   1.126 +#elif defined (TI_C5X_ASM)
   1.127 +#include "fixed_c5x.h"
   1.128 +#elif defined (TI_C6X_ASM)
   1.129 +#include "fixed_c6x.h"
   1.130 +#endif
   1.131 +
   1.132 +#endif
   1.133 +
   1.134 +#else /* FIXED_POINT */
   1.135 +
   1.136 +typedef float opus_val16;
   1.137 +typedef float opus_val32;
   1.138 +
   1.139 +typedef float celt_sig;
   1.140 +typedef float celt_norm;
   1.141 +typedef float celt_ener;
   1.142 +
   1.143 +#define Q15ONE 1.0f
   1.144 +
   1.145 +#define NORM_SCALING 1.f
   1.146 +
   1.147 +#define EPSILON 1e-15f
   1.148 +#define VERY_SMALL 1e-30f
   1.149 +#define VERY_LARGE16 1e15f
   1.150 +#define Q15_ONE ((opus_val16)1.f)
   1.151 +
   1.152 +#define QCONST16(x,bits) (x)
   1.153 +#define QCONST32(x,bits) (x)
   1.154 +
   1.155 +#define NEG16(x) (-(x))
   1.156 +#define NEG32(x) (-(x))
   1.157 +#define EXTRACT16(x) (x)
   1.158 +#define EXTEND32(x) (x)
   1.159 +#define SHR16(a,shift) (a)
   1.160 +#define SHL16(a,shift) (a)
   1.161 +#define SHR32(a,shift) (a)
   1.162 +#define SHL32(a,shift) (a)
   1.163 +#define PSHR32(a,shift) (a)
   1.164 +#define VSHR32(a,shift) (a)
   1.165 +
   1.166 +#define PSHR(a,shift)   (a)
   1.167 +#define SHR(a,shift)    (a)
   1.168 +#define SHL(a,shift)    (a)
   1.169 +#define SATURATE(x,a)   (x)
   1.170 +#define SATURATE16(x)   (x)
   1.171 +
   1.172 +#define ROUND16(a,shift)  (a)
   1.173 +#define HALF16(x)       (.5f*(x))
   1.174 +#define HALF32(x)       (.5f*(x))
   1.175 +
   1.176 +#define ADD16(a,b) ((a)+(b))
   1.177 +#define SUB16(a,b) ((a)-(b))
   1.178 +#define ADD32(a,b) ((a)+(b))
   1.179 +#define SUB32(a,b) ((a)-(b))
   1.180 +#define MULT16_16_16(a,b)     ((a)*(b))
   1.181 +#define MULT16_16(a,b)     ((opus_val32)(a)*(opus_val32)(b))
   1.182 +#define MAC16_16(c,a,b)     ((c)+(opus_val32)(a)*(opus_val32)(b))
   1.183 +
   1.184 +#define MULT16_32_Q15(a,b)     ((a)*(b))
   1.185 +#define MULT16_32_Q16(a,b)     ((a)*(b))
   1.186 +
   1.187 +#define MULT32_32_Q31(a,b)     ((a)*(b))
   1.188 +
   1.189 +#define MAC16_32_Q15(c,a,b)     ((c)+(a)*(b))
   1.190 +
   1.191 +#define MULT16_16_Q11_32(a,b)     ((a)*(b))
   1.192 +#define MULT16_16_Q11(a,b)     ((a)*(b))
   1.193 +#define MULT16_16_Q13(a,b)     ((a)*(b))
   1.194 +#define MULT16_16_Q14(a,b)     ((a)*(b))
   1.195 +#define MULT16_16_Q15(a,b)     ((a)*(b))
   1.196 +#define MULT16_16_P15(a,b)     ((a)*(b))
   1.197 +#define MULT16_16_P13(a,b)     ((a)*(b))
   1.198 +#define MULT16_16_P14(a,b)     ((a)*(b))
   1.199 +#define MULT16_32_P16(a,b)     ((a)*(b))
   1.200 +
   1.201 +#define DIV32_16(a,b)     (((opus_val32)(a))/(opus_val16)(b))
   1.202 +#define DIV32(a,b)     (((opus_val32)(a))/(opus_val32)(b))
   1.203 +
   1.204 +#define SCALEIN(a)      ((a)*CELT_SIG_SCALE)
   1.205 +#define SCALEOUT(a)     ((a)*(1/CELT_SIG_SCALE))
   1.206 +
   1.207 +#endif /* !FIXED_POINT */
   1.208 +
   1.209 +#ifndef GLOBAL_STACK_SIZE
   1.210 +#ifdef FIXED_POINT
   1.211 +#define GLOBAL_STACK_SIZE 100000
   1.212 +#else
   1.213 +#define GLOBAL_STACK_SIZE 100000
   1.214 +#endif
   1.215 +#endif
   1.216 +
   1.217 +#endif /* ARCH_H */

mercurial