From patchwork Wed Oct 9 10:17:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 15626 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 17EB6448B76 for ; Wed, 9 Oct 2019 13:17:34 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 088C8688256; Wed, 9 Oct 2019 13:17:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C00E86881EF for ; Wed, 9 Oct 2019 13:17:29 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id 5so1835131wmg.0 for ; Wed, 09 Oct 2019 03:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=FN49HwmW3eGYrfmYHEgUSUppowDG35jtNo5Yl8unXwA=; b=XDQtWVQwMsnmigzzZcQqXsCm68ZkvbUf5MvY5iuBsdgqZ1gVny3mzDxVfVSX6rUKSa aKitpnPwnK2sRG8EDfaNpt/PnFmPFuOn6bg6/YGH348uIHxJCmJNYSgFFMN6HrmBf0mi V+RijQbbqq46PURxjswaVxBz5NW4bjwBaLTiP5H+ydMeTy6xTV+M8Q1PiQVpy0fEk5i/ nvO8G5rkGK07mGZ+jc3K1wvQFqyAdWz2mNRyvLlajmLk+6z2nUZDGIgJpi915cwR+/yu xiv6RQ6hgrGGknBl4qzs4/qqNI9srWg6tW3HhfUNdTCF/4nLOrKg4O85AlEVQXqWD4Uc M5aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=FN49HwmW3eGYrfmYHEgUSUppowDG35jtNo5Yl8unXwA=; b=IXdAhkcfJDHyPe1rPjRp84Z/HQfg8Md5ENXLF/2ml28dc/0R6ormha7ZqYJ0RNyXrL FmKOfP+VumieA2KvhAZhCgWd+KACSMzg1/C0QjsGZ2oRG0/ZWilo0GZkIPqXqTtIj/kY 4yLnq2oBMSr/CN121Y4KYRROuIgv7NnqQGIpeEu2uqAymmpRf83y3yyXiLaZ69fG5Uih Ven7Kb4KwM2VLn/S8MYRumzI4pFHpbCaG+8u720hw8fF932wPLSs5QHzvqs7Tw9HqbHW jEFIsp6SDV28EZing75ibg9jYvDBXRRT3nKddQ0rS1j5sJEnlaWQu4fWr+Nrd2v37tZ1 6U8A== X-Gm-Message-State: APjAAAX9zZ319KLTekhy1cuklC/K6w/a6oGhs5v0JTMnKNVLhcHDQ+rQ jaMaFP7/VtTeMnkL9OLQqekPOkHV X-Google-Smtp-Source: APXvYqyhNRNipzSwXXdxYMS0PqtFaQoj1cOR00xbPlr4K69RNblIp3jKbfDVEpjjT90ZVPxR6Cyr5Q== X-Received: by 2002:a1c:f31a:: with SMTP id q26mr2098517wmq.68.1570616249065; Wed, 09 Oct 2019 03:17:29 -0700 (PDT) Received: from localhost.localdomain ([37.244.241.148]) by smtp.gmail.com with ESMTPSA id z13sm1727117wrq.51.2019.10.09.03.17.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 03:17:28 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Wed, 9 Oct 2019 12:17:05 +0200 Message-Id: <20191009101705.7072-14-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191009101705.7072-1-onemda@gmail.com> References: <20191009101705.7072-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH 14/14] avfilter/af_atempo: use ff_filter_process_command() 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- libavfilter/af_atempo.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c index 688dac5464..39b500ba95 100644 --- a/libavfilter/af_atempo.c +++ b/libavfilter/af_atempo.c @@ -162,7 +162,7 @@ static const AVOption atempo_options[] = { OFFSET(tempo), AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 }, YAE_ATEMPO_MIN, YAE_ATEMPO_MAX, - AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM }, + AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_COMMAND_PARAM }, { NULL } }; @@ -328,28 +328,14 @@ static int yae_reset(ATempoContext *atempo, return 0; } -static int yae_set_tempo(AVFilterContext *ctx, const char *arg_tempo) +static int yae_update(AVFilterContext *ctx) { const AudioFragment *prev; ATempoContext *atempo = ctx->priv; - char *tail = NULL; - double tempo = av_strtod(arg_tempo, &tail); - - if (tail && *tail) { - av_log(ctx, AV_LOG_ERROR, "Invalid tempo value '%s'\n", arg_tempo); - return AVERROR(EINVAL); - } - - if (tempo < YAE_ATEMPO_MIN || tempo > YAE_ATEMPO_MAX) { - av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [%f, %f] range\n", - tempo, YAE_ATEMPO_MIN, YAE_ATEMPO_MAX); - return AVERROR(EINVAL); - } prev = yae_prev_frag(atempo); atempo->origin[0] = prev->position[0] + atempo->window / 2; atempo->origin[1] = prev->position[1] + atempo->window / 2; - atempo->tempo = tempo; return 0; } @@ -1189,7 +1175,12 @@ static int process_command(AVFilterContext *ctx, int res_len, int flags) { - return !strcmp(cmd, "tempo") ? yae_set_tempo(ctx, arg) : AVERROR(ENOSYS); + int ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags); + + if (ret < 0) + return ret; + + return yae_update(ctx); } static const AVFilterPad atempo_inputs[] = {