aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-01-31 11:47:30 +0100
committerNiklas Haas <git@haasn.dev>2024-02-06 11:30:10 +0100
commitce81237d638214dd3fd64579805f67028f5bf144 (patch)
treeb1c295366c1290f7759358e30b54cb93c07b8c5c /libavfilter
parent8264f3612c2c6dfff05587175854b62650ac917c (diff)
downloadffmpeg-ce81237d638214dd3fd64579805f67028f5bf144.tar.gz
avfilter: pass link YUV colorspace to ff_draw_init2
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.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/qrencode.c8
-rw-r--r--libavfilter/src_avsynctest.c2
-rw-r--r--libavfilter/vf_datascope.c2
-rw-r--r--libavfilter/vf_drawtext.c2
-rw-r--r--libavfilter/vf_pad.c2
-rw-r--r--libavfilter/vf_rotate.c2
-rw-r--r--libavfilter/vf_shear.c2
-rw-r--r--libavfilter/vf_stack.c3
-rw-r--r--libavfilter/vf_subtitles.c3
-rw-r--r--libavfilter/vf_tile.c2
-rw-r--r--libavfilter/vf_tinterlace.c2
-rw-r--r--libavfilter/vf_tpad.c2
-rw-r--r--libavfilter/vsrc_testsrc.c9
13 files changed, 24 insertions, 17 deletions
diff --git a/libavfilter/qrencode.c b/libavfilter/qrencode.c
index 09af8dfb4e..6b86e01f57 100644
--- a/libavfilter/qrencode.c
+++ b/libavfilter/qrencode.c
@@ -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);
diff --git a/libavfilter/src_avsynctest.c b/libavfilter/src_avsynctest.c
index a0fef7a1cb..9fd0b590c1 100644
--- a/libavfilter/src_avsynctest.c
+++ b/libavfilter/src_avsynctest.c
@@ -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]);
diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c
index 89b59f2510..4845c9918d 100644
--- a/libavfilter/vf_datascope.c
+++ b/libavfilter/vf_datascope.c
@@ -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} );
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index fe7e6ace27..19599e065d 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -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_init2(&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);
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index e52f7284d4..240b6b929d 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -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;
diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c
index 96c250a459..3adde22c09 100644
--- a/libavfilter/vf_rotate.c
+++ b/libavfilter/vf_rotate.c
@@ -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;
diff --git a/libavfilter/vf_shear.c b/libavfilter/vf_shear.c
index 760caa5011..5d43809ccd 100644
--- a/libavfilter/vf_shear.c
+++ b/libavfilter/vf_shear.c
@@ -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;
diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
index 331dc7b3e3..2bb3d9b1d2 100644
--- a/libavfilter/vf_stack.c
+++ b/libavfilter/vf_stack.c
@@ -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);
}
diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index ef5f9cd866..366c0bf39e 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -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) {
diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
index ca2397fb18..b45e739bb6 100644
--- a/libavfilter/vf_tile.c
+++ b/libavfilter/vf_tile.c
@@ -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;
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index e221a6f941..8ff0aa8b4b 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -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)) {
diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index 1efe4ec479..9ef5956eac 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -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);
}
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 3b5536badc..73a61bfa45 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -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);