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 05AA948FFE for ; Wed, 31 Jan 2024 11:17:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6E75968D128; Wed, 31 Jan 2024 13:17:14 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 61BA268AB9C for ; Wed, 31 Jan 2024 13:17:08 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id D7FDB43F85; Wed, 31 Jan 2024 12:17:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1706699827; bh=tQ2sVUzLV41WIBwbQGV0wdHQr31G8hOd6cl3l1AQs1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vkb6XyA7qNfzEJxHqaVhR26f9dSyIyhyGjlcYk0ZMG4iT3tMxtBdVX3miKE2bZhf8 +z/Sh8zz96ApqQuDyhJMA2HHzOyZGD8+ZAEC5xJiudNg6uyhD6WOUAzBLRM0AFHdno XnX+BR+9q5Kswdz8wUNX1PoIlPUrMG//zGEBw5Ik= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 Jan 2024 12:17:04 +0100 Message-ID: <20240131111704.44140-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131111704.44140-1-ffmpeg@haasn.xyz> References: <20240131111704.44140-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vsrc_testsrc: switch to YUV colorspace negotiation API 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 Instead of overriding the frame properties in fill_picture(), advertise the supported YUV colorspace and range at format negotiation time. (The correct metadata will now be set automatically by ff_get_video_buffer) --- libavfilter/vsrc_testsrc.c | 47 +++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index 73a61bfa45..c51ba46c97 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -1418,6 +1418,24 @@ static const enum AVPixelFormat smptebars_pix_fmts[] = { AV_PIX_FMT_NONE, }; +static int smptebars_query_formats(AVFilterContext *ctx) +{ + enum AVColorSpace csp; + int ret; + + if (!strcmp(ctx->name, "smptehdbars")) { + csp = AVCOL_SPC_BT709; + } else { + csp = AVCOL_SPC_BT470BG; + } + + if ((ret = ff_set_common_color_spaces(ctx, ff_make_formats_list_singleton(csp)))) + return ret; + if ((ret = ff_set_common_color_ranges(ctx, ff_make_formats_list_singleton(AVCOL_RANGE_MPEG)))) + return ret; + return ff_set_common_formats_from_list(ctx, smptebars_pix_fmts); +} + AVFILTER_DEFINE_CLASS_EXT(palbars, "pal(75|100)bars", options); #if CONFIG_PAL75BARS_FILTER @@ -1428,9 +1446,6 @@ static void pal75bars_fill_picture(AVFilterContext *ctx, AVFrame *picref) int r_w, i, x = 0; const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format); - picref->color_range = AVCOL_RANGE_MPEG; - picref->colorspace = AVCOL_SPC_BT470BG; - r_w = FFALIGN((test->w + 7) / 8, 1 << pixdesc->log2_chroma_w); draw_bar(test, white, x, 0, r_w, test->h, picref); @@ -1461,7 +1476,7 @@ const AVFilter ff_vsrc_pal75bars = { .activate = activate, .inputs = NULL, FILTER_OUTPUTS(outputs), - FILTER_PIXFMTS_ARRAY(smptebars_pix_fmts), + FILTER_QUERY_FUNC(smptebars_query_formats), }; #endif /* CONFIG_PAL75BARS_FILTER */ @@ -1474,9 +1489,6 @@ static void pal100bars_fill_picture(AVFilterContext *ctx, AVFrame *picref) int r_w, i, x = 0; const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format); - picref->color_range = AVCOL_RANGE_MPEG; - picref->colorspace = AVCOL_SPC_BT470BG; - r_w = FFALIGN((test->w + 7) / 8, 1 << pixdesc->log2_chroma_w); for (i = 0; i < 7; i++) { @@ -1505,7 +1517,7 @@ const AVFilter ff_vsrc_pal100bars = { .activate = activate, .inputs = NULL, FILTER_OUTPUTS(outputs), - FILTER_PIXFMTS_ARRAY(smptebars_pix_fmts), + FILTER_QUERY_FUNC(smptebars_query_formats), }; #endif /* CONFIG_PAL100BARS_FILTER */ @@ -1520,8 +1532,6 @@ static void smptebars_fill_picture(AVFilterContext *ctx, AVFrame *picref) int r_w, r_h, w_h, p_w, p_h, i, tmp, x = 0; const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format); - picref->colorspace = AVCOL_SPC_BT470BG; - r_w = FFALIGN((test->w + 6) / 7, 1 << pixdesc->log2_chroma_w); r_h = FFALIGN(test->h * 2 / 3, 1 << pixdesc->log2_chroma_h); w_h = FFALIGN(test->h * 3 / 4 - r_h, 1 << pixdesc->log2_chroma_h); @@ -1572,7 +1582,7 @@ const AVFilter ff_vsrc_smptebars = { .activate = activate, .inputs = NULL, FILTER_OUTPUTS(outputs), - FILTER_PIXFMTS_ARRAY(smptebars_pix_fmts), + FILTER_QUERY_FUNC(smptebars_query_formats), }; #endif /* CONFIG_SMPTEBARS_FILTER */ @@ -1585,8 +1595,6 @@ static void smptehdbars_fill_picture(AVFilterContext *ctx, AVFrame *picref) int d_w, r_w, r_h, l_w, i, tmp, x = 0, y = 0; const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format); - picref->colorspace = AVCOL_SPC_BT709; - d_w = FFALIGN(test->w / 8, 1 << pixdesc->log2_chroma_w); r_h = FFALIGN(test->h * 7 / 12, 1 << pixdesc->log2_chroma_h); draw_bar(test, gray40, x, 0, d_w, r_h, picref); @@ -1675,7 +1683,7 @@ const AVFilter ff_vsrc_smptehdbars = { .activate = activate, .inputs = NULL, FILTER_OUTPUTS(outputs), - FILTER_PIXFMTS_ARRAY(smptebars_pix_fmts), + FILTER_QUERY_FUNC(smptebars_query_formats), }; #endif /* CONFIG_SMPTEHDBARS_FILTER */ @@ -2138,7 +2146,6 @@ ZONEPLATE_SLICE(16, uint16_t) static void zoneplate_fill_picture(AVFilterContext *ctx, AVFrame *frame) { TestSourceContext *test = ctx->priv; - frame->color_range = AVCOL_RANGE_JPEG; ff_filter_execute(ctx, test->fill_slice_fn, frame, NULL, FFMIN(frame->height, ff_filter_get_nb_threads(ctx))); } @@ -2194,6 +2201,14 @@ static const enum AVPixelFormat zoneplate_pix_fmts[] = { AV_PIX_FMT_NONE, }; +static int zoneplate_query_formats(AVFilterContext *ctx) +{ + int ret; + if ((ret = ff_set_common_color_ranges(ctx, ff_make_formats_list_singleton(AVCOL_RANGE_JPEG)))) + return ret; + return ff_set_common_formats_from_list(ctx, zoneplate_pix_fmts); +} + static const AVFilterPad avfilter_vsrc_zoneplate_outputs[] = { { .name = "default", @@ -2212,7 +2227,7 @@ const AVFilter ff_vsrc_zoneplate = { .activate = activate, .inputs = NULL, FILTER_OUTPUTS(avfilter_vsrc_zoneplate_outputs), - FILTER_PIXFMTS_ARRAY(zoneplate_pix_fmts), + FILTER_QUERY_FUNC(zoneplate_query_formats), .flags = AVFILTER_FLAG_SLICE_THREADS, .process_command = ff_filter_process_command, }; -- 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".