[MPlayer-dev-eng] [PATCH] Automatic downmix
Clément Bœsch
ubitux at gmail.com
Mon Sep 13 09:31:10 CEST 2010
> > [...]
> Oh sure, it didn't crossed my mind. Does this look good to you with this
> updated patch?
Fixed trailing space after BL comment in this patch (sorry).
--
Clément B.
-------------- next part --------------
Index: libaf/af.c
===================================================================
--- libaf/af.c (revision 32219)
+++ libaf/af.c (working copy)
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include "osdep/strsep.h"
+#include "libmpcodecs/dec_audio.h"
#include "af.h"
@@ -361,6 +362,25 @@
}
/**
+ * Automatic downmix to stereo in case the codec does not implement it.
+ */
+static void af_downmix(af_stream_t* s)
+{
+ static char * const downmix_strs[AF_NCH + 1] = {
+ [3] = "pan=2:" /*FL*/"0.6:0:" /*FR*/"0:0.6:" /*FC*/"0.4:0.4",
+ [4] = "pan=2:" /*FL*/"0.6:0:" /*FR*/"0:0.6:" /*BL*/"0.4:0:" /*BR*/"0:0.4",
+ [5] = "pan=2:" /*FL*/"0.5:0:" /*FR*/"0:0.5:" /*BL*/"0.2:0:" /*BR*/"0:0.2:" /*FC*/"0.3:0.3",
+ [6] = "pan=2:" /*FL*/"0.4:0:" /*FR*/"0:0.4:" /*BL*/"0.2:0:" /*BR*/"0:0.2:" /*FC*/"0.3:0.3:" /*LFE*/"0.1:0.1",
+ [7] = "pan=2:" /*FL*/"0.4:0:" /*FR*/"0:0.4:" /*BL*/"0.2:0:" /*BR*/"0:0.2:" /*FC*/"0.3:0.3:" /*AL*/"0.1:0:" /*AR*/"0:0.1",
+ [8] = "pan=2:" /*FL*/"0.4:0:" /*FR*/"0:0.4:" /*BL*/"0.15:0:" /*BR*/"0:0.15:" /*FC*/"0.25:0.25:" /*LFE*/"0.1:0.1:" /*AL*/"0.1:0:" /*AR*/"0:0.1",
+ };
+ char *af_pan_str = downmix_strs[s->last->data->nch];
+
+ if (af_pan_str)
+ af_append(s, s->last, af_pan_str);
+}
+
+/**
* Extend the filter chain so we get the required output format at the end.
* \return AF_ERROR on error, AF_OK if successful.
*/
@@ -396,6 +416,9 @@
return AF_ERROR;
}
+ // Append a downmix pan filter to the end of the chain if needed
+ af_downmix(s);
+
// Re init again just in case
if(AF_OK != af_reinit(s,s->first))
return AF_ERROR;
More information about the MPlayer-dev-eng
mailing list