diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2007-08-11 15:58:30 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2007-08-11 15:58:30 +0000 |
commit | 4e5ca9f0844b70aa599f96ac08f1b3db4ad57cb2 (patch) | |
tree | 30ae6b9e13098d39562438efb88167a555edf66b | |
parent | 9e50d836d4173f127adc56446fa74f1e103fa673 (diff) | |
download | gst-plugins-bad-4e5ca9f0844b70aa599f96ac08f1b3db4ad57cb2.tar.gz gst-plugins-bad-4e5ca9f0844b70aa599f96ac08f1b3db4ad57cb2.tar.bz2 gst-plugins-bad-4e5ca9f0844b70aa599f96ac08f1b3db4ad57cb2.zip |
gst/filter/: Fix processing with buffer sizes that are larger than the filter kernel size.
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (process_32), (process_64):
* gst/filter/gstlpwsinc.c: (process_32), (process_64):
Fix processing with buffer sizes that are larger than the filter
kernel size.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | gst/filter/gstbpwsinc.c | 28 | ||||
-rw-r--r-- | gst/filter/gstlpwsinc.c | 28 |
3 files changed, 55 insertions, 8 deletions
@@ -1,3 +1,10 @@ +2007-08-11 Sebastian Dröge <slomo@circular-chaos.org> + + * gst/filter/gstbpwsinc.c: (process_32), (process_64): + * gst/filter/gstlpwsinc.c: (process_32), (process_64): + Fix processing with buffer sizes that are larger than the filter + kernel size. + 2007-08-10 Wim Taymans <wim.taymans@gmail.com> * gst/rtpmanager/Makefile.am: diff --git a/gst/filter/gstbpwsinc.c b/gst/filter/gstbpwsinc.c index d6bb3d12..9d550ba3 100644 --- a/gst/filter/gstbpwsinc.c +++ b/gst/filter/gstbpwsinc.c @@ -245,6 +245,7 @@ process_32 (GstBPWSinc * self, gfloat * src, gfloat * dst, guint input_samples) gint kernel_length = self->kernel_length; gint i, j, k, l; gint channels = GST_AUDIO_FILTER (self)->format.channels; + gint res_start; /* convolution */ for (i = 0; i < input_samples; i++) { @@ -260,8 +261,17 @@ process_32 (GstBPWSinc * self, gfloat * src, gfloat * dst, guint input_samples) dst[i] += src[(l - j) * channels + k] * self->kernel[j]; } - /* copy the tail of the current input buffer to the residue */ - for (i = 0; i < kernel_length * channels; i++) + /* copy the tail of the current input buffer to the residue, while + * keeping parts of the residue if the input buffer is smaller than + * the kernel length */ + if (input_samples < kernel_length * channels) + res_start = kernel_length * channels - input_samples; + else + res_start = 0; + + for (i = 0; i < res_start; i++) + self->residue[i] = self->residue[i + input_samples]; + for (i = res_start; i < kernel_length * channels; i++) self->residue[i] = src[input_samples - kernel_length * channels + i]; } @@ -272,6 +282,7 @@ process_64 (GstBPWSinc * self, gdouble * src, gdouble * dst, gint kernel_length = self->kernel_length; gint i, j, k, l; gint channels = GST_AUDIO_FILTER (self)->format.channels; + gint res_start; /* convolution */ for (i = 0; i < input_samples; i++) { @@ -287,8 +298,17 @@ process_64 (GstBPWSinc * self, gdouble * src, gdouble * dst, dst[i] += src[(l - j) * channels + k] * self->kernel[j]; } - /* copy the tail of the current input buffer to the residue */ - for (i = 0; i < kernel_length * channels; i++) + /* copy the tail of the current input buffer to the residue, while + * keeping parts of the residue if the input buffer is smaller than + * the kernel length */ + if (input_samples < kernel_length * channels) + res_start = kernel_length * channels - input_samples; + else + res_start = 0; + + for (i = 0; i < res_start; i++) + self->residue[i] = self->residue[i + input_samples]; + for (i = res_start; i < kernel_length * channels; i++) self->residue[i] = src[input_samples - kernel_length * channels + i]; } diff --git a/gst/filter/gstlpwsinc.c b/gst/filter/gstlpwsinc.c index f6393169..54ebc2a3 100644 --- a/gst/filter/gstlpwsinc.c +++ b/gst/filter/gstlpwsinc.c @@ -240,6 +240,7 @@ process_32 (GstLPWSinc * self, gfloat * src, gfloat * dst, guint input_samples) gint kernel_length = self->kernel_length; gint i, j, k, l; gint channels = GST_AUDIO_FILTER (self)->format.channels; + gint res_start; /* convolution */ for (i = 0; i < input_samples; i++) { @@ -255,8 +256,17 @@ process_32 (GstLPWSinc * self, gfloat * src, gfloat * dst, guint input_samples) dst[i] += src[(l - j) * channels + k] * self->kernel[j]; } - /* copy the tail of the current input buffer to the residue */ - for (i = 0; i < kernel_length * channels; i++) + /* copy the tail of the current input buffer to the residue, while + * keeping parts of the residue if the input buffer is smaller than + * the kernel length */ + if (input_samples < kernel_length * channels) + res_start = kernel_length * channels - input_samples; + else + res_start = 0; + + for (i = 0; i < res_start; i++) + self->residue[i] = self->residue[i + input_samples]; + for (i = res_start; i < kernel_length * channels; i++) self->residue[i] = src[input_samples - kernel_length * channels + i]; } @@ -267,6 +277,7 @@ process_64 (GstLPWSinc * self, gdouble * src, gdouble * dst, gint kernel_length = self->kernel_length; gint i, j, k, l; gint channels = GST_AUDIO_FILTER (self)->format.channels; + gint res_start; /* convolution */ for (i = 0; i < input_samples; i++) { @@ -282,8 +293,17 @@ process_64 (GstLPWSinc * self, gdouble * src, gdouble * dst, dst[i] += src[(l - j) * channels + k] * self->kernel[j]; } - /* copy the tail of the current input buffer to the residue */ - for (i = 0; i < kernel_length * channels; i++) + /* copy the tail of the current input buffer to the residue, while + * keeping parts of the residue if the input buffer is smaller than + * the kernel length */ + if (input_samples < kernel_length * channels) + res_start = kernel_length * channels - input_samples; + else + res_start = 0; + + for (i = 0; i < res_start; i++) + self->residue[i] = self->residue[i + input_samples]; + for (i = res_start; i < kernel_length * channels; i++) self->residue[i] = src[input_samples - kernel_length * channels + i]; } |