@@ -638,7 +638,7 @@ static int qrencodesrc_config_props(AVFilterLink *outlink)
ff_draw_color(&qr->draw, &qr->draw_foreground_color, (const uint8_t *)&qr->foreground_color);
ff_draw_color(&qr->draw, &qr->draw_background_color, (const uint8_t *)&qr->background_color);
- ff_draw_init(&qr->draw0, outlink->format, FF_DRAW_PROCESS_ALPHA);
+ ff_draw_init2(&qr->draw0, outlink->format, outlink->colorspace, outlink->color_range, FF_DRAW_PROCESS_ALPHA);
ff_draw_color(&qr->draw0, &qr->draw0_background_color, (const uint8_t *)&qr->background_color);
outlink->w = qr->rendered_padded_qrcode_width;
@@ -730,7 +730,8 @@ static int qrencode_config_input(AVFilterLink *inlink)
qr->is_source = 0;
- ff_draw_init(&qr->draw, inlink->format, FF_DRAW_PROCESS_ALPHA);
+ ff_draw_init2(&qr->draw, inlink->format, inlink->colorspace, inlink->color_range,
+ FF_DRAW_PROCESS_ALPHA);
V(W) = V(main_w) = inlink->w;
V(H) = V(main_h) = inlink->h;
@@ -759,7 +760,8 @@ static int qrencode_config_input(AVFilterLink *inlink)
PARSE_EXPR(rendered_qrcode_width);
PARSE_EXPR(rendered_padded_qrcode_width);
- ff_draw_init(&qr->draw, inlink->format, FF_DRAW_PROCESS_ALPHA);
+ ff_draw_init2(&qr->draw, inlink->format, inlink->colorspace, inlink->color_range,
+ FF_DRAW_PROCESS_ALPHA);
ff_draw_color(&qr->draw, &qr->draw_foreground_color, (const uint8_t *)&qr->foreground_color);
ff_draw_color(&qr->draw, &qr->draw_background_color, (const uint8_t *)&qr->background_color);
@@ -160,7 +160,7 @@ static av_cold int config_props(AVFilterLink *outlink)
s->dir = 1;
s->prev_intpart = INT64_MIN;
- ff_draw_init(&s->draw, outlink->format, 0);
+ ff_draw_init2(&s->draw, outlink->format, outlink->colorspace, outlink->color_range, 0);
ff_draw_color(&s->draw, &s->fg, s->rgba[0]);
ff_draw_color(&s->draw, &s->bg, s->rgba[1]);
@@ -383,7 +383,7 @@ static int config_input(AVFilterLink *inlink)
uint8_t alpha = s->opacity * 255;
s->nb_planes = av_pix_fmt_count_planes(inlink->format);
- ff_draw_init(&s->draw, inlink->format, 0);
+ ff_draw_init2(&s->draw, inlink->format, inlink->colorspace, inlink->color_range, 0);
ff_draw_color(&s->draw, &s->white, (uint8_t[]){ 255, 255, 255, 255} );
ff_draw_color(&s->draw, &s->black, (uint8_t[]){ 0, 0, 0, alpha} );
ff_draw_color(&s->draw, &s->yellow, (uint8_t[]){ 255, 255, 0, 255} );
@@ -1152,7 +1152,7 @@ static int config_input(AVFilterLink *inlink)
char *expr;
int ret;
- ff_draw_init(&s->dc, inlink->format, FF_DRAW_PROCESS_ALPHA);
+ ff_draw_init(&s->dc, inlink->format, inlink->colorspace, inlink->color_range, FF_DRAW_PROCESS_ALPHA);
ff_draw_color(&s->dc, &s->fontcolor, s->fontcolor.rgba);
ff_draw_color(&s->dc, &s->shadowcolor, s->shadowcolor.rgba);
ff_draw_color(&s->dc, &s->bordercolor, s->bordercolor.rgba);
@@ -111,7 +111,7 @@ static int config_input(AVFilterLink *inlink)
double var_values[VARS_NB], res;
char *expr;
- ff_draw_init(&s->draw, inlink->format, 0);
+ ff_draw_init2(&s->draw, inlink->format, inlink->colorspace, inlink->color_range, 0);
ff_draw_color(&s->draw, &s->color, s->rgba_color);
var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
@@ -288,7 +288,7 @@ static int config_props(AVFilterLink *outlink)
double res;
char *expr;
- ff_draw_init(&rot->draw, inlink->format, 0);
+ ff_draw_init2(&rot->draw, inlink->format, inlink->colorspace, inlink->color_range, 0);
ff_draw_color(&rot->draw, &rot->color, rot->fillcolor);
rot->hsub = pixdesc->log2_chroma_w;
@@ -260,7 +260,7 @@ static int config_output(AVFilterLink *outlink)
s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(ctx->inputs[0]->h, desc->log2_chroma_h);
s->planeheight[0] = s->planeheight[3] = ctx->inputs[0]->h;
- ff_draw_init(&s->draw, outlink->format, 0);
+ ff_draw_init2(&s->draw, outlink->format, outlink->colorspace, outlink->color_range, 0);
ff_draw_color(&s->draw, &s->color, s->fillcolor);
s->filter_slice[0] = s->depth <= 8 ? filter_slice_nn8 : filter_slice_nn16;
@@ -304,7 +304,8 @@ static int config_output(AVFilterLink *outlink)
int inw, inh, size;
if (s->fillcolor_enable) {
- ff_draw_init(&s->draw, ctx->inputs[0]->format, 0);
+ const AVFilterLink *inlink = ctx->inputs[0];
+ ff_draw_init2(&s->draw, inlink->format, inlink->colorspace, inlink->color_range, 0);
ff_draw_color(&s->draw, &s->color, s->fillcolor);
}
@@ -148,7 +148,8 @@ static int config_input(AVFilterLink *inlink)
{
AssContext *ass = inlink->dst->priv;
- ff_draw_init(&ass->draw, inlink->format, ass->alpha ? FF_DRAW_PROCESS_ALPHA : 0);
+ ff_draw_init2(&ass->draw, inlink->format, inlink->colorspace, inlink->color_range,
+ ass->alpha ? FF_DRAW_PROCESS_ALPHA : 0);
ass_set_frame_size (ass->renderer, inlink->w, inlink->h);
if (ass->original_w && ass->original_h) {
@@ -139,7 +139,7 @@ static int config_props(AVFilterLink *outlink)
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
outlink->frame_rate = av_mul_q(inlink->frame_rate,
av_make_q(1, tile->nb_frames - tile->overlap));
- ff_draw_init(&tile->draw, inlink->format, 0);
+ ff_draw_init2(&tile->draw, inlink->format, inlink->colorspace, inlink->color_range, 0);
ff_draw_color(&tile->draw, &tile->blank, tile->rgba_color);
return 0;
@@ -225,7 +225,7 @@ static int config_out_props(AVFilterLink *outlink)
if (tinterlace->mode == MODE_PAD) {
uint8_t black[4] = { 0, 0, 0, 16 };
- ff_draw_init(&tinterlace->draw, outlink->format, 0);
+ ff_draw_init2(&tinterlace->draw, outlink->format, outlink->colorspace, outlink->color_range, 0);
ff_draw_color(&tinterlace->draw, &tinterlace->color, black);
/* limited range */
if (!ff_fmt_is_in(outlink->format, full_scale_yuvj_pix_fmts)) {
@@ -203,7 +203,7 @@ static int config_input(AVFilterLink *inlink)
TPadContext *s = ctx->priv;
if (needs_drawing(s)) {
- ff_draw_init(&s->draw, inlink->format, 0);
+ ff_draw_init2(&s->draw, inlink->format, inlink->colorspace, inlink->color_range, 0);
ff_draw_color(&s->draw, &s->color, s->rgba_color);
}
@@ -263,7 +263,8 @@ static int color_config_props(AVFilterLink *inlink)
TestSourceContext *test = ctx->priv;
int ret;
- ff_draw_init(&test->draw, inlink->format, 0);
+ ff_draw_init2(&test->draw, inlink->format, inlink->colorspace,
+ inlink->color_range, 0);
ff_draw_color(&test->draw, &test->color, test->color_rgba);
test->w = ff_draw_round_to_sub(&test->draw, 0, -1, test->w);
@@ -944,7 +945,8 @@ static int test2_config_props(AVFilterLink *inlink)
AVFilterContext *ctx = inlink->src;
TestSourceContext *s = ctx->priv;
- av_assert0(ff_draw_init(&s->draw, inlink->format, 0) >= 0);
+ av_assert0(ff_draw_init2(&s->draw, inlink->format, inlink->colorspace,
+ inlink->color_range, 0) >= 0);
s->w = ff_draw_round_to_sub(&s->draw, 0, -1, s->w);
s->h = ff_draw_round_to_sub(&s->draw, 1, -1, s->h);
if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
@@ -1964,7 +1966,8 @@ static int colorchart_config_props(AVFilterLink *inlink)
AVFilterContext *ctx = inlink->src;
TestSourceContext *s = ctx->priv;
- av_assert0(ff_draw_init(&s->draw, inlink->format, 0) >= 0);
+ av_assert0(ff_draw_init2(&s->draw, inlink->format, inlink->colorspace,
+ inlink->color_range, 0) >= 0);
if (av_image_check_size(s->w, s->h, 0, ctx) < 0)
return AVERROR(EINVAL);
return config_props(inlink);
@@ -17,12 +17,12 @@ gbrp12le 91fdad0d1edf7bfa2805e2041e8da3cd
gbrp14le deb2c3af6b48faa52f6a1f6590a0cdf7
gbrp16le a6156d1a37e05ee621b2a343fb158bd6
gbrp9le 9e827f438e081d334a6cae7e282698b0
-gray ddc663a0491df3959d9c5795dceaa72e
-gray10le e6559c1c8c05ce89f44b465573db44e7
-gray12le b066dd276b1698ee77d0c7eb95ff78c5
-gray14le 6d6b293b5d50944c5aa422245987c78e
-gray16le 2734ce1793a2216c5be30816689cd2fe
-gray9le f8f3dfe31ca5fcba828285bceefdab9a
+gray 2b9652a8b136316fada371d03ee252bc
+gray10le 0efebad19b92c6d6d915971c17ab55c4
+gray12le f03613250550d9dc253d46778f6d4bd6
+gray14le dbac6524c3793469c64fc0ee98d017fd
+gray16le 7b6db54ec8b4d9a8344443a3b3f50377
+gray9le 2d2bc7bd35c48fa61860162cf18a4dcf
nv12 381574979cb04be10c9168540310afad
nv16 d3a50501d2ea8535489fd5ec49e7866d
nv21 0fdeb2cdd56cf5a7147dc273456fa217
@@ -43,8 +43,8 @@ rgb48le ed08db9b1aa50d69b8c3d73db93e390e
rgba b157c90191463d34fb3ce77b36c96386
vuya 44368c0a758ee68e24ce976e3b1b8535
vuyx bc7c4f693a22cd1ac95e33d473086474
-ya16le 8dbfcb586abf626da7d1aca887a581b9
-ya8 495daaca2dcb4f7aeba7652768b41ced
+ya16le dfc900a8130a7c5e64201557cbaef50a
+ya8 5d25e9a7975805d3f0dac516a6132b6e
yuv410p cb871dcc1e84a7ef1d21f9237b88cf6e
yuv411p aec2c1740de9a62db0d41f4dda9121b0
yuv420p 4398e408fc35436ce4b20468946f58b6
From: Niklas Haas <git@haasn.dev> This makes all ff_draw_* based filters aware of YUV colorspaces and ranges. Needed for YUVJ removal. Also fixes a bug where e.g. vf_pad would generate a limited range background even after conversion to full-scale grayscale. The FATE changes were a consequence of the aforementioned bugfix - the gray scale files are output as full range (due to conversion by libswscale, which hard-codes gray = full), and appropriately tagged as such, but before this change the padded version incorrectly used a limited range (16) black background for these formats. --- libavfilter/qrencode.c | 8 +++++--- libavfilter/src_avsynctest.c | 2 +- libavfilter/vf_datascope.c | 2 +- libavfilter/vf_drawtext.c | 2 +- libavfilter/vf_pad.c | 2 +- libavfilter/vf_rotate.c | 2 +- libavfilter/vf_shear.c | 2 +- libavfilter/vf_stack.c | 3 ++- libavfilter/vf_subtitles.c | 3 ++- libavfilter/vf_tile.c | 2 +- libavfilter/vf_tinterlace.c | 2 +- libavfilter/vf_tpad.c | 2 +- libavfilter/vsrc_testsrc.c | 9 ++++++--- tests/ref/fate/filter-pixfmts-pad | 16 ++++++++-------- 14 files changed, 32 insertions(+), 25 deletions(-)