[vlc-commits] trivial_mixer: avoid useless memcpy

Thomas Guillem git at videolan.org
Fri Oct 21 14:34:24 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Oct 21 14:22:40 2016 +0200| [e791868c2916f63dcf514bab4f4445dc026da18a] | committer: Thomas Guillem

trivial_mixer: avoid useless memcpy

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

 modules/audio_filter/channel_mixer/trivial.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/modules/audio_filter/channel_mixer/trivial.c b/modules/audio_filter/channel_mixer/trivial.c
index 0085766..734f585 100644
--- a/modules/audio_filter/channel_mixer/trivial.c
+++ b/modules/audio_filter/channel_mixer/trivial.c
@@ -360,6 +360,25 @@ static int Create( vlc_object_t *p_this )
     }
 #endif
 
+    if( aout_FormatNbChannels( outfmt ) == aout_FormatNbChannels( infmt ) )
+    {
+        /* Channel layouts can be different but the channel order can be the
+         * same. This is the case for AOUT_CHANS_5_1 <-> AOUT_CHANS_5_1_MIDDLE
+         * for example. */
+        bool b_equals = true;
+        for( unsigned i = 0; i < aout_FormatNbChannels( outfmt ); ++i )
+            if( channel_map[i] == -1 || (unsigned) channel_map[i] != i )
+            {
+                b_equals = false;
+                break;
+            }
+        if( b_equals )
+        {
+            p_filter->pf_audio_filter = Equals;
+            return VLC_SUCCESS;
+        }
+    }
+
     p_filter->p_sys = malloc( sizeof(*p_filter->p_sys) );
     if(! p_filter->p_sys )
         return VLC_ENOMEM;



More information about the vlc-commits mailing list