From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vsrc_testsrc: switch to YUV colorspace negotiation API Date: Wed, 31 Jan 2024 12:17:04 +0100 Message-ID: <20240131111704.44140-2-ffmpeg@haasn.xyz> (raw) In-Reply-To: <20240131111704.44140-1-ffmpeg@haasn.xyz> From: Niklas Haas <git@haasn.dev> 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".
next prev parent reply other threads:[~2024-01-31 11:17 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-31 11:17 [FFmpeg-devel] [PATCH 1/2] avfilter: pass link YUV colorspace to ff_draw_init2 Niklas Haas 2024-01-31 11:17 ` Niklas Haas [this message] 2024-01-31 11:47 ` Diederick C. Niehorster 2024-02-05 12:38 ` Niklas Haas
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240131111704.44140-2-ffmpeg@haasn.xyz \ --to=ffmpeg@haasn.xyz \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=git@haasn.dev \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git