aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/drawutils.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2016-09-14 01:37:13 +0200
committerPaul B Mahol <onemda@gmail.com>2016-09-21 11:54:00 +0200
commit9d16e46d9eb4643ce119e26ed5c3975cb6cb7aa1 (patch)
tree3fb3c3ac0e88713266d9b655c25e9282f8b283aa /libavfilter/drawutils.c
parent6419b4c0cb154932b96c140bdf2a9c4eefddcbed (diff)
downloadffmpeg-9d16e46d9eb4643ce119e26ed5c3975cb6cb7aa1.tar.gz
avfilter/drawutils: allow drawing opaque text on transparent background
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/drawutils.c')
-rw-r--r--libavfilter/drawutils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
index f6760be963..f19fc5df1d 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 & FF_DRAW_PROCESS_ALPHA))); 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 & FF_DRAW_PROCESS_ALPHA));
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 & FF_DRAW_PROCESS_ALPHA));
nb_planes += !nb_planes;
for (plane = 0; plane < nb_planes; plane++) {
nb_comp = draw->pixelstep[plane];