[vlc-commits] headphone: fix overflow buffer handling
Tristan Matthews
git at videolan.org
Sun May 25 19:14:02 CEST 2014
vlc | branch: master | Tristan Matthews <le.businessman at gmail.com> | Sat May 24 16:47:14 2014 -0400| [1c6daf4c81766a9fb6503a4ab7434674364c1c59] | committer: Tristan Matthews
headphone: fix overflow buffer handling
Fixes #11502
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1c6daf4c81766a9fb6503a4ab7434674364c1c59
---
modules/audio_filter/channel_mixer/headphone.c | 34 +++++++++++++-----------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/modules/audio_filter/channel_mixer/headphone.c b/modules/audio_filter/channel_mixer/headphone.c
index 73180dd..43c6032 100644
--- a/modules/audio_filter/channel_mixer/headphone.c
+++ b/modules/audio_filter/channel_mixer/headphone.c
@@ -338,8 +338,9 @@ static void DoWork( filter_t * p_filter,
float * p_in = (float*) p_in_buf->p_buffer;
float * p_out;
- float * p_overflow;
- float * p_slide;
+ uint8_t * p_overflow;
+ uint8_t * p_end_overflow;
+ uint8_t * p_slide;
size_t i_overflow_size; /* in bytes */
size_t i_out_size; /* in bytes */
@@ -355,32 +356,33 @@ static void DoWork( filter_t * p_filter,
i_out_size = p_out_buf->i_buffer;
/* Slide the overflow buffer */
- p_overflow = p_sys->p_overflow_buffer;
+ p_overflow = (uint8_t *) p_sys->p_overflow_buffer;
i_overflow_size = p_sys->i_overflow_buffer_size;
+ p_end_overflow = p_overflow + i_overflow_size;
memset( p_out, 0, i_out_size );
- if ( i_out_size > i_overflow_size )
- memcpy( p_out, p_overflow, i_overflow_size );
- else
- memcpy( p_out, p_overflow, i_out_size );
+ memcpy( p_out, p_overflow, __MIN( i_out_size, i_overflow_size ) );
- p_slide = p_sys->p_overflow_buffer;
- while( p_slide < p_overflow + i_overflow_size )
+ p_slide = (uint8_t *) p_sys->p_overflow_buffer;
+ while( p_slide < p_end_overflow )
{
- if( p_slide + i_out_size < p_overflow + i_overflow_size )
+ size_t i_bytes_copied;
+
+ if( p_slide + i_out_size < p_end_overflow )
{
memset( p_slide, 0, i_out_size );
- if( p_slide + 2 * i_out_size < p_overflow + i_overflow_size )
- memcpy( p_slide, p_slide + i_out_size, i_out_size );
+ if( p_slide + 2 * i_out_size < p_end_overflow )
+ i_bytes_copied = i_out_size;
else
- memcpy( p_slide, p_slide + i_out_size,
- p_overflow + i_overflow_size - ( p_slide + i_out_size ) );
+ i_bytes_copied = p_end_overflow - ( p_slide + i_out_size );
+ memcpy( p_slide, p_slide + i_out_size, i_bytes_copied );
}
else
{
- memset( p_slide, 0, p_overflow + i_overflow_size - p_slide );
+ i_bytes_copied = p_end_overflow - p_slide;
+ memset( p_slide, 0, i_bytes_copied );
}
- p_slide += i_out_size;
+ p_slide += i_bytes_copied;
}
/* apply the atomic operations */
More information about the vlc-commits
mailing list