1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00

avfilter/vf_drawtext: use AVFilterContext for logging

This commit is contained in:
Niklas Haas
2025-08-11 15:47:48 +02:00
committed by Niklas Haas
parent 029f501a95
commit d276875c90

View File

@@ -1269,11 +1269,12 @@ static void update_alpha(DrawTextContext *s)
s->alpha = 256 * alpha;
}
static int draw_glyphs(DrawTextContext *s, AVFrame *frame,
static int draw_glyphs(AVFilterContext *ctx, AVFrame *frame,
FFDrawColor *color,
TextMetrics *metrics,
int x, int y, int borderw)
{
DrawTextContext *s = ctx->priv;
int g, l, x1, y1, w1, h1, idx;
int dx = 0, dy = 0, pdx = 0;
GlyphInfo *info;
@@ -1297,7 +1298,7 @@ static int draw_glyphs(DrawTextContext *s, AVFrame *frame,
if ((!j_left || j_right) && !s->tab_warning_printed && s->tab_count > 0) {
s->tab_warning_printed = 1;
av_log(s, AV_LOG_WARNING, "Tab characters are only supported with left horizontal alignment\n");
av_log(ctx, AV_LOG_WARNING, "Tab characters are only supported with left horizontal alignment\n");
}
clip_x = FFMIN(metrics->rect_x + s->box_width + s->bb_right, frame->width);
@@ -1510,7 +1511,7 @@ continue_on_failed2:
cur_line->width64 = w64;
av_log(s, AV_LOG_DEBUG, " Line: %d -- glyphs count: %d - width64: %d - offset_left64: %d - offset_right64: %d)\n",
av_log(ctx, AV_LOG_DEBUG, " Line: %d -- glyphs count: %d - width64: %d - offset_left64: %d - offset_right64: %d)\n",
line_count, hb->glyph_count, cur_line->width64, cur_line->offset_left64, cur_line->offset_right64);
if (w64 > width64) {
@@ -1613,7 +1614,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame)
return ret;
if (!av_bprint_is_complete(&s->expanded_fontcolor))
return AVERROR(ENOMEM);
av_log(s, AV_LOG_DEBUG, "Evaluated fontcolor is '%s'\n", s->expanded_fontcolor.str);
av_log(ctx, AV_LOG_DEBUG, "Evaluated fontcolor is '%s'\n", s->expanded_fontcolor.str);
ret = av_parse_color(s->fontcolor.rgba, s->expanded_fontcolor.str, -1, s);
if (ret)
return ret;
@@ -1797,20 +1798,20 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame)
}
if (s->shadowx || s->shadowy) {
if ((ret = draw_glyphs(s, frame, &shadowcolor, &metrics,
if ((ret = draw_glyphs(ctx, frame, &shadowcolor, &metrics,
s->shadowx, s->shadowy, s->borderw)) < 0) {
return ret;
}
}
if (s->borderw) {
if ((ret = draw_glyphs(s, frame, &bordercolor, &metrics,
if ((ret = draw_glyphs(ctx, frame, &bordercolor, &metrics,
0, 0, s->borderw)) < 0) {
return ret;
}
}
if ((ret = draw_glyphs(s, frame, &fontcolor, &metrics, 0,
if ((ret = draw_glyphs(ctx, frame, &fontcolor, &metrics, 0,
0, 0)) < 0) {
return ret;
}
@@ -1846,7 +1847,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
header = (AVDetectionBBoxHeader *)sd->data;
loop = header->nb_bboxes;
} else {
av_log(s, AV_LOG_WARNING, "No detection bboxes.\n");
av_log(ctx, AV_LOG_WARNING, "No detection bboxes.\n");
return ff_filter_frame(outlink, frame);
}
}