From patchwork Fri Aug 18 16:50:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 43265 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4c9d:b0:130:ccc6:6c4b with SMTP id fq29csp2803283pzb; Fri, 18 Aug 2023 09:51:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFasTjtdvE58uIF9GdfD0ta7Y3QvRgG1JjMldYCsmWRc5oXh54pbyTrZzOf43fAZNYrlhkP X-Received: by 2002:a17:907:2bc6:b0:99b:cb59:79b3 with SMTP id gv6-20020a1709072bc600b0099bcb5979b3mr3423384ejc.1.1692377467002; Fri, 18 Aug 2023 09:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692377466; cv=none; d=google.com; s=arc-20160816; b=0f/2ZKMukffW/3bRO/UMd+ZGh7ZLU1uLgz7TEkxYGCiVGfwPjF+TZ7oqOd2ctGE+tt uOI6HBWSM0ZNlsI7etF+b+uSzxsfNg2kQoxN0URhX/bXgnuBrxS3v170FzvKgo9spkTi mawsy9QE/q7vCT0MKHCwpAt5Z2KOQ29JcXW0lhvQYygVTrPFDwNDinpcI2hy6UzHNA32 13ZADThF/OvVt/T+vUuxxKmHDf+MI3D2HYKUoKYDnNXy4e5mD3XjQJBZY89u/glDctl/ MZ9VBOCbbvsuHd3mwhvERKGc9nuO1S8+iyffQK9tRFcKvHZztnRKnu0HFbTtxZFBacM5 9eXg== 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:dkim-signature:delivered-to; bh=wVNCPyXqCr+KjTXM2iKCdwZ49pg2lBmPsoITmnHY5IQ=; fh=gT0qIutk2UUjXR+TfNyL+SuB7mt8pajgYxSYYxhvGBk=; b=Rh4yx2YlzMnuN/qO5mCavY2BVjLkTotAFzKHRybIik9TGLTzZM5CYY6moxPaWiynpP mwyFeF6mTafjM9iVD4NZfnKgkXdsIVScV0DyFOrOcXv9DObNrrH4r0z+ZQXFhkZM6cju 6uzeP+9oXORO2kB044lek3ryePmIKISvg1Rf+nPTIVFRAbqcJT/h76PFI2SpG3V85/23 YlkT/E+zA3VyrlzFndDNn5bevP5nn4zzdiWVs/JYsm6ndAHfX2+k7CCBkQwSww/dpcje LbMhOu3ubGGhaPgSMOzQFbfS1TNg6lE6Y2jir2yr/gyTBwFkU0lYNLTMtb+kDyYJa/kH 6FAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=i3nRKgFY; 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 gq7-20020a170906e24700b0099d0cece94asi1493557ejb.146.2023.08.18.09.51.05; Fri, 18 Aug 2023 09:51:06 -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; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=i3nRKgFY; 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 723B268C6D8; Fri, 18 Aug 2023 19:50:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9A50A68BC82 for ; Fri, 18 Aug 2023 19:50:47 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 5F094471F7; Fri, 18 Aug 2023 18:50:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1692377447; bh=/Myzik16Uhnf36qyzPRmWe7wc0ZXQPLdpR4poZhOMy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i3nRKgFYDymIAiYboaGRLDZmvSDMZIi/PjzMw6zlIAX2xqk044AUzw0vNXfHkmd2f riaVRNW4nkJLM2+BDZHP4472kVYxGjuSaNAw/t8J/xpQNCfcsPA2Ie6VYmZWq0s+8M s+cxJBaAD45qQ1I4CyJx61b2iKQRf6VEyjdEr984= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 18 Aug 2023 18:50:44 +0200 Message-ID: <20230818165044.5512-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230818165044.5512-1-ffmpeg@haasn.xyz> References: <20230818165044.5512-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/vf_libplacebo: add extra_opts AVDictionary 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: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6BNESbiXZLch From: Niklas Haas Can be used to configure libplacebo's underlying raw options, which sometimes includes new or advanced / in-depth settings not (yet) exposed by vf_libplacebo. --- doc/filters.texi | 10 ++++++++++ libavfilter/vf_libplacebo.c | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index cac1ee43810..421785ef46f 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16312,6 +16312,16 @@ Render frames with rounded corners. The value, given as a float ranging from square to fully circular. In other words, it gives the radius divided by half the smaller side length. Defaults to @code{0.0}. +@item extra_opts +Pass extra libplacebo internal configuration options. These can be specified +as a list of @var{key}=@var{value} pairs separated by ':'. The following example +shows how to configure a custom filter kernel ("EWA LanczosSharp") and use it +to double the input image resolution: + +@example +-vf "libplacebo=w=iw*2:h=ih*2:extra_opts='upscaler=custom\:upscaler_preset=ewa_lanczos\:upscaler_blur=0.9812505644269356'" +@end example + @item colorspace @item color_primaries @item color_trc diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index b9effdbad95..942c3210424 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -192,6 +192,7 @@ typedef struct LibplaceboContext { int color_range; int color_primaries; int color_trc; + AVDictionary *extra_opts; /* pl_render_params */ pl_options opts; @@ -376,6 +377,7 @@ static int update_settings(AVFilterContext *ctx) { int err = 0; LibplaceboContext *s = ctx->priv; + AVDictionaryEntry *e = NULL; pl_options opts = s->opts; int gamut_mode = s->gamut_mode; uint8_t color_rgba[4]; @@ -505,6 +507,16 @@ static int update_settings(AVFilterContext *ctx) RET(find_scaler(ctx, &opts->params.upscaler, s->upscaler, 0)); RET(find_scaler(ctx, &opts->params.downscaler, s->downscaler, 0)); RET(find_scaler(ctx, &opts->params.frame_mixer, s->frame_mixer, 1)); + +#if PL_API_VER >= 309 + while ((e = av_dict_get(s->extra_opts, "", e, AV_DICT_IGNORE_SUFFIX))) { + if (!pl_options_set_str(s->opts, e->key, e->value)) { + err = AVERROR(EINVAL); + goto fail; + } + } +#endif + return 0; fail: @@ -1322,6 +1334,7 @@ static const AVOption libplacebo_options[] = { { "pad_crop_ratio", "ratio between padding and cropping when normalizing SAR (0=pad, 1=crop)", OFFSET(pad_crop_ratio), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, 1.0, DYNAMIC }, { "fillcolor", "Background fill color", OFFSET(fillcolor), AV_OPT_TYPE_STRING, {.str = "black"}, .flags = DYNAMIC }, { "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC }, + { "extra_opts", "Pass extra libplacebo-specific options using a :-separated list of key=value pairs", OFFSET(extra_opts), AV_OPT_TYPE_DICT, .flags = DYNAMIC }, {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"}, {"auto", "keep the same colorspace", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "colorspace"},