From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9D0004855C for ; Mon, 5 Feb 2024 18:39:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D101468D0EF; Mon, 5 Feb 2024 20:39:30 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A444868CD39 for ; Mon, 5 Feb 2024 20:39:24 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1707158364; bh=mkh8/5uXz3BRnuQycEC0iujGwIz8NYtuuygWNZH5onE=; h=From:To:Cc:Subject:Date:From; b=D8vqu6qUOyeZAUdj0SRWO1Dwq2EsO0VU0SeO5And8dceVSmVdUdHpIGdpDHiZ1UUN Glp6ueleKLME/HiOomrE94b4B3TLsxdatsIc9k3/3Aw/o5MFIr09P44h3H6GTzXabl fWXgJ570pHyDeeXYXI85Z961P+IiL0nblzg2VDe8= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 54793406AC; Mon, 5 Feb 2024 19:39:24 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Feb 2024 19:39:20 +0100 Message-ID: <20240205183921.52633-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avfilter/buffersink: add color_spaces, color_ranges params 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Niklas Haas An oversight in my previous series. This omission slipped under the radar because fftools/ffmpeg_filter.c did not use these options, instead preferring to insert an explicit format filter. --- libavfilter/buffersink.c | 29 ++++++++++++++++++++++++++--- libavfilter/buffersink.h | 2 ++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 6ba2970dd5..af7f8ab58a 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -48,6 +48,10 @@ typedef struct BufferSinkContext { /* only used for video */ enum AVPixelFormat *pixel_fmts; ///< list of accepted pixel formats int pixel_fmts_size; + enum AVColorSpace *color_spaces; ///< list of accepted color spaces + int color_spaces_size; + enum AVColorRange *color_ranges; ///< list of accepted color ranges + int color_ranges_size; /* only used for audio */ enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats @@ -250,19 +254,36 @@ int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out static int vsink_query_formats(AVFilterContext *ctx) { BufferSinkContext *buf = ctx->priv; - AVFilterFormats *formats = NULL; unsigned i; int ret; CHECK_LIST_SIZE(pixel_fmts) + CHECK_LIST_SIZE(color_spaces) + CHECK_LIST_SIZE(color_ranges) if (buf->pixel_fmts_size) { + AVFilterFormats *formats = NULL; for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++) if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0) return ret; if ((ret = ff_set_common_formats(ctx, formats)) < 0) return ret; - } else { - if ((ret = ff_default_query_formats(ctx)) < 0) + } + + if (buf->color_spaces_size) { + AVFilterFormats *formats = NULL; + for (i = 0; i < NB_ITEMS(buf->color_spaces); i++) + if ((ret = ff_add_format(&formats, buf->color_spaces[i])) < 0) + return ret; + if ((ret = ff_set_common_color_spaces(ctx, formats)) < 0) + return ret; + } + + if (buf->color_ranges_size) { + AVFilterFormats *formats = NULL; + for (i = 0; i < NB_ITEMS(buf->color_ranges); i++) + if ((ret = ff_add_format(&formats, buf->color_ranges[i])) < 0) + return ret; + if ((ret = ff_set_common_color_ranges(ctx, formats)) < 0) return ret; } @@ -365,6 +386,8 @@ static int asink_query_formats(AVFilterContext *ctx) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption buffersink_options[] = { { "pix_fmts", "set the supported pixel formats", OFFSET(pixel_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS }, + { "color_spaces", "set the supported color spaces", OFFSET(color_spaces), AV_OPT_TYPE_BINARY, .flags = FLAGS }, + { "color_ranges", "set the supported color ranges", OFFSET(color_ranges), AV_OPT_TYPE_BINARY, .flags = FLAGS }, { NULL }, }; #undef FLAGS diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h index a9374b8b4f..5f7172028d 100644 --- a/libavfilter/buffersink.h +++ b/libavfilter/buffersink.h @@ -55,6 +55,8 @@ * The format can be constrained by setting options, using av_opt_set() and * related functions with the AV_OPT_SEARCH_CHILDREN flag. * - pix_fmts (int list), + * - color_spaces (int list), + * - color_ranges (int list), * - sample_fmts (int list), * - sample_rates (int list), * - ch_layouts (string), -- 2.43.0 _______________________________________________ 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".