From patchwork Wed Jan 23 17:23:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 11842 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 60BDC44E8EF for ; Wed, 23 Jan 2019 19:23:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 79BA268A630; Wed, 23 Jan 2019 19:23:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx2.mailbox.org (mx2.mailbox.org [80.241.60.215]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8686C68A391 for ; Wed, 23 Jan 2019 19:23:25 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 31CE9A17C0 for ; Wed, 23 Jan 2019 18:23:43 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id 2fPs46_VU9mp for ; Wed, 23 Jan 2019 18:23:38 +0100 (CET) To: ffmpeg-devel@ffmpeg.org References: <686bb8c0-5bc3-78c8-0545-f94135c957d5@gyani.pro> From: Gyan Message-ID: <776f7883-a34f-8dc2-6376-3f7393cd26c1@gyani.pro> Date: Wed, 23 Jan 2019 22:53:34 +0530 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Subject: Re: [FFmpeg-devel] [PATCH] avfilter/acrossfade: allow skipping fade on inputs 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On 23-01-2019 07:40 PM, Paul B Mahol wrote: > On 1/23/19, Gyan wrote: >> >> On 23-01-2019 03:00 PM, Paul B Mahol wrote: >>> On 1/23/19, Gyan wrote: >>> Why? afade needs change too. >> If a user doesn't want to apply fade, then they can simply not add afade >> filter. This change is meant for users who want to combine two audio >> streams with overlap but don't want to apply fade to audio during overlap. >> > I do not like such reasoning, also you changed afade too with this approach. That was to prevent an integer value of nb_curves-1 from being accepted. Anyway, revised patch attached, although I don't see how afade=c=nofade   is useful. Gyan From e8ee422323eabad02ac4c2385c8d5a5997f6cab8 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Wed, 23 Jan 2019 13:35:23 +0530 Subject: [PATCH v2] avfilter/afade+acrossfade: allow skipping fade on inputs New fade curve value 'nofade' passes audio samples as-is. Primarily useful in carrying out acrossfade without fades. --- doc/filters.texi | 2 ++ libavfilter/af_afade.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index d06dfe089f..fc98323af0 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -958,6 +958,8 @@ select double-exponential seat select double-exponential sigmoid @item losi select logistic sigmoid +@item nofade +no fade applied @end table @end table diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c index 751db7da4d..195fb65ab5 100644 --- a/libavfilter/af_afade.c +++ b/libavfilter/af_afade.c @@ -51,7 +51,7 @@ typedef struct AudioFadeContext { int curve0, int curve1); } AudioFadeContext; -enum CurveType { TRI, QSIN, ESIN, HSIN, LOG, IPAR, QUA, CUB, SQU, CBR, PAR, EXP, IQSIN, IHSIN, DESE, DESI, LOSI, NB_CURVES }; +enum CurveType { TRI, QSIN, ESIN, HSIN, LOG, IPAR, QUA, CUB, SQU, CBR, PAR, EXP, IQSIN, IHSIN, DESE, DESI, LOSI, NONE, NB_CURVES }; #define OFFSET(x) offsetof(AudioFadeContext, x) #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM @@ -153,6 +153,9 @@ static double fade_gain(int curve, int64_t index, int64_t range) gain = (A - B) / (C - B); } break; + case NONE: + gain = 1.0; + break; } return gain; @@ -260,6 +263,7 @@ static const AVOption afade_options[] = { { "dese", "double-exponential seat", 0, AV_OPT_TYPE_CONST, {.i64 = DESE }, 0, 0, FLAGS, "curve" }, { "desi", "double-exponential sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = DESI }, 0, 0, FLAGS, "curve" }, { "losi", "logistic sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = LOSI }, 0, 0, FLAGS, "curve" }, + { "nofade", "no fade; keep audio as-is", 0, AV_OPT_TYPE_CONST, {.i64 = NONE }, 0, 0, FLAGS, "curve" }, { NULL } }; @@ -380,6 +384,7 @@ static const AVOption acrossfade_options[] = { { "dese", "double-exponential seat", 0, AV_OPT_TYPE_CONST, {.i64 = DESE }, 0, 0, FLAGS, "curve" }, { "desi", "double-exponential sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = DESI }, 0, 0, FLAGS, "curve" }, { "losi", "logistic sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = LOSI }, 0, 0, FLAGS, "curve" }, + { "nofade", "no fade; keep audio as-is", 0, AV_OPT_TYPE_CONST, {.i64 = NONE }, 0, 0, FLAGS, "curve" }, { "curve2", "set fade curve type for 2nd stream", OFFSET(curve2), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" }, { "c2", "set fade curve type for 2nd stream", OFFSET(curve2), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" }, { NULL }