[FFmpeg-devel] [PATCH 1/2] lavfi/drawtext: get bitmap from glyph in a separate step
Stefano Sabatini
stefasab at gmail.com
Sun Jan 12 10:35:04 CET 2014
On date Friday 2014-01-10 11:08:37 -0200, Ramiro Polla encoded:
> On Fri, Jan 10, 2014 at 6:40 AM, Stefano Sabatini <stefasab at gmail.com> wrote:
> > On date Friday 2014-01-10 04:36:14 -0200, Ramiro Polla encoded:
> >> This change makes it possible to transform the glyph or get its border before
> >> turning it into a bitmap.
> >
> >> From cdc01d133828f2222cc7e6fb2c0ffe7ecfd95d56 Mon Sep 17 00:00:00 2001
> >> From: Ramiro Polla <ramiro.polla at gmail.com>
> >> Date: Thu, 9 Jan 2014 18:47:17 -0200
> >> Subject: [PATCH 1/2] lavfi/drawtext: get bitmap from glyph in a separate step
> >>
> >> This change makes it possible to transform the glyph or get its border before
> >> turning it into a bitmap.
> >> ---
> >> libavfilter/vf_drawtext.c | 14 ++++++++++----
> >> 1 file changed, 10 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> >> index 91b8218..2dd95ce 100644
> >> --- a/libavfilter/vf_drawtext.c
> >> +++ b/libavfilter/vf_drawtext.c
> >> @@ -206,7 +206,7 @@ static const AVOption drawtext_options[]= {
> >> {"start_number", "start frame number for n/frame_num variable", OFFSET(start_number), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
> >>
> >> /* FT_LOAD_* flags */
> >> - { "ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), AV_OPT_TYPE_FLAGS, { .i64 = FT_LOAD_DEFAULT | FT_LOAD_RENDER}, 0, INT_MAX, FLAGS, "ft_load_flags" },
> >> + { "ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), AV_OPT_TYPE_FLAGS, { .i64 = FT_LOAD_DEFAULT }, 0, INT_MAX, FLAGS, "ft_load_flags" },
> >> { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_DEFAULT }, .flags = FLAGS, .unit = "ft_load_flags" },
> >> { "no_scale", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_NO_SCALE }, .flags = FLAGS, .unit = "ft_load_flags" },
> >> { "no_hinting", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_NO_HINTING }, .flags = FLAGS, .unit = "ft_load_flags" },
> >
> > Please update docs accordingly.
>
> Done.
>
> > Also I wonder if we should remove the render flag altogether.
> >
> > Previously it could be used to skip rendering, but since it is now a
> > two-steps process (load the glyph, render it), the render flags makes
> > no much sense and could indeed result in improper behavior.
>
> I don't see why use those flags except for allowing the user to tinker
> with the library and possible get some misbehaving code. I'd suggest
> removing them altogether.
At the time allowing the user to control all those flags looked like a
good idea.
After re-reading this:
http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_LOAD_XXX
I don't think so anymore.
I suppose we could drop&deprecate the flags option, the potentially
useful settings (like enabling/disabling hinting or mono) could be
enabled through dedicated flags.
>
> > What happens if you load glyph with +render and then convert it to a
> > glyph?
>
> It still works for the text, but not for the border afterwards.
>
> >> @@ -264,6 +264,7 @@ static int glyph_cmp(void *key, const void *b)
> >> static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
> >> {
> >> DrawTextContext *s = ctx->priv;
> >> + FT_BitmapGlyph bitmapglyph;
> >> Glyph *glyph;
> >> struct AVTreeNode *node = NULL;
> >> int ret;
> >> @@ -284,10 +285,15 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
> >> ret = AVERROR(EINVAL);
> >> goto error;
> >> }
> >
> >> + if (FT_Glyph_To_Bitmap(glyph->glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
> >> + ret = AVERROR(EINVAL);
> >
> > AVERROR_EXTERNAL
>
> Done. There are many others around this one to fix afterwards.
> From 48edeadd9d7bad26a443a01c1078e27329c11081 Mon Sep 17 00:00:00 2001
> From: Ramiro Polla <ramiro.polla at gmail.com>
> Date: Fri, 10 Jan 2014 11:03:12 -0200
> Subject: [PATCH] lavfi/drawtext: get bitmap from glyph in a separate step
>
> This change makes it possible to transform the glyph or get its border before
> turning it into a bitmap.
> ---
> doc/filters.texi | 2 +-
> libavfilter/vf_drawtext.c | 14 ++++++++++----
> 2 files changed, 11 insertions(+), 5 deletions(-)
LGTM, I'll apply the patch if I read no other comments.
--
FFmpeg = Funny and Fast MultiPurpose Extreme Game
More information about the ffmpeg-devel
mailing list