Commit 679039d9 authored by Rémi Duraffort's avatar Rémi Duraffort

No need to test for NULL here.

parent 552b005a
......@@ -157,12 +157,7 @@ static int Create( vlc_object_t *p_this )
static void Destroy( vlc_object_t *p_this )
{
aout_filter_t * p_filter = (aout_filter_t *)p_this;
if ( p_filter->p_sys != NULL )
{
free ( p_filter->p_sys );
p_filter->p_sys = NULL;
}
free( p_filter->p_sys );
}
/*****************************************************************************
......@@ -172,70 +167,67 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
{
VLC_UNUSED(p_aout);
aout_filter_sys_t * p_sys = p_filter->p_sys;
float * p_in = (float*) p_in_buf->p_buffer;
float * p_out = (float*) p_out_buf->p_buffer;
size_t i_nb_samples = p_in_buf->i_nb_samples;
size_t i_nb_channels = aout_FormatNbChannels( &p_filter->output );
size_t i_nb_rear = 0;
size_t i;
p_out_buf->i_nb_samples = i_nb_samples;
p_out_buf->i_nb_bytes = sizeof(float) * i_nb_samples
* aout_FormatNbChannels( &p_filter->output );
memset ( p_out , 0 , p_out_buf->i_nb_bytes );
memset( p_out, 0, p_out_buf->i_nb_bytes );
if ( p_filter->p_sys != NULL )
if( p_sys->i_rear_left >= 0 )
{
struct aout_filter_sys_t * p_sys = p_filter->p_sys;
size_t i_nb_rear = 0;
size_t i;
++i_nb_rear;
}
if( p_sys->i_rear_center >= 0 )
{
++i_nb_rear;
}
if( p_sys->i_rear_right >= 0 )
{
++i_nb_rear;
}
if ( p_sys->i_rear_left >= 0 )
for( i = 0; i < i_nb_samples; ++i )
{
float f_left = p_in[ i * 2 ];
float f_right = p_in[ i * 2 + 1 ];
float f_rear = ( f_left - f_right ) / i_nb_rear;
if( p_sys->i_center >= 0 )
{
++i_nb_rear;
float f_center = f_left + f_right;
f_left -= f_center / 2;
f_right -= f_center / 2;
p_out[ i * i_nb_channels + p_sys->i_center ] = f_center;
}
if ( p_sys->i_rear_center >= 0 )
if( p_sys->i_left >= 0 )
{
++i_nb_rear;
p_out[ i * i_nb_channels + p_sys->i_left ] = f_left;
}
if ( p_sys->i_rear_right >= 0 )
if( p_sys->i_right >= 0 )
{
++i_nb_rear;
p_out[ i * i_nb_channels + p_sys->i_right ] = f_right;
}
for ( i = 0; i < i_nb_samples; ++i )
if( p_sys->i_rear_left >= 0 )
{
float f_left = p_in[ i * 2 ];
float f_right = p_in[ i * 2 + 1 ];
float f_rear = ( f_left - f_right ) / i_nb_rear;
if ( p_sys->i_center >= 0 )
{
float f_center = f_left + f_right;
f_left -= f_center / 2;
f_right -= f_center / 2;
p_out[ i * i_nb_channels + p_sys->i_center ] = f_center;
}
if ( p_sys->i_left >= 0 )
{
p_out[ i * i_nb_channels + p_sys->i_left ] = f_left;
}
if ( p_sys->i_right >= 0 )
{
p_out[ i * i_nb_channels + p_sys->i_right ] = f_right;
}
if ( p_sys->i_rear_left >= 0 )
{
p_out[ i * i_nb_channels + p_sys->i_rear_left ] = f_rear;
}
if ( p_sys->i_rear_center >= 0 )
{
p_out[ i * i_nb_channels + p_sys->i_rear_center ] = f_rear;
}
if ( p_sys->i_rear_right >= 0 )
{
p_out[ i * i_nb_channels + p_sys->i_rear_right ] = f_rear;
}
p_out[ i * i_nb_channels + p_sys->i_rear_left ] = f_rear;
}
if( p_sys->i_rear_center >= 0 )
{
p_out[ i * i_nb_channels + p_sys->i_rear_center ] = f_rear;
}
if( p_sys->i_rear_right >= 0 )
{
p_out[ i * i_nb_channels + p_sys->i_rear_right ] = f_rear;
}
}
}
......@@ -470,85 +470,78 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_out = p_out_buf->p_buffer;
i_out_size = p_out_buf->i_nb_bytes;
if( p_sys != NULL )
{
/* Slide the overflow buffer */
p_overflow = p_sys->p_overflow_buffer;
i_overflow_size = p_sys->i_overflow_buffer_size;
/* Slide the overflow buffer */
p_overflow = p_sys->p_overflow_buffer;
i_overflow_size = p_sys->i_overflow_buffer_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 );
memset( p_out, 0, i_out_size );
if ( i_out_size > i_overflow_size )
memcpy( p_out, p_overflow, i_overflow_size );
p_slide = p_sys->p_overflow_buffer;
while( p_slide < p_overflow + i_overflow_size )
{
if( p_slide + i_out_size < p_overflow + i_overflow_size )
{
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 );
else
memcpy( p_slide, p_slide + i_out_size,
p_overflow + i_overflow_size - ( p_slide + i_out_size ) );
}
else
memcpy( p_out, p_overflow, i_out_size );
{
memset( p_slide, 0, p_overflow + i_overflow_size - p_slide );
}
p_slide += i_out_size;
}
p_slide = p_sys->p_overflow_buffer;
while( p_slide < p_overflow + i_overflow_size )
/* apply the atomic operations */
for( i = 0; i < p_sys->i_nb_atomic_operations; i++ )
{
/* shorter variable names */
i_source_channel_offset
= p_sys->p_atomic_operations[i].i_source_channel_offset;
i_dest_channel_offset
= p_sys->p_atomic_operations[i].i_dest_channel_offset;
i_delay = p_sys->p_atomic_operations[i].i_delay;
d_amplitude_factor
= p_sys->p_atomic_operations[i].d_amplitude_factor;
if( p_out_buf->i_nb_samples > i_delay )
{
if( p_slide + i_out_size < p_overflow + i_overflow_size )
/* current buffer coefficients */
for( j = 0; j < p_out_buf->i_nb_samples - i_delay; j++ )
{
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 );
else
memcpy( p_slide, p_slide + i_out_size,
p_overflow + i_overflow_size - ( p_slide + i_out_size ) );
((float*)p_out)[ (i_delay+j)*i_output_nb + i_dest_channel_offset ]
+= p_in[ j * i_input_nb + i_source_channel_offset ]
* d_amplitude_factor;
}
else
/* overflow buffer coefficients */
for( j = 0; j < i_delay; j++ )
{
memset( p_slide, 0, p_overflow + i_overflow_size - p_slide );
((float*)p_overflow)[ j*i_output_nb + i_dest_channel_offset ]
+= p_in[ (p_out_buf->i_nb_samples - i_delay + j)
* i_input_nb + i_source_channel_offset ]
* d_amplitude_factor;
}
p_slide += i_out_size;
}
/* apply the atomic operations */
for( i = 0; i < p_sys->i_nb_atomic_operations; i++ )
else
{
/* shorter variable names */
i_source_channel_offset
= p_sys->p_atomic_operations[i].i_source_channel_offset;
i_dest_channel_offset
= p_sys->p_atomic_operations[i].i_dest_channel_offset;
i_delay = p_sys->p_atomic_operations[i].i_delay;
d_amplitude_factor
= p_sys->p_atomic_operations[i].d_amplitude_factor;
if( p_out_buf->i_nb_samples > i_delay )
/* overflow buffer coefficients only */
for( j = 0; j < p_out_buf->i_nb_samples; j++ )
{
/* current buffer coefficients */
for( j = 0; j < p_out_buf->i_nb_samples - i_delay; j++ )
{
((float*)p_out)[ (i_delay+j)*i_output_nb + i_dest_channel_offset ]
+= p_in[ j * i_input_nb + i_source_channel_offset ]
* d_amplitude_factor;
}
/* overflow buffer coefficients */
for( j = 0; j < i_delay; j++ )
{
((float*)p_overflow)[ j*i_output_nb + i_dest_channel_offset ]
+= p_in[ (p_out_buf->i_nb_samples - i_delay + j)
* i_input_nb + i_source_channel_offset ]
* d_amplitude_factor;
}
}
else
{
/* overflow buffer coefficients only */
for( j = 0; j < p_out_buf->i_nb_samples; j++ )
{
((float*)p_overflow)[ (i_delay - p_out_buf->i_nb_samples + j)
* i_output_nb + i_dest_channel_offset ]
+= p_in[ j * i_input_nb + i_source_channel_offset ]
* d_amplitude_factor;
}
((float*)p_overflow)[ (i_delay - p_out_buf->i_nb_samples + j)
* i_output_nb + i_dest_channel_offset ]
+= p_in[ j * i_input_nb + i_source_channel_offset ]
* d_amplitude_factor;
}
}
}
else
{
memset( p_out, 0, i_out_size );
}
}
/*
......@@ -638,13 +631,9 @@ static void CloseFilter( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
if( p_filter->p_sys != NULL )
{
free( p_filter->p_sys->p_overflow_buffer );
free( p_filter->p_sys->p_atomic_operations );
free( p_filter->p_sys );
p_filter->p_sys = NULL;
}
free( p_filter->p_sys->p_overflow_buffer );
free( p_filter->p_sys->p_atomic_operations );
free( p_filter->p_sys );
}
static block_t *Convert( filter_t *p_filter, block_t *p_block )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment