audiowsincband: Fix range of kernel elements (lim -> lim-1)

This commit is contained in:
Sebastian Dröge 2011-04-13 18:01:01 +02:00
parent 4fd5fea2b2
commit de7a976531

View file

@ -272,11 +272,10 @@ gst_audio_wsincband_build_kernel (GstAudioWSincBand * self)
w = 2 * G_PI * (self->lower_frequency / GST_AUDIO_FILTER (self)->format.rate); w = 2 * G_PI * (self->lower_frequency / GST_AUDIO_FILTER (self)->format.rate);
kernel_lp = g_new (gdouble, len); kernel_lp = g_new (gdouble, len);
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
if (i == len / 2) if (i % 2 == 1 && i == (len - 1) / 2)
kernel_lp[i] = w; kernel_lp[i] = w;
else else
kernel_lp[i] = sin (w * (i - len / 2)) kernel_lp[i] = sin (w * (i - (len - 1) / 2)) / (i - (len - 1) / 2);
/ (i - len / 2);
/* windowing */ /* windowing */
switch (self->window) { switch (self->window) {
@ -310,11 +309,11 @@ gst_audio_wsincband_build_kernel (GstAudioWSincBand * self)
w = 2 * G_PI * (self->upper_frequency / GST_AUDIO_FILTER (self)->format.rate); w = 2 * G_PI * (self->upper_frequency / GST_AUDIO_FILTER (self)->format.rate);
kernel_hp = g_new (gdouble, len); kernel_hp = g_new (gdouble, len);
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
if (i == len / 2) if (i % 2 == 1 && i == (len - 1) / 2)
kernel_hp[i] = w; kernel_hp[i] = w;
else else
kernel_hp[i] = sin (w * (i - len / 2)) kernel_hp[i] = sin (w * (i - (len - 1) / 2)) / (i - (len - 1) / 2);
/ (i - len / 2);
/* Windowing */ /* Windowing */
switch (self->window) { switch (self->window) {
case WINDOW_HAMMING: case WINDOW_HAMMING:
@ -346,7 +345,12 @@ gst_audio_wsincband_build_kernel (GstAudioWSincBand * self)
/* do spectral inversion to go from lowpass to highpass */ /* do spectral inversion to go from lowpass to highpass */
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
kernel_hp[i] = -kernel_hp[i]; kernel_hp[i] = -kernel_hp[i];
kernel_hp[len / 2] += 1; if (len % 2 == 1) {
kernel_hp[(len - 1) / 2] += 1.0;
} else {
kernel_hp[len / 2 - 1] += 0.5;
kernel_hp[len / 2] += 0.5;
}
/* combine the two kernels */ /* combine the two kernels */
kernel = g_new (gdouble, len); kernel = g_new (gdouble, len);