mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
audioresample: Fix up indention
This commit is contained in:
parent
5826f79980
commit
122446476f
2 changed files with 47 additions and 41 deletions
|
@ -116,8 +116,7 @@ static void gst_audio_resample_set_property (GObject * object,
|
||||||
static void gst_audio_resample_get_property (GObject * object,
|
static void gst_audio_resample_get_property (GObject * object,
|
||||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GType
|
static GType speex_resampler_sinc_filter_mode_get_type (void);
|
||||||
speex_resampler_sinc_filter_mode_get_type (void);
|
|
||||||
|
|
||||||
/* vmethods */
|
/* vmethods */
|
||||||
static gboolean gst_audio_resample_get_unit_size (GstBaseTransform * base,
|
static gboolean gst_audio_resample_get_unit_size (GstBaseTransform * base,
|
||||||
|
@ -166,12 +165,13 @@ gst_audio_resample_class_init (GstAudioResampleClass * klass)
|
||||||
SPEEX_RESAMPLER_SINC_FILTER_DEFAULT,
|
SPEEX_RESAMPLER_SINC_FILTER_DEFAULT,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_SINC_FILTER_AUTO_THRESHOLD,
|
g_object_class_install_property (gobject_class,
|
||||||
g_param_spec_uint ("sinc-filter-auto-threshold", "Sinc filter auto mode threshold",
|
PROP_SINC_FILTER_AUTO_THRESHOLD,
|
||||||
|
g_param_spec_uint ("sinc-filter-auto-threshold",
|
||||||
|
"Sinc filter auto mode threshold",
|
||||||
"Memory usage threshold to use if sinc filter mode is AUTO, given in bytes",
|
"Memory usage threshold to use if sinc filter mode is AUTO, given in bytes",
|
||||||
0, G_MAXUINT,
|
0, G_MAXUINT, SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT,
|
||||||
SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT,
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (gstelement_class,
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
gst_static_pad_template_get (&gst_audio_resample_src_template));
|
gst_static_pad_template_get (&gst_audio_resample_src_template));
|
||||||
|
@ -211,7 +211,8 @@ gst_audio_resample_init (GstAudioResample * resample)
|
||||||
|
|
||||||
resample->quality = SPEEX_RESAMPLER_QUALITY_DEFAULT;
|
resample->quality = SPEEX_RESAMPLER_QUALITY_DEFAULT;
|
||||||
resample->sinc_filter_mode = SPEEX_RESAMPLER_SINC_FILTER_DEFAULT;
|
resample->sinc_filter_mode = SPEEX_RESAMPLER_SINC_FILTER_DEFAULT;
|
||||||
resample->sinc_filter_auto_threshold = SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT;
|
resample->sinc_filter_auto_threshold =
|
||||||
|
SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT;
|
||||||
|
|
||||||
gst_base_transform_set_gap_aware (trans, TRUE);
|
gst_base_transform_set_gap_aware (trans, TRUE);
|
||||||
gst_pad_set_query_function (trans->srcpad, gst_audio_resample_query);
|
gst_pad_set_query_function (trans->srcpad, gst_audio_resample_query);
|
||||||
|
@ -389,7 +390,7 @@ gst_audio_resample_init_state (GstAudioResample * resample, gint width,
|
||||||
const SpeexResampleFuncs *funcs = gst_audio_resample_get_funcs (width, fp);
|
const SpeexResampleFuncs *funcs = gst_audio_resample_get_funcs (width, fp);
|
||||||
|
|
||||||
ret = funcs->init (channels, inrate, outrate, quality,
|
ret = funcs->init (channels, inrate, outrate, quality,
|
||||||
sinc_filter_mode, sinc_filter_auto_threshold, &err);
|
sinc_filter_mode, sinc_filter_auto_threshold, &err);
|
||||||
|
|
||||||
if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) {
|
if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) {
|
||||||
GST_ERROR_OBJECT (resample, "Failed to create resampler state: %s",
|
GST_ERROR_OBJECT (resample, "Failed to create resampler state: %s",
|
||||||
|
@ -399,7 +400,7 @@ gst_audio_resample_init_state (GstAudioResample * resample, gint width,
|
||||||
|
|
||||||
if (sinc_filter_mode == SPEEX_RESAMPLER_SINC_FILTER_AUTO) {
|
if (sinc_filter_mode == SPEEX_RESAMPLER_SINC_FILTER_AUTO) {
|
||||||
GST_INFO_OBJECT (resample, "Using the %s sinc filter table",
|
GST_INFO_OBJECT (resample, "Using the %s sinc filter table",
|
||||||
funcs->get_sinc_filter_mode(ret) ? "full" : "interpolated");
|
funcs->get_sinc_filter_mode (ret) ? "full" : "interpolated");
|
||||||
}
|
}
|
||||||
|
|
||||||
funcs->skip_zeros (ret);
|
funcs->skip_zeros (ret);
|
||||||
|
@ -422,7 +423,8 @@ gst_audio_resample_update_state (GstAudioResample * resample, gint width,
|
||||||
if (resample->state == NULL) {
|
if (resample->state == NULL) {
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
} else if (resample->channels != channels || fp != resample->fp
|
} else if (resample->channels != channels || fp != resample->fp
|
||||||
|| width != resample->width || sinc_filter_mode != resample->sinc_filter_mode
|
|| width != resample->width
|
||||||
|
|| sinc_filter_mode != resample->sinc_filter_mode
|
||||||
|| sinc_filter_auto_threshold != resample->sinc_filter_auto_threshold) {
|
|| sinc_filter_auto_threshold != resample->sinc_filter_auto_threshold) {
|
||||||
resample->funcs->destroy (resample->state);
|
resample->funcs->destroy (resample->state);
|
||||||
resample->state =
|
resample->state =
|
||||||
|
@ -1328,7 +1330,7 @@ gst_audio_resample_set_property (GObject * object, guint prop_id,
|
||||||
quality, resample->fp, resample->sinc_filter_mode,
|
quality, resample->fp, resample->sinc_filter_mode,
|
||||||
resample->sinc_filter_auto_threshold);
|
resample->sinc_filter_auto_threshold);
|
||||||
break;
|
break;
|
||||||
case PROP_SINC_FILTER_MODE: {
|
case PROP_SINC_FILTER_MODE:{
|
||||||
/* FIXME locking! */
|
/* FIXME locking! */
|
||||||
SpeexResamplerSincFilterMode sinc_filter_mode = g_value_get_enum (value);
|
SpeexResamplerSincFilterMode sinc_filter_mode = g_value_get_enum (value);
|
||||||
|
|
||||||
|
@ -1339,7 +1341,7 @@ gst_audio_resample_set_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PROP_SINC_FILTER_AUTO_THRESHOLD: {
|
case PROP_SINC_FILTER_AUTO_THRESHOLD:{
|
||||||
/* FIXME locking! */
|
/* FIXME locking! */
|
||||||
guint32 sinc_filter_auto_threshold = g_value_get_uint (value);
|
guint32 sinc_filter_auto_threshold = g_value_get_uint (value);
|
||||||
|
|
||||||
|
@ -1369,10 +1371,10 @@ gst_audio_resample_get_property (GObject * object, guint prop_id,
|
||||||
g_value_set_int (value, resample->quality);
|
g_value_set_int (value, resample->quality);
|
||||||
break;
|
break;
|
||||||
case PROP_SINC_FILTER_MODE:
|
case PROP_SINC_FILTER_MODE:
|
||||||
g_value_set_enum(value, resample->sinc_filter_mode);
|
g_value_set_enum (value, resample->sinc_filter_mode);
|
||||||
break;
|
break;
|
||||||
case PROP_SINC_FILTER_AUTO_THRESHOLD:
|
case PROP_SINC_FILTER_AUTO_THRESHOLD:
|
||||||
g_value_set_uint(value, resample->sinc_filter_auto_threshold);
|
g_value_set_uint (value, resample->sinc_filter_auto_threshold);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -1387,15 +1389,17 @@ speex_resampler_sinc_filter_mode_get_type (void)
|
||||||
|
|
||||||
if (!speex_resampler_sinc_filter_mode_type) {
|
if (!speex_resampler_sinc_filter_mode_type) {
|
||||||
static GEnumValue sinc_filter_modes[] = {
|
static GEnumValue sinc_filter_modes[] = {
|
||||||
{ SPEEX_RESAMPLER_SINC_FILTER_INTERPOLATED, "Use interpolated sinc table", "interpolated" },
|
{SPEEX_RESAMPLER_SINC_FILTER_INTERPOLATED, "Use interpolated sinc table",
|
||||||
{ SPEEX_RESAMPLER_SINC_FILTER_FULL, "Use full sinc table", "full" },
|
"interpolated"},
|
||||||
{ SPEEX_RESAMPLER_SINC_FILTER_AUTO, "Use full table if table size below threshold", "auto" },
|
{SPEEX_RESAMPLER_SINC_FILTER_FULL, "Use full sinc table", "full"},
|
||||||
{ 0, NULL, NULL },
|
{SPEEX_RESAMPLER_SINC_FILTER_AUTO,
|
||||||
|
"Use full table if table size below threshold", "auto"},
|
||||||
|
{0, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
speex_resampler_sinc_filter_mode_type = g_enum_register_static (
|
speex_resampler_sinc_filter_mode_type =
|
||||||
"SpeexResamplerSincFilterMode",
|
g_enum_register_static ("SpeexResamplerSincFilterMode",
|
||||||
sinc_filter_modes);
|
sinc_filter_modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return speex_resampler_sinc_filter_mode_type;
|
return speex_resampler_sinc_filter_mode_type;
|
||||||
|
@ -1464,18 +1468,16 @@ _benchmark_integer_resampling (void)
|
||||||
orc_profile_init (&b);
|
orc_profile_init (&b);
|
||||||
|
|
||||||
sta = resample_float_resampler_init (1, 48000, 24000, 4,
|
sta = resample_float_resampler_init (1, 48000, 24000, 4,
|
||||||
SPEEX_RESAMPLER_SINC_FILTER_INTERPOLATED,
|
SPEEX_RESAMPLER_SINC_FILTER_INTERPOLATED,
|
||||||
SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT,
|
SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT, NULL);
|
||||||
NULL);
|
|
||||||
if (sta == NULL) {
|
if (sta == NULL) {
|
||||||
GST_ERROR ("Failed to create float resampler state");
|
GST_ERROR ("Failed to create float resampler state");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
stb = resample_int_resampler_init (1, 48000, 24000, 4,
|
stb = resample_int_resampler_init (1, 48000, 24000, 4,
|
||||||
SPEEX_RESAMPLER_SINC_FILTER_INTERPOLATED,
|
SPEEX_RESAMPLER_SINC_FILTER_INTERPOLATED,
|
||||||
SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT,
|
SPEEX_RESAMPLER_SINC_FILTER_AUTO_THRESHOLD_DEFAULT, NULL);
|
||||||
NULL);
|
|
||||||
if (stb == NULL) {
|
if (stb == NULL) {
|
||||||
resample_float_resampler_destroy (sta);
|
resample_float_resampler_destroy (sta);
|
||||||
GST_ERROR ("Failed to create int resampler state");
|
GST_ERROR ("Failed to create int resampler state");
|
||||||
|
|
|
@ -478,7 +478,7 @@ resampler_basic_direct_single (SpeexResamplerState * st,
|
||||||
const spx_word16_t *iptr = &in[last_sample];
|
const spx_word16_t *iptr = &in[last_sample];
|
||||||
|
|
||||||
SSE_FALLBACK (INNER_PRODUCT_SINGLE)
|
SSE_FALLBACK (INNER_PRODUCT_SINGLE)
|
||||||
NEON_FALLBACK (INNER_PRODUCT_SINGLE)
|
NEON_FALLBACK (INNER_PRODUCT_SINGLE)
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for (j = 0; j < N; j++)
|
for (j = 0; j < N; j++)
|
||||||
sum += MULT16_16 (sinc[j], iptr[j]);
|
sum += MULT16_16 (sinc[j], iptr[j]);
|
||||||
|
@ -497,14 +497,14 @@ resampler_basic_direct_single (SpeexResamplerState * st,
|
||||||
*/
|
*/
|
||||||
#if defined(OVERRIDE_INNER_PRODUCT_SINGLE) && defined(_USE_NEON)
|
#if defined(OVERRIDE_INNER_PRODUCT_SINGLE) && defined(_USE_NEON)
|
||||||
NEON_IMPLEMENTATION (INNER_PRODUCT_SINGLE)
|
NEON_IMPLEMENTATION (INNER_PRODUCT_SINGLE)
|
||||||
sum = inner_product_single (sinc, iptr, N);
|
sum = inner_product_single (sinc, iptr, N);
|
||||||
NEON_END(INNER_PRODUCT_SINGLE)
|
NEON_END (INNER_PRODUCT_SINGLE)
|
||||||
#elif defined(OVERRIDE_INNER_PRODUCT_SINGLE) && defined(_USE_SSE)
|
#elif defined(OVERRIDE_INNER_PRODUCT_SINGLE) && defined(_USE_SSE)
|
||||||
SSE_IMPLEMENTATION (INNER_PRODUCT_SINGLE)
|
SSE_IMPLEMENTATION (INNER_PRODUCT_SINGLE)
|
||||||
sum = inner_product_single (sinc, iptr, N);
|
sum = inner_product_single (sinc, iptr, N);
|
||||||
SSE_END (INNER_PRODUCT_SINGLE)
|
SSE_END (INNER_PRODUCT_SINGLE)
|
||||||
#endif
|
#endif
|
||||||
out[out_stride * out_sample++] = SATURATE32PSHR(sum, 15, 32767);
|
out[out_stride * out_sample++] = SATURATE32PSHR (sum, 15, 32767);
|
||||||
last_sample += int_advance;
|
last_sample += int_advance;
|
||||||
samp_frac_num += frac_advance;
|
samp_frac_num += frac_advance;
|
||||||
if (samp_frac_num >= den_rate) {
|
if (samp_frac_num >= den_rate) {
|
||||||
|
@ -642,7 +642,7 @@ resampler_basic_interpolate_single (SpeexResamplerState * st,
|
||||||
interp);
|
interp);
|
||||||
SSE_END (INTERPOLATE_PRODUCT_SINGLE)
|
SSE_END (INTERPOLATE_PRODUCT_SINGLE)
|
||||||
#endif
|
#endif
|
||||||
out[out_stride * out_sample++] = SATURATE32PSHR(sum, 14, 32767);
|
out[out_stride * out_sample++] = SATURATE32PSHR (sum, 14, 32767);
|
||||||
last_sample += int_advance;
|
last_sample += int_advance;
|
||||||
samp_frac_num += frac_advance;
|
samp_frac_num += frac_advance;
|
||||||
if (samp_frac_num >= den_rate) {
|
if (samp_frac_num >= den_rate) {
|
||||||
|
@ -946,7 +946,8 @@ update_filter (SpeexResamplerState * st)
|
||||||
|
|
||||||
EXPORT SpeexResamplerState *
|
EXPORT SpeexResamplerState *
|
||||||
speex_resampler_init (spx_uint32_t nb_channels, spx_uint32_t in_rate,
|
speex_resampler_init (spx_uint32_t nb_channels, spx_uint32_t in_rate,
|
||||||
spx_uint32_t out_rate, int quality, SpeexResamplerSincFilterMode sinc_filter_mode,
|
spx_uint32_t out_rate, int quality,
|
||||||
|
SpeexResamplerSincFilterMode sinc_filter_mode,
|
||||||
spx_uint32_t sinc_filter_auto_threshold, int *err)
|
spx_uint32_t sinc_filter_auto_threshold, int *err)
|
||||||
{
|
{
|
||||||
return speex_resampler_init_frac (nb_channels, in_rate, out_rate, in_rate,
|
return speex_resampler_init_frac (nb_channels, in_rate, out_rate, in_rate,
|
||||||
|
@ -1068,13 +1069,16 @@ speex_resampler_init_frac (spx_uint32_t nb_channels, spx_uint32_t ratio_num,
|
||||||
|
|
||||||
if (sinc_filter_mode == RESAMPLER_SINC_FILTER_AUTO) {
|
if (sinc_filter_mode == RESAMPLER_SINC_FILTER_AUTO) {
|
||||||
/*
|
/*
|
||||||
Estimate how big the filter table would become if the full mode were to be used
|
Estimate how big the filter table would become if the full mode were to be used
|
||||||
calculations used correspond to the ones in update_filter()
|
calculations used correspond to the ones in update_filter()
|
||||||
if the size is bigger than the threshold, use interpolated sinc instead
|
if the size is bigger than the threshold, use interpolated sinc instead
|
||||||
*/
|
*/
|
||||||
spx_uint32_t base_filter_length = st->filt_len = quality_map[st->quality].base_length;
|
spx_uint32_t base_filter_length = st->filt_len =
|
||||||
spx_uint32_t filter_table_size = base_filter_length * st->den_rate * sizeof(spx_uint16_t);
|
quality_map[st->quality].base_length;
|
||||||
st->use_full_sinc_table = (filter_table_size > sinc_filter_auto_threshold) ? 0 : 1;
|
spx_uint32_t filter_table_size =
|
||||||
|
base_filter_length * st->den_rate * sizeof (spx_uint16_t);
|
||||||
|
st->use_full_sinc_table =
|
||||||
|
(filter_table_size > sinc_filter_auto_threshold) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_filter (st);
|
update_filter (st);
|
||||||
|
|
Loading…
Reference in a new issue