ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 47:9e361da97763 1 /* Copyright (C) 2002 Jean-Marc Valin */
TMBOY 47:9e361da97763 2 /**
TMBOY 47:9e361da97763 3 @file misc.h
TMBOY 47:9e361da97763 4 @brief Various compatibility routines for Speex
TMBOY 47:9e361da97763 5 */
TMBOY 47:9e361da97763 6 /*
TMBOY 47:9e361da97763 7 Redistribution and use in source and binary forms, with or without
TMBOY 47:9e361da97763 8 modification, are permitted provided that the following conditions
TMBOY 47:9e361da97763 9 are met:
TMBOY 47:9e361da97763 10
TMBOY 47:9e361da97763 11 - Redistributions of source code must retain the above copyright
TMBOY 47:9e361da97763 12 notice, this list of conditions and the following disclaimer.
TMBOY 47:9e361da97763 13
TMBOY 47:9e361da97763 14 - Redistributions in binary form must reproduce the above copyright
TMBOY 47:9e361da97763 15 notice, this list of conditions and the following disclaimer in the
TMBOY 47:9e361da97763 16 documentation and/or other materials provided with the distribution.
TMBOY 47:9e361da97763 17
TMBOY 47:9e361da97763 18 - Neither the name of the Xiph.org Foundation nor the names of its
TMBOY 47:9e361da97763 19 contributors may be used to endorse or promote products derived from
TMBOY 47:9e361da97763 20 this software without specific prior written permission.
TMBOY 47:9e361da97763 21
TMBOY 47:9e361da97763 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
TMBOY 47:9e361da97763 23 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
TMBOY 47:9e361da97763 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
TMBOY 47:9e361da97763 25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
TMBOY 47:9e361da97763 26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
TMBOY 47:9e361da97763 27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
TMBOY 47:9e361da97763 28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
TMBOY 47:9e361da97763 29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
TMBOY 47:9e361da97763 30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
TMBOY 47:9e361da97763 31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
TMBOY 47:9e361da97763 32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
TMBOY 47:9e361da97763 33 */
TMBOY 47:9e361da97763 34
TMBOY 47:9e361da97763 35 #ifndef MISC_H
TMBOY 47:9e361da97763 36 #define MISC_H
TMBOY 47:9e361da97763 37
TMBOY 47:9e361da97763 38 #ifndef SPEEX_VERSION
TMBOY 47:9e361da97763 39 #define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */
TMBOY 47:9e361da97763 40 #define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
TMBOY 47:9e361da97763 41 #define SPEEX_MICRO_VERSION 14 /**< Micro Speex version. */
TMBOY 47:9e361da97763 42 #define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
TMBOY 47:9e361da97763 43 #define SPEEX_VERSION "speex-1.2beta2" /**< Speex version string. */
TMBOY 47:9e361da97763 44 #endif
TMBOY 47:9e361da97763 45
TMBOY 47:9e361da97763 46 /* A couple test to catch stupid option combinations */
TMBOY 47:9e361da97763 47 #ifdef FIXED_POINT
TMBOY 47:9e361da97763 48
TMBOY 47:9e361da97763 49 #ifdef _USE_SSE
TMBOY 47:9e361da97763 50 #error SSE is only for floating-point
TMBOY 47:9e361da97763 51 #endif
TMBOY 47:9e361da97763 52 #if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
TMBOY 47:9e361da97763 53 #error Make up your mind. What CPU do you have?
TMBOY 47:9e361da97763 54 #endif
TMBOY 47:9e361da97763 55 #ifdef VORBIS_PSYCHO
TMBOY 47:9e361da97763 56 #error Vorbis-psy model currently not implemented in fixed-point
TMBOY 47:9e361da97763 57 #endif
TMBOY 47:9e361da97763 58
TMBOY 47:9e361da97763 59 #else
TMBOY 47:9e361da97763 60
TMBOY 47:9e361da97763 61 #if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
TMBOY 47:9e361da97763 62 #error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
TMBOY 47:9e361da97763 63 #endif
TMBOY 47:9e361da97763 64 #ifdef FIXED_POINT_DEBUG
TMBOY 47:9e361da97763 65 #error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"
TMBOY 47:9e361da97763 66 #endif
TMBOY 47:9e361da97763 67
TMBOY 47:9e361da97763 68
TMBOY 47:9e361da97763 69 #endif
TMBOY 47:9e361da97763 70
TMBOY 47:9e361da97763 71 #include "arch.h"
TMBOY 47:9e361da97763 72
TMBOY 47:9e361da97763 73 #ifndef RELEASE
TMBOY 47:9e361da97763 74 /** Print a named vector to stdout */
TMBOY 47:9e361da97763 75 void print_vec(float *vec, int len, char *name);
TMBOY 47:9e361da97763 76 #endif
TMBOY 47:9e361da97763 77
TMBOY 47:9e361da97763 78 /** Convert little endian */
TMBOY 47:9e361da97763 79 static inline spx_int32_t le_int(spx_int32_t i)
TMBOY 47:9e361da97763 80 {
TMBOY 47:9e361da97763 81 #if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) )
TMBOY 47:9e361da97763 82 spx_uint32_t ui, ret;
TMBOY 47:9e361da97763 83 ui = i;
TMBOY 47:9e361da97763 84 ret = ui>>24;
TMBOY 47:9e361da97763 85 ret |= (ui>>8)&0x0000ff00;
TMBOY 47:9e361da97763 86 ret |= (ui<<8)&0x00ff0000;
TMBOY 47:9e361da97763 87 ret |= (ui<<24);
TMBOY 47:9e361da97763 88 return ret;
TMBOY 47:9e361da97763 89 #else
TMBOY 47:9e361da97763 90 return i;
TMBOY 47:9e361da97763 91 #endif
TMBOY 47:9e361da97763 92 }
TMBOY 47:9e361da97763 93
TMBOY 47:9e361da97763 94 /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
TMBOY 47:9e361da97763 95 void *speex_alloc (int size);
TMBOY 47:9e361da97763 96
TMBOY 47:9e361da97763 97 /** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
TMBOY 47:9e361da97763 98 void *speex_alloc_scratch (int size);
TMBOY 47:9e361da97763 99
TMBOY 47:9e361da97763 100 /** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */
TMBOY 47:9e361da97763 101 void *speex_realloc (void *ptr, int size);
TMBOY 47:9e361da97763 102
TMBOY 47:9e361da97763 103 /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */
TMBOY 47:9e361da97763 104 void speex_free (void *ptr);
TMBOY 47:9e361da97763 105
TMBOY 47:9e361da97763 106 /** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
TMBOY 47:9e361da97763 107 void speex_free_scratch (void *ptr);
TMBOY 47:9e361da97763 108
TMBOY 47:9e361da97763 109 /** Speex wrapper for mem_move */
TMBOY 47:9e361da97763 110 void *speex_move (void *dest, void *src, int n);
TMBOY 47:9e361da97763 111
TMBOY 47:9e361da97763 112 /** Abort with an error message to stderr (internal Speex error) */
TMBOY 47:9e361da97763 113 void speex_error(const char *str);
TMBOY 47:9e361da97763 114
TMBOY 47:9e361da97763 115 /** Print warning message to stderr (programming error) */
TMBOY 47:9e361da97763 116 void speex_warning(const char *str);
TMBOY 47:9e361da97763 117
TMBOY 47:9e361da97763 118 /** Print warning message with integer argument to stderr */
TMBOY 47:9e361da97763 119 void speex_warning_int(const char *str, int val);
TMBOY 47:9e361da97763 120
TMBOY 47:9e361da97763 121 /** Print notification message to stderr */
TMBOY 47:9e361da97763 122 void speex_notify(const char *str);
TMBOY 47:9e361da97763 123
TMBOY 47:9e361da97763 124 /** Generate a random number */
TMBOY 47:9e361da97763 125 spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed);
TMBOY 47:9e361da97763 126
TMBOY 47:9e361da97763 127 /** Speex wrapper for putc */
TMBOY 47:9e361da97763 128 void _speex_putc(int ch, void *file);
TMBOY 47:9e361da97763 129
TMBOY 47:9e361da97763 130 #endif