From faceb389ec12c13cc41901bc62265045f6f1ff39 Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Wed, 5 Mar 2003 19:31:32 +0000 Subject: [PATCH] * modules/audio_filter/resampler/bandlimited.c: added a few more sanity checks. --- modules/audio_filter/resampler/bandlimited.c | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/audio_filter/resampler/bandlimited.c b/modules/audio_filter/resampler/bandlimited.c index 964f528ec8..a2ad7bc68e 100644 --- a/modules/audio_filter/resampler/bandlimited.c +++ b/modules/audio_filter/resampler/bandlimited.c @@ -2,7 +2,7 @@ * bandlimited.c : bandlimited interpolation resampler ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: bandlimited.c,v 1.3 2003/03/04 22:08:33 gbazin Exp $ + * $Id: bandlimited.c,v 1.4 2003/03/05 19:31:32 gbazin Exp $ * * Authors: Gildas Bazin * @@ -255,10 +255,10 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, d_scale_factor = SMALL_FILTER_SCALE * d_factor + 0.5; /* Apply the old rate until we have enough samples for the new one */ - /* TODO: Check we have enough samples */ i_in = p_filter->p_sys->i_old_wing; p_in += p_filter->p_sys->i_old_wing * i_nb_channels; - for( ; i_in < i_filter_wing; i_in++ ) + for( ; i_in < i_filter_wing && + (i_in + p_filter->p_sys->i_old_wing) < i_in_nb; i_in++ ) { if( p_filter->p_sys->d_old_factor == 1 ) { @@ -299,6 +299,16 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, *(p_out+i) *= d_old_scale_factor; } #endif + + /* Sanity check */ + if( p_out_buf->i_size/p_filter->input.i_bytes_per_frame + <= (unsigned int)i_out+1 ) + { + p_out += i_nb_channels; + i_out++; + p_filter->p_sys->i_remainder += p_filter->input.i_rate; + break; + } } else { @@ -328,7 +338,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, } /* Apply the new rate for the rest of the samples */ - /* TODO: Check we have enough future samples for the new rate */ if( i_in < i_in_nb - i_filter_wing ) { p_filter->p_sys->i_old_rate = p_filter->input.i_rate; @@ -366,6 +375,15 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, *(p_out+i) *= d_old_scale_factor; } #endif + /* Sanity check */ + if( p_out_buf->i_size/p_filter->input.i_bytes_per_frame + <= (unsigned int)i_out+1 ) + { + p_out += i_nb_channels; + i_out++; + p_filter->p_sys->i_remainder += p_filter->input.i_rate; + break; + } } else { -- 2.39.2