[vlc-commits] faad: do not reorder Ambisonics channels

Adrien Maglo git at videolan.org
Fri Jan 5 09:47:43 CET 2018


vlc/vlc-3.0 | branch: master | Adrien Maglo <magsoft at videolan.org> | Thu Dec 21 18:15:01 2017 +0100| [c7e8c371e00cef338043a67291a219b30b85ca2d] | committer: Thomas Guillem

faad: do not reorder Ambisonics channels

Keep the original decoded order to achieve a correct Ambisonics rendering.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit b08ec3f97def3dcb540a20c8027c42c2258507a3)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=c7e8c371e00cef338043a67291a219b30b85ca2d
---

 modules/codec/faad.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 01aaafcb07..15243e1d8a 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -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 )



More information about the vlc-commits mailing list