mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
gst/speexresample/: Update speex resampler to latest SVN. We're now down to only the changes noted in README again.
Original commit message from CVS: * gst/speexresample/README: * gst/speexresample/arch.h: * gst/speexresample/resample.c: (resampler_basic_direct_single), (resampler_basic_direct_double), (resampler_basic_interpolate_single), (resampler_basic_interpolate_double), (speex_resampler_process_native), (speex_resampler_process_float), (speex_resampler_process_int), (speex_resampler_process_interleaved_float), (speex_resampler_process_interleaved_int), (speex_resampler_get_input_latency), (speex_resampler_get_output_latency): * gst/speexresample/speex_resampler.h: Update speex resampler to latest SVN. We're now down to only the changes noted in README again. * gst/speexresample/speex_resampler_wrapper.h: * gst/speexresample/gstspeexresample.c: (gst_speex_resample_push_drain), (gst_speex_resample_query): Adjust to API changes.
This commit is contained in:
parent
67d4bcd555
commit
d222cb6c14
7 changed files with 171 additions and 268 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2007-11-26 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* gst/speexresample/README:
|
||||
* gst/speexresample/arch.h:
|
||||
* gst/speexresample/resample.c: (resampler_basic_direct_single),
|
||||
(resampler_basic_direct_double),
|
||||
(resampler_basic_interpolate_single),
|
||||
(resampler_basic_interpolate_double),
|
||||
(speex_resampler_process_native), (speex_resampler_process_float),
|
||||
(speex_resampler_process_int),
|
||||
(speex_resampler_process_interleaved_float),
|
||||
(speex_resampler_process_interleaved_int),
|
||||
(speex_resampler_get_input_latency),
|
||||
(speex_resampler_get_output_latency):
|
||||
* gst/speexresample/speex_resampler.h:
|
||||
Update speex resampler to latest SVN. We're now down to only the
|
||||
changes noted in README again.
|
||||
|
||||
* gst/speexresample/speex_resampler_wrapper.h:
|
||||
* gst/speexresample/gstspeexresample.c:
|
||||
(gst_speex_resample_push_drain), (gst_speex_resample_query):
|
||||
Adjust to API changes.
|
||||
|
||||
2007-11-25 Edward Hervey <bilboed@bilboed.com>
|
||||
|
||||
* gst/flv/gstflvparse.c: (gst_flv_parse_tag_audio),
|
||||
|
|
|
@ -3,7 +3,7 @@ arch.h
|
|||
fixed_generic.h
|
||||
speex_resampler.h
|
||||
|
||||
are taken from http://svn.xiph.org/trunk/speex/ revision 14208.
|
||||
are taken from http://svn.xiph.org/trunk/speex/ revision 14232.
|
||||
|
||||
The only changes are:
|
||||
|
||||
|
@ -46,9 +46,9 @@ The only changes are:
|
|||
|
||||
#else /* OUTSIDE_SPEEX */
|
||||
|
||||
--- speex/libspeex/resample.c 2007-11-21 11:07:32.000000000 +0100
|
||||
+++ speexresample/resample.c 2007-11-21 11:15:09.000000000 +0100
|
||||
@@ -62,20 +62,22 @@
|
||||
--- speex/libspeex/resample.c 2007-11-25 14:15:38.000000000 +0100
|
||||
+++ speexresample/resample.c 2007-11-25 14:15:31.000000000 +0100
|
||||
@@ -62,20 +62,23 @@
|
||||
|
||||
#ifdef OUTSIDE_SPEEX
|
||||
#include <stdlib.h>
|
||||
|
@ -69,6 +69,7 @@ The only changes are:
|
|||
+ return g_realloc (ptr, size);
|
||||
}
|
||||
-static void
|
||||
+
|
||||
+static inline void
|
||||
speex_free (void *ptr)
|
||||
{
|
||||
|
@ -77,4 +78,3 @@ The only changes are:
|
|||
}
|
||||
|
||||
#include "speex_resampler.h"
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
|
||||
#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */
|
||||
#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
|
||||
#define SPEEX_VERSION "speex-1.2beta3" /**< Speex version string. */
|
||||
#define SPEEX_VERSION "speex-1.2beta4" /**< Speex version string. */
|
||||
#endif
|
||||
|
||||
/* A couple test to catch stupid option combinations */
|
||||
|
@ -127,8 +127,6 @@ typedef spx_word32_t spx_sig_t;
|
|||
#include "fixed_arm5e.h"
|
||||
#elif defined (ARM4_ASM)
|
||||
#include "fixed_arm4.h"
|
||||
#elif defined (ARM5E_ASM)
|
||||
#include "fixed_arm5e.h"
|
||||
#elif defined (BFIN_ASM)
|
||||
#include "fixed_bfin.h"
|
||||
#endif
|
||||
|
|
|
@ -524,7 +524,7 @@ gst_speex_resample_push_drain (GstSpeexResample * resample)
|
|||
|
||||
resample_float_resampler_get_ratio (resample->state, &num, &den);
|
||||
|
||||
out_len = resample_float_resampler_get_latency (resample->state);
|
||||
out_len = resample_float_resampler_get_input_latency (resample->state);
|
||||
out_len = out_processed = (out_len * den + (num >> 1)) / num;
|
||||
outsize = 4 * out_len * resample->channels;
|
||||
} else {
|
||||
|
@ -532,7 +532,7 @@ gst_speex_resample_push_drain (GstSpeexResample * resample)
|
|||
|
||||
resample_int_resampler_get_ratio (resample->state, &num, &den);
|
||||
|
||||
out_len = resample_int_resampler_get_latency (resample->state);
|
||||
out_len = resample_int_resampler_get_input_latency (resample->state);
|
||||
out_len = out_processed = (out_len * den + (num >> 1)) / num;
|
||||
outsize = 2 * out_len * resample->channels;
|
||||
}
|
||||
|
@ -545,12 +545,19 @@ gst_speex_resample_push_drain (GstSpeexResample * resample)
|
|||
return;
|
||||
}
|
||||
|
||||
if (resample->fp)
|
||||
err = resample_float_resampler_drain_interleaved_float (resample->state,
|
||||
(gfloat *) GST_BUFFER_DATA (buf), &out_processed);
|
||||
else
|
||||
err = resample_int_resampler_drain_interleaved_int (resample->state,
|
||||
(gint16 *) GST_BUFFER_DATA (buf), &out_processed);
|
||||
if (resample->fp) {
|
||||
guint len = resample_float_resampler_get_input_latency (resample->state);
|
||||
|
||||
err =
|
||||
resample_float_resampler_process_interleaved_float (resample->state,
|
||||
NULL, &len, (gfloat *) GST_BUFFER_DATA (buf), &out_processed);
|
||||
} else {
|
||||
guint len = resample_int_resampler_get_input_latency (resample->state);
|
||||
|
||||
err =
|
||||
resample_int_resampler_process_interleaved_int (resample->state, NULL,
|
||||
&len, (gint16 *) GST_BUFFER_DATA (buf), &out_processed);
|
||||
}
|
||||
|
||||
if (err != RESAMPLER_ERR_SUCCESS) {
|
||||
GST_WARNING ("Failed to process drain: %s",
|
||||
|
@ -866,10 +873,10 @@ gst_speex_resample_query (GstPad * pad, GstQuery * query)
|
|||
|
||||
if (resample->state && resample->fp)
|
||||
resampler_latency =
|
||||
resample_float_resampler_get_latency (resample->state);
|
||||
resample_float_resampler_get_input_latency (resample->state);
|
||||
else if (resample->state && !resample->fp)
|
||||
resampler_latency =
|
||||
resample_int_resampler_get_latency (resample->state);
|
||||
resample_int_resampler_get_input_latency (resample->state);
|
||||
else
|
||||
resampler_latency = 0;
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ speex_realloc (void *ptr, int size)
|
|||
{
|
||||
return g_realloc (ptr, size);
|
||||
}
|
||||
|
||||
static inline void
|
||||
speex_free (void *ptr)
|
||||
{
|
||||
|
@ -395,10 +396,13 @@ resampler_basic_direct_single (SpeexResamplerState * st,
|
|||
}
|
||||
|
||||
/* Do the new part */
|
||||
ptr = in + st->in_stride * (last_sample - N + 1 + j);
|
||||
for (; j < N; j++) {
|
||||
sum += MULT16_16 (*ptr, st->sinc_table[samp_frac_num * st->filt_len + j]);
|
||||
ptr += st->in_stride;
|
||||
if (in != NULL) {
|
||||
ptr = in + st->in_stride * (last_sample - N + 1 + j);
|
||||
for (; j < N; j++) {
|
||||
sum +=
|
||||
MULT16_16 (*ptr, st->sinc_table[samp_frac_num * st->filt_len + j]);
|
||||
ptr += st->in_stride;
|
||||
}
|
||||
}
|
||||
|
||||
*out = PSHR32 (sum, 15);
|
||||
|
@ -447,12 +451,14 @@ resampler_basic_direct_double (SpeexResamplerState * st,
|
|||
}
|
||||
|
||||
/* Do the new part */
|
||||
ptr = in + st->in_stride * (last_sample - N + 1 + j);
|
||||
for (; j < N; j++) {
|
||||
sum +=
|
||||
MULT16_16 (*ptr,
|
||||
(double) st->sinc_table[samp_frac_num * st->filt_len + j]);
|
||||
ptr += st->in_stride;
|
||||
if (in != NULL) {
|
||||
ptr = in + st->in_stride * (last_sample - N + 1 + j);
|
||||
for (; j < N; j++) {
|
||||
sum +=
|
||||
MULT16_16 (*ptr,
|
||||
(double) st->sinc_table[samp_frac_num * st->filt_len + j]);
|
||||
ptr += st->in_stride;
|
||||
}
|
||||
}
|
||||
|
||||
*out = sum;
|
||||
|
@ -524,24 +530,27 @@ resampler_basic_interpolate_single (SpeexResamplerState * st,
|
|||
MULT16_16 (curr_mem,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset + 1]);
|
||||
}
|
||||
ptr = in + st->in_stride * (last_sample - N + 1 + j);
|
||||
/* Do the new part */
|
||||
for (; j < N; j++) {
|
||||
spx_word16_t curr_in = *ptr;
|
||||
|
||||
ptr += st->in_stride;
|
||||
accum[0] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset - 2]);
|
||||
accum[1] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset - 1]);
|
||||
accum[2] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset]);
|
||||
accum[3] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset + 1]);
|
||||
if (in != NULL) {
|
||||
ptr = in + st->in_stride * (last_sample - N + 1 + j);
|
||||
/* Do the new part */
|
||||
for (; j < N; j++) {
|
||||
spx_word16_t curr_in = *ptr;
|
||||
|
||||
ptr += st->in_stride;
|
||||
accum[0] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset - 2]);
|
||||
accum[1] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset - 1]);
|
||||
accum[2] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset]);
|
||||
accum[3] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset + 1]);
|
||||
}
|
||||
}
|
||||
cubic_coef (frac, interp);
|
||||
sum =
|
||||
|
@ -611,24 +620,26 @@ resampler_basic_interpolate_double (SpeexResamplerState * st,
|
|||
MULT16_16 (curr_mem,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset + 1]);
|
||||
}
|
||||
ptr = in + st->in_stride * (last_sample - N + 1 + j);
|
||||
/* Do the new part */
|
||||
for (; j < N; j++) {
|
||||
double curr_in = *ptr;
|
||||
if (in != NULL) {
|
||||
ptr = in + st->in_stride * (last_sample - N + 1 + j);
|
||||
/* Do the new part */
|
||||
for (; j < N; j++) {
|
||||
double curr_in = *ptr;
|
||||
|
||||
ptr += st->in_stride;
|
||||
accum[0] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset - 2]);
|
||||
accum[1] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset - 1]);
|
||||
accum[2] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset]);
|
||||
accum[3] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset + 1]);
|
||||
ptr += st->in_stride;
|
||||
accum[0] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset - 2]);
|
||||
accum[1] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset - 1]);
|
||||
accum[2] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset]);
|
||||
accum[3] +=
|
||||
MULT16_16 (curr_in,
|
||||
st->sinc_table[4 + (j + 1) * st->oversample - offset + 1]);
|
||||
}
|
||||
}
|
||||
cubic_coef (frac, interp);
|
||||
sum =
|
||||
|
@ -971,9 +982,13 @@ speex_resampler_process_native (SpeexResamplerState * st,
|
|||
|
||||
for (j = 0; j < N - 1 - (spx_int32_t) * in_len; j++)
|
||||
mem[j] = mem[j + *in_len];
|
||||
for (; j < N - 1; j++)
|
||||
mem[j] = in[st->in_stride * (j + *in_len - N + 1)];
|
||||
|
||||
if (in != NULL) {
|
||||
for (; j < N - 1; j++)
|
||||
mem[j] = in[st->in_stride * (j + *in_len - N + 1)];
|
||||
} else {
|
||||
for (; j < N - 1; j++)
|
||||
mem[j] = 0;
|
||||
}
|
||||
return RESAMPLER_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -998,10 +1013,16 @@ speex_resampler_process_float (SpeexResamplerState * st,
|
|||
ALLOC(y, *out_len, spx_word16_t); */
|
||||
istride_save = st->in_stride;
|
||||
ostride_save = st->out_stride;
|
||||
for (i = 0; i < *in_len; i++)
|
||||
x[i] = WORD2INT (in[i * st->in_stride]);
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, x, in_len, y, out_len);
|
||||
if (in != NULL) {
|
||||
for (i = 0; i < *in_len; i++)
|
||||
x[i] = WORD2INT (in[i * st->in_stride]);
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, x, in_len, y, out_len);
|
||||
} else {
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, NULL, in_len, y,
|
||||
out_len);
|
||||
}
|
||||
st->in_stride = istride_save;
|
||||
st->out_stride = ostride_save;
|
||||
for (i = 0; i < *out_len; i++)
|
||||
|
@ -1022,10 +1043,17 @@ speex_resampler_process_float (SpeexResamplerState * st,
|
|||
ichunk = FIXED_STACK_ALLOC;
|
||||
if (ochunk > FIXED_STACK_ALLOC)
|
||||
ochunk = FIXED_STACK_ALLOC;
|
||||
for (i = 0; i < ichunk; i++)
|
||||
x[i] = WORD2INT (in[i * st->in_stride]);
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, x, &ichunk, y, &ochunk);
|
||||
if (in != NULL) {
|
||||
for (i = 0; i < ichunk; i++)
|
||||
x[i] = WORD2INT (in[i * st->in_stride]);
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, x, &ichunk, y,
|
||||
&ochunk);
|
||||
} else {
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, NULL, &ichunk, y,
|
||||
&ochunk);
|
||||
}
|
||||
st->in_stride = istride_save;
|
||||
st->out_stride = ostride_save;
|
||||
for (i = 0; i < ochunk; i++)
|
||||
|
@ -1077,10 +1105,16 @@ speex_resampler_process_int (SpeexResamplerState * st,
|
|||
ALLOC(y, *out_len, spx_word16_t); */
|
||||
istride_save = st->in_stride;
|
||||
ostride_save = st->out_stride;
|
||||
for (i = 0; i < *in_len; i++)
|
||||
x[i] = in[i * st->in_stride];
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, x, in_len, y, out_len);
|
||||
if (in != NULL) {
|
||||
for (i = 0; i < *in_len; i++)
|
||||
x[i] = in[i * st->in_stride];
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, x, in_len, y, out_len);
|
||||
} else {
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, NULL, in_len, y,
|
||||
out_len);
|
||||
}
|
||||
st->in_stride = istride_save;
|
||||
st->out_stride = ostride_save;
|
||||
for (i = 0; i < *out_len; i++)
|
||||
|
@ -1101,10 +1135,17 @@ speex_resampler_process_int (SpeexResamplerState * st,
|
|||
ichunk = FIXED_STACK_ALLOC;
|
||||
if (ochunk > FIXED_STACK_ALLOC)
|
||||
ochunk = FIXED_STACK_ALLOC;
|
||||
for (i = 0; i < ichunk; i++)
|
||||
x[i] = in[i * st->in_stride];
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, x, &ichunk, y, &ochunk);
|
||||
if (in != NULL) {
|
||||
for (i = 0; i < ichunk; i++)
|
||||
x[i] = in[i * st->in_stride];
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, x, &ichunk, y,
|
||||
&ochunk);
|
||||
} else {
|
||||
st->in_stride = st->out_stride = 1;
|
||||
speex_resampler_process_native (st, channel_index, NULL, &ichunk, y,
|
||||
&ochunk);
|
||||
}
|
||||
st->in_stride = istride_save;
|
||||
st->out_stride = ostride_save;
|
||||
for (i = 0; i < ochunk; i++)
|
||||
|
@ -1134,7 +1175,10 @@ speex_resampler_process_interleaved_float (SpeexResamplerState * st,
|
|||
st->in_stride = st->out_stride = st->nb_channels;
|
||||
for (i = 0; i < st->nb_channels; i++) {
|
||||
*out_len = bak_len;
|
||||
speex_resampler_process_float (st, i, in + i, in_len, out + i, out_len);
|
||||
if (in != NULL)
|
||||
speex_resampler_process_float (st, i, in + i, in_len, out + i, out_len);
|
||||
else
|
||||
speex_resampler_process_float (st, i, NULL, in_len, out + i, out_len);
|
||||
}
|
||||
st->in_stride = istride_save;
|
||||
st->out_stride = ostride_save;
|
||||
|
@ -1156,7 +1200,10 @@ speex_resampler_process_interleaved_int (SpeexResamplerState * st,
|
|||
st->in_stride = st->out_stride = st->nb_channels;
|
||||
for (i = 0; i < st->nb_channels; i++) {
|
||||
*out_len = bak_len;
|
||||
speex_resampler_process_int (st, i, in + i, in_len, out + i, out_len);
|
||||
if (in != NULL)
|
||||
speex_resampler_process_int (st, i, in + i, in_len, out + i, out_len);
|
||||
else
|
||||
speex_resampler_process_int (st, i, NULL, in_len, out + i, out_len);
|
||||
}
|
||||
st->in_stride = istride_save;
|
||||
st->out_stride = ostride_save;
|
||||
|
@ -1273,133 +1320,16 @@ speex_resampler_get_output_stride (SpeexResamplerState * st,
|
|||
}
|
||||
|
||||
int
|
||||
speex_resampler_get_latency (SpeexResamplerState * st)
|
||||
speex_resampler_get_input_latency (SpeexResamplerState * st)
|
||||
{
|
||||
return st->filt_len / 2;
|
||||
}
|
||||
|
||||
int
|
||||
speex_resampler_drain_float (SpeexResamplerState * st,
|
||||
spx_uint32_t channel_index, float *out, spx_uint32_t * out_len)
|
||||
speex_resampler_get_output_latency (SpeexResamplerState * st)
|
||||
{
|
||||
spx_uint32_t in_len;
|
||||
int ret;
|
||||
float *in;
|
||||
|
||||
in_len = speex_resampler_get_latency (st);
|
||||
|
||||
in = speex_alloc (sizeof (float) * in_len);
|
||||
*out_len =
|
||||
MIN (in_len * st->den_rate + (st->num_rate >> 1) / st->num_rate,
|
||||
*out_len);
|
||||
|
||||
ret =
|
||||
speex_resampler_process_float (st, channel_index, in, &in_len, out,
|
||||
out_len);
|
||||
|
||||
speex_free (in);
|
||||
|
||||
speex_resampler_reset_mem (st);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
speex_resampler_drain_int (SpeexResamplerState * st,
|
||||
spx_uint32_t channel_index, spx_int16_t * out, spx_uint32_t * out_len)
|
||||
{
|
||||
spx_uint32_t in_len;
|
||||
int ret;
|
||||
spx_int16_t *in;
|
||||
|
||||
in_len = speex_resampler_get_latency (st);
|
||||
|
||||
in = speex_alloc (sizeof (spx_int16_t) * in_len);
|
||||
*out_len =
|
||||
MIN (in_len * st->den_rate + (st->num_rate >> 1) / st->num_rate,
|
||||
*out_len);
|
||||
|
||||
ret =
|
||||
speex_resampler_process_int (st, channel_index, in, &in_len, out,
|
||||
out_len);
|
||||
|
||||
speex_free (in);
|
||||
|
||||
speex_resampler_reset_mem (st);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
speex_resampler_drain_interleaved_float (SpeexResamplerState * st,
|
||||
float *out, spx_uint32_t * out_len)
|
||||
{
|
||||
spx_uint32_t i;
|
||||
int istride_save, ostride_save;
|
||||
spx_uint32_t bak_len;
|
||||
spx_uint32_t in_len;
|
||||
float *in;
|
||||
|
||||
in_len = speex_resampler_get_latency (st);
|
||||
|
||||
in = speex_alloc (sizeof (float) * in_len);
|
||||
*out_len =
|
||||
MIN (in_len * st->den_rate + (st->num_rate >> 1) / st->num_rate,
|
||||
*out_len);
|
||||
bak_len = *out_len;
|
||||
|
||||
istride_save = st->in_stride;
|
||||
ostride_save = st->out_stride;
|
||||
st->in_stride = 1;
|
||||
st->out_stride = st->nb_channels;
|
||||
for (i = 0; i < st->nb_channels; i++) {
|
||||
*out_len = bak_len;
|
||||
speex_resampler_process_float (st, i, in, &in_len, out + i, out_len);
|
||||
}
|
||||
st->in_stride = istride_save;
|
||||
st->out_stride = ostride_save;
|
||||
|
||||
speex_free (in);
|
||||
|
||||
speex_resampler_reset_mem (st);
|
||||
|
||||
return RESAMPLER_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
speex_resampler_drain_interleaved_int (SpeexResamplerState * st,
|
||||
spx_int16_t * out, spx_uint32_t * out_len)
|
||||
{
|
||||
spx_uint32_t i;
|
||||
int istride_save, ostride_save;
|
||||
spx_uint32_t bak_len;
|
||||
spx_uint32_t in_len;
|
||||
spx_int16_t *in;
|
||||
|
||||
in_len = speex_resampler_get_latency (st);
|
||||
|
||||
in = speex_alloc (sizeof (spx_int16_t) * in_len);
|
||||
*out_len =
|
||||
MIN (in_len * st->den_rate + (st->num_rate >> 1) / st->num_rate,
|
||||
*out_len);
|
||||
bak_len = *out_len;
|
||||
|
||||
istride_save = st->in_stride;
|
||||
ostride_save = st->out_stride;
|
||||
st->in_stride = 1;
|
||||
st->out_stride = st->nb_channels;
|
||||
for (i = 0; i < st->nb_channels; i++) {
|
||||
*out_len = bak_len;
|
||||
speex_resampler_process_int (st, i, in, &in_len, out + i, out_len);
|
||||
}
|
||||
st->in_stride = istride_save;
|
||||
st->out_stride = ostride_save;
|
||||
|
||||
speex_free (in);
|
||||
|
||||
speex_resampler_reset_mem (st);
|
||||
|
||||
return RESAMPLER_ERR_SUCCESS;
|
||||
return ((st->filt_len / 2) * st->den_rate +
|
||||
(st->num_rate >> 1)) / st->num_rate;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -73,11 +73,8 @@
|
|||
#define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
|
||||
#define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride)
|
||||
#define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride)
|
||||
#define speex_resampler_get_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_latency)
|
||||
#define speex_resampler_drain_float CAT_PREFIX(RANDOM_PREFIX,_resampler_drain_float)
|
||||
#define speex_resampler_drain_int CAT_PREFIX(RANDOM_PREFIX,_resampler_drain_int)
|
||||
#define speex_resampler_drain_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_drain_interleaved_float)
|
||||
#define speex_resampler_drain_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_drain_interleaved_int)
|
||||
#define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency)
|
||||
#define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency)
|
||||
#define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
|
||||
#define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
|
||||
#define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
|
||||
|
@ -288,7 +285,7 @@ void speex_resampler_set_input_stride(SpeexResamplerState *st,
|
|||
|
||||
/** Get the input stride.
|
||||
* @param st Resampler state
|
||||
* @param stride Input stride
|
||||
* @param stride Input stride copied
|
||||
*/
|
||||
void speex_resampler_get_input_stride(SpeexResamplerState *st,
|
||||
spx_uint32_t *stride);
|
||||
|
@ -301,7 +298,7 @@ void speex_resampler_set_output_stride(SpeexResamplerState *st,
|
|||
spx_uint32_t stride);
|
||||
|
||||
/** Get the output stride.
|
||||
* @param st Resampler state
|
||||
* @param st Resampler state copied
|
||||
* @param stride Output stride
|
||||
*/
|
||||
void speex_resampler_get_output_stride(SpeexResamplerState *st,
|
||||
|
@ -310,58 +307,12 @@ void speex_resampler_get_output_stride(SpeexResamplerState *st,
|
|||
/** Get the latency in input samples introduced by the resampler.
|
||||
* @param st Resampler state
|
||||
*/
|
||||
int speex_resampler_get_latency(SpeexResamplerState *st);
|
||||
int speex_resampler_get_input_latency(SpeexResamplerState *st);
|
||||
|
||||
/**
|
||||
* Outputs the remaining samples into a float array.
|
||||
/** Get the latency in output samples introduced by the resampler.
|
||||
* @param st Resampler state
|
||||
* @param channel_index Index of the channel to process for the multi-channel
|
||||
* base (0 otherwise)
|
||||
* of samples processed
|
||||
* @param out Output buffer
|
||||
* @param out_len Size of the output buffer. Returns the number of samples written
|
||||
*/
|
||||
int speex_resampler_drain_float(SpeexResamplerState *st,
|
||||
spx_uint32_t channel_index,
|
||||
float *out,
|
||||
spx_uint32_t *out_len);
|
||||
/**
|
||||
* Outputs the remaining samples into an int array.
|
||||
* @param st Resampler state
|
||||
* @param channel_index Index of the channel to process for the multi-channel
|
||||
* base (0 otherwise)
|
||||
* of samples processed
|
||||
* @param out Output buffer
|
||||
* @param out_len Size of the output buffer. Returns the number of samples written
|
||||
*/
|
||||
int speex_resampler_drain_int(SpeexResamplerState *st,
|
||||
spx_uint32_t channel_index,
|
||||
spx_int16_t *out,
|
||||
spx_uint32_t *out_len);
|
||||
/**
|
||||
* Outputs the remaining samples into a float array.
|
||||
* @param st Resampler state
|
||||
* @param channel_index Index of the channel to process for the multi-channel
|
||||
* base (0 otherwise)
|
||||
* of samples processed
|
||||
* @param out Output buffer
|
||||
* @param out_len Size of the output buffer. Returns the number of samples written
|
||||
*/
|
||||
int speex_resampler_drain_interleaved_float(SpeexResamplerState *st,
|
||||
float *out,
|
||||
spx_uint32_t *out_len);
|
||||
/**
|
||||
* Outputs the remaining samples into an int array.
|
||||
* @param st Resampler state
|
||||
* @param channel_index Index of the channel to process for the multi-channel
|
||||
* base (0 otherwise)
|
||||
* of samples processed
|
||||
* @param out Output buffer
|
||||
* @param out_len Size of the output buffer. Returns the number of samples written
|
||||
*/
|
||||
int speex_resampler_drain_interleaved_int(SpeexResamplerState *st,
|
||||
spx_int16_t *out,
|
||||
spx_uint32_t *out_len);
|
||||
int speex_resampler_get_output_latency(SpeexResamplerState *st);
|
||||
|
||||
/** 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
|
||||
|
|
|
@ -67,8 +67,8 @@ void resample_float_resampler_get_ratio (SpeexResamplerState * st,
|
|||
void resample_int_resampler_get_ratio (SpeexResamplerState * st,
|
||||
guint32 * ratio_num, guint32 * ratio_den);
|
||||
|
||||
int resample_float_resampler_get_latency (SpeexResamplerState * st);
|
||||
int resample_int_resampler_get_latency (SpeexResamplerState * st);
|
||||
int resample_float_resampler_get_input_latency (SpeexResamplerState * st);
|
||||
int resample_int_resampler_get_input_latency (SpeexResamplerState * st);
|
||||
|
||||
int resample_float_resampler_set_quality (SpeexResamplerState * st,
|
||||
gint quality);
|
||||
|
@ -77,12 +77,6 @@ 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_drain_interleaved_float (SpeexResamplerState
|
||||
* st, gfloat * out, guint32 * out_len);
|
||||
int resample_int_resampler_drain_interleaved_int (SpeexResamplerState
|
||||
* st, gint16 * out, guint32 * out_len);
|
||||
|
||||
int resample_float_resampler_skip_zeros (SpeexResamplerState * st);
|
||||
int resample_int_resampler_skip_zeros (SpeexResamplerState * st);
|
||||
|
||||
|
|
Loading…
Reference in a new issue