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 0B3024EF09 for ; Thu, 19 Feb 2026 16:30:51 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'/aSh53CNwkANLOFnCvKQkEa0+e7v4s94fDtqH1mnmdw=', expected b'qHASGVcM2+HMmOgtolS+6Pt+fDcnMstzTmzqLZ/S6Zo=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771518637; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=/aSh53CNwkANLOFnCvKQkEa0+e7v4s94fDtqH1mnmdw=; b=Jz8D8J0kq1KMoaNmaQ+voni3u0TUPcgvB0HJO9slYYYKomv5iBKFufd4zox/HHi+QrSMz KDg5Kyg+7PG9cuiUW/gbXgDQa0zBV9L8H+HG6Zi2ZuuYQaJe/tXfedYaQWfdwb6NPxmxsGP dtehn8JeSkLm6ss+xkmyoZQhlH88YLkNhr8vLQSVgrocBT5bnD/ir0RUKYudTK9AE1bqFkj QlbRBlzMJtK66ZpDKDi/yO/TAcnd8dQ0IJrSB0sLkvfSTfGzpc+aSdy5bbLfw6aKoCZwSyO quYtb7ksMKf97nkbLTDlQr39wE/ospjPEauFs/3wJVkTDgMPvm5N3GfhDxJw== Received: from [172.18.0.3] (unknown [172.18.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 6BB52680229; Thu, 19 Feb 2026 18:30:37 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1771518625; b=RQRvTyf/R2H+TqSXZNVdjDJUu0HY+bJxQr/s7dv6Jf0w/y4U8ZCFTEGsuvC/pTE/KFXsd G4pRqCuHHUUQqgVKwGue4vUytD5TfXnE68YRpRqufJx4In+UJIL55/mqg/VlyiDmkBBWSMH Trr662GHNPILx//eXYVq3kGJAp9M63pBY3bIbr6Pi2t9xxnT7g9pAGaV+uUfPQMNUYq7khg z3wioX00j+NKu5AF0JxvhqtNCGN9/cVZDlnZJ6QfTwr+o7JONlPwI8h/63BRJW7IdefljZz wGxYzDqNleIDAnTRfWcd9Iws4RJoWACl6Sp01lqVrMJwNEjUXhDy9aBAm3xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1771518625; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=5CUmRWBGSZSVdSRRmlux54OOeCcSP+xDayov4i3ox/0=; b=RPK6Jbfk/hHGz8ZWH8fnkbKUG8LTlLiffqwB1MNa/snyNzxX1M8mc8mMJ/k4QEIDgp+Bu tqILtpavzCvuPBWihTFabJ2rZsqe/x/Y2qIxem45xGRRSX5sm4ZKISQIFBz8Wud5JmlQhyl E2Ia8yaH7ix8ZHVWxdf4bAGHr+7Iu+T6IlpXDPaotFNN7e/qaWMQtGTA8rqSVi8ttZMeKn5 WAEwPGn92X4xkvRmYDYG4z00IIHXrZ9NY/THQcNxhbUo+WwV4BGWgfNbYBz+f8Ot9IYGLQf /w6sZRxmBsM2SG5pe1vOEi58OtzDU7EHUFCuuFI+YKREPU6vG3Ro07R28aBw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771518618; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=qHASGVcM2+HMmOgtolS+6Pt+fDcnMstzTmzqLZ/S6Zo=; b=m/M0pFURkEVWxjfN6zatvc9SGnMfBnWyQe5B7R04lU4F5HeLeo7tm8AXcBExhaqt+dZsA MdkWq8k5+XaRPX7pJ8K3kbXTMY6S9dKmCTTouiNYgqAVgqhYxAS0Z7O5KuUrbnDo6+exsil trumj9zhdhJuU5rNoMih/mneS6wW9SepzN8I2znWVrcYTcrTGd4Okbg2M/skAlqiRp1KnaP rTnbHIHUZx/cA0L1nBIJcIPJq69VOFYw2f+MIWwUwQt++YV0cZagfd0C3SWBFh3yufYmKXv S2IJs1bRpM/Hp38Lj5409PWUDCriGoWDahS5tWUudBxB8Bdurx1mJTmAdCAA== MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Feb 2026 16:30:17 -0000 Message-ID: <177151861807.25.11437578450679972850@29965ddac10e> Message-ID-Hash: 5V6HD5325IVWG4RGEIUTAQVUC4JNI3W5 X-Message-ID-Hash: 5V6HD5325IVWG4RGEIUTAQVUC4JNI3W5 X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] avfilter/vf_opencolorio: Updating query_formats to specify different input and output pix_fmts. (PR #21799) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: richardssam via ffmpeg-devel Cc: richardssam Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21799 opened by richardssam URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21799 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21799.patch The format parameter within the filter was specifying the output filter, but doing it too late, so some filters were getting a different value for the output pix_fmt (e.g. zscale). Separately there are enough issues with outputting half-floats (since negative numbers get truncated) that we are better off saying that we don't support outputs of half floats. However, I do still want to support half floats as inputs without forcing them to use a format string (so in that case, the output is forced to be AV_PIX_FMT_GBRAPF32 if nothing is defined. So switched to using FILTER_QUERY_FUNC2 so that I could specify separate input and output pixel_formats. Signed-off-by: Sam.Richards@taurich.org >>From f4ffc851b0cd0fb6f9ffc3cbcf0ac2a7c3679076 Mon Sep 17 00:00:00 2001 From: "Sam.Richards@taurich.org" Date: Thu, 19 Feb 2026 16:24:36 +0000 Subject: [PATCH] avfilter/vf_opencolorio: Updating query_formats to FILTER_QUERY_FUNC2 The format parameter within the filter was specifying the output filter, but doing it too late, so some filters were getting a different value for the output pix_fmt (e.g. zscale). Separately there are enough issues with outputting half-floats (since negative numbers get truncated) that we are better off saying that we dont support outputs of half floats. However, I do still want to support half floats as inputs without forcing them to use a format string (so in that case, the output is forced to be AV_PIX_FMT_GBRAPF32 if nothing is defined. Signed-off-by: Sam.Richards@taurich.org --- libavfilter/vf_opencolorio.c | 100 ++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 20 deletions(-) diff --git a/libavfilter/vf_opencolorio.c b/libavfilter/vf_opencolorio.c index d34922deca..3e89355d35 100644 --- a/libavfilter/vf_opencolorio.c +++ b/libavfilter/vf_opencolorio.c @@ -62,21 +62,62 @@ static int ocio_filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_ return ocio_apply(ctx, s->ocio, in, out, slice_start, slice_h); } -static int query_formats(AVFilterContext *ctx) { - static const enum AVPixelFormat pix_fmts[] = { - // 8-bit - AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB24, - // 16-bit - AV_PIX_FMT_RGBA64, AV_PIX_FMT_RGB48, - // 10-bit - AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, - // 12-bit - AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, - // Half-float and float - AV_PIX_FMT_GBRPF16, AV_PIX_FMT_GBRAPF16, - // Float - AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, AV_PIX_FMT_NONE}; - return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); +// All pixel formats supported by this filter for inputs. +static const enum AVPixelFormat supported_pix_fmts[] = { + // 8-bit + AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB24, + // 16-bit + AV_PIX_FMT_RGBA64, AV_PIX_FMT_RGB48, + // 10-bit + AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, + // 12-bit + AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, + // Half-float (input only by default; swscale clips negatives on output) + AV_PIX_FMT_GBRPF16, AV_PIX_FMT_GBRAPF16, + // Float + AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, + AV_PIX_FMT_NONE +}; + +// Default output formats (excludes half-float to avoid swscale negative clipping) +static const enum AVPixelFormat output_pix_fmts[] = { + // 8-bit + AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB24, + // 16-bit + AV_PIX_FMT_RGBA64, AV_PIX_FMT_RGB48, + // 10-bit + AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRAP10, + // 12-bit + AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRAP12, + // Float + AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, + AV_PIX_FMT_NONE +}; + +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) +{ + const OCIOContext *s = ctx->priv; + int ret; + + // Input accepts all supported formats including half-float + ret = ff_formats_ref(ff_make_pixel_format_list(supported_pix_fmts), + &cfg_in[0]->formats); + if (ret < 0) + return ret; + + // Output: if user specified a format, constrain to just that format + if (s->output_format != AV_PIX_FMT_NONE) { + const enum AVPixelFormat user_fmts[] = { s->output_format, AV_PIX_FMT_NONE }; + ret = ff_formats_ref(ff_make_pixel_format_list(user_fmts), + &cfg_out[0]->formats); + } else { + // Default output excludes half-float formats + ret = ff_formats_ref(ff_make_pixel_format_list(output_pix_fmts), + &cfg_out[0]->formats); + } + return ret; } static int config_props(AVFilterLink *inlink) @@ -95,8 +136,8 @@ static int config_props(AVFilterLink *inlink) if (s->output_format == AV_PIX_FMT_NONE) { // Need to set the output format now, if not known. if (is_half) { - // If its half-float, we output float, due to a bug in ffmpeg with - // half-float frames + // If the user hasn't specified an output format, and the input is half-float, we output float to be safe. + // swscale clips negative values to 0, which can be problematic since it can occur with OCIO transforms. s->output_format = AV_PIX_FMT_GBRAPF32; } else { // If output format not set, use same as input @@ -126,10 +167,29 @@ static int config_props(AVFilterLink *inlink) static av_cold int init(AVFilterContext *ctx) { OCIOContext *s = ctx->priv; - if (s->out_format_string != NULL) + if (s->out_format_string != NULL) { s->output_format = av_get_pix_fmt(s->out_format_string); - else + if (s->output_format == AV_PIX_FMT_NONE) { + av_log(ctx, AV_LOG_ERROR, "Unknown pixel format: '%s'\n", + s->out_format_string); + return AVERROR(EINVAL); + } + // Verify the format is a supported output format + int valid = 0; + for (int i = 0; output_pix_fmts[i] != AV_PIX_FMT_NONE; i++) { + if (s->output_format == output_pix_fmts[i]) { + valid = 1; + break; + } + } + if (!valid) { + av_log(ctx, AV_LOG_ERROR, + "Unsupported output format: '%s'\n", s->out_format_string); + return AVERROR(EINVAL); + } + } else { s->output_format = AV_PIX_FMT_NONE; // Default to same as input format (see later). + } if (s->filetransform && strlen(s->filetransform) > 0) { s->ocio = ocio_create_file_transform_processor( @@ -286,4 +346,4 @@ const FFFilter ff_vf_ocio = { .uninit = uninit, FILTER_INPUTS(inputs), FILTER_OUTPUTS(outputs), - FILTER_QUERY_FUNC(query_formats)}; + FILTER_QUERY_FUNC2(query_formats)}; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org