Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
1449edf4
Commit
1449edf4
authored
Jan 18, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for the Speex resampler.
parent
7d377894
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
2110 additions
and
16 deletions
+2110
-16
extras/speex_resampler/README.md
extras/speex_resampler/README.md
+32
-0
extras/speex_resampler/ma_speex_resampler.h
extras/speex_resampler/ma_speex_resampler.h
+25
-0
extras/speex_resampler/thirdparty/arch.h
extras/speex_resampler/thirdparty/arch.h
+219
-0
extras/speex_resampler/thirdparty/resample.c
extras/speex_resampler/thirdparty/resample.c
+1239
-0
extras/speex_resampler/thirdparty/resample_sse.h
extras/speex_resampler/thirdparty/resample_sse.h
+128
-0
extras/speex_resampler/thirdparty/speex_resampler.h
extras/speex_resampler/thirdparty/speex_resampler.h
+343
-0
research/ma_resampler.h
research/ma_resampler.h
+124
-16
No files found.
extras/speex_resampler/README.md
0 → 100644
View file @
1449edf4
This code in the
`thirdparty`
directory is taken from opus-tools (https://github.com/xiph/opus-tools). Note
that unlike miniaudio, this code is _not_ public domain. The opus-tools license is below:
```
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.
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 COPYRIGHT OWNER
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.
```
Note that miniaudio does not use any of this code by default and is strictly opt-in. While miniaudio reproduces
this license text in it's source redistributions (in this file, and in each source file), it does not have any
control over binary distributions. When opting-in to use the Speex resampler you will need to consider this if
you redistribute a binary.
extras/speex_resampler/ma_speex_resampler.h
0 → 100644
View file @
1449edf4
#ifndef ma_speex_resampler_h
#define ma_speex_resampler_h
#define OUTSIDE_SPEEX
#define RANDOM_PREFIX ma_speex
#include "thirdparty/speex_resampler.h"
#endif
/* ma_speex_resampler_h */
#if defined(MINIAUDIO_SPEEX_RESAMPLER_IMPLEMENTATION)
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable:4244)
/* conversion from 'x' to 'y', possible loss of data */
#pragma warning(disable:4018)
/* signed/unsigned mismatch */
#else
#pragma GCC diagnostic push
#endif
#include "thirdparty/resample.c"
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#else
#pragma GCC diagnostic pop
#endif
#endif
\ No newline at end of file
extras/speex_resampler/thirdparty/arch.h
0 → 100644
View file @
1449edf4
/* Copyright (C) 2003 Jean-Marc Valin */
/**
@file arch.h
@brief Various architecture definitions Speex
*/
/*
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 ARCH_H
#define ARCH_H
/* A couple test to catch stupid option combinations */
#ifdef FIXED_POINT
#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
#error Make up your mind. What CPU do you have?
#endif
#else
#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
#endif
#endif
#ifndef OUTSIDE_SPEEX
#include "speex/speexdsp_types.h"
#endif
#define ABS(x) ((x) < 0 ? (-(x)) : (x))
/**< Absolute integer value. */
#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. */
#define ABS32(x) ((x) < 0 ? (-(x)) : (x))
/**< Absolute 32-bit value. */
#define MIN32(a,b) ((a) < (b) ? (a) : (b))
/**< Maximum 32-bit value. */
#define MAX32(a,b) ((a) > (b) ? (a) : (b))
/**< Maximum 32-bit value. */
#ifdef FIXED_POINT
typedef
spx_int16_t
spx_word16_t
;
typedef
spx_int32_t
spx_word32_t
;
typedef
spx_word32_t
spx_mem_t
;
typedef
spx_word16_t
spx_coef_t
;
typedef
spx_word16_t
spx_lsp_t
;
typedef
spx_word32_t
spx_sig_t
;
#define Q15ONE 32767
#define LPC_SCALING 8192
#define SIG_SCALING 16384
#define LSP_SCALING 8192.
#define GAMMA_SCALING 32768.
#define GAIN_SCALING 64
#define GAIN_SCALING_1 0.015625
#define LPC_SHIFT 13
#define LSP_SHIFT 13
#define SIG_SHIFT 14
#define GAIN_SHIFT 6
#define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x)))
#define VERY_SMALL 0
#define VERY_LARGE32 ((spx_word32_t)2147483647)
#define VERY_LARGE16 ((spx_word16_t)32767)
#define Q15_ONE ((spx_word16_t)32767)
#ifdef FIXED_DEBUG
#include "fixed_debug.h"
#else
#include "fixed_generic.h"
#ifdef ARM5E_ASM
#include "fixed_arm5e.h"
#elif defined (ARM4_ASM)
#include "fixed_arm4.h"
#elif defined (BFIN_ASM)
#include "fixed_bfin.h"
#endif
#endif
#else
typedef
float
spx_mem_t
;
typedef
float
spx_coef_t
;
typedef
float
spx_lsp_t
;
typedef
float
spx_sig_t
;
typedef
float
spx_word16_t
;
typedef
float
spx_word32_t
;
#define Q15ONE 1.0f
#define LPC_SCALING 1.f
#define SIG_SCALING 1.f
#define LSP_SCALING 1.f
#define GAMMA_SCALING 1.f
#define GAIN_SCALING 1.f
#define GAIN_SCALING_1 1.f
#define VERY_SMALL 1e-15f
#define VERY_LARGE32 1e15f
#define VERY_LARGE16 1e15f
#define Q15_ONE ((spx_word16_t)1.f)
#define QCONST16(x,bits) (x)
#define QCONST32(x,bits) (x)
#define NEG16(x) (-(x))
#define NEG32(x) (-(x))
#define EXTRACT16(x) (x)
#define EXTEND32(x) (x)
#define SHR16(a,shift) (a)
#define SHL16(a,shift) (a)
#define SHR32(a,shift) (a)
#define SHL32(a,shift) (a)
#define PSHR16(a,shift) (a)
#define PSHR32(a,shift) (a)
#define VSHR32(a,shift) (a)
#define SATURATE16(x,a) (x)
#define SATURATE32(x,a) (x)
#define SATURATE32PSHR(x,shift,a) (x)
#define PSHR(a,shift) (a)
#define SHR(a,shift) (a)
#define SHL(a,shift) (a)
#define SATURATE(x,a) (x)
#define ADD16(a,b) ((a)+(b))
#define SUB16(a,b) ((a)-(b))
#define ADD32(a,b) ((a)+(b))
#define SUB32(a,b) ((a)-(b))
#define MULT16_16_16(a,b) ((a)*(b))
#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b))
#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
#define MULT16_32_Q11(a,b) ((a)*(b))
#define MULT16_32_Q13(a,b) ((a)*(b))
#define MULT16_32_Q14(a,b) ((a)*(b))
#define MULT16_32_Q15(a,b) ((a)*(b))
#define MULT16_32_P15(a,b) ((a)*(b))
#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b))
#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b))
#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b))
#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b))
#define MAC16_16_P13(c,a,b) ((c)+(a)*(b))
#define MULT16_16_Q11_32(a,b) ((a)*(b))
#define MULT16_16_Q13(a,b) ((a)*(b))
#define MULT16_16_Q14(a,b) ((a)*(b))
#define MULT16_16_Q15(a,b) ((a)*(b))
#define MULT16_16_P15(a,b) ((a)*(b))
#define MULT16_16_P13(a,b) ((a)*(b))
#define MULT16_16_P14(a,b) ((a)*(b))
#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))
#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))
#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))
#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))
#define WORD2INT(x) ((x) < -32767.5f ? -32768 : \
((x) > 32766.5f ? 32767 : (spx_int16_t)floor(.5 + (x))))
#endif
#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
/* 2 on TI C5x DSP */
#define BYTES_PER_CHAR 2
#define BITS_PER_CHAR 16
#define LOG2_BITS_PER_CHAR 4
#else
#define BYTES_PER_CHAR 1
#define BITS_PER_CHAR 8
#define LOG2_BITS_PER_CHAR 3
#endif
#ifdef FIXED_DEBUG
extern
long
long
spx_mips
;
#endif
#endif
extras/speex_resampler/thirdparty/resample.c
0 → 100644
View file @
1449edf4
This diff is collapsed.
Click to expand it.
extras/speex_resampler/thirdparty/resample_sse.h
0 → 100644
View file @
1449edf4
/* Copyright (C) 2007-2008 Jean-Marc Valin
* Copyright (C) 2008 Thorvald Natvig
*/
/**
@file resample_sse.h
@brief Resampler functions (SSE version)
*/
/*
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.
*/
#include <xmmintrin.h>
#define OVERRIDE_INNER_PRODUCT_SINGLE
static
inline
float
inner_product_single
(
const
float
*
a
,
const
float
*
b
,
unsigned
int
len
)
{
int
i
;
float
ret
;
__m128
sum
=
_mm_setzero_ps
();
for
(
i
=
0
;
i
<
len
;
i
+=
8
)
{
sum
=
_mm_add_ps
(
sum
,
_mm_mul_ps
(
_mm_loadu_ps
(
a
+
i
),
_mm_loadu_ps
(
b
+
i
)));
sum
=
_mm_add_ps
(
sum
,
_mm_mul_ps
(
_mm_loadu_ps
(
a
+
i
+
4
),
_mm_loadu_ps
(
b
+
i
+
4
)));
}
sum
=
_mm_add_ps
(
sum
,
_mm_movehl_ps
(
sum
,
sum
));
sum
=
_mm_add_ss
(
sum
,
_mm_shuffle_ps
(
sum
,
sum
,
0x55
));
_mm_store_ss
(
&
ret
,
sum
);
return
ret
;
}
#define OVERRIDE_INTERPOLATE_PRODUCT_SINGLE
static
inline
float
interpolate_product_single
(
const
float
*
a
,
const
float
*
b
,
unsigned
int
len
,
const
spx_uint32_t
oversample
,
float
*
frac
)
{
int
i
;
float
ret
;
__m128
sum
=
_mm_setzero_ps
();
__m128
f
=
_mm_loadu_ps
(
frac
);
for
(
i
=
0
;
i
<
len
;
i
+=
2
)
{
sum
=
_mm_add_ps
(
sum
,
_mm_mul_ps
(
_mm_load1_ps
(
a
+
i
),
_mm_loadu_ps
(
b
+
i
*
oversample
)));
sum
=
_mm_add_ps
(
sum
,
_mm_mul_ps
(
_mm_load1_ps
(
a
+
i
+
1
),
_mm_loadu_ps
(
b
+
(
i
+
1
)
*
oversample
)));
}
sum
=
_mm_mul_ps
(
f
,
sum
);
sum
=
_mm_add_ps
(
sum
,
_mm_movehl_ps
(
sum
,
sum
));
sum
=
_mm_add_ss
(
sum
,
_mm_shuffle_ps
(
sum
,
sum
,
0x55
));
_mm_store_ss
(
&
ret
,
sum
);
return
ret
;
}
#ifdef __SSE2__
#include <emmintrin.h>
#define OVERRIDE_INNER_PRODUCT_DOUBLE
static
inline
double
inner_product_double
(
const
float
*
a
,
const
float
*
b
,
unsigned
int
len
)
{
int
i
;
double
ret
;
__m128d
sum
=
_mm_setzero_pd
();
__m128
t
;
for
(
i
=
0
;
i
<
len
;
i
+=
8
)
{
t
=
_mm_mul_ps
(
_mm_loadu_ps
(
a
+
i
),
_mm_loadu_ps
(
b
+
i
));
sum
=
_mm_add_pd
(
sum
,
_mm_cvtps_pd
(
t
));
sum
=
_mm_add_pd
(
sum
,
_mm_cvtps_pd
(
_mm_movehl_ps
(
t
,
t
)));
t
=
_mm_mul_ps
(
_mm_loadu_ps
(
a
+
i
+
4
),
_mm_loadu_ps
(
b
+
i
+
4
));
sum
=
_mm_add_pd
(
sum
,
_mm_cvtps_pd
(
t
));
sum
=
_mm_add_pd
(
sum
,
_mm_cvtps_pd
(
_mm_movehl_ps
(
t
,
t
)));
}
sum
=
_mm_add_sd
(
sum
,
_mm_unpackhi_pd
(
sum
,
sum
));
_mm_store_sd
(
&
ret
,
sum
);
return
ret
;
}
#define OVERRIDE_INTERPOLATE_PRODUCT_DOUBLE
static
inline
double
interpolate_product_double
(
const
float
*
a
,
const
float
*
b
,
unsigned
int
len
,
const
spx_uint32_t
oversample
,
float
*
frac
)
{
int
i
;
double
ret
;
__m128d
sum
;
__m128d
sum1
=
_mm_setzero_pd
();
__m128d
sum2
=
_mm_setzero_pd
();
__m128
f
=
_mm_loadu_ps
(
frac
);
__m128d
f1
=
_mm_cvtps_pd
(
f
);
__m128d
f2
=
_mm_cvtps_pd
(
_mm_movehl_ps
(
f
,
f
));
__m128
t
;
for
(
i
=
0
;
i
<
len
;
i
+=
2
)
{
t
=
_mm_mul_ps
(
_mm_load1_ps
(
a
+
i
),
_mm_loadu_ps
(
b
+
i
*
oversample
));
sum1
=
_mm_add_pd
(
sum1
,
_mm_cvtps_pd
(
t
));
sum2
=
_mm_add_pd
(
sum2
,
_mm_cvtps_pd
(
_mm_movehl_ps
(
t
,
t
)));
t
=
_mm_mul_ps
(
_mm_load1_ps
(
a
+
i
+
1
),
_mm_loadu_ps
(
b
+
(
i
+
1
)
*
oversample
));
sum1
=
_mm_add_pd
(
sum1
,
_mm_cvtps_pd
(
t
));
sum2
=
_mm_add_pd
(
sum2
,
_mm_cvtps_pd
(
_mm_movehl_ps
(
t
,
t
)));
}
sum1
=
_mm_mul_pd
(
f1
,
sum1
);
sum2
=
_mm_mul_pd
(
f2
,
sum2
);
sum
=
_mm_add_pd
(
sum1
,
sum2
);
sum
=
_mm_add_sd
(
sum
,
_mm_unpackhi_pd
(
sum
,
sum
));
_mm_store_sd
(
&
ret
,
sum
);
return
ret
;
}
#endif
extras/speex_resampler/thirdparty/speex_resampler.h
0 → 100644
View file @
1449edf4
This diff is collapsed.
Click to expand it.
research/ma_resampler.h
View file @
1449edf4
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment