[vlc-devel] commit: Fixed bandlimited invalid writes when downsampling. (Laurent Aimar )

git version control git at videolan.org
Sun Jan 24 14:49:19 CET 2010


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Jan 24 14:45:06 2010 +0100| [2cf478feb4090b073bda5639432ab3c4da5217f2] | committer: Laurent Aimar 

Fixed bandlimited invalid writes when downsampling.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2cf478feb4090b073bda5639432ab3c4da5217f2
---

 modules/audio_filter/resampler/bandlimited.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/modules/audio_filter/resampler/bandlimited.c b/modules/audio_filter/resampler/bandlimited.c
index 112f624..18fb3ed 100644
--- a/modules/audio_filter/resampler/bandlimited.c
+++ b/modules/audio_filter/resampler/bandlimited.c
@@ -224,6 +224,8 @@ static block_t *Resample( filter_t * p_filter, block_t * p_in_buf )
 
         while( p_sys->i_remainder < p_filter->fmt_out.audio.i_rate )
         {
+            if( p_out_buf->i_buffer/i_bytes_per_frame <= i_out )
+                break;
 
             if( p_sys->d_old_factor >= 1 )
             {
@@ -250,15 +252,6 @@ static block_t *Resample( filter_t * p_filter, block_t * p_in_buf )
                     *(p_out+i) *= d_old_scale_factor;
                 }
 #endif
-
-                /* Sanity check */
-                if( p_out_buf->i_buffer/i_bytes_per_frame <= i_out+1 )
-                {
-                    p_out += i_nb_channels;
-                    i_out++;
-                    p_sys->i_remainder += p_filter->fmt_in.audio.i_rate;
-                    break;
-                }
             }
             else
             {
@@ -297,7 +290,10 @@ static block_t *Resample( filter_t * p_filter, block_t * p_in_buf )
     {
         while( p_sys->i_remainder < p_filter->fmt_out.audio.i_rate )
         {
+            if( p_out_buf->i_buffer/i_bytes_per_frame <= i_out )
+                break;
 
+            assert( i_out < p_out_buf->i_buffer/i_bytes_per_frame );
             if( d_factor >= 1 )
             {
                 /* FilterFloatUP() is faster if we can use it */
@@ -324,14 +320,6 @@ static block_t *Resample( filter_t * p_filter, block_t * p_in_buf )
                     *(p_out+i) *= d_old_scale_factor;
                 }
 #endif
-                /* Sanity check */
-                if( p_out_buf->i_buffer/i_bytes_per_frame <= i_out+1 )
-                {
-                    p_out += i_nb_channels;
-                    i_out++;
-                    p_sys->i_remainder += p_filter->fmt_in.audio.i_rate;
-                    break;
-                }
             }
             else
             {




More information about the vlc-devel mailing list