From patchwork Sun Sep 4 19:45:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 419 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp2417664vsd; Sun, 4 Sep 2016 12:45:17 -0700 (PDT) X-Received: by 10.194.103.3 with SMTP id fs3mr28326733wjb.115.1473018317681; Sun, 04 Sep 2016 12:45:17 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u140si14083884wmu.87.2016.09.04.12.45.17; Sun, 04 Sep 2016 12:45:17 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C9365689E4E; Sun, 4 Sep 2016 22:45:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 83023689DF8 for ; Sun, 4 Sep 2016 22:45:00 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 144CC100E2A; Sun, 4 Sep 2016 21:45:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id swTM+yxPyDRc; Sun, 4 Sep 2016 21:45:07 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id C488E100B88; Sun, 4 Sep 2016 21:45:07 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Sep 2016 21:45:01 +0200 Message-Id: <1473018301-23871-1-git-send-email-cus@passwd.hu> X-Mailer: git-send-email 2.6.6 Subject: [FFmpeg-devel] [PATCH] avfilter/af_amerge: add reorder_inputs option to be able to turn off reordering X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- 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. +@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);