[vlc-devel] [PATCH] Added Central Channel Filter module

Vedanta Nayak vedantnayak2 at gmail.com
Wed Apr 8 14:52:52 CEST 2020


Hello,
I have changed the case of the define, changed the static_assert and
removed the extra factor multiplication.

---
 modules/audio_filter/center.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/audio_filter/center.c b/modules/audio_filter/center.c
index 54147dd57c..a69232acf2 100644
--- a/modules/audio_filter/center.c
+++ b/modules/audio_filter/center.c
@@ -28,7 +28,7 @@
 #include <vlc_filter.h>
 #include <vlc_plugin.h>
 
-#define i_nb_channels 3
+#define I_NB_CHANNELS 3
 
 static block_t *Process  (filter_t *, block_t *);
 
@@ -39,7 +39,7 @@ static int Open (vlc_object_t *in)
     {
         return VLC_EGENERIC;
     }
-    static_assert(AOUT_CHAN_LEFT <= AOUT_CHAN_RIGHT <= AOUT_CHAN_CENTER, "Change in channel order.");
+    static_assert(AOUT_CHANIDX_CENTER > AOUT_CHANIDX_RIGHT && AOUT_CHANIDX_RIGHT > AOUT_CHANIDX_LEFT, "Change in channel order.");
     filter->fmt_out.audio.i_format = VLC_CODEC_FL32;
     filter->fmt_in.audio.i_format = VLC_CODEC_FL32;
     filter->fmt_out.audio.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER;
@@ -55,7 +55,7 @@ static block_t *Process ( filter_t *filter, block_t *in_buf )
     float *in = (float*)in_buf->p_buffer;
     size_t i_nb_samples = in_buf->i_nb_samples;
     size_t i;
-    block_t *out_buf = block_Alloc(sizeof(float) * i_nb_samples * i_nb_channels );
+    block_t *out_buf = block_Alloc(sizeof(float) * i_nb_samples * I_NB_CHANNELS );
     if ( !out_buf )
     {
         block_Release(in_buf);
@@ -72,9 +72,9 @@ static block_t *Process ( filter_t *filter, block_t *in_buf )
         float left = in[i*2];
         float right = in[i*2+1];
         float center = ( left + right ) * factor / 2;
-        p_out[i * i_nb_channels   ] = left;
-        p_out[i * i_nb_channels + 1 ] = right;
-        p_out[i * i_nb_channels + 2 ] = center * factor;
+        p_out[i * I_NB_CHANNELS   ] = left;
+        p_out[i * I_NB_CHANNELS + 1 ] = right;
+        p_out[i * I_NB_CHANNELS + 2 ] = center;
     }
     block_Release(in_buf);
     return out_buf;
-- 
2.26.0



More information about the vlc-devel mailing list