From 12766882b5d6ffcb8c48f2fa0a1f19ab17c05077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 30 Oct 2008 12:43:44 +0000 Subject: Add support for double samples as input and refactor the usage of the different compilation flavors of the speex resa... Original commit message from CVS: * gst/speexresample/Makefile.am: * gst/speexresample/arch.h: * gst/speexresample/gstspeexresample.c: (gst_speex_resample_stop), (gst_speex_resample_get_unit_size), (gst_speex_resample_get_funcs), (gst_speex_resample_init_state), (gst_speex_resample_update_state), (gst_speex_resample_reset_state), (gst_speex_resample_parse_caps), (_gcd), (gst_speex_resample_transform_size), (gst_speex_resample_set_caps), (gst_speex_resample_push_drain), (gst_speex_resample_process), (gst_speex_resample_transform), (gst_speex_resample_query), (gst_speex_resample_set_property): * gst/speexresample/gstspeexresample.h: * gst/speexresample/resample.c: * gst/speexresample/speex_resampler.h: * gst/speexresample/speex_resampler_double.c: * gst/speexresample/speex_resampler_wrapper.h: * tests/check/elements/speexresample.c: (setup_speexresample), (test_perfect_stream_instance), (GST_START_TEST), (test_discont_stream_instance): Add support for double samples as input and refactor the usage of the different compilation flavors of the speex resampler. --- gst/speexresample/speex_resampler_wrapper.h | 125 ++++++++++++++++++++++------ 1 file changed, 98 insertions(+), 27 deletions(-) (limited to 'gst/speexresample/speex_resampler_wrapper.h') diff --git a/gst/speexresample/speex_resampler_wrapper.h b/gst/speexresample/speex_resampler_wrapper.h index 6d7c17d0..6f3fba9b 100644 --- a/gst/speexresample/speex_resampler_wrapper.h +++ b/gst/speexresample/speex_resampler_wrapper.h @@ -39,48 +39,119 @@ enum typedef struct SpeexResamplerState_ SpeexResamplerState; -SpeexResamplerState *resample_float_resampler_init (guint32 nb_channels, - guint32 in_rate, guint32 out_rate, gint quality, gint * err); -SpeexResamplerState *resample_int_resampler_init (guint32 nb_channels, +typedef struct { + SpeexResamplerState *(*init) (guint32 nb_channels, guint32 in_rate, guint32 out_rate, gint quality, gint * err); + void (*destroy) (SpeexResamplerState * st); + int (*process) (SpeexResamplerState * + st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len); + int (*set_rate) (SpeexResamplerState * st, + guint32 in_rate, guint32 out_rate); + void (*get_rate) (SpeexResamplerState * st, + guint32 * in_rate, guint32 * out_rate); + void (*get_ratio) (SpeexResamplerState * st, + guint32 * ratio_num, guint32 * ratio_den); + int (*get_input_latency) (SpeexResamplerState * st); + int (*set_quality) (SpeexResamplerState * st, gint quality); + int (*reset_mem) (SpeexResamplerState * st); + int (*skip_zeros) (SpeexResamplerState * st); + const char * (*strerror) (gint err); +} SpeexResampleFuncs; -#define resample_resampler_destroy resample_int_resampler_destroy -void resample_resampler_destroy (SpeexResamplerState * st); - +SpeexResamplerState *resample_float_resampler_init (guint32 nb_channels, + guint32 in_rate, guint32 out_rate, gint quality, gint * err); +void resample_float_resampler_destroy (SpeexResamplerState * st); int resample_float_resampler_process_interleaved_float (SpeexResamplerState * - st, const gfloat * in, guint32 * in_len, gfloat * out, guint32 * out_len); -int resample_int_resampler_process_interleaved_int (SpeexResamplerState * st, - const gint16 * in, guint32 * in_len, gint16 * out, guint32 * out_len); - + st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len); int resample_float_resampler_set_rate (SpeexResamplerState * st, guint32 in_rate, guint32 out_rate); -int resample_int_resampler_set_rate (SpeexResamplerState * st, - guint32 in_rate, guint32 out_rate); - void resample_float_resampler_get_rate (SpeexResamplerState * st, guint32 * in_rate, guint32 * out_rate); -void resample_int_resampler_get_rate (SpeexResamplerState * st, - guint32 * in_rate, guint32 * out_rate); - void resample_float_resampler_get_ratio (SpeexResamplerState * st, guint32 * ratio_num, guint32 * ratio_den); -void resample_int_resampler_get_ratio (SpeexResamplerState * st, +int resample_float_resampler_get_input_latency (SpeexResamplerState * st); +int resample_float_resampler_set_quality (SpeexResamplerState * st, gint quality); +int resample_float_resampler_reset_mem (SpeexResamplerState * st); +int resample_float_resampler_skip_zeros (SpeexResamplerState * st); +const char * resample_float_resampler_strerror (gint err); + +static const SpeexResampleFuncs float_funcs = +{ + resample_float_resampler_init, + resample_float_resampler_destroy, + resample_float_resampler_process_interleaved_float, + resample_float_resampler_set_rate, + resample_float_resampler_get_rate, + resample_float_resampler_get_ratio, + resample_float_resampler_get_input_latency, + resample_float_resampler_set_quality, + resample_float_resampler_reset_mem, + resample_float_resampler_skip_zeros, + resample_float_resampler_strerror +}; + +SpeexResamplerState *resample_double_resampler_init (guint32 nb_channels, + guint32 in_rate, guint32 out_rate, gint quality, gint * err); +void resample_double_resampler_destroy (SpeexResamplerState * st); +int resample_double_resampler_process_interleaved_float (SpeexResamplerState * + st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len); +int resample_double_resampler_set_rate (SpeexResamplerState * st, + guint32 in_rate, guint32 out_rate); +void resample_double_resampler_get_rate (SpeexResamplerState * st, + guint32 * in_rate, guint32 * out_rate); +void resample_double_resampler_get_ratio (SpeexResamplerState * st, guint32 * ratio_num, guint32 * ratio_den); +int resample_double_resampler_get_input_latency (SpeexResamplerState * st); +int resample_double_resampler_set_quality (SpeexResamplerState * st, gint quality); +int resample_double_resampler_reset_mem (SpeexResamplerState * st); +int resample_double_resampler_skip_zeros (SpeexResamplerState * st); +const char * resample_double_resampler_strerror (gint err); -int resample_float_resampler_get_input_latency (SpeexResamplerState * st); -int resample_int_resampler_get_input_latency (SpeexResamplerState * st); +static const SpeexResampleFuncs double_funcs = +{ + resample_double_resampler_init, + resample_double_resampler_destroy, + resample_double_resampler_process_interleaved_float, + resample_double_resampler_set_rate, + resample_double_resampler_get_rate, + resample_double_resampler_get_ratio, + resample_double_resampler_get_input_latency, + resample_double_resampler_set_quality, + resample_double_resampler_reset_mem, + resample_double_resampler_skip_zeros, + resample_double_resampler_strerror +}; -int resample_float_resampler_set_quality (SpeexResamplerState * st, - gint quality); +SpeexResamplerState *resample_int_resampler_init (guint32 nb_channels, + guint32 in_rate, guint32 out_rate, gint quality, gint * err); +void resample_int_resampler_destroy (SpeexResamplerState * st); +int resample_int_resampler_process_interleaved_int (SpeexResamplerState * + st, const guint8 * in, guint32 * in_len, guint8 * out, guint32 * out_len); +int resample_int_resampler_set_rate (SpeexResamplerState * st, + guint32 in_rate, guint32 out_rate); +void resample_int_resampler_get_rate (SpeexResamplerState * st, + guint32 * in_rate, guint32 * out_rate); +void resample_int_resampler_get_ratio (SpeexResamplerState * st, + guint32 * ratio_num, guint32 * ratio_den); +int resample_int_resampler_get_input_latency (SpeexResamplerState * st); int resample_int_resampler_set_quality (SpeexResamplerState * st, gint quality); - -int resample_float_resampler_reset_mem (SpeexResamplerState * st); int resample_int_resampler_reset_mem (SpeexResamplerState * st); - -int resample_float_resampler_skip_zeros (SpeexResamplerState * st); int resample_int_resampler_skip_zeros (SpeexResamplerState * st); +const char * resample_int_resampler_strerror (gint err); -#define resample_resampler_strerror resample_int_resampler_strerror -const char *resample_resampler_strerror (gint err); +static const SpeexResampleFuncs int_funcs = +{ + resample_int_resampler_init, + resample_int_resampler_destroy, + resample_int_resampler_process_interleaved_int, + resample_int_resampler_set_rate, + resample_int_resampler_get_rate, + resample_int_resampler_get_ratio, + resample_int_resampler_get_input_latency, + resample_int_resampler_set_quality, + resample_int_resampler_reset_mem, + resample_int_resampler_skip_zeros, + resample_int_resampler_strerror +}; #endif /* __SPEEX_RESAMPLER_WRAPPER_H__ */ -- cgit v1.2.1