Commit af147ca1 authored by Ilkka Ollakka's avatar Ilkka Ollakka

trivial: fix upmixing case and handle dualmono

Earlier commit for dualmono (from 2003) seemed to miss some cases
and reordering the if cases as I assume dualmono isn't most common
case in filter.

Ref #7261
parent 6b7dcd70
......@@ -105,14 +105,16 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
if( i_input_nb >= i_output_nb )
{
p_out_buf = p_in_buf; /* mix in place */
p_out_buf->i_buffer = p_in_buf->i_buffer / i_input_nb * i_output_nb;
p_out_buf->i_buffer = p_in_buf->i_buffer * i_output_nb / i_input_nb;
}
else
{
p_out_buf = block_Alloc(
p_in_buf->i_buffer / i_input_nb * i_output_nb );
p_in_buf->i_buffer * i_output_nb / i_input_nb );
if( !p_out_buf )
goto out;
/* on upmixing case, zero out buffer */
memset( p_out_buf->p_buffer, 0, p_out_buf->i_buffer );
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_dts = p_in_buf->i_dts;
p_out_buf->i_pts = p_in_buf->i_pts;
......@@ -121,11 +123,18 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
float * p_dest = (float *)p_out_buf->p_buffer;
const float * p_src = (float *)p_in_buf->p_buffer;
const bool b_reverse_stereo = p_filter->fmt_out.audio.i_original_channels & AOUT_CHAN_REVERSESTEREO;
bool b_dualmono2stereo = (p_filter->fmt_in.audio.i_original_channels & AOUT_CHAN_DUALMONO );
b_dualmono2stereo &= (p_filter->fmt_out.audio.i_physical_channels & ( AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT ));
b_dualmono2stereo &= ((p_filter->fmt_out.audio.i_physical_channels & AOUT_CHAN_PHYSMASK) != (p_filter->fmt_in.audio.i_physical_channels & AOUT_CHAN_PHYSMASK));
if ( (p_filter->fmt_out.audio.i_original_channels & AOUT_CHAN_PHYSMASK)
!= (p_filter->fmt_in.audio.i_original_channels & AOUT_CHAN_PHYSMASK)
&& (p_filter->fmt_in.audio.i_original_channels & AOUT_CHAN_PHYSMASK)
== (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) )
if( likely( !b_reverse_stereo && ! b_dualmono2stereo ) )
{
SparseCopy( p_dest, p_src, p_in_buf->i_nb_samples, i_output_nb,
i_input_nb );
}
/* Special case from dual mono to stereo */
else if ( b_dualmono2stereo )
{
int i;
/* This is a bit special. */
......@@ -156,8 +165,7 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
}
}
}
else if ( p_filter->fmt_out.audio.i_original_channels
& AOUT_CHAN_REVERSESTEREO )
else if ( b_reverse_stereo )
{
/* Reverse-stereo mode */
int i;
......@@ -171,11 +179,6 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
p_src += 2;
}
}
else
{
SparseCopy( p_dest, p_src, p_in_buf->i_nb_samples, i_output_nb,
i_input_nb );
}
out:
if( p_in_buf != p_out_buf )
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