From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 6390E4007A for ; Thu, 17 Jul 2025 14:47:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 0DE6D68EE9D; Thu, 17 Jul 2025 17:47:07 +0300 (EEST) Received: from vidala.pars.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 2AF2D68ECFC for ; Thu, 17 Jul 2025 17:47:00 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; s=202405r; d=lynne.ee; c=relaxed/relaxed; h=From:To:Subject:Date:Message-ID; t=1752763619; bh=JXAjA1V0mF8gw7pH3JsRYW2 BeCR92xfxyRQT+1jjLb8=; b=ayg+DJQAxusWNcU0cryHI8SD46IXpgd14PA/24BjrF4oeLl3E0 mf2an7WlKGYJjDBWOjXPrPf0qneiDSYP7ospHh1Bekx8aE0S2IcHAcYEaVrlq1C8s6Rs/3lqSTq vJX538lAayLwYL6zw7svjNZb3uF68JxkXpxKCCosb4IeV+/CgT+xHrqGduUVb8wYVWgW6k6Rgcj P7L6Yvb7jTLnuXN38IucXjbqrI8AB1YMjlK2JyE6926/RZ+GL8/zboKYXnEfXZYJS9H0RJDTeIb gx3HDATYQsehxtecwOPX2qyKXL4zlSIlNHHQhVc8w16sNs1h7aq+oIdD+lrTe+KzvtQ==; DKIM-Signature: v=1; a=ed25519-sha256; s=202405e; d=lynne.ee; c=relaxed/relaxed; h=From:To:Subject:Date:Message-ID; t=1752763619; bh=JXAjA1V0mF8gw7pH3JsRYW2 BeCR92xfxyRQT+1jjLb8=; b=eTTAF3tH/iqrvKKzhqMh8E4Q6cPHjFLV4r+uix+4yDCLHDdoAO qmXN8le2wtHH+71BSU6vr1pUrS9cXDU7rVAA==; Message-ID: <910b3589-b5f9-4082-9280-c9f71bec6bf1@lynne.ee> Date: Thu, 17 Jul 2025 23:46:57 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20250712185128.862167-1-dev@lynne.ee> Content-Language: en-US From: Lynne In-Reply-To: <20250712185128.862167-1-dev@lynne.ee> Subject: Re: [FFmpeg-devel] [PATCH v2 01/13] vf_libplacebo: add support for specifying a LUT for the input 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 13/07/2025 03:51, Lynne wrote: > This makes it possible to apply Adobe .cube files to inputs. > --- > doc/filters.texi | 30 ++++++++++++++++++++++++++++++ > libavfilter/vf_libplacebo.c | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 66 insertions(+) > > diff --git a/doc/filters.texi b/doc/filters.texi > index ed2956fe75..13add0ff01 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -16321,6 +16321,36 @@ 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 lut > +Specifies a custom LUT (in Adobe .cube format) to apply to the colors > +as part of color conversion. The exact interpretation depends on the value > +of @option{lut_type}. > + > +@item lut_type > +Controls the interpretation of color values fed to and from the LUT > +specified as @option{lut}. Valid values are: > + > +@table @samp > +@item auto > +Chooses the interpretation of the LUT automatically from tagged > +metadata, and otherwise falls back to @samp{native}. (Default) > + > +@item native > +Applied to raw image contents in its native RGB colorspace (non-linear > +light), before conversion to the output color space. > + > +@item normalized > +Applied to the normalized RGB image contents, in linear light, before > +conversion to the output color space. > + > +@item conversion > +Fully replaces the conversion from the image color space to the output > +color space. If such a LUT is present, it has the highest priority, and > +overrides any ICC profiles, as well as options related to tone mapping > +and output colorimetry (@option{color_primaries}, @option{color_trc}). > + > +@end table > + > @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 > diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c > index 475030c80d..cbdbe3e665 100644 > --- a/libavfilter/vf_libplacebo.c > +++ b/libavfilter/vf_libplacebo.c > @@ -159,6 +159,7 @@ typedef struct LibplaceboContext { > pl_vulkan vulkan; > pl_gpu gpu; > pl_tex tex[4]; > + struct pl_custom_lut *lut; > > /* input state */ > LibplaceboInput *inputs; > @@ -184,6 +185,8 @@ typedef struct LibplaceboContext { > AVExpr *pos_x_pexpr, *pos_y_pexpr, *pos_w_pexpr, *pos_h_pexpr; > float pad_crop_ratio; > float corner_rounding; > + char *lut_filename; > + enum pl_lut_type lut_type; > int force_original_aspect_ratio; > int force_divisible_by; > int reset_sar; > @@ -371,6 +374,26 @@ static int find_scaler(AVFilterContext *avctx, > return AVERROR(EINVAL); > } > > +static int parse_custom_lut(LibplaceboContext *s) > +{ > + int ret; > + uint8_t *lutbuf; > + size_t lutbuf_size; > + > + if ((ret = av_file_map(s->lut_filename, &lutbuf, &lutbuf_size, 0, s)) < 0) { > + av_log(s, AV_LOG_ERROR, > + "The LUT file '%s' could not be read: %s\n", > + s->lut_filename, av_err2str(ret)); > + return ret; > + } > + > + s->lut = pl_lut_parse_cube(s->log, lutbuf, lutbuf_size); > + av_file_unmap(lutbuf, lutbuf_size); > + if (!s->lut) > + return AVERROR(EINVAL); > + return 0; > +} > + > static int update_settings(AVFilterContext *ctx) > { > int err = 0; > @@ -729,6 +752,9 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct > RET(parse_shader(avctx, buf, buf_len)); > } > > + if (s->lut_filename) > + RET(parse_custom_lut(s)); > + > /* Initialize inputs */ > s->inputs = av_calloc(s->nb_inputs, sizeof(*s->inputs)); > if (!s->inputs) > @@ -757,6 +783,7 @@ static void libplacebo_uninit(AVFilterContext *avctx) > av_freep(&s->inputs); > } > > + pl_lut_free(&s->lut); > #if PL_API_VER >= 351 > pl_cache_destroy(&s->cache); > #endif > @@ -1005,6 +1032,8 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, > .tex = tex, > .map_dovi = s->apply_dovi, > )); > + out->lut = s->lut; > + out->lut_type = s->lut_type; > > if (!s->apply_filmgrain) > out->film_grain.type = PL_FILM_GRAIN_NONE; > @@ -1406,6 +1435,13 @@ 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_COLOR, {.str = "black@0"}, .flags = DYNAMIC }, > { "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC }, > + { "lut", "Path to custom LUT file to apply", OFFSET(lut_filename), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = STATIC }, > + { "lut_type", "Application mode of the custom LUT", OFFSET(lut_type), AV_OPT_TYPE_INT, { .i64 = PL_LUT_UNKNOWN }, 0, PL_LUT_CONVERSION, STATIC, .unit = "lut_type" }, > + { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = PL_LUT_UNKNOWN }, 0, 0, STATIC, .unit = "lut_type" }, > + { "native", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = PL_LUT_NATIVE }, 0, 0, STATIC, .unit = "lut_type" }, > + { "normalized", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = PL_LUT_NORMALIZED }, 0, 0, STATIC, .unit = "lut_type" }, > + { "conversion", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = PL_LUT_CONVERSION }, 0, 0, STATIC, .unit = "lut_type" }, > + > { "extra_opts", "Pass extra libplacebo-specific options using a :-separated list of key=value pairs", OFFSET(extra_opts), AV_OPT_TYPE_DICT, .flags = DYNAMIC }, > #if PL_API_VER >= 351 > { "shader_cache", "Set shader cache path", OFFSET(shader_cache), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = STATIC }, Planning to push the patchset (excluding all VP9-related commits) later today. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".