ex

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers misc.h Source File

misc.h

Go to the documentation of this file.
00001 /* Copyright (C) 2002 Jean-Marc Valin */
00002 /**
00003    @file misc.h
00004    @brief Various compatibility routines for Speex
00005 */
00006 /*
00007    Redistribution and use in source and binary forms, with or without
00008    modification, are permitted provided that the following conditions
00009    are met:
00010    
00011    - Redistributions of source code must retain the above copyright
00012    notice, this list of conditions and the following disclaimer.
00013    
00014    - Redistributions in binary form must reproduce the above copyright
00015    notice, this list of conditions and the following disclaimer in the
00016    documentation and/or other materials provided with the distribution.
00017    
00018    - Neither the name of the Xiph.org Foundation nor the names of its
00019    contributors may be used to endorse or promote products derived from
00020    this software without specific prior written permission.
00021    
00022    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00026    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 */
00034 
00035 #ifndef MISC_H
00036 #define MISC_H
00037 
00038 #ifndef SPEEX_VERSION
00039 #define SPEEX_MAJOR_VERSION 1         /**< Major Speex version. */
00040 #define SPEEX_MINOR_VERSION 1         /**< Minor Speex version. */
00041 #define SPEEX_MICRO_VERSION 14        /**< Micro Speex version. */
00042 #define SPEEX_EXTRA_VERSION ""        /**< Extra Speex version. */
00043 #define SPEEX_VERSION "speex-1.2beta2"  /**< Speex version string. */
00044 #endif
00045 
00046 /* A couple test to catch stupid option combinations */
00047 #ifdef FIXED_POINT
00048 
00049 #ifdef _USE_SSE
00050 #error SSE is only for floating-point
00051 #endif
00052 #if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
00053 #error Make up your mind. What CPU do you have?
00054 #endif
00055 #ifdef VORBIS_PSYCHO
00056 #error Vorbis-psy model currently not implemented in fixed-point
00057 #endif
00058 
00059 #else
00060 
00061 #if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
00062 #error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
00063 #endif
00064 #ifdef FIXED_POINT_DEBUG
00065 #error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"
00066 #endif
00067 
00068 
00069 #endif
00070 
00071 #include "arch.h"
00072 
00073 #ifndef RELEASE
00074 /** Print a named vector to stdout */
00075 void print_vec(float *vec, int len, char *name);
00076 #endif
00077 
00078 /** Convert little endian */
00079 static inline spx_int32_t le_int(spx_int32_t i)
00080 {
00081 #if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) )
00082    spx_uint32_t ui, ret;
00083    ui = i;
00084    ret =  ui>>24;
00085    ret |= (ui>>8)&0x0000ff00;
00086    ret |= (ui<<8)&0x00ff0000;
00087    ret |= (ui<<24);
00088    return ret;
00089 #else
00090    return i;
00091 #endif
00092 }
00093 
00094 /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
00095 void *speex_alloc (int size);
00096 
00097 /** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
00098 void *speex_alloc_scratch (int size);
00099 
00100 /** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */
00101 void *speex_realloc (void *ptr, int size);
00102 
00103 /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */
00104 void speex_free (void *ptr);
00105 
00106 /** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
00107 void speex_free_scratch (void *ptr);
00108 
00109 /** Speex wrapper for mem_move */
00110 void *speex_move (void *dest, void *src, int n);
00111 
00112 /** Abort with an error message to stderr (internal Speex error) */
00113 void speex_error(const char *str);
00114 
00115 /** Print warning message to stderr (programming error) */
00116 void speex_warning(const char *str);
00117 
00118 /** Print warning message with integer argument to stderr */
00119 void speex_warning_int(const char *str, int val);
00120 
00121 /** Print notification message to stderr */
00122 void speex_notify(const char *str);
00123 
00124 /** Generate a random number */
00125 spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed);
00126 
00127 /** Speex wrapper for putc */
00128 void _speex_putc(int ch, void *file);
00129 
00130 #endif