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)
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -1418,6 +1418,24 @@ static const enum AVPixelFormat smptebars_pix_fmts[] = { · 1417 unmodified lines | ||
| 1418 | 1418 | AV_PIX_FMT_NONE, |
| 1419 | 1419 | }; |
| 1420 | 1420 | |
| 1421 | +static int smptebars_query_formats(AVFilterContext *ctx) | |
| 1422 | +{ | |
| 1423 | + enum AVColorSpace csp; | |
| 1424 | + int ret; | |
| 1425 | + | |
| 1426 | + if (!strcmp(ctx->name, "smptehdbars")) { | |
| 1427 | + csp = AVCOL_SPC_BT709; | |
| 1428 | + } else { | |
| 1429 | + csp = AVCOL_SPC_BT470BG; | |
| 1430 | + } | |
| 1431 | + | |
| 1432 | + if ((ret = ff_set_common_color_spaces(ctx, ff_make_formats_list_singleton(csp)))) | |
| 1433 | + return ret; | |
| 1434 | + if ((ret = ff_set_common_color_ranges(ctx, ff_make_formats_list_singleton(AVCOL_RANGE_MPEG)))) | |
| 1435 | + return ret; | |
| 1436 | + return ff_set_common_formats_from_list(ctx, smptebars_pix_fmts); | |
| 1437 | +} | |
| 1438 | + | |
| 1421 | 1439 | AVFILTER_DEFINE_CLASS_EXT(palbars, "pal(75|100)bars", options); |
| 1422 | 1440 | |
| 1423 | 1441 | #if CONFIG_PAL75BARS_FILTER |
| @@ -1428,9 +1446,6 @@ static void pal75bars_fill_picture(AVFilterContext *ctx, AVFrame *picref) · 4 unmodified lines | ||
| 1428 | 1446 | int r_w, i, x = 0; |
| 1429 | 1447 | const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format); |
| 1430 | 1448 | |
| 1431 | − picref->color_range = AVCOL_RANGE_MPEG; | |
| 1432 | − picref->colorspace = AVCOL_SPC_BT470BG; | |
| 1433 | − | |
| 1434 | 1449 | r_w = FFALIGN((test->w + 7) / 8, 1 << pixdesc->log2_chroma_w); |
| 1435 | 1450 | |
| 1436 | 1451 | draw_bar(test, white, x, 0, r_w, test->h, picref); |
| @@ -1461,7 +1476,7 @@ const AVFilter ff_vsrc_pal75bars = { · 24 unmodified lines | ||
| 1461 | 1476 | .activate = activate, |
| 1462 | 1477 | .inputs = NULL, |
| 1463 | 1478 | FILTER_OUTPUTS(outputs), |
| 1464 | − FILTER_PIXFMTS_ARRAY(smptebars_pix_fmts), | |
| 1479 | + FILTER_QUERY_FUNC(smptebars_query_formats), | |
| 1465 | 1480 | }; |
| 1466 | 1481 | |
| 1467 | 1482 | #endif /* CONFIG_PAL75BARS_FILTER */ |
| @@ -1474,9 +1489,6 @@ static void pal100bars_fill_picture(AVFilterContext *ctx, AVFrame *picref) · 6 unmodified lines | ||
| 1474 | 1489 | int r_w, i, x = 0; |
| 1475 | 1490 | const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format); |
| 1476 | 1491 | |
| 1477 | − picref->color_range = AVCOL_RANGE_MPEG; | |
| 1478 | − picref->colorspace = AVCOL_SPC_BT470BG; | |
| 1479 | − | |
| 1480 | 1492 | r_w = FFALIGN((test->w + 7) / 8, 1 << pixdesc->log2_chroma_w); |
| 1481 | 1493 | |
| 1482 | 1494 | for (i = 0; i < 7; i++) { |
| @@ -1505,7 +1517,7 @@ const AVFilter ff_vsrc_pal100bars = { · 22 unmodified lines | ||
| 1505 | 1517 | .activate = activate, |
| 1506 | 1518 | .inputs = NULL, |
| 1507 | 1519 | FILTER_OUTPUTS(outputs), |
| 1508 | − FILTER_PIXFMTS_ARRAY(smptebars_pix_fmts), | |
| 1520 | + FILTER_QUERY_FUNC(smptebars_query_formats), | |
| 1509 | 1521 | }; |
| 1510 | 1522 | |
| 1511 | 1523 | #endif /* CONFIG_PAL100BARS_FILTER */ |
| @@ -1520,8 +1532,6 @@ static void smptebars_fill_picture(AVFilterContext *ctx, AVFrame *picref) · 8 unmodified lines | ||
| 1520 | 1532 | int r_w, r_h, w_h, p_w, p_h, i, tmp, x = 0; |
| 1521 | 1533 | const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format); |
| 1522 | 1534 | |
| 1523 | − picref->colorspace = AVCOL_SPC_BT470BG; | |
| 1524 | − | |
| 1525 | 1535 | r_w = FFALIGN((test->w + 6) / 7, 1 << pixdesc->log2_chroma_w); |
| 1526 | 1536 | r_h = FFALIGN(test->h * 2 / 3, 1 << pixdesc->log2_chroma_h); |
| 1527 | 1537 | w_h = FFALIGN(test->h * 3 / 4 - r_h, 1 << pixdesc->log2_chroma_h); |
| @@ -1572,7 +1582,7 @@ const AVFilter ff_vsrc_smptebars = { · 44 unmodified lines | ||
| 1572 | 1582 | .activate = activate, |
| 1573 | 1583 | .inputs = NULL, |
| 1574 | 1584 | FILTER_OUTPUTS(outputs), |
| 1575 | − FILTER_PIXFMTS_ARRAY(smptebars_pix_fmts), | |
| 1585 | + FILTER_QUERY_FUNC(smptebars_query_formats), | |
| 1576 | 1586 | }; |
| 1577 | 1587 | |
| 1578 | 1588 | #endif /* CONFIG_SMPTEBARS_FILTER */ |
| @@ -1585,8 +1595,6 @@ static void smptehdbars_fill_picture(AVFilterContext *ctx, AVFrame *picref) · 6 unmodified lines | ||
| 1585 | 1595 | int d_w, r_w, r_h, l_w, i, tmp, x = 0, y = 0; |
| 1586 | 1596 | const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(picref->format); |
| 1587 | 1597 | |
| 1588 | − picref->colorspace = AVCOL_SPC_BT709; | |
| 1589 | − | |
| 1590 | 1598 | d_w = FFALIGN(test->w / 8, 1 << pixdesc->log2_chroma_w); |
| 1591 | 1599 | r_h = FFALIGN(test->h * 7 / 12, 1 << pixdesc->log2_chroma_h); |
| 1592 | 1600 | draw_bar(test, gray40, x, 0, d_w, r_h, picref); |
| @@ -1675,7 +1683,7 @@ const AVFilter ff_vsrc_smptehdbars = { · 82 unmodified lines | ||
| 1675 | 1683 | .activate = activate, |
| 1676 | 1684 | .inputs = NULL, |
| 1677 | 1685 | FILTER_OUTPUTS(outputs), |
| 1678 | − FILTER_PIXFMTS_ARRAY(smptebars_pix_fmts), | |
| 1686 | + FILTER_QUERY_FUNC(smptebars_query_formats), | |
| 1679 | 1687 | }; |
| 1680 | 1688 | |
| 1681 | 1689 | #endif /* CONFIG_SMPTEHDBARS_FILTER */ |
| @@ -2138,7 +2146,6 @@ ZONEPLATE_SLICE(16, uint16_t) · 456 unmodified lines | ||
| 2138 | 2146 | static void zoneplate_fill_picture(AVFilterContext *ctx, AVFrame *frame) |
| 2139 | 2147 | { |
| 2140 | 2148 | TestSourceContext *test = ctx->priv; |
| 2141 | − frame->color_range = AVCOL_RANGE_JPEG; | |
| 2142 | 2149 | ff_filter_execute(ctx, test->fill_slice_fn, frame, NULL, |
| 2143 | 2150 | FFMIN(frame->height, ff_filter_get_nb_threads(ctx))); |
| 2144 | 2151 | } |
| @@ -2194,6 +2201,14 @@ static const enum AVPixelFormat zoneplate_pix_fmts[] = { · 49 unmodified lines | ||
| 2194 | 2201 | AV_PIX_FMT_NONE, |
| 2195 | 2202 | }; |
| 2196 | 2203 | |
| 2204 | +static int zoneplate_query_formats(AVFilterContext *ctx) | |
| 2205 | +{ | |
| 2206 | + int ret; | |
| 2207 | + if ((ret = ff_set_common_color_ranges(ctx, ff_make_formats_list_singleton(AVCOL_RANGE_JPEG)))) | |
| 2208 | + return ret; | |
| 2209 | + return ff_set_common_formats_from_list(ctx, zoneplate_pix_fmts); | |
| 2210 | +} | |
| 2211 | + | |
| 2197 | 2212 | static const AVFilterPad avfilter_vsrc_zoneplate_outputs[] = { |
| 2198 | 2213 | { |
| 2199 | 2214 | .name = "default", |
| @@ -2212,7 +2227,7 @@ const AVFilter ff_vsrc_zoneplate = { · 12 unmodified lines | ||
| 2212 | 2227 | .activate = activate, |
| 2213 | 2228 | .inputs = NULL, |
| 2214 | 2229 | FILTER_OUTPUTS(avfilter_vsrc_zoneplate_outputs), |
| 2215 | − FILTER_PIXFMTS_ARRAY(zoneplate_pix_fmts), | |
| 2230 | + FILTER_QUERY_FUNC(zoneplate_query_formats), | |
| 2216 | 2231 | .flags = AVFILTER_FLAG_SLICE_THREADS, |
| 2217 | 2232 | .process_command = ff_filter_process_command, |
| 2218 | 2233 | }; |