[FFmpeg-devel] [PATCH] avfilter/af_amerge: add reorder_inputs option to be able to turn off reordering
Marton Balint
cus at passwd.hu
Sun Sep 4 22:45:01 EEST 2016
Signed-off-by: Marton Balint <cus at passwd.hu>
---
doc/filters.texi | 11 +++++++----
libavfilter/af_amerge.c | 12 ++++++++----
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index c12b093..b1e3890 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1069,15 +1069,18 @@ The filter accepts the following options:
@item inputs
Set the number of inputs. Default is 2.
+ at item reorder_inputs
+Try to reorder the inputs based on their channel layout. Default is true.
+
@end table
If the channel layouts of the inputs are disjoint, and therefore compatible,
the channel layout of the output will be set accordingly and the channels
will be reordered as necessary. If the channel layouts of the inputs are not
-disjoint, the output will have all the channels of the first input then all
-the channels of the second input, in that order, and the channel layout of
-the output will be the default value corresponding to the total number of
-channels.
+disjoint or @var{reorder_inputs} is set to false, the output will have all the
+channels of the first input then all the channels of the second input, in that
+order, and the channel layout of the output will be the default value
+corresponding to the total number of channels.
For example, if the first input is in 2.1 (FL+FR+LF) and the second input
is FC+BL+BR, then the output will be in 5.1, with the channels in the
diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c
index 2b4edb0..419e696 100644
--- a/libavfilter/af_amerge.c
+++ b/libavfilter/af_amerge.c
@@ -37,6 +37,7 @@
typedef struct {
const AVClass *class;
int nb_inputs;
+ int reorder_inputs;
int route[SWR_CH_MAX]; /**< channels routing, see copy_samples */
int bps;
struct amerge_input {
@@ -53,6 +54,8 @@ typedef struct {
static const AVOption amerge_options[] = {
{ "inputs", "specify the number of inputs", OFFSET(nb_inputs),
AV_OPT_TYPE_INT, { .i64 = 2 }, 2, SWR_CH_MAX, FLAGS },
+ { "reorder_inputs", "try to reorder inputs based on their channel layout", OFFSET(reorder_inputs),
+ AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
{ NULL }
};
@@ -103,10 +106,11 @@ static int query_formats(AVFilterContext *ctx)
av_log(ctx, AV_LOG_ERROR, "Too many channels (max %d)\n", SWR_CH_MAX);
return AVERROR(EINVAL);
}
- if (overlap) {
- av_log(ctx, AV_LOG_WARNING,
- "Input channel layouts overlap: "
- "output layout will be determined by the number of distinct input channels\n");
+ if (!s->reorder_inputs || overlap) {
+ if (overlap)
+ av_log(ctx, AV_LOG_WARNING,
+ "Input channel layouts overlap: "
+ "output layout will be determined by the number of distinct input channels\n");
for (i = 0; i < nb_ch; i++)
s->route[i] = i;
outlayout = av_get_default_channel_layout(nb_ch);
--
2.6.6
More information about the ffmpeg-devel
mailing list