mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:12:59 +00:00
- Import libsamplerate from http://www.mega-nerd.com/SRC/download.html
- It will be used for samplerate conversion in kmixer - Thanks to blight for helping with asm - Do not import medium / high quality coeffs (600KB / 8MB file size) svn path=/trunk/; revision=39864
This commit is contained in:
parent
dffc4ed5a6
commit
e0a999407e
12 changed files with 5548 additions and 0 deletions
3
reactos/lib/3rdparty/3rdparty.rbuild
vendored
3
reactos/lib/3rdparty/3rdparty.rbuild
vendored
|
@ -13,6 +13,9 @@
|
||||||
<directory name="icu4ros">
|
<directory name="icu4ros">
|
||||||
<xi:include href="icu4ros/icu4ros.rbuild" />
|
<xi:include href="icu4ros/icu4ros.rbuild" />
|
||||||
</directory>
|
</directory>
|
||||||
|
<directory name="libsamplerate">
|
||||||
|
<xi:include href="libsamplerate/libsamplerate.rbuild" />
|
||||||
|
</directory>
|
||||||
<directory name="libwine">
|
<directory name="libwine">
|
||||||
<xi:include href="libwine/libwine.rbuild" />
|
<xi:include href="libwine/libwine.rbuild" />
|
||||||
</directory>
|
</directory>
|
||||||
|
|
157
reactos/lib/3rdparty/libsamplerate/common.h
vendored
Normal file
157
reactos/lib/3rdparty/libsamplerate/common.h
vendored
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
/*
|
||||||
|
** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation; either version 2 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with this program; if not, write to the Free Software
|
||||||
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This code is part of Secret Rabibt Code aka libsamplerate. A commercial
|
||||||
|
** use license for this code is available, please see:
|
||||||
|
** http://www.mega-nerd.com/SRC/procedure.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_H_INCLUDED
|
||||||
|
#define COMMON_H_INCLUDED
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
#elif (SIZEOF_INT == 4)
|
||||||
|
typedef int int32_t ;
|
||||||
|
#elif (SIZEOF_LONG == 4)
|
||||||
|
typedef long int32_t ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SRC_MAX_RATIO 256
|
||||||
|
#define SRC_MAX_RATIO_STR "256"
|
||||||
|
|
||||||
|
#define SRC_MIN_RATIO_DIFF (1e-20)
|
||||||
|
|
||||||
|
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
|
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
|
|
||||||
|
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
|
||||||
|
#define OFFSETOF(type,member) ((int) (&((type*) 0)->member))
|
||||||
|
|
||||||
|
#define MAKE_MAGIC(a,b,c,d,e,f) ((a) + ((b) << 4) + ((c) << 8) + ((d) << 12) + ((e) << 16) + ((f) << 20))
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# define WARN_UNUSED __attribute__ ((warn_unused_result))
|
||||||
|
#else
|
||||||
|
# define WARN_UNUSED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "samplerate.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{ SRC_FALSE = 0,
|
||||||
|
SRC_TRUE = 1,
|
||||||
|
|
||||||
|
SRC_MODE_PROCESS = 555,
|
||||||
|
SRC_MODE_CALLBACK = 556
|
||||||
|
} ;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{ SRC_ERR_NO_ERROR = 0,
|
||||||
|
|
||||||
|
SRC_ERR_MALLOC_FAILED,
|
||||||
|
SRC_ERR_BAD_STATE,
|
||||||
|
SRC_ERR_BAD_DATA,
|
||||||
|
SRC_ERR_BAD_DATA_PTR,
|
||||||
|
SRC_ERR_NO_PRIVATE,
|
||||||
|
SRC_ERR_BAD_SRC_RATIO,
|
||||||
|
SRC_ERR_BAD_PROC_PTR,
|
||||||
|
SRC_ERR_SHIFT_BITS,
|
||||||
|
SRC_ERR_FILTER_LEN,
|
||||||
|
SRC_ERR_BAD_CONVERTER,
|
||||||
|
SRC_ERR_BAD_CHANNEL_COUNT,
|
||||||
|
SRC_ERR_SINC_BAD_BUFFER_LEN,
|
||||||
|
SRC_ERR_SIZE_INCOMPATIBILITY,
|
||||||
|
SRC_ERR_BAD_PRIV_PTR,
|
||||||
|
SRC_ERR_BAD_SINC_STATE,
|
||||||
|
SRC_ERR_DATA_OVERLAP,
|
||||||
|
SRC_ERR_BAD_CALLBACK,
|
||||||
|
SRC_ERR_BAD_MODE,
|
||||||
|
SRC_ERR_NULL_CALLBACK,
|
||||||
|
SRC_ERR_NO_VARIABLE_RATIO,
|
||||||
|
SRC_ERR_SINC_PREPARE_DATA_BAD_LEN,
|
||||||
|
|
||||||
|
/* This must be the last error number. */
|
||||||
|
SRC_ERR_MAX_ERROR
|
||||||
|
} ;
|
||||||
|
|
||||||
|
typedef struct SRC_PRIVATE_tag
|
||||||
|
{ double last_ratio, last_position ;
|
||||||
|
|
||||||
|
int error ;
|
||||||
|
int channels ;
|
||||||
|
|
||||||
|
/* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
|
||||||
|
int mode ;
|
||||||
|
|
||||||
|
/* Pointer to data to converter specific data. */
|
||||||
|
void *private_data ;
|
||||||
|
|
||||||
|
/* Varispeed process function. */
|
||||||
|
int (*vari_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
|
||||||
|
|
||||||
|
/* Constant speed process function. */
|
||||||
|
int (*const_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
|
||||||
|
|
||||||
|
/* State reset. */
|
||||||
|
void (*reset) (struct SRC_PRIVATE_tag *psrc) ;
|
||||||
|
|
||||||
|
/* Data specific to SRC_MODE_CALLBACK. */
|
||||||
|
src_callback_t callback_func ;
|
||||||
|
void *user_callback_data ;
|
||||||
|
long saved_frames ;
|
||||||
|
float *saved_data ;
|
||||||
|
} SRC_PRIVATE ;
|
||||||
|
|
||||||
|
/* In src_sinc.c */
|
||||||
|
const char* sinc_get_name (int src_enum) ;
|
||||||
|
const char* sinc_get_description (int src_enum) ;
|
||||||
|
|
||||||
|
int sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
|
||||||
|
|
||||||
|
/* In src_linear.c */
|
||||||
|
const char* linear_get_name (int src_enum) ;
|
||||||
|
const char* linear_get_description (int src_enum) ;
|
||||||
|
|
||||||
|
int linear_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
|
||||||
|
|
||||||
|
/* In src_zoh.c */
|
||||||
|
const char* zoh_get_name (int src_enum) ;
|
||||||
|
const char* zoh_get_description (int src_enum) ;
|
||||||
|
|
||||||
|
int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
|
||||||
|
|
||||||
|
/*----------------------------------------------------------
|
||||||
|
** Common static inline functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline double
|
||||||
|
fmod_one (double x)
|
||||||
|
{ double res ;
|
||||||
|
|
||||||
|
res = x - lrint (x) ;
|
||||||
|
if (res < 0.0)
|
||||||
|
return res + 1.0 ;
|
||||||
|
|
||||||
|
return res ;
|
||||||
|
} /* fmod_one */
|
||||||
|
|
||||||
|
#endif /* COMMON_H_INCLUDED */
|
||||||
|
|
205
reactos/lib/3rdparty/libsamplerate/config.h
vendored
Normal file
205
reactos/lib/3rdparty/libsamplerate/config.h
vendored
Normal file
|
@ -0,0 +1,205 @@
|
||||||
|
/*
|
||||||
|
** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation; either version 2 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with this program; if not, write to the Free Software
|
||||||
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This is the Win32 specific config.h header file.
|
||||||
|
**
|
||||||
|
** On Unix (including MacOSX), this header file is automatically generated
|
||||||
|
** during the configure process while on Win32 this has to be hand edited
|
||||||
|
** to keep it up to date.
|
||||||
|
**
|
||||||
|
** This is also a good file to add Win32 specific things.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** MSVC++ assumes that all floating point constants without a trailing
|
||||||
|
** letter 'f' are double precision.
|
||||||
|
**
|
||||||
|
** If this assumption is incorrect and one of these floating point constants
|
||||||
|
** is assigned to a float variable MSVC++ generates a warning.
|
||||||
|
**
|
||||||
|
** Since there are currently about 25000 of these warnings generated in
|
||||||
|
** src/src_sinc.c this slows down compile times considerably. The
|
||||||
|
** following #pragma disables the warning.
|
||||||
|
*/
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable: 4305)
|
||||||
|
#endif
|
||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
** Normal #defines follow.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Set to 1 if the compile is GNU GCC. */
|
||||||
|
#define COMPILER_IS_GCC 0
|
||||||
|
|
||||||
|
/* Target processor clips on negative float to int conversion. */
|
||||||
|
#define CPU_CLIPS_NEGATIVE 1
|
||||||
|
|
||||||
|
/* Target processor clips on positive float to int conversion. */
|
||||||
|
#define CPU_CLIPS_POSITIVE 0
|
||||||
|
|
||||||
|
/* Target processor is big endian. */
|
||||||
|
#define CPU_IS_BIG_ENDIAN 0
|
||||||
|
|
||||||
|
/* Target processor is little endian. */
|
||||||
|
#define CPU_IS_LITTLE_ENDIAN 1
|
||||||
|
|
||||||
|
/* Set to 1 to enable debugging. */
|
||||||
|
#define ENABLE_DEBUG 0
|
||||||
|
|
||||||
|
/* Major version of GCC or 3 otherwise. */
|
||||||
|
/* #undef GCC_MAJOR_VERSION */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `alarm' function. */
|
||||||
|
/* #undef HAVE_ALARM */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `calloc' function. */
|
||||||
|
#define HAVE_CALLOC 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ceil' function. */
|
||||||
|
#define HAVE_CEIL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
/* #undef HAVE_DLFCN_H */
|
||||||
|
|
||||||
|
/* Set to 1 if you have libfftw3. */
|
||||||
|
/* #undef HAVE_FFTW3 */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `floor' function. */
|
||||||
|
#define HAVE_FLOOR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `fmod' function. */
|
||||||
|
#define HAVE_FMOD 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `free' function. */
|
||||||
|
#define HAVE_FREE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
/* #undef HAVE_INTTYPES_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `m' library (-lm). */
|
||||||
|
/* #undef HAVE_LIBM */
|
||||||
|
|
||||||
|
/* Define if you have C99's lrint function. */
|
||||||
|
/* #undef HAVE_LRINT */
|
||||||
|
|
||||||
|
/* Define if you have C99's lrintf function. */
|
||||||
|
/* #undef HAVE_LRINTF */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `malloc' function. */
|
||||||
|
#define HAVE_MALLOC 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memcpy' function. */
|
||||||
|
#define HAVE_MEMCPY 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memmove' function. */
|
||||||
|
#define HAVE_MEMMOVE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define if you have signal SIGALRM. */
|
||||||
|
/* #undef HAVE_SIGALRM */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `signal' function. */
|
||||||
|
/* #undef HAVE_SIGNAL */
|
||||||
|
|
||||||
|
/* Set to 1 if you have libsndfile. */
|
||||||
|
#define HAVE_SNDFILE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
/* #undef HAVE_STDINT_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#define HAVE_STRINGS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#define HAVE_SYS_STAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||||
|
/* #undef HAVE_SYS_TIMES_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#define HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||||
|
*/
|
||||||
|
#define LT_OBJDIR ".libs/"
|
||||||
|
|
||||||
|
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||||
|
/* #undef NO_MINUS_C_MINUS_O */
|
||||||
|
|
||||||
|
/* Set to 1 if compiling for Win32 */
|
||||||
|
#define OS_IS_WIN32 1
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "libsamplerate"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT "erikd@mega-nerd.com"
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME "libsamplerate"
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING "libsamplerate 0.1.7"
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME "libsamplerate"
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION "0.1.7"
|
||||||
|
|
||||||
|
/* The size of `double', as computed by sizeof. */
|
||||||
|
#define SIZEOF_DOUBLE 8
|
||||||
|
|
||||||
|
/* The size of `float', as computed by sizeof. */
|
||||||
|
#define SIZEOF_FLOAT 4
|
||||||
|
|
||||||
|
/* The size of `int', as computed by sizeof. */
|
||||||
|
#define SIZEOF_INT 4
|
||||||
|
|
||||||
|
/* The size of `long', as computed by sizeof. */
|
||||||
|
#define SIZEOF_LONG 4
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#define VERSION "0.1.4"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Extra Win32 hacks. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Microsoft's compiler still does not support the 1999 ISO C Standard
|
||||||
|
** which includes 'inline'.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define inline __inline
|
||||||
|
|
2505
reactos/lib/3rdparty/libsamplerate/fastest_coeffs.h
vendored
Normal file
2505
reactos/lib/3rdparty/libsamplerate/fastest_coeffs.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
274
reactos/lib/3rdparty/libsamplerate/float_cast.h
vendored
Normal file
274
reactos/lib/3rdparty/libsamplerate/float_cast.h
vendored
Normal file
|
@ -0,0 +1,274 @@
|
||||||
|
/*
|
||||||
|
** Copyright (C) 2001-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
** the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU Lesser General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU Lesser General Public License
|
||||||
|
** along with this program; if not, write to the Free Software
|
||||||
|
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Version 1.4 */
|
||||||
|
|
||||||
|
#ifndef FLOAT_CAST_HEADER
|
||||||
|
#define FLOAT_CAST_HEADER
|
||||||
|
|
||||||
|
/*============================================================================
|
||||||
|
** On Intel Pentium processors (especially PIII and probably P4), converting
|
||||||
|
** from float to int is very slow. To meet the C specs, the code produced by
|
||||||
|
** most C compilers targeting Pentium needs to change the FPU rounding mode
|
||||||
|
** before the float to int conversion is performed.
|
||||||
|
**
|
||||||
|
** Changing the FPU rounding mode causes the FPU pipeline to be flushed. It
|
||||||
|
** is this flushing of the pipeline which is so slow.
|
||||||
|
**
|
||||||
|
** Fortunately the ISO C99 specifications define the functions lrint, lrintf,
|
||||||
|
** llrint and llrintf which fix this problem as a side effect.
|
||||||
|
**
|
||||||
|
** On Unix-like systems, the configure process should have detected the
|
||||||
|
** presence of these functions. If they weren't found we have to replace them
|
||||||
|
** here with a standard C cast.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The C99 prototypes for lrint and lrintf are as follows:
|
||||||
|
**
|
||||||
|
** long int lrintf (float x) ;
|
||||||
|
** long int lrint (double x) ;
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The presence of the required functions are detected during the configure
|
||||||
|
** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
|
||||||
|
** the config.h file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define HAVE_LRINT_REPLACEMENT 0
|
||||||
|
|
||||||
|
#if (HAVE_LRINT && HAVE_LRINTF)
|
||||||
|
|
||||||
|
/*
|
||||||
|
** These defines enable functionality introduced with the 1999 ISO C
|
||||||
|
** standard. They must be defined before the inclusion of math.h to
|
||||||
|
** engage them. If optimisation is enabled, these functions will be
|
||||||
|
** inlined. With optimisation switched off, you have to link in the
|
||||||
|
** maths library using -lm.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _ISOC9X_SOURCE 1
|
||||||
|
#define _ISOC99_SOURCE 1
|
||||||
|
|
||||||
|
#define __USE_ISOC9X 1
|
||||||
|
#define __USE_ISOC99 1
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#elif (defined (__CYGWIN__))
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#undef HAVE_LRINT_REPLACEMENT
|
||||||
|
#define HAVE_LRINT_REPLACEMENT 1
|
||||||
|
|
||||||
|
#undef lrint
|
||||||
|
#undef lrintf
|
||||||
|
|
||||||
|
#define lrint double2int
|
||||||
|
#define lrintf float2int
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The native CYGWIN lrint and lrintf functions are buggy:
|
||||||
|
** http://sourceware.org/ml/cygwin/2005-06/msg00153.html
|
||||||
|
** http://sourceware.org/ml/cygwin/2005-09/msg00047.html
|
||||||
|
** and slow.
|
||||||
|
** These functions (pulled from the Public Domain MinGW math.h header)
|
||||||
|
** replace the native versions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline long double2int (double in)
|
||||||
|
{ long retval ;
|
||||||
|
|
||||||
|
__asm__ __volatile__
|
||||||
|
( "fistpl %0"
|
||||||
|
: "=m" (retval)
|
||||||
|
: "t" (in)
|
||||||
|
: "st"
|
||||||
|
) ;
|
||||||
|
|
||||||
|
return retval ;
|
||||||
|
} /* double2int */
|
||||||
|
|
||||||
|
static inline long float2int (float in)
|
||||||
|
{ long retval ;
|
||||||
|
|
||||||
|
__asm__ __volatile__
|
||||||
|
( "fistpl %0"
|
||||||
|
: "=m" (retval)
|
||||||
|
: "t" (in)
|
||||||
|
: "st"
|
||||||
|
) ;
|
||||||
|
|
||||||
|
return retval ;
|
||||||
|
} /* float2int */
|
||||||
|
|
||||||
|
#elif (defined (WIN32) || defined (_WIN32))
|
||||||
|
|
||||||
|
#undef HAVE_LRINT_REPLACEMENT
|
||||||
|
#define HAVE_LRINT_REPLACEMENT 1
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Win32 doesn't seem to have these functions.
|
||||||
|
** Therefore implement inline versions of these functions here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
__inline long int
|
||||||
|
lrint (double flt)
|
||||||
|
{ int intgr ;
|
||||||
|
|
||||||
|
_asm
|
||||||
|
{ fld flt
|
||||||
|
fistp intgr
|
||||||
|
} ;
|
||||||
|
|
||||||
|
return intgr ;
|
||||||
|
}
|
||||||
|
|
||||||
|
__inline long int
|
||||||
|
lrintf (float flt)
|
||||||
|
{ int intgr ;
|
||||||
|
|
||||||
|
_asm
|
||||||
|
{ fld flt
|
||||||
|
fistp intgr
|
||||||
|
} ;
|
||||||
|
|
||||||
|
return intgr ;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static __inline long int
|
||||||
|
lrint (double flt)
|
||||||
|
{
|
||||||
|
int intgr ;
|
||||||
|
__asm__ __volatile__ ("fldl %1; fistpl %0;" : "=m" (intgr) : "m" (flt));
|
||||||
|
return intgr ;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline long int
|
||||||
|
lrintf (float flt)
|
||||||
|
{
|
||||||
|
int intgr ;
|
||||||
|
|
||||||
|
__asm__ __volatile__ ("flds %1; fistpl %0;" : "=m" (intgr) : "m" (flt));
|
||||||
|
return intgr ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif (defined (__MWERKS__) && defined (macintosh))
|
||||||
|
|
||||||
|
/* This MacOS 9 solution was provided by Stephane Letz */
|
||||||
|
|
||||||
|
#undef HAVE_LRINT_REPLACEMENT
|
||||||
|
#define HAVE_LRINT_REPLACEMENT 1
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#undef lrint
|
||||||
|
#undef lrintf
|
||||||
|
|
||||||
|
#define lrint double2int
|
||||||
|
#define lrintf float2int
|
||||||
|
|
||||||
|
inline int
|
||||||
|
float2int (register float in)
|
||||||
|
{ long res [2] ;
|
||||||
|
|
||||||
|
asm
|
||||||
|
{ fctiw in, in
|
||||||
|
stfd in, res
|
||||||
|
}
|
||||||
|
return res [1] ;
|
||||||
|
} /* float2int */
|
||||||
|
|
||||||
|
inline int
|
||||||
|
double2int (register double in)
|
||||||
|
{ long res [2] ;
|
||||||
|
|
||||||
|
asm
|
||||||
|
{ fctiw in, in
|
||||||
|
stfd in, res
|
||||||
|
}
|
||||||
|
return res [1] ;
|
||||||
|
} /* double2int */
|
||||||
|
|
||||||
|
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||||
|
|
||||||
|
/* For Apple MacOSX. */
|
||||||
|
|
||||||
|
#undef HAVE_LRINT_REPLACEMENT
|
||||||
|
#define HAVE_LRINT_REPLACEMENT 1
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#undef lrint
|
||||||
|
#undef lrintf
|
||||||
|
|
||||||
|
#define lrint double2int
|
||||||
|
#define lrintf float2int
|
||||||
|
|
||||||
|
inline static long
|
||||||
|
float2int (register float in)
|
||||||
|
{ int res [2] ;
|
||||||
|
|
||||||
|
__asm__ __volatile__
|
||||||
|
( "fctiw %1, %1\n\t"
|
||||||
|
"stfd %1, %0"
|
||||||
|
: "=m" (res) /* Output */
|
||||||
|
: "f" (in) /* Input */
|
||||||
|
: "memory"
|
||||||
|
) ;
|
||||||
|
|
||||||
|
return res [1] ;
|
||||||
|
} /* lrintf */
|
||||||
|
|
||||||
|
inline static long
|
||||||
|
double2int (register double in)
|
||||||
|
{ int res [2] ;
|
||||||
|
|
||||||
|
__asm__ __volatile__
|
||||||
|
( "fctiw %1, %1\n\t"
|
||||||
|
"stfd %1, %0"
|
||||||
|
: "=m" (res) /* Output */
|
||||||
|
: "f" (in) /* Input */
|
||||||
|
: "memory"
|
||||||
|
) ;
|
||||||
|
|
||||||
|
return res [1] ;
|
||||||
|
} /* lrint */
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifndef __sgi
|
||||||
|
#warning "Don't have the functions lrint() and lrintf()."
|
||||||
|
#warning "Replacing these functions with a standard C cast."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define lrint(dbl) ((long) (dbl))
|
||||||
|
#define lrintf(flt) ((long) (flt))
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FLOAT_CAST_HEADER */
|
||||||
|
|
9
reactos/lib/3rdparty/libsamplerate/libsamplerate.rbuild
vendored
Normal file
9
reactos/lib/3rdparty/libsamplerate/libsamplerate.rbuild
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd">
|
||||||
|
<module name="libsamplerate" type="staticlibrary" allowwarnings="true">
|
||||||
|
<include base="libsamplerate">.</include>
|
||||||
|
<file>samplerate.c</file>
|
||||||
|
<file>src_linear.c</file>
|
||||||
|
<file>src_sinc.c</file>
|
||||||
|
<file>src_zoh.c</file>
|
||||||
|
</module>
|
545
reactos/lib/3rdparty/libsamplerate/samplerate.c
vendored
Normal file
545
reactos/lib/3rdparty/libsamplerate/samplerate.c
vendored
Normal file
|
@ -0,0 +1,545 @@
|
||||||
|
/*
|
||||||
|
** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation; either version 2 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with this program; if not, write to the Free Software
|
||||||
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This code is part of Secret Rabibt Code aka libsamplerate. A commercial
|
||||||
|
** use license for this code is available, please see:
|
||||||
|
** http://www.mega-nerd.com/SRC/procedure.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "samplerate.h"
|
||||||
|
#include "float_cast.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
static int psrc_set_converter (SRC_PRIVATE *psrc, int converter_type) ;
|
||||||
|
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
is_bad_src_ratio (double ratio)
|
||||||
|
{ return (ratio < (1.0 / SRC_MAX_RATIO) || ratio > (1.0 * SRC_MAX_RATIO)) ;
|
||||||
|
} /* is_bad_src_ratio */
|
||||||
|
|
||||||
|
SRC_STATE *
|
||||||
|
src_new (int converter_type, int channels, int *error)
|
||||||
|
{ SRC_PRIVATE *psrc ;
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
*error = SRC_ERR_NO_ERROR ;
|
||||||
|
|
||||||
|
if (channels < 1)
|
||||||
|
{ if (error)
|
||||||
|
*error = SRC_ERR_BAD_CHANNEL_COUNT ;
|
||||||
|
return NULL ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
if ((psrc = calloc (1, sizeof (*psrc))) == NULL)
|
||||||
|
{ if (error)
|
||||||
|
*error = SRC_ERR_MALLOC_FAILED ;
|
||||||
|
return NULL ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
psrc->channels = channels ;
|
||||||
|
psrc->mode = SRC_MODE_PROCESS ;
|
||||||
|
|
||||||
|
if (psrc_set_converter (psrc, converter_type) != SRC_ERR_NO_ERROR)
|
||||||
|
{ if (error)
|
||||||
|
*error = SRC_ERR_BAD_CONVERTER ;
|
||||||
|
free (psrc) ;
|
||||||
|
psrc = NULL ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
src_reset ((SRC_STATE*) psrc) ;
|
||||||
|
|
||||||
|
return (SRC_STATE*) psrc ;
|
||||||
|
} /* src_new */
|
||||||
|
|
||||||
|
SRC_STATE*
|
||||||
|
src_callback_new (src_callback_t func, int converter_type, int channels, int *error, void* cb_data)
|
||||||
|
{ SRC_STATE *src_state ;
|
||||||
|
|
||||||
|
if (func == NULL)
|
||||||
|
{ if (error)
|
||||||
|
*error = SRC_ERR_BAD_CALLBACK ;
|
||||||
|
return NULL ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
if (error != NULL)
|
||||||
|
*error = 0 ;
|
||||||
|
|
||||||
|
if ((src_state = src_new (converter_type, channels, error)) == NULL)
|
||||||
|
return NULL ;
|
||||||
|
|
||||||
|
src_reset (src_state) ;
|
||||||
|
|
||||||
|
((SRC_PRIVATE*) src_state)->mode = SRC_MODE_CALLBACK ;
|
||||||
|
((SRC_PRIVATE*) src_state)->callback_func = func ;
|
||||||
|
((SRC_PRIVATE*) src_state)->user_callback_data = cb_data ;
|
||||||
|
|
||||||
|
return src_state ;
|
||||||
|
} /* src_callback_new */
|
||||||
|
|
||||||
|
SRC_STATE *
|
||||||
|
src_delete (SRC_STATE *state)
|
||||||
|
{ SRC_PRIVATE *psrc ;
|
||||||
|
|
||||||
|
psrc = (SRC_PRIVATE*) state ;
|
||||||
|
if (psrc)
|
||||||
|
{ if (psrc->private_data)
|
||||||
|
free (psrc->private_data) ;
|
||||||
|
memset (psrc, 0, sizeof (SRC_PRIVATE)) ;
|
||||||
|
free (psrc) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
return NULL ;
|
||||||
|
} /* src_state */
|
||||||
|
|
||||||
|
int
|
||||||
|
src_process (SRC_STATE *state, SRC_DATA *data)
|
||||||
|
{ SRC_PRIVATE *psrc ;
|
||||||
|
int error ;
|
||||||
|
|
||||||
|
psrc = (SRC_PRIVATE*) state ;
|
||||||
|
|
||||||
|
if (psrc == NULL)
|
||||||
|
return SRC_ERR_BAD_STATE ;
|
||||||
|
if (psrc->vari_process == NULL || psrc->const_process == NULL)
|
||||||
|
return SRC_ERR_BAD_PROC_PTR ;
|
||||||
|
|
||||||
|
if (psrc->mode != SRC_MODE_PROCESS)
|
||||||
|
return SRC_ERR_BAD_MODE ;
|
||||||
|
|
||||||
|
/* Check for valid SRC_DATA first. */
|
||||||
|
if (data == NULL)
|
||||||
|
return SRC_ERR_BAD_DATA ;
|
||||||
|
|
||||||
|
/* And that data_in and data_out are valid. */
|
||||||
|
if (data->data_in == NULL || data->data_out == NULL)
|
||||||
|
return SRC_ERR_BAD_DATA_PTR ;
|
||||||
|
|
||||||
|
/* Check src_ratio is in range. */
|
||||||
|
if (is_bad_src_ratio (data->src_ratio))
|
||||||
|
return SRC_ERR_BAD_SRC_RATIO ;
|
||||||
|
|
||||||
|
if (data->input_frames < 0)
|
||||||
|
data->input_frames = 0 ;
|
||||||
|
if (data->output_frames < 0)
|
||||||
|
data->output_frames = 0 ;
|
||||||
|
|
||||||
|
if (data->data_in < data->data_out)
|
||||||
|
{ if (data->data_in + data->input_frames * psrc->channels > data->data_out)
|
||||||
|
{ /*-printf ("\n\ndata_in: %p data_out: %p\n",
|
||||||
|
(void*) (data->data_in + data->input_frames * psrc->channels), (void*) data->data_out) ;-*/
|
||||||
|
return SRC_ERR_DATA_OVERLAP ;
|
||||||
|
} ;
|
||||||
|
}
|
||||||
|
else if (data->data_out + data->output_frames * psrc->channels > data->data_in)
|
||||||
|
{ /*-printf ("\n\ndata_in : %p ouput frames: %ld data_out: %p\n", (void*) data->data_in, data->output_frames, (void*) data->data_out) ;
|
||||||
|
|
||||||
|
printf ("data_out: %p (%p) data_in: %p\n", (void*) data->data_out,
|
||||||
|
(void*) (data->data_out + data->input_frames * psrc->channels), (void*) data->data_in) ;-*/
|
||||||
|
return SRC_ERR_DATA_OVERLAP ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/* Set the input and output counts to zero. */
|
||||||
|
data->input_frames_used = 0 ;
|
||||||
|
data->output_frames_gen = 0 ;
|
||||||
|
|
||||||
|
/* Special case for when last_ratio has not been set. */
|
||||||
|
if (psrc->last_ratio < (1.0 / SRC_MAX_RATIO))
|
||||||
|
psrc->last_ratio = data->src_ratio ;
|
||||||
|
|
||||||
|
/* Now process. */
|
||||||
|
if (fabs (psrc->last_ratio - data->src_ratio) < 1e-15)
|
||||||
|
error = psrc->const_process (psrc, data) ;
|
||||||
|
else
|
||||||
|
error = psrc->vari_process (psrc, data) ;
|
||||||
|
|
||||||
|
return error ;
|
||||||
|
} /* src_process */
|
||||||
|
|
||||||
|
long
|
||||||
|
src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data)
|
||||||
|
{ SRC_PRIVATE *psrc ;
|
||||||
|
SRC_DATA src_data ;
|
||||||
|
|
||||||
|
long output_frames_gen ;
|
||||||
|
int error = 0 ;
|
||||||
|
|
||||||
|
if (state == NULL)
|
||||||
|
return 0 ;
|
||||||
|
|
||||||
|
if (frames <= 0)
|
||||||
|
return 0 ;
|
||||||
|
|
||||||
|
psrc = (SRC_PRIVATE*) state ;
|
||||||
|
|
||||||
|
if (psrc->mode != SRC_MODE_CALLBACK)
|
||||||
|
{ psrc->error = SRC_ERR_BAD_MODE ;
|
||||||
|
return 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
if (psrc->callback_func == NULL)
|
||||||
|
{ psrc->error = SRC_ERR_NULL_CALLBACK ;
|
||||||
|
return 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
memset (&src_data, 0, sizeof (src_data)) ;
|
||||||
|
|
||||||
|
/* Check src_ratio is in range. */
|
||||||
|
if (is_bad_src_ratio (src_ratio))
|
||||||
|
{ psrc->error = SRC_ERR_BAD_SRC_RATIO ;
|
||||||
|
return 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/* Switch modes temporarily. */
|
||||||
|
src_data.src_ratio = src_ratio ;
|
||||||
|
src_data.data_out = data ;
|
||||||
|
src_data.output_frames = frames ;
|
||||||
|
|
||||||
|
src_data.data_in = psrc->saved_data ;
|
||||||
|
src_data.input_frames = psrc->saved_frames ;
|
||||||
|
|
||||||
|
output_frames_gen = 0 ;
|
||||||
|
while (output_frames_gen < frames)
|
||||||
|
{ /* Use a dummy array for the case where the callback function
|
||||||
|
** returns without setting the ptr.
|
||||||
|
*/
|
||||||
|
float dummy [1] ;
|
||||||
|
|
||||||
|
if (src_data.input_frames == 0)
|
||||||
|
{ float *ptr = dummy ;
|
||||||
|
|
||||||
|
src_data.input_frames = psrc->callback_func (psrc->user_callback_data, &ptr) ;
|
||||||
|
src_data.data_in = ptr ;
|
||||||
|
|
||||||
|
if (src_data.input_frames == 0)
|
||||||
|
src_data.end_of_input = 1 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Now call process function. However, we need to set the mode
|
||||||
|
** to SRC_MODE_PROCESS first and when we return set it back to
|
||||||
|
** SRC_MODE_CALLBACK.
|
||||||
|
*/
|
||||||
|
psrc->mode = SRC_MODE_PROCESS ;
|
||||||
|
error = src_process (state, &src_data) ;
|
||||||
|
psrc->mode = SRC_MODE_CALLBACK ;
|
||||||
|
|
||||||
|
if (error != 0)
|
||||||
|
break ;
|
||||||
|
|
||||||
|
src_data.data_in += src_data.input_frames_used * psrc->channels ;
|
||||||
|
src_data.input_frames -= src_data.input_frames_used ;
|
||||||
|
|
||||||
|
src_data.data_out += src_data.output_frames_gen * psrc->channels ;
|
||||||
|
src_data.output_frames -= src_data.output_frames_gen ;
|
||||||
|
|
||||||
|
output_frames_gen += src_data.output_frames_gen ;
|
||||||
|
|
||||||
|
if (src_data.end_of_input == SRC_TRUE && src_data.output_frames_gen == 0)
|
||||||
|
break ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
psrc->saved_data = src_data.data_in ;
|
||||||
|
psrc->saved_frames = src_data.input_frames ;
|
||||||
|
|
||||||
|
if (error != 0)
|
||||||
|
{ psrc->error = error ;
|
||||||
|
return 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
return output_frames_gen ;
|
||||||
|
} /* src_callback_read */
|
||||||
|
|
||||||
|
/*==========================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
src_set_ratio (SRC_STATE *state, double new_ratio)
|
||||||
|
{ SRC_PRIVATE *psrc ;
|
||||||
|
|
||||||
|
psrc = (SRC_PRIVATE*) state ;
|
||||||
|
|
||||||
|
if (psrc == NULL)
|
||||||
|
return SRC_ERR_BAD_STATE ;
|
||||||
|
if (psrc->vari_process == NULL || psrc->const_process == NULL)
|
||||||
|
return SRC_ERR_BAD_PROC_PTR ;
|
||||||
|
|
||||||
|
if (is_bad_src_ratio (new_ratio))
|
||||||
|
return SRC_ERR_BAD_SRC_RATIO ;
|
||||||
|
|
||||||
|
psrc->last_ratio = new_ratio ;
|
||||||
|
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
} /* src_set_ratio */
|
||||||
|
|
||||||
|
int
|
||||||
|
src_reset (SRC_STATE *state)
|
||||||
|
{ SRC_PRIVATE *psrc ;
|
||||||
|
|
||||||
|
if ((psrc = (SRC_PRIVATE*) state) == NULL)
|
||||||
|
return SRC_ERR_BAD_STATE ;
|
||||||
|
|
||||||
|
if (psrc->reset != NULL)
|
||||||
|
psrc->reset (psrc) ;
|
||||||
|
|
||||||
|
psrc->last_position = 0.0 ;
|
||||||
|
psrc->last_ratio = 0.0 ;
|
||||||
|
|
||||||
|
psrc->saved_data = NULL ;
|
||||||
|
psrc->saved_frames = 0 ;
|
||||||
|
|
||||||
|
psrc->error = SRC_ERR_NO_ERROR ;
|
||||||
|
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
} /* src_reset */
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
** Control functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const char *
|
||||||
|
src_get_name (int converter_type)
|
||||||
|
{ const char *desc ;
|
||||||
|
|
||||||
|
if ((desc = sinc_get_name (converter_type)) != NULL)
|
||||||
|
return desc ;
|
||||||
|
|
||||||
|
if ((desc = zoh_get_name (converter_type)) != NULL)
|
||||||
|
return desc ;
|
||||||
|
|
||||||
|
if ((desc = linear_get_name (converter_type)) != NULL)
|
||||||
|
return desc ;
|
||||||
|
|
||||||
|
return NULL ;
|
||||||
|
} /* src_get_name */
|
||||||
|
|
||||||
|
const char *
|
||||||
|
src_get_description (int converter_type)
|
||||||
|
{ const char *desc ;
|
||||||
|
|
||||||
|
if ((desc = sinc_get_description (converter_type)) != NULL)
|
||||||
|
return desc ;
|
||||||
|
|
||||||
|
if ((desc = zoh_get_description (converter_type)) != NULL)
|
||||||
|
return desc ;
|
||||||
|
|
||||||
|
if ((desc = linear_get_description (converter_type)) != NULL)
|
||||||
|
return desc ;
|
||||||
|
|
||||||
|
return NULL ;
|
||||||
|
} /* src_get_description */
|
||||||
|
|
||||||
|
const char *
|
||||||
|
src_get_version (void)
|
||||||
|
{ return PACKAGE "-" VERSION " (c) 2002-2008 Erik de Castro Lopo" ;
|
||||||
|
} /* src_get_version */
|
||||||
|
|
||||||
|
int
|
||||||
|
src_is_valid_ratio (double ratio)
|
||||||
|
{
|
||||||
|
if (is_bad_src_ratio (ratio))
|
||||||
|
return SRC_FALSE ;
|
||||||
|
|
||||||
|
return SRC_TRUE ;
|
||||||
|
} /* src_is_valid_ratio */
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
** Error reporting functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
src_error (SRC_STATE *state)
|
||||||
|
{ if (state)
|
||||||
|
return ((SRC_PRIVATE*) state)->error ;
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
} /* src_error */
|
||||||
|
|
||||||
|
const char*
|
||||||
|
src_strerror (int error)
|
||||||
|
{
|
||||||
|
switch (error)
|
||||||
|
{ case SRC_ERR_NO_ERROR :
|
||||||
|
return "No error." ;
|
||||||
|
case SRC_ERR_MALLOC_FAILED :
|
||||||
|
return "Malloc failed." ;
|
||||||
|
case SRC_ERR_BAD_STATE :
|
||||||
|
return "SRC_STATE pointer is NULL." ;
|
||||||
|
case SRC_ERR_BAD_DATA :
|
||||||
|
return "SRC_DATA pointer is NULL." ;
|
||||||
|
case SRC_ERR_BAD_DATA_PTR :
|
||||||
|
return "SRC_DATA->data_out is NULL." ;
|
||||||
|
case SRC_ERR_NO_PRIVATE :
|
||||||
|
return "Internal error. No private data." ;
|
||||||
|
|
||||||
|
case SRC_ERR_BAD_SRC_RATIO :
|
||||||
|
return "SRC ratio outside [1/" SRC_MAX_RATIO_STR ", " SRC_MAX_RATIO_STR "] range." ;
|
||||||
|
|
||||||
|
case SRC_ERR_BAD_SINC_STATE :
|
||||||
|
return "src_process() called without reset after end_of_input." ;
|
||||||
|
case SRC_ERR_BAD_PROC_PTR :
|
||||||
|
return "Internal error. No process pointer." ;
|
||||||
|
case SRC_ERR_SHIFT_BITS :
|
||||||
|
return "Internal error. SHIFT_BITS too large." ;
|
||||||
|
case SRC_ERR_FILTER_LEN :
|
||||||
|
return "Internal error. Filter length too large." ;
|
||||||
|
case SRC_ERR_BAD_CONVERTER :
|
||||||
|
return "Bad converter number." ;
|
||||||
|
case SRC_ERR_BAD_CHANNEL_COUNT :
|
||||||
|
return "Channel count must be >= 1." ;
|
||||||
|
case SRC_ERR_SINC_BAD_BUFFER_LEN :
|
||||||
|
return "Internal error. Bad buffer length. Please report this." ;
|
||||||
|
case SRC_ERR_SIZE_INCOMPATIBILITY :
|
||||||
|
return "Internal error. Input data / internal buffer size difference. Please report this." ;
|
||||||
|
case SRC_ERR_BAD_PRIV_PTR :
|
||||||
|
return "Internal error. Private pointer is NULL. Please report this." ;
|
||||||
|
case SRC_ERR_DATA_OVERLAP :
|
||||||
|
return "Input and output data arrays overlap." ;
|
||||||
|
case SRC_ERR_BAD_CALLBACK :
|
||||||
|
return "Supplied callback function pointer is NULL." ;
|
||||||
|
case SRC_ERR_BAD_MODE :
|
||||||
|
return "Calling mode differs from initialisation mode (ie process v callback)." ;
|
||||||
|
case SRC_ERR_NULL_CALLBACK :
|
||||||
|
return "Callback function pointer is NULL in src_callback_read ()." ;
|
||||||
|
case SRC_ERR_NO_VARIABLE_RATIO :
|
||||||
|
return "This converter only allows constant conversion ratios." ;
|
||||||
|
case SRC_ERR_SINC_PREPARE_DATA_BAD_LEN :
|
||||||
|
return "Internal error : Bad length in prepare_data ()." ;
|
||||||
|
|
||||||
|
case SRC_ERR_MAX_ERROR :
|
||||||
|
return "Placeholder. No error defined for this error number." ;
|
||||||
|
|
||||||
|
default : break ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL ;
|
||||||
|
} /* src_strerror */
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
** Simple interface for performing a single conversion from input buffer to
|
||||||
|
** output buffer at a fixed conversion ratio.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
src_simple (SRC_DATA *src_data, int converter, int channels)
|
||||||
|
{ SRC_STATE *src_state ;
|
||||||
|
int error ;
|
||||||
|
|
||||||
|
if ((src_state = src_new (converter, channels, &error)) == NULL)
|
||||||
|
return error ;
|
||||||
|
|
||||||
|
src_data->end_of_input = 1 ; /* Only one buffer worth of input. */
|
||||||
|
|
||||||
|
error = src_process (src_state, src_data) ;
|
||||||
|
|
||||||
|
src_state = src_delete (src_state) ;
|
||||||
|
|
||||||
|
return error ;
|
||||||
|
} /* src_simple */
|
||||||
|
|
||||||
|
void
|
||||||
|
src_short_to_float_array (const short *in, float *out, int len)
|
||||||
|
{
|
||||||
|
while (len)
|
||||||
|
{ len -- ;
|
||||||
|
out [len] = (float) (in [len] / (1.0 * 0x8000)) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
return ;
|
||||||
|
} /* src_short_to_float_array */
|
||||||
|
|
||||||
|
void
|
||||||
|
src_float_to_short_array (const float *in, short *out, int len)
|
||||||
|
{ double scaled_value ;
|
||||||
|
|
||||||
|
while (len)
|
||||||
|
{ len -- ;
|
||||||
|
|
||||||
|
scaled_value = in [len] * (8.0 * 0x10000000) ;
|
||||||
|
if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||||
|
{ out [len] = 32767 ;
|
||||||
|
continue ;
|
||||||
|
} ;
|
||||||
|
if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))
|
||||||
|
{ out [len] = -32768 ;
|
||||||
|
continue ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
out [len] = (short) (lrint (scaled_value) >> 16) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
} /* src_float_to_short_array */
|
||||||
|
|
||||||
|
void
|
||||||
|
src_int_to_float_array (const int *in, float *out, int len)
|
||||||
|
{
|
||||||
|
while (len)
|
||||||
|
{ len -- ;
|
||||||
|
out [len] = (float) (in [len] / (8.0 * 0x10000000)) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
return ;
|
||||||
|
} /* src_int_to_float_array */
|
||||||
|
|
||||||
|
void
|
||||||
|
src_float_to_int_array (const float *in, int *out, int len)
|
||||||
|
{ double scaled_value ;
|
||||||
|
|
||||||
|
while (len)
|
||||||
|
{ len -- ;
|
||||||
|
|
||||||
|
scaled_value = in [len] * (8.0 * 0x10000000) ;
|
||||||
|
if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7FFFFFFF))
|
||||||
|
{ out [len] = 0x7fffffff ;
|
||||||
|
continue ;
|
||||||
|
} ;
|
||||||
|
if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10000000))
|
||||||
|
{ out [len] = -1 - 0x7fffffff ;
|
||||||
|
continue ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
out [len] = lrint (scaled_value) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
} /* src_float_to_int_array */
|
||||||
|
|
||||||
|
/*==============================================================================
|
||||||
|
** Private functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
psrc_set_converter (SRC_PRIVATE *psrc, int converter_type)
|
||||||
|
{
|
||||||
|
if (sinc_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
|
||||||
|
if (zoh_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
|
||||||
|
if (linear_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
|
||||||
|
return SRC_ERR_BAD_CONVERTER ;
|
||||||
|
} /* psrc_set_converter */
|
||||||
|
|
197
reactos/lib/3rdparty/libsamplerate/samplerate.h
vendored
Normal file
197
reactos/lib/3rdparty/libsamplerate/samplerate.h
vendored
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
/*
|
||||||
|
** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation; either version 2 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with this program; if not, write to the Free Software
|
||||||
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This code is part of Secret Rabibt Code aka libsamplerate. A commercial
|
||||||
|
** use license for this code is available, please see:
|
||||||
|
** http://www.mega-nerd.com/SRC/procedure.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** API documentation is available here:
|
||||||
|
** http://www.mega-nerd.com/SRC/api.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SAMPLERATE_H
|
||||||
|
#define SAMPLERATE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
|
/* Opaque data type SRC_STATE. */
|
||||||
|
typedef struct SRC_STATE_tag SRC_STATE ;
|
||||||
|
|
||||||
|
/* SRC_DATA is used to pass data to src_simple() and src_process(). */
|
||||||
|
typedef struct
|
||||||
|
{ float *data_in, *data_out ;
|
||||||
|
|
||||||
|
long input_frames, output_frames ;
|
||||||
|
long input_frames_used, output_frames_gen ;
|
||||||
|
|
||||||
|
int end_of_input ;
|
||||||
|
|
||||||
|
double src_ratio ;
|
||||||
|
} SRC_DATA ;
|
||||||
|
|
||||||
|
/* SRC_CB_DATA is used with callback based API. */
|
||||||
|
typedef struct
|
||||||
|
{ long frames ;
|
||||||
|
float *data_in ;
|
||||||
|
} SRC_CB_DATA ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** User supplied callback function type for use with src_callback_new()
|
||||||
|
** and src_callback_read(). First parameter is the same pointer that was
|
||||||
|
** passed into src_callback_new(). Second parameter is pointer to a
|
||||||
|
** pointer. The user supplied callback function must modify *data to
|
||||||
|
** point to the start of the user supplied float array. The user supplied
|
||||||
|
** function must return the number of frames that **data points to.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef long (*src_callback_t) (void *cb_data, float **data) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Standard initialisation function : return an anonymous pointer to the
|
||||||
|
** internal state of the converter. Choose a converter from the enums below.
|
||||||
|
** Error returned in *error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRC_STATE* src_new (int converter_type, int channels, int *error) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Initilisation for callback based API : return an anonymous pointer to the
|
||||||
|
** internal state of the converter. Choose a converter from the enums below.
|
||||||
|
** The cb_data pointer can point to any data or be set to NULL. Whatever the
|
||||||
|
** value, when processing, user supplied function "func" gets called with
|
||||||
|
** cb_data as first parameter.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels,
|
||||||
|
int *error, void* cb_data) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Cleanup all internal allocations.
|
||||||
|
** Always returns NULL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SRC_STATE* src_delete (SRC_STATE *state) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Standard processing function.
|
||||||
|
** Returns non zero on error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int src_process (SRC_STATE *state, SRC_DATA *data) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Callback based processing function. Read up to frames worth of data from
|
||||||
|
** the converter int *data and return frames read or -1 on error.
|
||||||
|
*/
|
||||||
|
long src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Simple interface for performing a single conversion from input buffer to
|
||||||
|
** output buffer at a fixed conversion ratio.
|
||||||
|
** Simple interface does not require initialisation as it can only operate on
|
||||||
|
** a single buffer worth of audio.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int src_simple (SRC_DATA *data, int converter_type, int channels) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This library contains a number of different sample rate converters,
|
||||||
|
** numbered 0 through N.
|
||||||
|
**
|
||||||
|
** Return a string giving either a name or a more full description of each
|
||||||
|
** sample rate converter or NULL if no sample rate converter exists for
|
||||||
|
** the given value. The converters are sequentially numbered from 0 to N.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const char *src_get_name (int converter_type) ;
|
||||||
|
const char *src_get_description (int converter_type) ;
|
||||||
|
const char *src_get_version (void) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Set a new SRC ratio. This allows step responses
|
||||||
|
** in the conversion ratio.
|
||||||
|
** Returns non zero on error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int src_set_ratio (SRC_STATE *state, double new_ratio) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Reset the internal SRC state.
|
||||||
|
** Does not modify the quality settings.
|
||||||
|
** Does not free any memory allocations.
|
||||||
|
** Returns non zero on error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int src_reset (SRC_STATE *state) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Return TRUE if ratio is a valid conversion ratio, FALSE
|
||||||
|
** otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int src_is_valid_ratio (double ratio) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Return an error number.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int src_error (SRC_STATE *state) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Convert the error number into a string.
|
||||||
|
*/
|
||||||
|
const char* src_strerror (int error) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The following enums can be used to set the interpolator type
|
||||||
|
** using the function src_set_converter().
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SRC_SINC_BEST_QUALITY = 0,
|
||||||
|
SRC_SINC_MEDIUM_QUALITY = 1,
|
||||||
|
SRC_SINC_FASTEST = 2,
|
||||||
|
SRC_ZERO_ORDER_HOLD = 3,
|
||||||
|
SRC_LINEAR = 4,
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Extra helper functions for converting from short to float and
|
||||||
|
** back again.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void src_short_to_float_array (const short *in, float *out, int len) ;
|
||||||
|
void src_float_to_short_array (const float *in, short *out, int len) ;
|
||||||
|
|
||||||
|
void src_int_to_float_array (const int *in, float *out, int len) ;
|
||||||
|
void src_float_to_int_array (const float *in, int *out, int len) ;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* SAMPLERATE_H */
|
||||||
|
|
217
reactos/lib/3rdparty/libsamplerate/src_linear.c
vendored
Normal file
217
reactos/lib/3rdparty/libsamplerate/src_linear.c
vendored
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
/*
|
||||||
|
** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation; either version 2 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with this program; if not, write to the Free Software
|
||||||
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This code is part of Secret Rabibt Code aka libsamplerate. A commercial
|
||||||
|
** use license for this code is available, please see:
|
||||||
|
** http://www.mega-nerd.com/SRC/procedure.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "float_cast.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
static int linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
|
||||||
|
static void linear_reset (SRC_PRIVATE *psrc) ;
|
||||||
|
|
||||||
|
/*========================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LINEAR_MAGIC_MARKER MAKE_MAGIC ('l', 'i', 'n', 'e', 'a', 'r')
|
||||||
|
|
||||||
|
#define SRC_DEBUG 0
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{ int linear_magic_marker ;
|
||||||
|
int channels ;
|
||||||
|
int reset ;
|
||||||
|
long in_count, in_used ;
|
||||||
|
long out_count, out_gen ;
|
||||||
|
float last_value [1] ;
|
||||||
|
} LINEAR_DATA ;
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
|
||||||
|
{ LINEAR_DATA *priv ;
|
||||||
|
double src_ratio, input_index, rem ;
|
||||||
|
int ch ;
|
||||||
|
|
||||||
|
if (psrc->private_data == NULL)
|
||||||
|
return SRC_ERR_NO_PRIVATE ;
|
||||||
|
|
||||||
|
priv = (LINEAR_DATA*) psrc->private_data ;
|
||||||
|
|
||||||
|
if (priv->reset)
|
||||||
|
{ /* If we have just been reset, set the last_value data. */
|
||||||
|
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||||
|
priv->last_value [ch] = data->data_in [ch] ;
|
||||||
|
priv->reset = 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
priv->in_count = data->input_frames * priv->channels ;
|
||||||
|
priv->out_count = data->output_frames * priv->channels ;
|
||||||
|
priv->in_used = priv->out_gen = 0 ;
|
||||||
|
|
||||||
|
src_ratio = psrc->last_ratio ;
|
||||||
|
input_index = psrc->last_position ;
|
||||||
|
|
||||||
|
/* Calculate samples before first sample in input array. */
|
||||||
|
while (input_index < 1.0 && priv->out_gen < priv->out_count)
|
||||||
|
{
|
||||||
|
if (priv->in_used + priv->channels * (1.0 + input_index) >= priv->in_count)
|
||||||
|
break ;
|
||||||
|
|
||||||
|
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||||
|
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
|
||||||
|
|
||||||
|
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||||
|
{ data->data_out [priv->out_gen] = (float) (priv->last_value [ch] + input_index *
|
||||||
|
(data->data_in [ch] - priv->last_value [ch])) ;
|
||||||
|
priv->out_gen ++ ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/* Figure out the next index. */
|
||||||
|
input_index += 1.0 / src_ratio ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
rem = fmod_one (input_index) ;
|
||||||
|
priv->in_used += priv->channels * lrint (input_index - rem) ;
|
||||||
|
input_index = rem ;
|
||||||
|
|
||||||
|
/* Main processing loop. */
|
||||||
|
while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index < priv->in_count)
|
||||||
|
{
|
||||||
|
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||||
|
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
|
||||||
|
|
||||||
|
if (SRC_DEBUG && priv->in_used < priv->channels && input_index < 1.0)
|
||||||
|
{ printf ("Whoops!!!! in_used : %ld channels : %d input_index : %f\n", priv->in_used, priv->channels, input_index) ;
|
||||||
|
exit (1) ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||||
|
{ data->data_out [priv->out_gen] = (float) (data->data_in [priv->in_used - priv->channels + ch] + input_index *
|
||||||
|
(data->data_in [priv->in_used + ch] - data->data_in [priv->in_used - priv->channels + ch])) ;
|
||||||
|
priv->out_gen ++ ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/* Figure out the next index. */
|
||||||
|
input_index += 1.0 / src_ratio ;
|
||||||
|
rem = fmod_one (input_index) ;
|
||||||
|
|
||||||
|
priv->in_used += priv->channels * lrint (input_index - rem) ;
|
||||||
|
input_index = rem ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
if (priv->in_used > priv->in_count)
|
||||||
|
{ input_index += (priv->in_used - priv->in_count) / priv->channels ;
|
||||||
|
priv->in_used = priv->in_count ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
psrc->last_position = input_index ;
|
||||||
|
|
||||||
|
if (priv->in_used > 0)
|
||||||
|
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||||
|
priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ;
|
||||||
|
|
||||||
|
/* Save current ratio rather then target ratio. */
|
||||||
|
psrc->last_ratio = src_ratio ;
|
||||||
|
|
||||||
|
data->input_frames_used = priv->in_used / priv->channels ;
|
||||||
|
data->output_frames_gen = priv->out_gen / priv->channels ;
|
||||||
|
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
} /* linear_vari_process */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
const char*
|
||||||
|
linear_get_name (int src_enum)
|
||||||
|
{
|
||||||
|
if (src_enum == SRC_LINEAR)
|
||||||
|
return "Linear Interpolator" ;
|
||||||
|
|
||||||
|
return NULL ;
|
||||||
|
} /* linear_get_name */
|
||||||
|
|
||||||
|
const char*
|
||||||
|
linear_get_description (int src_enum)
|
||||||
|
{
|
||||||
|
if (src_enum == SRC_LINEAR)
|
||||||
|
return "Linear interpolator, very fast, poor quality." ;
|
||||||
|
|
||||||
|
return NULL ;
|
||||||
|
} /* linear_get_descrition */
|
||||||
|
|
||||||
|
int
|
||||||
|
linear_set_converter (SRC_PRIVATE *psrc, int src_enum)
|
||||||
|
{ LINEAR_DATA *priv = NULL ;
|
||||||
|
|
||||||
|
if (src_enum != SRC_LINEAR)
|
||||||
|
return SRC_ERR_BAD_CONVERTER ;
|
||||||
|
|
||||||
|
if (psrc->private_data != NULL)
|
||||||
|
{ free (psrc->private_data) ;
|
||||||
|
psrc->private_data = NULL ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
if (psrc->private_data == NULL)
|
||||||
|
{ priv = calloc (1, sizeof (*priv) + psrc->channels * sizeof (float)) ;
|
||||||
|
if (priv == NULL)
|
||||||
|
return SRC_ERR_MALLOC_FAILED ;
|
||||||
|
psrc->private_data = priv ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
priv->linear_magic_marker = LINEAR_MAGIC_MARKER ;
|
||||||
|
priv->channels = psrc->channels ;
|
||||||
|
|
||||||
|
psrc->const_process = linear_vari_process ;
|
||||||
|
psrc->vari_process = linear_vari_process ;
|
||||||
|
psrc->reset = linear_reset ;
|
||||||
|
|
||||||
|
linear_reset (psrc) ;
|
||||||
|
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
} /* linear_set_converter */
|
||||||
|
|
||||||
|
/*===================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
linear_reset (SRC_PRIVATE *psrc)
|
||||||
|
{ LINEAR_DATA *priv = NULL ;
|
||||||
|
|
||||||
|
priv = (LINEAR_DATA*) psrc->private_data ;
|
||||||
|
if (priv == NULL)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
priv->channels = psrc->channels ;
|
||||||
|
priv->reset = 1 ;
|
||||||
|
memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ;
|
||||||
|
|
||||||
|
return ;
|
||||||
|
} /* linear_reset */
|
||||||
|
|
1206
reactos/lib/3rdparty/libsamplerate/src_sinc.c
vendored
Normal file
1206
reactos/lib/3rdparty/libsamplerate/src_sinc.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
208
reactos/lib/3rdparty/libsamplerate/src_zoh.c
vendored
Normal file
208
reactos/lib/3rdparty/libsamplerate/src_zoh.c
vendored
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
/*
|
||||||
|
** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation; either version 2 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with this program; if not, write to the Free Software
|
||||||
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This code is part of Secret Rabibt Code aka libsamplerate. A commercial
|
||||||
|
** use license for this code is available, please see:
|
||||||
|
** http://www.mega-nerd.com/SRC/procedure.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "float_cast.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
static int zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
|
||||||
|
static void zoh_reset (SRC_PRIVATE *psrc) ;
|
||||||
|
|
||||||
|
/*========================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ZOH_MAGIC_MARKER MAKE_MAGIC ('s', 'r', 'c', 'z', 'o', 'h')
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{ int zoh_magic_marker ;
|
||||||
|
int channels ;
|
||||||
|
int reset ;
|
||||||
|
long in_count, in_used ;
|
||||||
|
long out_count, out_gen ;
|
||||||
|
float last_value [1] ;
|
||||||
|
} ZOH_DATA ;
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data)
|
||||||
|
{ ZOH_DATA *priv ;
|
||||||
|
double src_ratio, input_index, rem ;
|
||||||
|
int ch ;
|
||||||
|
|
||||||
|
if (psrc->private_data == NULL)
|
||||||
|
return SRC_ERR_NO_PRIVATE ;
|
||||||
|
|
||||||
|
priv = (ZOH_DATA*) psrc->private_data ;
|
||||||
|
|
||||||
|
if (priv->reset)
|
||||||
|
{ /* If we have just been reset, set the last_value data. */
|
||||||
|
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||||
|
priv->last_value [ch] = data->data_in [ch] ;
|
||||||
|
priv->reset = 0 ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
priv->in_count = data->input_frames * priv->channels ;
|
||||||
|
priv->out_count = data->output_frames * priv->channels ;
|
||||||
|
priv->in_used = priv->out_gen = 0 ;
|
||||||
|
|
||||||
|
src_ratio = psrc->last_ratio ;
|
||||||
|
input_index = psrc->last_position ;
|
||||||
|
|
||||||
|
/* Calculate samples before first sample in input array. */
|
||||||
|
while (input_index < 1.0 && priv->out_gen < priv->out_count)
|
||||||
|
{
|
||||||
|
if (priv->in_used + priv->channels * input_index >= priv->in_count)
|
||||||
|
break ;
|
||||||
|
|
||||||
|
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||||
|
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
|
||||||
|
|
||||||
|
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||||
|
{ data->data_out [priv->out_gen] = priv->last_value [ch] ;
|
||||||
|
priv->out_gen ++ ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/* Figure out the next index. */
|
||||||
|
input_index += 1.0 / src_ratio ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
rem = fmod_one (input_index) ;
|
||||||
|
priv->in_used += priv->channels * lrint (input_index - rem) ;
|
||||||
|
input_index = rem ;
|
||||||
|
|
||||||
|
/* Main processing loop. */
|
||||||
|
while (priv->out_gen < priv->out_count && priv->in_used + priv->channels * input_index <= priv->in_count)
|
||||||
|
{
|
||||||
|
if (priv->out_count > 0 && fabs (psrc->last_ratio - data->src_ratio) > SRC_MIN_RATIO_DIFF)
|
||||||
|
src_ratio = psrc->last_ratio + priv->out_gen * (data->src_ratio - psrc->last_ratio) / priv->out_count ;
|
||||||
|
|
||||||
|
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||||
|
{ data->data_out [priv->out_gen] = data->data_in [priv->in_used - priv->channels + ch] ;
|
||||||
|
priv->out_gen ++ ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/* Figure out the next index. */
|
||||||
|
input_index += 1.0 / src_ratio ;
|
||||||
|
rem = fmod_one (input_index) ;
|
||||||
|
|
||||||
|
priv->in_used += priv->channels * lrint (input_index - rem) ;
|
||||||
|
input_index = rem ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
if (priv->in_used > priv->in_count)
|
||||||
|
{ input_index += (priv->in_used - priv->in_count) / priv->channels ;
|
||||||
|
priv->in_used = priv->in_count ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
psrc->last_position = input_index ;
|
||||||
|
|
||||||
|
if (priv->in_used > 0)
|
||||||
|
for (ch = 0 ; ch < priv->channels ; ch++)
|
||||||
|
priv->last_value [ch] = data->data_in [priv->in_used - priv->channels + ch] ;
|
||||||
|
|
||||||
|
/* Save current ratio rather then target ratio. */
|
||||||
|
psrc->last_ratio = src_ratio ;
|
||||||
|
|
||||||
|
data->input_frames_used = priv->in_used / priv->channels ;
|
||||||
|
data->output_frames_gen = priv->out_gen / priv->channels ;
|
||||||
|
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
} /* zoh_vari_process */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
const char*
|
||||||
|
zoh_get_name (int src_enum)
|
||||||
|
{
|
||||||
|
if (src_enum == SRC_ZERO_ORDER_HOLD)
|
||||||
|
return "ZOH Interpolator" ;
|
||||||
|
|
||||||
|
return NULL ;
|
||||||
|
} /* zoh_get_name */
|
||||||
|
|
||||||
|
const char*
|
||||||
|
zoh_get_description (int src_enum)
|
||||||
|
{
|
||||||
|
if (src_enum == SRC_ZERO_ORDER_HOLD)
|
||||||
|
return "Zero order hold interpolator, very fast, poor quality." ;
|
||||||
|
|
||||||
|
return NULL ;
|
||||||
|
} /* zoh_get_descrition */
|
||||||
|
|
||||||
|
int
|
||||||
|
zoh_set_converter (SRC_PRIVATE *psrc, int src_enum)
|
||||||
|
{ ZOH_DATA *priv = NULL ;
|
||||||
|
|
||||||
|
if (src_enum != SRC_ZERO_ORDER_HOLD)
|
||||||
|
return SRC_ERR_BAD_CONVERTER ;
|
||||||
|
|
||||||
|
if (psrc->private_data != NULL)
|
||||||
|
{ free (psrc->private_data) ;
|
||||||
|
psrc->private_data = NULL ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
if (psrc->private_data == NULL)
|
||||||
|
{ priv = calloc (1, sizeof (*priv) + psrc->channels * sizeof (float)) ;
|
||||||
|
if (priv == NULL)
|
||||||
|
return SRC_ERR_MALLOC_FAILED ;
|
||||||
|
psrc->private_data = priv ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
priv->zoh_magic_marker = ZOH_MAGIC_MARKER ;
|
||||||
|
priv->channels = psrc->channels ;
|
||||||
|
|
||||||
|
psrc->const_process = zoh_vari_process ;
|
||||||
|
psrc->vari_process = zoh_vari_process ;
|
||||||
|
psrc->reset = zoh_reset ;
|
||||||
|
|
||||||
|
zoh_reset (psrc) ;
|
||||||
|
|
||||||
|
return SRC_ERR_NO_ERROR ;
|
||||||
|
} /* zoh_set_converter */
|
||||||
|
|
||||||
|
/*===================================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
zoh_reset (SRC_PRIVATE *psrc)
|
||||||
|
{ ZOH_DATA *priv ;
|
||||||
|
|
||||||
|
priv = (ZOH_DATA*) psrc->private_data ;
|
||||||
|
if (priv == NULL)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
priv->channels = psrc->channels ;
|
||||||
|
priv->reset = 1 ;
|
||||||
|
memset (priv->last_value, 0, sizeof (priv->last_value [0]) * priv->channels) ;
|
||||||
|
|
||||||
|
return ;
|
||||||
|
} /* zoh_reset */
|
||||||
|
|
22
reactos/lib/3rdparty/libsamplerate/unistd.h
vendored
Normal file
22
reactos/lib/3rdparty/libsamplerate/unistd.h
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
** Copyright (C) 2002 Erik de Castro Lopo <erikd@zip.com.au>
|
||||||
|
**
|
||||||
|
** This program is free software; you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
** the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** This program is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU Lesser General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU Lesser General Public License
|
||||||
|
** along with this program; if not, write to the Free Software
|
||||||
|
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Emtpy file to prevent Win32 compiler from complaining that the
|
||||||
|
** file doesn't exist.
|
||||||
|
*/
|
Loading…
Add table
Add a link
Reference in a new issue