From 0daade2ce6042d380bf513b8c95760c432f3e939 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Thu, 25 Aug 2005 12:31:31 +0000 Subject: gst/audioresample/: add room for extra overlap samples when asked to transform size protect against possible mem corr... Original commit message from CVS: * gst/audioresample/debug.c: * gst/audioresample/gstaudioresample.c: add room for extra overlap samples when asked to transform size protect against possible mem corruption and check for discrepancies between written size and outbuffer's size so we can warn for potential problems * gst/audioresample/resample.c: (resample_init), (resample_get_output_size_for_input), (resample_get_output_size), (resample_set_n_channels), (resample_set_format): set debug level based on RESAMPLE_DEBUG env var make sure that get_output_size* returns a whole number of sample_size set sample_size each time either channel or format is set * gst/audioresample/resample_chunk.c: (resample_scale_chunk): * gst/audioresample/resample_functable.c: (resample_scale_functable): * gst/audioresample/resample_ref.c: (resample_scale_ref): remove r->sample_size, it's done in resample.c now add some debugging to the ref implementation make sure we only give back bytes that are wholes of the sample size --- gst/audioresample/resample_ref.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gst/audioresample/resample_ref.c') diff --git a/gst/audioresample/resample_ref.c b/gst/audioresample/resample_ref.c index 6717aa23..3fc9d2e8 100644 --- a/gst/audioresample/resample_ref.c +++ b/gst/audioresample/resample_ref.c @@ -56,7 +56,6 @@ void resample_scale_ref (ResampleState * r) { if (r->need_reinit) { - r->sample_size = r->n_channels * resample_format_size (r->format); RESAMPLE_DEBUG ("sample size %d", r->sample_size); if (r->buffer) @@ -88,19 +87,24 @@ resample_scale_ref (ResampleState * r) #endif } - while (r->o_size > 0) { + RESAMPLE_DEBUG ("asked to resample %d bytes", r->o_size); + + while (r->o_size >= r->sample_size) { double midpoint; int i; int j; - RESAMPLE_DEBUG ("i_start %g", r->i_start); midpoint = r->i_start + (r->filter_length - 1) * 0.5 * r->i_inc; + RESAMPLE_DEBUG ("still need to output %d bytes, i_start %g, midpoint %f", + r->o_size, r->i_start, midpoint); if (midpoint > 0.5 * r->i_inc) { RESAMPLE_ERROR ("inconsistent state"); } while (midpoint < -0.5 * r->i_inc) { AudioresampleBuffer *buffer; + RESAMPLE_DEBUG ("midpoint %f < %f, r->i_inc %f", midpoint, + -0.5 * r->i_inc, r->i_inc); buffer = audioresample_buffer_queue_pull (r->queue, r->sample_size); if (buffer == NULL) { RESAMPLE_ERROR ("buffer_queue_pull returned NULL"); @@ -206,5 +210,4 @@ resample_scale_ref (ResampleState * r) r->o_buf += r->sample_size; r->o_size -= r->sample_size; } - } -- cgit v1.2.1