forked from len0rd/rockbox
Sync Speex to SVN. Add new header file to adapt to Speex' new way of doing wrapper functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15209 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6dc3a743ad
commit
56db559754
29 changed files with 639 additions and 673 deletions
|
@ -35,6 +35,8 @@
|
|||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include "config-speex.h"
|
||||
|
||||
#ifndef SPEEX_VERSION
|
||||
#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */
|
||||
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
|
||||
|
@ -69,16 +71,14 @@
|
|||
#endif
|
||||
|
||||
#include "arch.h"
|
||||
|
||||
#ifndef RELEASE
|
||||
/** Print a named vector to stdout */
|
||||
void print_vec(float *vec, int len, char *name);
|
||||
#endif
|
||||
#include "rockbox.h"
|
||||
|
||||
/** Convert little endian */
|
||||
static inline spx_int32_t le_int(spx_int32_t i)
|
||||
{
|
||||
#if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) )
|
||||
#if 1
|
||||
return letoh32(i);
|
||||
#elif !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) )
|
||||
spx_uint32_t ui, ret;
|
||||
ui = i;
|
||||
ret = ui>>24;
|
||||
|
@ -91,40 +91,138 @@ static inline spx_int32_t le_int(spx_int32_t i)
|
|||
#endif
|
||||
}
|
||||
|
||||
#define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__);
|
||||
#define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}}
|
||||
|
||||
#ifndef RELEASE
|
||||
static void print_vec(float *vec, int len, char *name)
|
||||
{
|
||||
int i;
|
||||
printf ("%s ", name);
|
||||
for (i=0;i<len;i++)
|
||||
printf (" %f", vec[i]);
|
||||
printf ("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_DEBUG
|
||||
long long spx_mips=0;
|
||||
#endif
|
||||
|
||||
|
||||
/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
|
||||
void *speex_alloc (int size);
|
||||
#ifndef OVERRIDE_SPEEX_ALLOC
|
||||
static inline void *speex_alloc (int size)
|
||||
{
|
||||
return calloc(size,1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
|
||||
void *speex_alloc_scratch (int size);
|
||||
#ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH
|
||||
static inline void *speex_alloc_scratch (int size)
|
||||
{
|
||||
return calloc(size,1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */
|
||||
void *speex_realloc (void *ptr, int size);
|
||||
#ifndef OVERRIDE_SPEEX_REALLOC
|
||||
static inline void *speex_realloc (void *ptr, int size)
|
||||
{
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */
|
||||
void speex_free (void *ptr);
|
||||
#ifndef OVERRIDE_SPEEX_FREE
|
||||
static inline void speex_free (void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
|
||||
void speex_free_scratch (void *ptr);
|
||||
|
||||
/** Speex wrapper for mem_move */
|
||||
void *speex_move (void *dest, void *src, int n);
|
||||
|
||||
/** Abort with an error message to stderr (internal Speex error) */
|
||||
void speex_error(const char *str);
|
||||
|
||||
/** Print warning message to stderr (programming error) */
|
||||
void speex_warning(const char *str);
|
||||
/** Same as speex_free, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
|
||||
#ifndef OVERRIDE_SPEEX_FREE_SCRATCH
|
||||
static inline void speex_free_scratch (void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Print warning message with integer argument to stderr */
|
||||
void speex_warning_int(const char *str, int val);
|
||||
#ifndef OVERRIDE_SPEEX_MOVE
|
||||
static inline void *speex_move (void *dest, void *src, int n)
|
||||
{
|
||||
return memmove(dest,src,n);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Print notification message to stderr */
|
||||
void speex_notify(const char *str);
|
||||
#ifndef OVERRIDE_SPEEX_FATAL
|
||||
static inline void _speex_fatal(const char *str, const char *file, int line)
|
||||
{
|
||||
fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Generate a random number */
|
||||
spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed);
|
||||
#ifndef OVERRIDE_SPEEX_WARNING
|
||||
static inline void speex_warning(const char *str)
|
||||
{
|
||||
#ifndef DISABLE_WARNINGS
|
||||
fprintf (stderr, "warning: %s\n", str);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_WARNING_INT
|
||||
static inline void speex_warning_int(const char *str, int val)
|
||||
{
|
||||
#ifndef DISABLE_WARNINGS
|
||||
fprintf (stderr, "warning: %s %d\n", str, val);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_NOTIFY
|
||||
static inline void speex_notify(const char *str)
|
||||
{
|
||||
#ifndef DISABLE_NOTIFICATIONS
|
||||
fprintf (stderr, "notification: %s\n", str);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
/** Generate a pseudo-random number */
|
||||
static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
|
||||
{
|
||||
spx_word32_t res;
|
||||
*seed = 1664525 * *seed + 1013904223;
|
||||
res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std);
|
||||
return EXTRACT16(PSHR32(SUB32(res, SHR32(res, 3)),14));
|
||||
}
|
||||
#else
|
||||
/** Generate a pseudo-random number */
|
||||
static inline spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
|
||||
{
|
||||
const unsigned int jflone = 0x3f800000;
|
||||
const unsigned int jflmsk = 0x007fffff;
|
||||
union {int i; float f;} ran;
|
||||
*seed = 1664525 * *seed + 1013904223;
|
||||
ran.i = jflone | (jflmsk & *seed);
|
||||
ran.f -= 1.5;
|
||||
return 3.4642*std*ran.f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_PUTC
|
||||
/** Speex wrapper for putc */
|
||||
void _speex_putc(int ch, void *file);
|
||||
static inline void _speex_putc(int ch, void *file)
|
||||
{
|
||||
FILE *f = (FILE *)file;
|
||||
fprintf(f, "%c", ch);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue