mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
gst/speexresample/: Update Speex resampler with latest version from Speex GIT.
Original commit message from CVS: * gst/speexresample/README: * gst/speexresample/arch.h: * gst/speexresample/fixed_arm4.h: * gst/speexresample/fixed_arm5e.h: * gst/speexresample/fixed_bfin.h: * gst/speexresample/fixed_debug.h: * gst/speexresample/fixed_generic.h: * gst/speexresample/resample.c: (compute_func), (main), (sinc), (cubic_coef), (resampler_basic_direct_single), (resampler_basic_direct_double), (resampler_basic_interpolate_single), (resampler_basic_interpolate_double), (update_filter), (speex_resampler_init_frac), (speex_resampler_process_native), (speex_resampler_magic), (speex_resampler_process_float), (speex_resampler_process_int), (speex_resampler_process_interleaved_float), (speex_resampler_process_interleaved_int), (speex_resampler_set_rate_frac), (speex_resampler_skip_zeros), (speex_resampler_reset_mem): * gst/speexresample/speex_resampler.h: Update Speex resampler with latest version from Speex GIT.
This commit is contained in:
parent
1672bf00cd
commit
0331f0c33b
10 changed files with 1442 additions and 558 deletions
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2008-10-28 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* gst/speexresample/README:
|
||||
* gst/speexresample/arch.h:
|
||||
* gst/speexresample/fixed_arm4.h:
|
||||
* gst/speexresample/fixed_arm5e.h:
|
||||
* gst/speexresample/fixed_bfin.h:
|
||||
* gst/speexresample/fixed_debug.h:
|
||||
* gst/speexresample/fixed_generic.h:
|
||||
* gst/speexresample/resample.c: (compute_func), (main), (sinc),
|
||||
(cubic_coef), (resampler_basic_direct_single),
|
||||
(resampler_basic_direct_double),
|
||||
(resampler_basic_interpolate_single),
|
||||
(resampler_basic_interpolate_double), (update_filter),
|
||||
(speex_resampler_init_frac), (speex_resampler_process_native),
|
||||
(speex_resampler_magic), (speex_resampler_process_float),
|
||||
(speex_resampler_process_int),
|
||||
(speex_resampler_process_interleaved_float),
|
||||
(speex_resampler_process_interleaved_int),
|
||||
(speex_resampler_set_rate_frac), (speex_resampler_skip_zeros),
|
||||
(speex_resampler_reset_mem):
|
||||
* gst/speexresample/speex_resampler.h:
|
||||
Update Speex resampler with latest version from Speex GIT.
|
||||
|
||||
2008-10-27 Michael Smith <msmith@songbirdnest.com>
|
||||
|
||||
* gst/aiffparse/aiffparse.c:
|
||||
|
|
|
@ -1,37 +1,76 @@
|
|||
resample.c
|
||||
arch.h
|
||||
fixed_arm4.h
|
||||
fixed_arm5e.h
|
||||
fixed_bfin.h
|
||||
fixed_debug.h
|
||||
fixed_generic.h
|
||||
resample.c
|
||||
speex_resampler.h
|
||||
|
||||
are taken from http://svn.xiph.org/trunk/speex/ revision 14232.
|
||||
are taken from http://git.xiph.org/speex.git/ as of 2008-10-28.
|
||||
|
||||
The only changes are:
|
||||
|
||||
--- speex/libspeex/arch.h 2007-11-21 11:05:46.000000000 +0100
|
||||
+++ speexresample/arch.h 2007-11-20 05:41:09.000000000 +0100
|
||||
@@ -78,7 +78,9 @@
|
||||
#include "speex/speex_types.h"
|
||||
--- arch.h 2008-10-28 12:21:37.000000000 +0100
|
||||
+++ arch.h 2008-10-28 12:27:56.000000000 +0100
|
||||
@@ -78,7 +78,10 @@
|
||||
#include "../include/speex/speex_types.h"
|
||||
#endif
|
||||
|
||||
+#ifndef ABS
|
||||
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
|
||||
+#endif
|
||||
+
|
||||
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
|
||||
#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */
|
||||
#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */
|
||||
|
||||
--- speex/include/speex/speex_resampler.h 2007-11-21 11:05:44.000000000 +0100
|
||||
+++ speexresample/speex_resampler.h 2007-11-21 11:10:02.000000000 +0100
|
||||
@@ -41,6 +41,8 @@
|
||||
--- resample.c 2008-10-28 12:21:35.000000000 +0100
|
||||
+++ resample.c 2008-10-28 12:33:46.000000000 +0100
|
||||
@@ -63,22 +63,27 @@
|
||||
|
||||
#ifdef OUTSIDE_SPEEX
|
||||
|
||||
#include <stdlib.h>
|
||||
-static void *
|
||||
+
|
||||
+#include <glib.h>
|
||||
+
|
||||
/********* WARNING: MENTAL SANITY ENDS HERE *************/
|
||||
+#define EXPORT
|
||||
+
|
||||
+static inline void *
|
||||
speex_alloc (int size)
|
||||
{
|
||||
- return calloc (size, 1);
|
||||
+ return g_malloc0 (size);
|
||||
}
|
||||
|
||||
/* If the resampler is defined outside of Speex, we change the symbol names so that
|
||||
@@ -75,10 +77,10 @@
|
||||
-static void *
|
||||
+static inline void *
|
||||
speex_realloc (void *ptr, int size)
|
||||
{
|
||||
- return realloc (ptr, size);
|
||||
+ return g_realloc (ptr, size);
|
||||
}
|
||||
|
||||
-static void
|
||||
+static inline void
|
||||
speex_free (void *ptr)
|
||||
{
|
||||
- free (ptr);
|
||||
+ g_free (ptr);
|
||||
}
|
||||
|
||||
#include "speex_resampler.h"
|
||||
@@ -90,7 +95,6 @@
|
||||
#include "os_support.h"
|
||||
#endif /* OUTSIDE_SPEEX */
|
||||
|
||||
-#include "stack_alloc.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifndef M_PI
|
||||
--- speex_resampler.h 2008-10-28 12:21:37.000000000 +0100
|
||||
+++ speex_resampler.h 2008-10-28 12:30:48.000000000 +0100
|
||||
@@ -77,10 +77,10 @@
|
||||
#define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
|
||||
#define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
|
||||
|
||||
|
@ -46,35 +85,3 @@ The only changes are:
|
|||
|
||||
#else /* OUTSIDE_SPEEX */
|
||||
|
||||
--- speex/libspeex/resample.c 2007-11-25 14:15:38.000000000 +0100
|
||||
+++ speexresample/resample.c 2007-11-25 14:15:31.000000000 +0100
|
||||
@@ -62,20 +62,23 @@
|
||||
|
||||
#ifdef OUTSIDE_SPEEX
|
||||
#include <stdlib.h>
|
||||
-static void *
|
||||
+#include <glib.h>
|
||||
+
|
||||
+static inline void *
|
||||
speex_alloc (int size)
|
||||
{
|
||||
- return calloc (size, 1);
|
||||
+ return g_malloc0 (size);
|
||||
}
|
||||
-static void *
|
||||
+static inline void *
|
||||
speex_realloc (void *ptr, int size)
|
||||
{
|
||||
- return realloc (ptr, size);
|
||||
+ return g_realloc (ptr, size);
|
||||
}
|
||||
-static void
|
||||
+
|
||||
+static inline void
|
||||
speex_free (void *ptr)
|
||||
{
|
||||
- free (ptr);
|
||||
+ g_free (ptr);
|
||||
}
|
||||
|
||||
#include "speex_resampler.h"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
|
||||
#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */
|
||||
#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
|
||||
#define SPEEX_VERSION "speex-1.2beta4" /**< Speex version string. */
|
||||
#define SPEEX_VERSION "speex-1.2beta3" /**< Speex version string. */
|
||||
#endif
|
||||
|
||||
/* A couple test to catch stupid option combinations */
|
||||
|
@ -75,12 +75,13 @@
|
|||
#endif
|
||||
|
||||
#ifndef OUTSIDE_SPEEX
|
||||
#include "speex/speex_types.h"
|
||||
#include "../include/speex/speex_types.h"
|
||||
#endif
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
|
||||
#endif
|
||||
|
||||
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
|
||||
#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */
|
||||
#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */
|
||||
|
@ -234,7 +235,7 @@ typedef float spx_word32_t;
|
|||
|
||||
|
||||
#ifdef FIXED_DEBUG
|
||||
long long spx_mips=0;
|
||||
extern long long spx_mips;
|
||||
#endif
|
||||
|
||||
|
||||
|
|
130
gst/speexresample/fixed_arm4.h
Normal file
130
gst/speexresample/fixed_arm4.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/* Copyright (C) 2004 Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_arm4.h
|
||||
@brief ARM4 fixed-point operations
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_ARM4_H
|
||||
#define FIXED_ARM4_H
|
||||
|
||||
#undef MULT16_32_Q14
|
||||
static inline spx_word32_t
|
||||
MULT16_32_Q14 (spx_word16_t x, spx_word32_t y)
|
||||
{
|
||||
int res;
|
||||
int dummy;
|
||||
asm ("smull %0,%1,%2,%3 \n\t" "mov %0, %0, lsr #14 \n\t" "add %0, %0, %1, lsl #18 \n\t":"=&r" (res),
|
||||
"=&r"
|
||||
(dummy)
|
||||
: "r" (y), "r" ((int) x));
|
||||
return (res);
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q15
|
||||
static inline spx_word32_t
|
||||
MULT16_32_Q15 (spx_word16_t x, spx_word32_t y)
|
||||
{
|
||||
int res;
|
||||
int dummy;
|
||||
asm ("smull %0,%1,%2,%3 \n\t" "mov %0, %0, lsr #15 \n\t" "add %0, %0, %1, lsl #17 \n\t":"=&r" (res),
|
||||
"=&r"
|
||||
(dummy)
|
||||
: "r" (y), "r" ((int) x));
|
||||
return (res);
|
||||
}
|
||||
|
||||
#undef DIV32_16
|
||||
static inline short
|
||||
DIV32_16 (int a, int b)
|
||||
{
|
||||
int res = 0;
|
||||
int dead1, dead2, dead3, dead4, dead5;
|
||||
__asm__ __volatile__ ("\teor %5, %0, %1\n"
|
||||
"\tmovs %4, %0\n"
|
||||
"\trsbmi %0, %0, #0 \n"
|
||||
"\tmovs %4, %1\n"
|
||||
"\trsbmi %1, %1, #0 \n"
|
||||
"\tmov %4, #1\n"
|
||||
"\tsubs %3, %0, %1, asl #14 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #14 \n"
|
||||
"\tsubs %3, %0, %1, asl #13 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #13 \n"
|
||||
"\tsubs %3, %0, %1, asl #12 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #12 \n"
|
||||
"\tsubs %3, %0, %1, asl #11 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #11 \n"
|
||||
"\tsubs %3, %0, %1, asl #10 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #10 \n"
|
||||
"\tsubs %3, %0, %1, asl #9 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #9 \n"
|
||||
"\tsubs %3, %0, %1, asl #8 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #8 \n"
|
||||
"\tsubs %3, %0, %1, asl #7 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #7 \n"
|
||||
"\tsubs %3, %0, %1, asl #6 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #6 \n"
|
||||
"\tsubs %3, %0, %1, asl #5 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #5 \n"
|
||||
"\tsubs %3, %0, %1, asl #4 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #4 \n"
|
||||
"\tsubs %3, %0, %1, asl #3 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #3 \n"
|
||||
"\tsubs %3, %0, %1, asl #2 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #2 \n"
|
||||
"\tsubs %3, %0, %1, asl #1 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #1 \n"
|
||||
"\tsubs %3, %0, %1 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4 \n"
|
||||
"\tmovs %5, %5, lsr #31 \n"
|
||||
"\trsbne %2, %2, #0 \n":"=r" (dead1), "=r" (dead2), "=r" (res),
|
||||
"=r" (dead3), "=r" (dead4), "=r" (dead5)
|
||||
:"0" (a), "1" (b), "2" (res)
|
||||
:"cc");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
166
gst/speexresample/fixed_arm5e.h
Normal file
166
gst/speexresample/fixed_arm5e.h
Normal file
|
@ -0,0 +1,166 @@
|
|||
/* Copyright (C) 2003 Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_arm5e.h
|
||||
@brief ARM-tuned fixed-point operations
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_ARM5E_H
|
||||
#define FIXED_ARM5E_H
|
||||
|
||||
#undef MULT16_16
|
||||
static inline spx_word32_t
|
||||
MULT16_16 (spx_word16_t x, spx_word16_t y)
|
||||
{
|
||||
int res;
|
||||
asm ("smulbb %0,%1,%2;\n":"=&r" (res)
|
||||
: "%r" (x), "r" (y));
|
||||
return (res);
|
||||
}
|
||||
|
||||
#undef MAC16_16
|
||||
static inline spx_word32_t
|
||||
MAC16_16 (spx_word32_t a, spx_word16_t x, spx_word32_t y)
|
||||
{
|
||||
int res;
|
||||
asm ("smlabb %0,%1,%2,%3;\n":"=&r" (res)
|
||||
: "%r" (x), "r" (y), "r" (a));
|
||||
return (res);
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q15
|
||||
static inline spx_word32_t
|
||||
MULT16_32_Q15 (spx_word16_t x, spx_word32_t y)
|
||||
{
|
||||
int res;
|
||||
asm ("smulwb %0,%1,%2;\n":"=&r" (res)
|
||||
: "%r" (y << 1), "r" (x));
|
||||
return (res);
|
||||
}
|
||||
|
||||
#undef MAC16_32_Q15
|
||||
static inline spx_word32_t
|
||||
MAC16_32_Q15 (spx_word32_t a, spx_word16_t x, spx_word32_t y)
|
||||
{
|
||||
int res;
|
||||
asm ("smlawb %0,%1,%2,%3;\n":"=&r" (res)
|
||||
: "%r" (y << 1), "r" (x), "r" (a));
|
||||
return (res);
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q11
|
||||
static inline spx_word32_t
|
||||
MULT16_32_Q11 (spx_word16_t x, spx_word32_t y)
|
||||
{
|
||||
int res;
|
||||
asm ("smulwb %0,%1,%2;\n":"=&r" (res)
|
||||
: "%r" (y << 5), "r" (x));
|
||||
return (res);
|
||||
}
|
||||
|
||||
#undef MAC16_32_Q11
|
||||
static inline spx_word32_t
|
||||
MAC16_32_Q11 (spx_word32_t a, spx_word16_t x, spx_word32_t y)
|
||||
{
|
||||
int res;
|
||||
asm ("smlawb %0,%1,%2,%3;\n":"=&r" (res)
|
||||
: "%r" (y << 5), "r" (x), "r" (a));
|
||||
return (res);
|
||||
}
|
||||
|
||||
#undef DIV32_16
|
||||
static inline short
|
||||
DIV32_16 (int a, int b)
|
||||
{
|
||||
int res = 0;
|
||||
int dead1, dead2, dead3, dead4, dead5;
|
||||
__asm__ __volatile__ ("\teor %5, %0, %1\n"
|
||||
"\tmovs %4, %0\n"
|
||||
"\trsbmi %0, %0, #0 \n"
|
||||
"\tmovs %4, %1\n"
|
||||
"\trsbmi %1, %1, #0 \n"
|
||||
"\tmov %4, #1\n"
|
||||
"\tsubs %3, %0, %1, asl #14 \n"
|
||||
"\torrpl %2, %2, %4, asl #14 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #13 \n"
|
||||
"\torrpl %2, %2, %4, asl #13 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #12 \n"
|
||||
"\torrpl %2, %2, %4, asl #12 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #11 \n"
|
||||
"\torrpl %2, %2, %4, asl #11 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #10 \n"
|
||||
"\torrpl %2, %2, %4, asl #10 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #9 \n"
|
||||
"\torrpl %2, %2, %4, asl #9 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #8 \n"
|
||||
"\torrpl %2, %2, %4, asl #8 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #7 \n"
|
||||
"\torrpl %2, %2, %4, asl #7 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #6 \n"
|
||||
"\torrpl %2, %2, %4, asl #6 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #5 \n"
|
||||
"\torrpl %2, %2, %4, asl #5 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #4 \n"
|
||||
"\torrpl %2, %2, %4, asl #4 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #3 \n"
|
||||
"\torrpl %2, %2, %4, asl #3 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #2 \n"
|
||||
"\torrpl %2, %2, %4, asl #2 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1, asl #1 \n"
|
||||
"\torrpl %2, %2, %4, asl #1 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tsubs %3, %0, %1 \n"
|
||||
"\torrpl %2, %2, %4 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\tmovs %5, %5, lsr #31 \n"
|
||||
"\trsbne %2, %2, #0 \n":"=r" (dead1), "=r" (dead2), "=r" (res),
|
||||
"=r" (dead3), "=r" (dead4), "=r" (dead5)
|
||||
:"0" (a), "1" (b), "2" (res)
|
||||
:"memory", "cc");
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
134
gst/speexresample/fixed_bfin.h
Normal file
134
gst/speexresample/fixed_bfin.h
Normal file
|
@ -0,0 +1,134 @@
|
|||
/* Copyright (C) 2005 Analog Devices
|
||||
Author: Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_bfin.h
|
||||
@brief Blackfin fixed-point operations
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_BFIN_H
|
||||
#define FIXED_BFIN_H
|
||||
|
||||
#undef PDIV32_16
|
||||
static inline spx_word16_t
|
||||
PDIV32_16 (spx_word32_t a, spx_word16_t b)
|
||||
{
|
||||
spx_word32_t res, bb;
|
||||
bb = b;
|
||||
a += b >> 1;
|
||||
__asm__ ("P0 = 15;\n\t" "R0 = %1;\n\t" "R1 = %2;\n\t"
|
||||
//"R0 = R0 + R1;\n\t"
|
||||
"R0 <<= 1;\n\t" "DIVS (R0, R1);\n\t" "LOOP divide%= LC0 = P0;\n\t" "LOOP_BEGIN divide%=;\n\t" "DIVQ (R0, R1);\n\t" "LOOP_END divide%=;\n\t" "R0 = R0.L;\n\t" "%0 = R0;\n\t":"=m"
|
||||
(res)
|
||||
: "m" (a), "m" (bb)
|
||||
: "P0", "R0", "R1", "cc");
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef DIV32_16
|
||||
static inline spx_word16_t
|
||||
DIV32_16 (spx_word32_t a, spx_word16_t b)
|
||||
{
|
||||
spx_word32_t res, bb;
|
||||
bb = b;
|
||||
/* Make the roundinf consistent with the C version
|
||||
(do we need to do that?) */
|
||||
if (a < 0)
|
||||
a += (b - 1);
|
||||
__asm__ ("P0 = 15;\n\t" "R0 = %1;\n\t" "R1 = %2;\n\t" "R0 <<= 1;\n\t" "DIVS (R0, R1);\n\t" "LOOP divide%= LC0 = P0;\n\t" "LOOP_BEGIN divide%=;\n\t" "DIVQ (R0, R1);\n\t" "LOOP_END divide%=;\n\t" "R0 = R0.L;\n\t" "%0 = R0;\n\t":"=m" (res)
|
||||
: "m" (a), "m" (bb)
|
||||
: "P0", "R0", "R1", "cc");
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MAX16
|
||||
static inline spx_word16_t
|
||||
MAX16 (spx_word16_t a, spx_word16_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__ ("%1 = %1.L (X);\n\t" "%2 = %2.L (X);\n\t" "%0 = MAX(%1,%2);":"=d" (res)
|
||||
: "%d" (a), "d" (b)
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q15
|
||||
static inline spx_word32_t
|
||||
MULT16_32_Q15 (spx_word16_t a, spx_word32_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__ ("A1 = %2.L*%1.L (M);\n\t" "A1 = A1 >>> 15;\n\t" "%0 = (A1 += %2.L*%1.H) ;\n\t":"=&W" (res),
|
||||
"=&d"
|
||||
(b)
|
||||
: "d" (a), "1" (b)
|
||||
: "A1");
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MAC16_32_Q15
|
||||
static inline spx_word32_t
|
||||
MAC16_32_Q15 (spx_word32_t c, spx_word16_t a, spx_word32_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__ ("A1 = %2.L*%1.L (M);\n\t" "A1 = A1 >>> 15;\n\t" "%0 = (A1 += %2.L*%1.H);\n\t" "%0 = %0 + %4;\n\t":"=&W" (res),
|
||||
"=&d"
|
||||
(b)
|
||||
: "d" (a), "1" (b), "d" (c)
|
||||
: "A1");
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q14
|
||||
static inline spx_word32_t
|
||||
MULT16_32_Q14 (spx_word16_t a, spx_word32_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__ ("%2 <<= 1;\n\t" "A1 = %1.L*%2.L (M);\n\t" "A1 = A1 >>> 15;\n\t" "%0 = (A1 += %1.L*%2.H);\n\t":"=W" (res), "=d" (a),
|
||||
"=d"
|
||||
(b)
|
||||
: "1" (a), "2" (b)
|
||||
: "A1");
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MAC16_32_Q14
|
||||
static inline spx_word32_t
|
||||
MAC16_32_Q14 (spx_word32_t c, spx_word16_t a, spx_word32_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__ ("%1 <<= 1;\n\t" "A1 = %2.L*%1.L (M);\n\t" "A1 = A1 >>> 15;\n\t" "%0 = (A1 += %2.L*%1.H);\n\t" "%0 = %0 + %4;\n\t":"=&W" (res),
|
||||
"=&d"
|
||||
(b)
|
||||
: "d" (a), "1" (b), "d" (c)
|
||||
: "A1");
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
525
gst/speexresample/fixed_debug.h
Normal file
525
gst/speexresample/fixed_debug.h
Normal file
|
@ -0,0 +1,525 @@
|
|||
/* Copyright (C) 2003 Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_debug.h
|
||||
@brief Fixed-point operations with debugging
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_DEBUG_H
|
||||
#define FIXED_DEBUG_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern long long spx_mips;
|
||||
#define MIPS_INC spx_mips++,
|
||||
|
||||
#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
|
||||
#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
|
||||
|
||||
|
||||
#define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768)
|
||||
#define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL)
|
||||
|
||||
static inline short
|
||||
NEG16 (int x)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT (x)) {
|
||||
fprintf (stderr, "NEG16: input is not short: %d\n", (int) x);
|
||||
}
|
||||
res = -x;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "NEG16: output is not short: %d\n", (int) res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int
|
||||
NEG32 (long long x)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT (x)) {
|
||||
fprintf (stderr, "NEG16: input is not int: %d\n", (int) x);
|
||||
}
|
||||
res = -x;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "NEG16: output is not int: %d\n", (int) res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define EXTRACT16(x) _EXTRACT16(x, __FILE__, __LINE__)
|
||||
static inline short
|
||||
_EXTRACT16 (int x, char *file, int line)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT (x)) {
|
||||
fprintf (stderr, "EXTRACT16: input is not short: %d in %s: line %d\n", x,
|
||||
file, line);
|
||||
}
|
||||
res = x;
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define EXTEND32(x) _EXTEND32(x, __FILE__, __LINE__)
|
||||
static inline int
|
||||
_EXTEND32 (int x, char *file, int line)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT (x)) {
|
||||
fprintf (stderr, "EXTEND32: input is not short: %d in %s: line %d\n", x,
|
||||
file, line);
|
||||
}
|
||||
res = x;
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define SHR16(a, shift) _SHR16(a, shift, __FILE__, __LINE__)
|
||||
static inline short
|
||||
_SHR16 (int a, int shift, char *file, int line)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (shift)) {
|
||||
fprintf (stderr, "SHR16: inputs are not short: %d >> %d in %s: line %d\n",
|
||||
a, shift, file, line);
|
||||
}
|
||||
res = a >> shift;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "SHR16: output is not short: %d in %s: line %d\n", res,
|
||||
file, line);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define SHL16(a, shift) _SHL16(a, shift, __FILE__, __LINE__)
|
||||
static inline short
|
||||
_SHL16 (int a, int shift, char *file, int line)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (shift)) {
|
||||
fprintf (stderr, "SHL16: inputs are not short: %d %d in %s: line %d\n", a,
|
||||
shift, file, line);
|
||||
}
|
||||
res = a << shift;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "SHL16: output is not short: %d in %s: line %d\n", res,
|
||||
file, line);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int
|
||||
SHR32 (long long a, int shift)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT (a) || !VERIFY_SHORT (shift)) {
|
||||
fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int) a, shift);
|
||||
}
|
||||
res = a >> shift;
|
||||
if (!VERIFY_INT (res)) {
|
||||
fprintf (stderr, "SHR32: output is not int: %d\n", (int) res);
|
||||
}
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int
|
||||
SHL32 (long long a, int shift)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT (a) || !VERIFY_SHORT (shift)) {
|
||||
fprintf (stderr, "SHL32: inputs are not int: %d %d\n", (int) a, shift);
|
||||
}
|
||||
res = a << shift;
|
||||
if (!VERIFY_INT (res)) {
|
||||
fprintf (stderr, "SHL32: output is not int: %d\n", (int) res);
|
||||
}
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define PSHR16(a,shift) (SHR16(ADD16((a),((1<<((shift))>>1))),shift))
|
||||
#define PSHR32(a,shift) (SHR32(ADD32((a),((EXTEND32(1)<<((shift))>>1))),shift))
|
||||
#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
|
||||
|
||||
#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
|
||||
//#define SHR(a,shift) ((a) >> (shift))
|
||||
//#define SHL(a,shift) ((a) << (shift))
|
||||
|
||||
#define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__)
|
||||
static inline short
|
||||
_ADD16 (int a, int b, char *file, int line)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "ADD16: inputs are not short: %d %d in %s: line %d\n", a,
|
||||
b, file, line);
|
||||
}
|
||||
res = a + b;
|
||||
if (!VERIFY_SHORT (res)) {
|
||||
fprintf (stderr, "ADD16: output is not short: %d+%d=%d in %s: line %d\n", a,
|
||||
b, res, file, line);
|
||||
}
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define SUB16(a, b) _SUB16(a, b, __FILE__, __LINE__)
|
||||
static inline short
|
||||
_SUB16 (int a, int b, char *file, int line)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "SUB16: inputs are not short: %d %d in %s: line %d\n", a,
|
||||
b, file, line);
|
||||
}
|
||||
res = a - b;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "SUB16: output is not short: %d in %s: line %d\n", res,
|
||||
file, line);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define ADD32(a, b) _ADD32(a, b, __FILE__, __LINE__)
|
||||
static inline int
|
||||
_ADD32 (long long a, long long b, char *file, int line)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT (a) || !VERIFY_INT (b)) {
|
||||
fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n",
|
||||
(int) a, (int) b, file, line);
|
||||
}
|
||||
res = a + b;
|
||||
if (!VERIFY_INT (res)) {
|
||||
fprintf (stderr, "ADD32: output is not int: %d in %s: line %d\n", (int) res,
|
||||
file, line);
|
||||
}
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int
|
||||
SUB32 (long long a, long long b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT (a) || !VERIFY_INT (b)) {
|
||||
fprintf (stderr, "SUB32: inputs are not int: %d %d\n", (int) a, (int) b);
|
||||
}
|
||||
res = a - b;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "SUB32: output is not int: %d\n", (int) res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define ADD64(a,b) (MIPS_INC(a)+(b))
|
||||
|
||||
/* result fits in 16 bits */
|
||||
static inline short
|
||||
MULT16_16_16 (int a, int b)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16_16: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = a * b;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "MULT16_16_16: output is not short: %d\n", res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define MULT16_16(a, b) _MULT16_16(a, b, __FILE__, __LINE__)
|
||||
static inline int
|
||||
_MULT16_16 (int a, int b, char *file, int line)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n",
|
||||
a, b, file, line);
|
||||
}
|
||||
res = ((long long) a) * b;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n",
|
||||
(int) res, file, line);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define MAC16_16(c,a,b) (spx_mips--,ADD32((c),MULT16_16((a),(b))))
|
||||
#define MAC16_16_Q11(c,a,b) (EXTRACT16(ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),11)))))
|
||||
#define MAC16_16_Q13(c,a,b) (EXTRACT16(ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),13)))))
|
||||
#define MAC16_16_P13(c,a,b) (EXTRACT16(ADD32((c),SHR32(ADD32(4096,MULT16_16((a),(b))),13))))
|
||||
|
||||
|
||||
#define MULT16_32_QX(a, b, Q) _MULT16_32_QX(a, b, Q, __FILE__, __LINE__)
|
||||
static inline int
|
||||
_MULT16_32_QX (int a, long long b, int Q, char *file, int line)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_INT (b)) {
|
||||
fprintf (stderr,
|
||||
"MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q,
|
||||
(int) a, (int) b, file, line);
|
||||
}
|
||||
if (ABS32 (b) >= (EXTEND32 (1) << (15 + Q)))
|
||||
fprintf (stderr,
|
||||
"MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q,
|
||||
(int) a, (int) b, file, line);
|
||||
res = (((long long) a) * (long long) b) >> Q;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr,
|
||||
"MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q,
|
||||
(int) a, (int) b, (int) res, file, line);
|
||||
spx_mips += 5;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int
|
||||
MULT16_32_PX (int a, long long b, int Q)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_INT (b)) {
|
||||
fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q,
|
||||
(int) a, (int) b);
|
||||
}
|
||||
if (ABS32 (b) >= (EXTEND32 (1) << (15 + Q)))
|
||||
fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q,
|
||||
(int) a, (int) b);
|
||||
res = ((((long long) a) * (long long) b) + ((EXTEND32 (1) << Q) >> 1)) >> Q;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int) a,
|
||||
(int) b, (int) res);
|
||||
spx_mips += 5;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#define MULT16_32_Q11(a,b) MULT16_32_QX(a,b,11)
|
||||
#define MAC16_32_Q11(c,a,b) ADD32((c),MULT16_32_Q11((a),(b)))
|
||||
#define MULT16_32_Q12(a,b) MULT16_32_QX(a,b,12)
|
||||
#define MULT16_32_Q13(a,b) MULT16_32_QX(a,b,13)
|
||||
#define MULT16_32_Q14(a,b) MULT16_32_QX(a,b,14)
|
||||
#define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15)
|
||||
#define MULT16_32_P15(a,b) MULT16_32_PX(a,b,15)
|
||||
#define MAC16_32_Q15(c,a,b) ADD32((c),MULT16_32_Q15((a),(b)))
|
||||
|
||||
static inline int
|
||||
SATURATE (int a, int b)
|
||||
{
|
||||
if (a > b)
|
||||
a = b;
|
||||
if (a < -b)
|
||||
a = -b;
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline int
|
||||
MULT16_16_Q11_32 (int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long) a) * b;
|
||||
res >>= 11;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int) a,
|
||||
(int) b, (int) res);
|
||||
spx_mips += 3;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short
|
||||
MULT16_16_Q13 (int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long) a) * b;
|
||||
res >>= 13;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b,
|
||||
(int) res);
|
||||
spx_mips += 3;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short
|
||||
MULT16_16_Q14 (int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long) a) * b;
|
||||
res >>= 14;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int) res);
|
||||
spx_mips += 3;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short
|
||||
MULT16_16_Q15 (int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long) a) * b;
|
||||
res >>= 15;
|
||||
if (!VERIFY_SHORT (res)) {
|
||||
fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int) res);
|
||||
}
|
||||
spx_mips += 3;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short
|
||||
MULT16_16_P13 (int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long) a) * b;
|
||||
res += 4096;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "MULT16_16_P13: overflow: %d*%d=%d\n", a, b, (int) res);
|
||||
res >>= 13;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b,
|
||||
(int) res);
|
||||
spx_mips += 4;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short
|
||||
MULT16_16_P14 (int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long) a) * b;
|
||||
res += 8192;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "MULT16_16_P14: overflow: %d*%d=%d\n", a, b, (int) res);
|
||||
res >>= 14;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b,
|
||||
(int) res);
|
||||
spx_mips += 4;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short
|
||||
MULT16_16_P15 (int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long) a) * b;
|
||||
res += 16384;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "MULT16_16_P15: overflow: %d*%d=%d\n", a, b, (int) res);
|
||||
res >>= 15;
|
||||
if (!VERIFY_SHORT (res))
|
||||
fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b,
|
||||
(int) res);
|
||||
spx_mips += 4;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define DIV32_16(a, b) _DIV32_16(a, b, __FILE__, __LINE__)
|
||||
|
||||
static inline int
|
||||
_DIV32_16 (long long a, long long b, char *file, int line)
|
||||
{
|
||||
long long res;
|
||||
if (b == 0) {
|
||||
fprintf (stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n",
|
||||
(int) a, (int) b, file, line);
|
||||
return 0;
|
||||
}
|
||||
if (!VERIFY_INT (a) || !VERIFY_SHORT (b)) {
|
||||
fprintf (stderr,
|
||||
"DIV32_16: inputs are not int/short: %d %d in %s: line %d\n", (int) a,
|
||||
(int) b, file, line);
|
||||
}
|
||||
res = a / b;
|
||||
if (!VERIFY_SHORT (res)) {
|
||||
fprintf (stderr,
|
||||
"DIV32_16: output is not short: %d / %d = %d in %s: line %d\n", (int) a,
|
||||
(int) b, (int) res, file, line);
|
||||
if (res > 32767)
|
||||
res = 32767;
|
||||
if (res < -32768)
|
||||
res = -32768;
|
||||
}
|
||||
spx_mips += 20;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define DIV32(a, b) _DIV32(a, b, __FILE__, __LINE__)
|
||||
static inline int
|
||||
_DIV32 (long long a, long long b, char *file, int line)
|
||||
{
|
||||
long long res;
|
||||
if (b == 0) {
|
||||
fprintf (stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int) a,
|
||||
(int) b, file, line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!VERIFY_INT (a) || !VERIFY_INT (b)) {
|
||||
fprintf (stderr, "DIV32: inputs are not int/short: %d %d in %s: line %d\n",
|
||||
(int) a, (int) b, file, line);
|
||||
}
|
||||
res = a / b;
|
||||
if (!VERIFY_INT (res))
|
||||
fprintf (stderr, "DIV32: output is not int: %d in %s: line %d\n", (int) res,
|
||||
file, line);
|
||||
spx_mips += 36;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define PDIV32(a,b) DIV32(ADD32((a),(b)>>1),b)
|
||||
#define PDIV32_16(a,b) DIV32_16(ADD32((a),(b)>>1),b)
|
||||
|
||||
#endif
|
|
@ -47,14 +47,14 @@
|
|||
#define SHR32(a,shift) ((a) >> (shift))
|
||||
#define SHL32(a,shift) ((a) << (shift))
|
||||
#define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift))
|
||||
#define PSHR32(a,shift) (SHR32((a)+((1<<((shift))>>1)),shift))
|
||||
#define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift))
|
||||
#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
|
||||
#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
|
||||
#define SHR(a,shift) ((a) >> (shift))
|
||||
#define SHL(a,shift) ((spx_word32_t)(a) << (shift))
|
||||
#define PSHR(a,shift) (SHR((a)+((1<<((shift))>>1)),shift))
|
||||
#define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))
|
||||
#define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -41,8 +41,6 @@
|
|||
|
||||
#ifdef OUTSIDE_SPEEX
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/********* WARNING: MENTAL SANITY ENDS HERE *************/
|
||||
|
||||
/* If the resampler is defined outside of Speex, we change the symbol names so that
|
||||
|
@ -86,12 +84,17 @@
|
|||
|
||||
#else /* OUTSIDE_SPEEX */
|
||||
|
||||
#include "speex/speex_types.h"
|
||||
#ifdef _BUILD_SPEEX
|
||||
# include "speex_types.h"
|
||||
#else
|
||||
# include <speex/speex_types.h>
|
||||
#endif
|
||||
|
||||
#endif /* OUTSIDE_SPEEX */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define SPEEX_RESAMPLER_QUALITY_MAX 10
|
||||
|
@ -100,7 +103,8 @@ extern "C" {
|
|||
#define SPEEX_RESAMPLER_QUALITY_VOIP 3
|
||||
#define SPEEX_RESAMPLER_QUALITY_DESKTOP 5
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
RESAMPLER_ERR_SUCCESS = 0,
|
||||
RESAMPLER_ERR_ALLOC_FAILED = 1,
|
||||
RESAMPLER_ERR_BAD_STATE = 2,
|
||||
|
@ -123,10 +127,7 @@ typedef struct SpeexResamplerState_ SpeexResamplerState;
|
|||
* @retval NULL Error: not enough memory
|
||||
*/
|
||||
SpeexResamplerState *speex_resampler_init (spx_uint32_t nb_channels,
|
||||
spx_uint32_t in_rate,
|
||||
spx_uint32_t out_rate,
|
||||
int quality,
|
||||
int *err);
|
||||
spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err);
|
||||
|
||||
/** Create a new resampler with fractional input/output rates. The sampling
|
||||
* rate ratio is an arbitrary rational number with both the numerator and
|
||||
|
@ -144,10 +145,7 @@ SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels,
|
|||
SpeexResamplerState *speex_resampler_init_frac (spx_uint32_t nb_channels,
|
||||
spx_uint32_t ratio_num,
|
||||
spx_uint32_t ratio_den,
|
||||
spx_uint32_t in_rate,
|
||||
spx_uint32_t out_rate,
|
||||
int quality,
|
||||
int *err);
|
||||
spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err);
|
||||
|
||||
/** Destroy a resampler state.
|
||||
* @param st Resampler state
|
||||
|
@ -167,9 +165,7 @@ void speex_resampler_destroy(SpeexResamplerState *st);
|
|||
int speex_resampler_process_float (SpeexResamplerState * st,
|
||||
spx_uint32_t channel_index,
|
||||
const float *in,
|
||||
spx_uint32_t *in_len,
|
||||
float *out,
|
||||
spx_uint32_t *out_len);
|
||||
spx_uint32_t * in_len, float *out, spx_uint32_t * out_len);
|
||||
|
||||
/** Resample an int array. The input and output buffers must *not* overlap.
|
||||
* @param st Resampler state
|
||||
|
@ -184,9 +180,7 @@ int speex_resampler_process_float(SpeexResamplerState *st,
|
|||
int speex_resampler_process_int (SpeexResamplerState * st,
|
||||
spx_uint32_t channel_index,
|
||||
const spx_int16_t * in,
|
||||
spx_uint32_t *in_len,
|
||||
spx_int16_t *out,
|
||||
spx_uint32_t *out_len);
|
||||
spx_uint32_t * in_len, spx_int16_t * out, spx_uint32_t * out_len);
|
||||
|
||||
/** Resample an interleaved float array. The input and output buffers must *not* overlap.
|
||||
* @param st Resampler state
|
||||
|
@ -199,9 +193,7 @@ int speex_resampler_process_int(SpeexResamplerState *st,
|
|||
*/
|
||||
int speex_resampler_process_interleaved_float (SpeexResamplerState * st,
|
||||
const float *in,
|
||||
spx_uint32_t *in_len,
|
||||
float *out,
|
||||
spx_uint32_t *out_len);
|
||||
spx_uint32_t * in_len, float *out, spx_uint32_t * out_len);
|
||||
|
||||
/** Resample an interleaved int array. The input and output buffers must *not* overlap.
|
||||
* @param st Resampler state
|
||||
|
@ -214,9 +206,7 @@ int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
|
|||
*/
|
||||
int speex_resampler_process_interleaved_int (SpeexResamplerState * st,
|
||||
const spx_int16_t * in,
|
||||
spx_uint32_t *in_len,
|
||||
spx_int16_t *out,
|
||||
spx_uint32_t *out_len);
|
||||
spx_uint32_t * in_len, spx_int16_t * out, spx_uint32_t * out_len);
|
||||
|
||||
/** Set (change) the input/output sampling rates (integer value).
|
||||
* @param st Resampler state
|
||||
|
@ -224,8 +214,7 @@ int speex_resampler_process_interleaved_int(SpeexResamplerState *st,
|
|||
* @param out_rate Output sampling rate (integer number of Hz).
|
||||
*/
|
||||
int speex_resampler_set_rate (SpeexResamplerState * st,
|
||||
spx_uint32_t in_rate,
|
||||
spx_uint32_t out_rate);
|
||||
spx_uint32_t in_rate, spx_uint32_t out_rate);
|
||||
|
||||
/** Get the current input/output sampling rates (integer value).
|
||||
* @param st Resampler state
|
||||
|
@ -233,8 +222,7 @@ int speex_resampler_set_rate(SpeexResamplerState *st,
|
|||
* @param out_rate Output sampling rate (integer number of Hz) copied.
|
||||
*/
|
||||
void speex_resampler_get_rate (SpeexResamplerState * st,
|
||||
spx_uint32_t *in_rate,
|
||||
spx_uint32_t *out_rate);
|
||||
spx_uint32_t * in_rate, spx_uint32_t * out_rate);
|
||||
|
||||
/** Set (change) the input/output sampling rates and resampling ratio
|
||||
* (fractional values in Hz supported).
|
||||
|
@ -246,9 +234,7 @@ void speex_resampler_get_rate(SpeexResamplerState *st,
|
|||
*/
|
||||
int speex_resampler_set_rate_frac (SpeexResamplerState * st,
|
||||
spx_uint32_t ratio_num,
|
||||
spx_uint32_t ratio_den,
|
||||
spx_uint32_t in_rate,
|
||||
spx_uint32_t out_rate);
|
||||
spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate);
|
||||
|
||||
/** Get the current resampling ratio. This will be reduced to the least
|
||||
* common denominator.
|
||||
|
@ -257,24 +243,21 @@ int speex_resampler_set_rate_frac(SpeexResamplerState *st,
|
|||
* @param ratio_den Denominator of the sampling rate ratio copied
|
||||
*/
|
||||
void speex_resampler_get_ratio (SpeexResamplerState * st,
|
||||
spx_uint32_t *ratio_num,
|
||||
spx_uint32_t *ratio_den);
|
||||
spx_uint32_t * ratio_num, spx_uint32_t * ratio_den);
|
||||
|
||||
/** Set (change) the conversion quality.
|
||||
* @param st Resampler state
|
||||
* @param quality Resampling quality between 0 and 10, where 0 has poor
|
||||
* quality and 10 has very high quality.
|
||||
*/
|
||||
int speex_resampler_set_quality(SpeexResamplerState *st,
|
||||
int quality);
|
||||
int speex_resampler_set_quality (SpeexResamplerState * st, int quality);
|
||||
|
||||
/** Get the conversion quality.
|
||||
* @param st Resampler state
|
||||
* @param quality Resampling quality between 0 and 10, where 0 has poor
|
||||
* quality and 10 has very high quality.
|
||||
*/
|
||||
void speex_resampler_get_quality(SpeexResamplerState *st,
|
||||
int *quality);
|
||||
void speex_resampler_get_quality (SpeexResamplerState * st, int *quality);
|
||||
|
||||
/** Set (change) the input stride.
|
||||
* @param st Resampler state
|
||||
|
|
Loading…
Reference in a new issue