[MPlayer-dev-eng] [PATCH] Automatic downmix
Clément Bœsch
ubitux at gmail.com
Mon Sep 13 08:58:26 CEST 2010
On Mon, Sep 13, 2010 at 07:20:09AM +0200, Reimar Döffinger wrote:
> > [...]
> af_pan can only handle float. You should check it still works with an ao
> that can only handle int.
Mmh. The pan filter simply does not apply in this case, and there is this
message:
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format floatle
[AO SDL] Unsupported audio format: 0x1d.
> Also the behaviour might be less surprising if you'd try to prepend
> af_pan first, but I admit that's likely to be quite messy...
> Anyway, printing a warning if audio_output_channels < s->last->data->nch
> might make sense, the behaviour of -channels 1 compared to -channels 2
> is not exactly consistent like this.
Is this related to the downmix?
> > [...]
> Much smaller/simpler as:
> static const char * const downmix_strs[AF_NCH] = {
> NULL, NULL, NULL,
> "pan=2:"/*Left:*/"0.6:0:"/*Right:*/"0:0.6:":0.4:0.4".
> ....
> };
> const char *str = downmix_strs[s->last->data->nch];
> if (str)
> af_append(s, s->last, str);
Oh sure, it didn't crossed my mind. Does this look good to you with this
updated patch?
Regards,
--
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