From d36adc543b5a32ee8b1a496733809057258b5415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 21 Nov 2008 15:45:15 +0000 Subject: [PATCH] gst/speexresample/gstspeexresample.c: Add a "filter-length" property that maps to the quality values for compatibilty... Original commit message from CVS: * gst/speexresample/gstspeexresample.c: (gst_speex_resample_class_init), (gst_speex_resample_set_property), (gst_speex_resample_get_property): Add a "filter-length" property that maps to the quality values for compatibilty with audioresample. --- gst/speexresample/gstspeexresample.c | 81 +++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/gst/speexresample/gstspeexresample.c b/gst/speexresample/gstspeexresample.c index 010991d68b..4c6dbffe6f 100644 --- a/gst/speexresample/gstspeexresample.c +++ b/gst/speexresample/gstspeexresample.c @@ -59,7 +59,8 @@ GST_DEBUG_CATEGORY (speex_resample_debug); enum { PROP_0, - PROP_QUALITY + PROP_QUALITY, + PROP_FILTER_LENGTH }; #define SUPPORTED_CAPS \ @@ -169,6 +170,14 @@ gst_speex_resample_class_init (GstSpeexResampleClass * klass) SPEEX_RESAMPLER_QUALITY_DEFAULT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + /* FIXME 0.11: Remove this property, it's just for compatibility + * with old audioresample + */ + g_object_class_install_property (gobject_class, PROP_FILTER_LENGTH, + g_param_spec_int ("filter-length", "Filter length", + "DEPRECATED, DON'T USE THIS! " "Length of the resample filter", 0, + G_MAXINT, 64, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + GST_BASE_TRANSFORM_CLASS (klass)->start = GST_DEBUG_FUNCPTR (gst_speex_resample_start); GST_BASE_TRANSFORM_CLASS (klass)->stop = @@ -1158,6 +1167,39 @@ gst_speex_resample_set_property (GObject * object, guint prop_id, resample->channels, resample->inrate, resample->outrate, resample->quality, resample->fp); break; + case PROP_FILTER_LENGTH:{ + gint filter_length = g_value_get_int (value); + + if (filter_length <= 8) + resample->quality = 0; + else if (filter_length <= 16) + resample->quality = 1; + else if (filter_length <= 32) + resample->quality = 2; + else if (filter_length <= 48) + resample->quality = 3; + else if (filter_length <= 64) + resample->quality = 4; + else if (filter_length <= 80) + resample->quality = 5; + else if (filter_length <= 96) + resample->quality = 6; + else if (filter_length <= 128) + resample->quality = 7; + else if (filter_length <= 160) + resample->quality = 8; + else if (filter_length <= 192) + resample->quality = 9; + else + resample->quality = 10; + + GST_DEBUG_OBJECT (resample, "new quality %d", resample->quality); + + gst_speex_resample_update_state (resample, resample->width, + resample->channels, resample->inrate, resample->outrate, + resample->quality, resample->fp); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1176,6 +1218,43 @@ gst_speex_resample_get_property (GObject * object, guint prop_id, case PROP_QUALITY: g_value_set_int (value, resample->quality); break; + case PROP_FILTER_LENGTH: + switch (resample->quality) { + case 0: + g_value_set_int (value, 8); + break; + case 1: + g_value_set_int (value, 16); + break; + case 2: + g_value_set_int (value, 32); + break; + case 3: + g_value_set_int (value, 48); + break; + case 4: + g_value_set_int (value, 64); + break; + case 5: + g_value_set_int (value, 80); + break; + case 6: + g_value_set_int (value, 96); + break; + case 7: + g_value_set_int (value, 128); + break; + case 8: + g_value_set_int (value, 160); + break; + case 9: + g_value_set_int (value, 192); + break; + case 10: + g_value_set_int (value, 256); + break; + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break;