Message ID | 1473809900-18068-1-git-send-email-onemda@gmail.com |
---|---|
State | Superseded |
Headers | show |
On 9/14/16, Paul B Mahol <onemda@gmail.com> wrote: > Signed-off-by: Paul B Mahol <onemda@gmail.com> > --- > Fixes #3302. > --- > libavfilter/drawutils.c | 7 ++++--- > libavfilter/drawutils.h | 1 + > libavfilter/vf_drawtext.c | 2 +- > 3 files changed, 6 insertions(+), 4 deletions(-) > Also fixes #3571.
On Wed, Sep 14, 2016 at 01:38:20AM +0200, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol <onemda@gmail.com> > --- > Fixes #3302. > --- > libavfilter/drawutils.c | 7 ++++--- > libavfilter/drawutils.h | 1 + > libavfilter/vf_drawtext.c | 2 +- > 3 files changed, 6 insertions(+), 4 deletions(-) > > diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c > index f6760be..905eaa3 100644 > --- a/libavfilter/drawutils.c > +++ b/libavfilter/drawutils.c > @@ -211,10 +211,11 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) > draw->desc = desc; > draw->format = format; > draw->nb_planes = nb_planes; > + draw->flags = flags; > memcpy(draw->pixelstep, pixelstep, sizeof(draw->pixelstep)); > draw->hsub[1] = draw->hsub[2] = draw->hsub_max = desc->log2_chroma_w; > draw->vsub[1] = draw->vsub[2] = draw->vsub_max = desc->log2_chroma_h; > - for (i = 0; i < (desc->nb_components - !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)); i++) > + for (i = 0; i < (desc->nb_components - !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA && !(flags & 1))); i++) > draw->comp_mask[desc->comp[i].plane] |= > 1 << desc->comp[i].offset; > return 0; > @@ -452,7 +453,7 @@ void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color, > /* 0x101 * alpha is in the [ 2 ; 0x1001] range */ > alpha = 0x101 * color->rgba[3] + 0x2; > } > - nb_planes = draw->nb_planes - !!(draw->desc->flags & AV_PIX_FMT_FLAG_ALPHA); > + nb_planes = draw->nb_planes - !!(draw->desc->flags & AV_PIX_FMT_FLAG_ALPHA && !(draw->flags & 1)); > nb_planes += !nb_planes; > for (plane = 0; plane < nb_planes; plane++) { > nb_comp = draw->pixelstep[plane]; > @@ -630,7 +631,7 @@ void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, > } else { > alpha = (0x101 * color->rgba[3] + 0x2) >> 8; > } > - nb_planes = draw->nb_planes - !!(draw->desc->flags & AV_PIX_FMT_FLAG_ALPHA); > + nb_planes = draw->nb_planes - !!(draw->desc->flags & AV_PIX_FMT_FLAG_ALPHA && !(draw->flags & 1)); > nb_planes += !nb_planes; > for (plane = 0; plane < nb_planes; plane++) { > nb_comp = draw->pixelstep[plane]; > diff --git a/libavfilter/drawutils.h b/libavfilter/drawutils.h > index 1fb3e4f..11ec97a 100644 > --- a/libavfilter/drawutils.h > +++ b/libavfilter/drawutils.h > @@ -55,6 +55,7 @@ typedef struct FFDrawContext { > uint8_t vsub[MAX_PLANES]; /*< vertical subsampling */ > uint8_t hsub_max; > uint8_t vsub_max; > + unsigned flags; > } FFDrawContext; > > typedef struct FFDrawColor { > diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c > index 214aef0..996c26d 100644 > --- a/libavfilter/vf_drawtext.c > +++ b/libavfilter/vf_drawtext.c > @@ -730,7 +730,7 @@ static int config_input(AVFilterLink *inlink) > DrawTextContext *s = ctx->priv; > int ret; > > - ff_draw_init(&s->dc, inlink->format, 0); > + ff_draw_init(&s->dc, inlink->format, 1); the docs need an update they say "No flags currently defined." also a named identifer would be more descriptive than 1 [...]
diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c index f6760be..905eaa3 100644 --- a/libavfilter/drawutils.c +++ b/libavfilter/drawutils.c @@ -211,10 +211,11 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) draw->desc = desc; draw->format = format; draw->nb_planes = nb_planes; + draw->flags = flags; memcpy(draw->pixelstep, pixelstep, sizeof(draw->pixelstep)); draw->hsub[1] = draw->hsub[2] = draw->hsub_max = desc->log2_chroma_w; draw->vsub[1] = draw->vsub[2] = draw->vsub_max = desc->log2_chroma_h; - for (i = 0; i < (desc->nb_components - !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)); i++) + for (i = 0; i < (desc->nb_components - !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA && !(flags & 1))); i++) draw->comp_mask[desc->comp[i].plane] |= 1 << desc->comp[i].offset; return 0; @@ -452,7 +453,7 @@ void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color, /* 0x101 * alpha is in the [ 2 ; 0x1001] range */ alpha = 0x101 * color->rgba[3] + 0x2; } - nb_planes = draw->nb_planes - !!(draw->desc->flags & AV_PIX_FMT_FLAG_ALPHA); + nb_planes = draw->nb_planes - !!(draw->desc->flags & AV_PIX_FMT_FLAG_ALPHA && !(draw->flags & 1)); nb_planes += !nb_planes; for (plane = 0; plane < nb_planes; plane++) { nb_comp = draw->pixelstep[plane]; @@ -630,7 +631,7 @@ void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, } else { alpha = (0x101 * color->rgba[3] + 0x2) >> 8; } - nb_planes = draw->nb_planes - !!(draw->desc->flags & AV_PIX_FMT_FLAG_ALPHA); + nb_planes = draw->nb_planes - !!(draw->desc->flags & AV_PIX_FMT_FLAG_ALPHA && !(draw->flags & 1)); nb_planes += !nb_planes; for (plane = 0; plane < nb_planes; plane++) { nb_comp = draw->pixelstep[plane]; diff --git a/libavfilter/drawutils.h b/libavfilter/drawutils.h index 1fb3e4f..11ec97a 100644 --- a/libavfilter/drawutils.h +++ b/libavfilter/drawutils.h @@ -55,6 +55,7 @@ typedef struct FFDrawContext { uint8_t vsub[MAX_PLANES]; /*< vertical subsampling */ uint8_t hsub_max; uint8_t vsub_max; + unsigned flags; } FFDrawContext; typedef struct FFDrawColor { diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 214aef0..996c26d 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -730,7 +730,7 @@ static int config_input(AVFilterLink *inlink) DrawTextContext *s = ctx->priv; int ret; - ff_draw_init(&s->dc, inlink->format, 0); + ff_draw_init(&s->dc, inlink->format, 1); 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);
Signed-off-by: Paul B Mahol <onemda@gmail.com> --- Fixes #3302. --- libavfilter/drawutils.c | 7 ++++--- libavfilter/drawutils.h | 1 + libavfilter/vf_drawtext.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)