From patchwork Mon Aug 9 14:50:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linjie Fu X-Patchwork-Id: 29381 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp2933655ioh; Mon, 9 Aug 2021 07:50:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrU2kTMuoKMSyw4bAKKfwCkjVDmQS57DGhx0ICHYlsey0mJHwAO+CbMrhsjAnTMs+9SR1o X-Received: by 2002:a05:6402:160c:: with SMTP id f12mr30510241edv.122.1628520649419; Mon, 09 Aug 2021 07:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628520649; cv=none; d=google.com; s=arc-20160816; b=W9pY6I8pdewOhKZMOKAwNNstryHAzez30Acdhbxv37mPQ6o2R7DAC3k5CQwqB+JgJd IhEUOuLY7zggNbzyf3srvEI39J2ZNc9v7eTRREbhieWIy6/SNyTsiAeOM/0r0uXotTJb etTXtPbOf20t9SUKwBspRe5ogXnkUdjm0HX3W24LNKIBnAvfhJVpNXrOxCmgwSOsoZJj q2CgDW+4dvIGt2F1NcbNgX8XRG2BgvHjEl3vdDZ5RLv2kmE/AcPYukhVtA4CRaOTCOm7 yS4Jcn1CAmuy9zsLRwO+zejusnGJBVuhFRTN8AJk5rpiudv+09SETQGH+L3V6GQztwSo bJIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=p6xVK9aoVMZf1UNZ/e1kdqDoVLcwGuey4bfTgVoz9q8=; b=C+yZZigwvE8mz4gkBGQHpA0B4sbkRPI8hVGErG6hT92H7lihtqfj4Fz3E1fTdlMcp5 jutar8JpoXNzRs2ADotenWCaqBpTpRJLF3VqZ5cMuhuYm/GoCBcVqaWeSdVaMm3PCYMf ks+xmHGfW4mecwH9RgbGO/s/CwmgAnJ37DOFqwX047mlPMmVICFEkFDebDmE7lHL523U PxlxdcV+EWIUnY+e15ss7NF07REVEOEc/wjQsKbuUoE97QpmRNxvNtKGQDS3WRW5BSCz mVP4FfVb0pta9pkPNu1I77nWrJTKgi+SrimGUnvCkAvBGe6owi0BpvS1QSPuxL1uwpIu wB7A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v12si4004497eds.540.2021.08.09.07.50.48; Mon, 09 Aug 2021 07:50:49 -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 240ED68A2AE; Mon, 9 Aug 2021 17:50:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from zg8tmty1ljiyny4xntqumjca.icoremail.net (zg8tmty1ljiyny4xntqumjca.icoremail.net [165.227.154.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with SMTP id AE9EF68991B for ; Mon, 9 Aug 2021 17:50:37 +0300 (EEST) Received: from localhost.localdomain (unknown [58.247.209.118]) by mail-app4 (Coremail) with SMTP id cS_KCgBXnay2QBFhQLnqAQ--.24743S2; Mon, 09 Aug 2021 22:50:30 +0800 (CST) From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 Aug 2021 22:50:13 +0800 Message-Id: <20210809145014.98012-1-fulinjie@zju.edu.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: cS_KCgBXnay2QBFhQLnqAQ--.24743S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrWrKF18ZrWfArykCr47XFb_yoW8Cry5pw 4F93WrGFZ3JrWIvan2vr1rWa1rGrykGFW7urZYy398A3s8JryUt3y2krWY9rWjywnrZr4F qFyjk34UX3WqvaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkYb7Iv0xC_Zr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkIecxEwVAFwVW5XwCF04k2 0xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI 8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jrv_JF1lIxkGc2Ij64vIr41l IxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIx AIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU8C_M3UUUUU== X-CM-SenderInfo: ysrvjiarsuq6lmxovvfxof0/ Subject: [FFmpeg-devel] [PATCH v2 1/2] lavfi/vf_scale: dump the exact swscale_options to passed to libswscale X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Linjie Fu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: JhUIy5Qn9Sg0 From: Linjie Fu Printed verbose log doesn't match the sws_flags specified in the cmdline for simple filter graph. ffmpeg .. -sws_flags bicubic .. [auto_scaler_0] w:iw h:ih flags:'' interl:0 [auto_scaler_0] w:310 h:449 fmt:yuva420p sar:0/1 -> w:310 h:449 fmt:yuv420p sar:0/1 flags:0x0 Filter complex doesn't have this issue as mentioned in 12e7e1d03, the auto-inserted scaler accepts sws_flags in filtergraph complex which overrides the 'flags' option for vf_scale and dump it as a verbose log: ffmpeg .. -filter_complex "sws_flags=bicubic;format=nv12" .. [auto_scaler_0] w:iw h:ih flags:'bicubic' interl:0 [auto_scaler_0] w:310 h:449 fmt:yuva420p sar:0/1 -> w:310 h:449 fmt:nv12 sar:0/1 flags:0x2 To catch the difference, dump the exact sws_flags which is passed to libswscale. [auto_scaler_0] swscale_options:'sws_flags=bicubic' Signed-off-by: Linjie Fu --- libavfilter/vf_scale.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index aa855b894a..dc8051a236 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -552,10 +552,16 @@ static int config_props(AVFilterLink *outlink) scale->out_range == AVCOL_RANGE_JPEG, 0); if (scale->opts) { + char args[512] = { 0 }; AVDictionaryEntry *e = NULL; while ((e = av_dict_get(scale->opts, "", e, AV_DICT_IGNORE_SUFFIX))) { if ((ret = av_opt_set(*s, e->key, e->value, 0)) < 0) return ret; + av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value); + } + if (args[0] != '\0') { + args[strlen(args)-1] = 0; + av_log(ctx, AV_LOG_VERBOSE, "swscale_options:'%s'\n", args); } } /* Override YUV420P default settings to have the correct (MPEG-2) chroma positions From patchwork Mon Aug 9 14:50:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linjie Fu X-Patchwork-Id: 29380 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp2933801ioh; Mon, 9 Aug 2021 07:50:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDaX4/5Y8PpZTQocZpj4J8qnsx2SnCgSEHS71wl9VAwl+WkKshYRJ3SLzIk8AkgCuG4tWA X-Received: by 2002:a17:906:1da1:: with SMTP id u1mr22550822ejh.307.1628520659391; Mon, 09 Aug 2021 07:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628520659; cv=none; d=google.com; s=arc-20160816; b=aDk+RGI5qwIN1uZ/U4/LltGiDGIIMDA+9fNMteCVu0NAVLhdGuvj1WqReknb38+orc sZvNVmMbjb1ZMDUwNrJBwxPkwR6HnMy3DmtIzc1VWTxEjTn/MsDX3c5RZodM377Bbijm 1ZaN4U4QBGe6fMKldc2yuGBi6l+5DSe0yUVIGvIbqD9K0gDgh3E5CVHD88EZmW5qJzJz oVkvp0py6awZP3983IDr97kclNQzak6ns8KrUdYorChuoSqrndHl/XF+SjUUwM54qICn rPCQpZ4o84aZJSMcGtY4g9Xywd7zIRpFp0hMwVfYBv87FbKNDiUAC4rgHv6T0R+PcLYv Ybrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=RBbhMFyobyeCx3gGX9ZUDwew6wo0NOxlh0qg9TuXEDc=; b=heKGurmUrxFsPtPTliE0QSTIsol9V3eTJqsD+ftvQq//athAD7duKbQD+Lh/mw1XXT CRRfiwsglBVlSqSgOrkMDxQZs2hgwZDUf9nBZPMZrPgesQSKhGFYBZh10vRywBdurc+v KiJ9FWL7Nw5GV1qcPJtIq66BQ6C2z1QyHd3Dr8Xz8whdS6YzClcuo63lMG8vAU90F65X IuM5XRXxuIG85QtlC13VSgZMKldXKGf8fvmWH49W4J6x2m8rbs5tsxeYFuHzE2h/2xTq yV3m9MpEUGS64K8PiWn/BJ/tjHRkDRQT80ttWM6ary7wCJQugLa0OzF/1Dazs4pPeF/D QaTw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 5si19774033ejq.621.2021.08.09.07.50.59; Mon, 09 Aug 2021 07:50:59 -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 166B668A2FE; Mon, 9 Aug 2021 17:50:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from zg8tmty1ljiyny4xntqumjca.icoremail.net (zg8tmty1ljiyny4xntqumjca.icoremail.net [165.227.154.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with SMTP id 2272068991B for ; Mon, 9 Aug 2021 17:50:38 +0300 (EEST) Received: from localhost.localdomain (unknown [58.247.209.118]) by mail-app4 (Coremail) with SMTP id cS_KCgBXnay2QBFhQLnqAQ--.24743S3; Mon, 09 Aug 2021 22:50:34 +0800 (CST) From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 Aug 2021 22:50:14 +0800 Message-Id: <20210809145014.98012-2-fulinjie@zju.edu.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210809145014.98012-1-fulinjie@zju.edu.cn> References: <20210809145014.98012-1-fulinjie@zju.edu.cn> MIME-Version: 1.0 X-CM-TRANSID: cS_KCgBXnay2QBFhQLnqAQ--.24743S3 X-Coremail-Antispam: 1UD129KBjvJXoWxCw45Jr1fKr4rCF45ur17Jrb_yoW5AFyrpa 1fCa4kGF17KF1fCFnFv3WxXr4YgrWrGryFvrWrtr9rXF4DKr92y393Cry5uw17G3WUCrs7 Ja15ta4UCwnrKw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Kb7Iv0xC_Zr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI 8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kE wVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x 0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF 7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F4 0Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC 6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc2xSY4AK67AK6ry5MxAIw28IcxkI7VAKI4 8JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xv wVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUXVWUAwCIc40Y0x0EwIxGrwCI42IY6xIIjx v20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20E Y4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267 AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU49YFDUUUU X-CM-SenderInfo: ysrvjiarsuq6lmxovvfxof0/ Subject: [FFmpeg-devel] [PATCH v2 2/2] libavfilter/graphparser: Add scale_sws_opts parse support in avfilter_graph_parse2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Linjie Fu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: K/hwPZh9Dcvd From: Linjie Fu To pass the swscale options for the inserted scalers. ffmpeg -i input.mp4 -filter_complex \ "scale_sws_opts=alphablend=checkerboard;format=nv12" \ -t 0.5 output.mp4 Update docs. Signed-off-by: Linjie Fu --- doc/filters.texi | 7 ++++--- libavfilter/graphparser.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index bdeb3fedfd..67108f91ff 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -204,9 +204,9 @@ pads must be connected. A filtergraph is considered valid if all the filter input and output pads of all the filterchains are connected. Libavfilter will automatically insert @ref{scale} filters where format -conversion is required. It is possible to specify swscale flags -for those automatically inserted scalers by prepending -@code{sws_flags=@var{flags};} +conversion is required. It is possible to specify swscale flags or +scale_sws_opts for those automatically inserted scalers by prepending +@code{sws_flags=@var{flags};} or @code{scale_sws_opts=@var{scale_sws_opts};} to the filtergraph description. Here is a BNF description of the filtergraph syntax: @@ -219,6 +219,7 @@ Here is a BNF description of the filtergraph syntax: @var{FILTER} ::= [@var{LINKLABELS}] @var{FILTER_NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}] @var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}] @var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}] +@var{FILTERGRAPH} ::= [scale_sws_opts=@var{opts};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}] @end example @anchor{filtergraph escaping} diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c index 1385c3ae71..96ae8940af 100644 --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@ -415,6 +415,25 @@ static int parse_sws_flags(const char **buf, AVFilterGraph *graph) return 0; } +static int parse_scale_sws_opts(const char **buf, AVFilterGraph *graph) +{ + char *p = strchr(*buf, ';'); + + if (!av_strstart(*buf, "scale_sws_opts=", buf)) + return 0; + + if (!p) { + av_log(graph, AV_LOG_ERROR, "scale_sws_opts not terminated with ';'.\n"); + return AVERROR(EINVAL); + } + + av_freep(&graph->scale_sws_opts); + graph->scale_sws_opts = av_strndup(*buf, p - *buf); + + *buf = p + 1; + return 0; +} + int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs) @@ -429,6 +448,9 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, if ((ret = parse_sws_flags(&filters, graph)) < 0) goto fail; + if ((ret = parse_scale_sws_opts(&filters, graph)) < 0) + goto fail; + do { AVFilterContext *filter; filters += strspn(filters, WHITESPACES);