Commit b08ec3f9 authored by Adrien Maglo's avatar Adrien Maglo Committed by Jean-Baptiste Kempf

faad: do not reorder Ambisonics channels

Keep the original decoded order to achieve a correct Ambisonics rendering.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 01fd9fe4
......@@ -512,24 +512,29 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
/* Convert frame.channel_position to our own channel values */
p_dec->fmt_out.audio.i_physical_channels = 0;
uint32_t pi_faad_channels_positions[FAAD_CHANNEL_ID_COUNT] = {0};
uint8_t pi_neworder_table[AOUT_CHAN_MAX];
for( size_t i = 0; i < frame.channels; i++ )
uint32_t pi_faad_channels_positions[FAAD_CHANNEL_ID_COUNT] = {0};
bool b_reorder = false;
if (p_dec->fmt_out.audio.channel_type == AUDIO_CHANNEL_TYPE_BITMAP)
{
unsigned pos = frame.channel_position[i];
if( likely(pos < FAAD_CHANNEL_ID_COUNT) )
for( size_t i = 0; i < frame.channels; i++ )
{
pi_faad_channels_positions[i] = pi_tovlcmapping[pos];
p_dec->fmt_out.audio.i_physical_channels |= pi_faad_channels_positions[i];
unsigned pos = frame.channel_position[i];
if( likely(pos < FAAD_CHANNEL_ID_COUNT) )
{
pi_faad_channels_positions[i] = pi_tovlcmapping[pos];
p_dec->fmt_out.audio.i_physical_channels |= pi_faad_channels_positions[i];
}
else pi_faad_channels_positions[i] = 0;
}
else pi_faad_channels_positions[i] = 0;
}
bool b_reorder = aout_CheckChannelReorder( pi_faad_channels_positions, NULL,
p_dec->fmt_out.audio.i_physical_channels, pi_neworder_table );
b_reorder = aout_CheckChannelReorder( pi_faad_channels_positions, NULL,
p_dec->fmt_out.audio.i_physical_channels, pi_neworder_table );
p_dec->fmt_out.audio.i_channels = popcount(p_dec->fmt_out.audio.i_physical_channels);
p_dec->fmt_out.audio.i_channels = popcount(p_dec->fmt_out.audio.i_physical_channels);
}
if( !decoder_UpdateAudioFormat( p_dec ) && p_dec->fmt_out.audio.i_channels > 0 )
p_out = decoder_NewAudioBuffer( p_dec, frame.samples / p_dec->fmt_out.audio.i_channels );
......@@ -541,9 +546,12 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
frame.samples / frame.channels )
- p_out->i_pts;
/* Don't kill speakers if some weird mapping does not gets 1:1 */
if( popcount(p_dec->fmt_out.audio.i_physical_channels) != frame.channels )
memset( p_out->p_buffer, 0, p_out->i_buffer );
if ( p_dec->fmt_out.audio.channel_type == AUDIO_CHANNEL_TYPE_BITMAP )
{
/* Don't kill speakers if some weird mapping does not gets 1:1 */
if( popcount(p_dec->fmt_out.audio.i_physical_channels) != frame.channels )
memset( p_out->p_buffer, 0, p_out->i_buffer );
}
/* FIXME: replace when aout_channel_reorder can take samples from a different buffer */
if( b_reorder )
......
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