Commit cd3b4161 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ugly resampler: use memcpy()

parent 2e12c3f3
......@@ -84,11 +84,11 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
if( p_filter->fmt_out.audio.i_rate == p_filter->fmt_in.audio.i_rate )
return p_in_buf;
unsigned int i_nb_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
unsigned int i_in_nb = p_in_buf->i_nb_samples;
unsigned int i_out_nb = i_in_nb * p_filter->fmt_out.audio.i_rate
/ p_filter->fmt_in.audio.i_rate;
unsigned int i_sample_bytes = i_nb_channels * sizeof(int32_t);
block_t *p_out_buf = p_in_buf;
unsigned int i_out_nb = p_in_buf->i_nb_samples
* p_filter->fmt_out.audio.i_rate / p_filter->fmt_in.audio.i_rate;
const unsigned int i_sample_bytes =
aout_FormatNbChannels( &p_filter->fmt_in.audio ) * sizeof(int32_t);
if( p_filter->fmt_out.audio.i_rate > p_filter->fmt_in.audio.i_rate )
{
......@@ -97,33 +97,30 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
goto out;
}
int32_t *p_out = (int32_t*)p_out_buf->p_buffer;
const int32_t *p_in = (int32_t*)p_in_buf->p_buffer;
unsigned char *p_out = p_out_buf->p_buffer;
unsigned char *p_in = p_in_buf->p_buffer;
unsigned int i_remainder = 0;
for( unsigned i_out = i_out_nb ; i_out-- ; )
p_out_buf->i_nb_samples = i_out_nb;
p_out_buf->i_buffer = i_out_nb * i_sample_bytes;
p_out_buf->i_pts = p_in_buf->i_pts;
p_out_buf->i_length = p_out_buf->i_nb_samples *
1000000 / p_filter->fmt_out.audio.i_rate;
while( i_out_nb )
{
for( unsigned i_chan = i_nb_channels ; i_chan ; )
{
i_chan--;
p_out[i_chan] = p_in[i_chan];
}
p_out += i_nb_channels;
memcpy( p_out, p_in, i_sample_bytes );
p_out += i_sample_bytes;
i_out_nb--;
i_remainder += p_filter->fmt_in.audio.i_rate;
while( i_remainder >= p_filter->fmt_out.audio.i_rate )
{
p_in += i_nb_channels;
p_in += i_sample_bytes;
i_remainder -= p_filter->fmt_out.audio.i_rate;
}
}
p_out_buf->i_nb_samples = i_out_nb;
p_out_buf->i_buffer = i_out_nb * i_sample_bytes;
p_out_buf->i_pts = p_in_buf->i_pts;
p_out_buf->i_length = p_out_buf->i_nb_samples *
1000000 / p_filter->fmt_out.audio.i_rate;
if( p_in_buf != p_out_buf )
out:
block_Release( p_in_buf );
......
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