[MPlayer-dev-eng] [PATCH] Automatic downmix

ubitux ubitux at gmail.com
Tue Aug 10 20:57:57 CEST 2010


Oups, bad patch sorry. Fixed in this mail.

-- 
ubitux
-------------- next part --------------
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 31950)
+++ mplayer.c	(working copy)
@@ -1647,6 +1647,50 @@
 ///@}
 // OSDMsgStack
 
+/**
+ * \brief Automatic downmix to stereo in case the codec does not implement it
+ */
+static void downmix_if_needed()
+{
+    if (audio_output_channels != 2)
+        return;
+    switch (mpctx->sh_audio->channels) {
+    case 6:
+        af_add(mpctx->mixer.afilter, "pan=2:"
+                                     "1:0:"      // Left
+                                     "0:1:"      // Right
+                                     "0.7:0.7:"  // Center
+                                     "0.3:0.3:"  // LFE
+                                     "0.5:0:"    // Back left
+                                     "0:0.5"     // Back right
+        );
+        break;
+    case 5:
+        af_add(mpctx->mixer.afilter, "pan=2:"
+                                     "1:0:"      // Left
+                                     "0:1:"      // Right
+                                     "0.7:0.7:"  // Center
+                                     "0.5:0:"    // Back left
+                                     "0:0.5"     // Back right
+        );
+        break;
+    case 4:
+        af_add(mpctx->mixer.afilter, "pan=2:"
+                                     "1:0:"      // Left
+                                     "0:1:"      // Right
+                                     "0.5:0:"    // Back left
+                                     "0:0.5"     // Back right
+        );
+        break;
+    case 3:
+        af_add(mpctx->mixer.afilter, "pan=2:"
+                                     "1:0:"      // Left
+                                     "0:1:"      // Right
+                                     "0.7:0.7"   // Center
+        );
+        break;
+    }
+}
 
 void reinit_audio_chain(void) {
     if (!mpctx->sh_audio)
@@ -1706,6 +1750,8 @@
     }
     mpctx->mixer.audio_out = mpctx->audio_out;
     mpctx->mixer.volstep = volstep;
+
+    downmix_if_needed();
     return;
 
 init_error:


More information about the MPlayer-dev-eng mailing list