From 5a6cc15e68593cdd71eb7f5d08173518601e580b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 21 Mar 2007 12:20:04 +0100 Subject: Update version of speex resampler plugin From: Jean-Marc Valin I'm attaching an updated version of my resampler plugin. It fixes a few minor issues and it adds support for fixed-point processing (just add -DFIXED_POINT to the build). Let me know if there's any problem. --- pph/speex_resampler.h | 78 +++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 36 deletions(-) (limited to 'pph/speex_resampler.h') diff --git a/pph/speex_resampler.h b/pph/speex_resampler.h index 8ba6790..1499ce0 100644 --- a/pph/speex_resampler.h +++ b/pph/speex_resampler.h @@ -46,7 +46,7 @@ /* If the resampler is defined outside of Speex, we change the symbol names so that there won't be any clash if linking with Speex later on. */ -#define RANDOM_PREFIX ALSA_PUBLIC_PARROT_HACK_PLUGIN +/* #define RANDOM_PREFIX your software name here */ #ifndef RANDOM_PREFIX #error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes" #endif @@ -75,10 +75,15 @@ #define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem) #define spx_int16_t short +#define spx_int32_t int +#define spx_uint16_t unsigned short +#define spx_uint32_t unsigned int +#if 0 #ifdef FIXED_POINT -#define spx_word16_t short -#define spx_word32_t int +/*#define spx_word16_t spx_int16_t +#define spx_word32_t spx_int32_t*/ +#include "arch.h" #else /* FIXED_POINT */ @@ -88,7 +93,8 @@ #define MULT16_32_Q15(a,b) ((a)*(b)) #define PSHR32(a,b) (a) #endif /* FIXED_POINT */ - +#endif + #else /* OUTSIDE_SPEEX */ #include "speex/speex_types.h" @@ -117,9 +123,9 @@ typedef struct SpeexResamplerState_ SpeexResamplerState; * @return Newly created resampler state * @retval NULL Error: not enough memory */ -SpeexResamplerState *speex_resampler_init(int nb_channels, - int in_rate, - int out_rate, +SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, + spx_uint32_t in_rate, + spx_uint32_t out_rate, int quality); /** Create a new resampler with fractional input/output rates. The sampling @@ -135,11 +141,11 @@ SpeexResamplerState *speex_resampler_init(int nb_channels, * @return Newly created resampler state * @retval NULL Error: not enough memory */ -SpeexResamplerState *speex_resampler_init_frac(int nb_channels, - int ratio_num, - int ratio_den, - int in_rate, - int out_rate, +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); /** Destroy a resampler state. @@ -158,11 +164,11 @@ void speex_resampler_destroy(SpeexResamplerState *st); * @param out_len Size of the output buffer. Returns the number of samples written */ void speex_resampler_process_float(SpeexResamplerState *st, - int channel_index, + spx_uint32_t channel_index, const float *in, - int *in_len, + spx_uint32_t *in_len, float *out, - int *out_len); + spx_uint32_t *out_len); /** Resample an int array. The input and output buffers must *not* overlap. * @param st Resampler state @@ -175,11 +181,11 @@ void speex_resampler_process_float(SpeexResamplerState *st, * @param out_len Size of the output buffer. Returns the number of samples written */ void speex_resampler_process_int(SpeexResamplerState *st, - int channel_index, + spx_uint32_t channel_index, const spx_int16_t *in, - int *in_len, + spx_uint32_t *in_len, spx_int16_t *out, - int *out_len); + spx_uint32_t *out_len); /** Resample an interleaved float array. The input and output buffers must *not* overlap. * @param st Resampler state @@ -192,9 +198,9 @@ void speex_resampler_process_int(SpeexResamplerState *st, */ void speex_resampler_process_interleaved_float(SpeexResamplerState *st, const float *in, - int *in_len, + spx_uint32_t *in_len, float *out, - int *out_len); + spx_uint32_t *out_len); /** Resample an interleaved int array. The input and output buffers must *not* overlap. * @param st Resampler state @@ -207,9 +213,9 @@ void speex_resampler_process_interleaved_float(SpeexResamplerState *st, */ void speex_resampler_process_interleaved_int(SpeexResamplerState *st, const spx_int16_t *in, - int *in_len, + spx_uint32_t *in_len, spx_int16_t *out, - int *out_len); + spx_uint32_t *out_len); /** Set (change) the input/output sampling rates (integer value). * @param st Resampler state @@ -217,8 +223,8 @@ void speex_resampler_process_interleaved_int(SpeexResamplerState *st, * @param out_rate Output sampling rate (integer number of Hz). */ void speex_resampler_set_rate(SpeexResamplerState *st, - int in_rate, - int 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 @@ -226,8 +232,8 @@ void speex_resampler_set_rate(SpeexResamplerState *st, * @param out_rate Output sampling rate (integer number of Hz) copied. */ void speex_resampler_get_rate(SpeexResamplerState *st, - int *in_rate, - int *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). @@ -238,10 +244,10 @@ void speex_resampler_get_rate(SpeexResamplerState *st, * @param out_rate Output sampling rate rounded to the nearest integer (in Hz). */ void speex_resampler_set_rate_frac(SpeexResamplerState *st, - int ratio_num, - int ratio_den, - int in_rate, - int out_rate); + spx_uint32_t ratio_num, + 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. @@ -250,8 +256,8 @@ void speex_resampler_set_rate_frac(SpeexResamplerState *st, * @param ratio_den Denominator of the sampling rate ratio copied */ void speex_resampler_get_ratio(SpeexResamplerState *st, - int *ratio_num, - int *ratio_den); + spx_uint32_t *ratio_num, + spx_uint32_t *ratio_den); /** Set (change) the conversion quality. * @param st Resampler state @@ -274,28 +280,28 @@ void speex_resampler_get_quality(SpeexResamplerState *st, * @param stride Input stride */ void speex_resampler_set_input_stride(SpeexResamplerState *st, - int stride); + spx_uint32_t stride); /** Get the input stride. * @param st Resampler state * @param stride Input stride copied */ void speex_resampler_get_input_stride(SpeexResamplerState *st, - int *stride); + spx_uint32_t *stride); /** Set (change) the output stride. * @param st Resampler state * @param stride Output stride */ void speex_resample_set_output_stride(SpeexResamplerState *st, - int stride); + spx_uint32_t stride); /** Get the output stride. * @param st Resampler state copied * @param stride Output stride */ void speex_resample_get_output_stride(SpeexResamplerState *st, - int *stride); + spx_uint32_t *stride); /** Make sure that the first samples to go out of the resamplers don't have * leading zeros. This is only useful before starting to use a newly created -- cgit