[FFmpeg-devel] [PATCH] Support alphablending in the overlay filter

Cédric Schieli cschieli
Fri May 15 11:12:34 CEST 2009


2009/5/15 Martin Storsj? <martin at martin.st>:
> Hi,
>
> The attached patch is an attempt at supporting alphablending of the
> overlaid video/image in the overlay filter.
>
> First, a third positional parameter is added to the filter, for enabling
> blending. This should probably be rewritten using av_set_options_string as
> a named parameter, e.g. blend=1.
>
> Originally, the overlay filter gets one single AVFilterFormats list which
> is assigned to all input and output pads (by
> avfilter_default_query_formats). When configuring the formats of the
> links, the main input trims this format list to the one format that the
> main input has, forcing the second input to use the same format. Since the
> main input probably won't contain alpha (while the second input will do,
> in order to make any sense to do blending), the formats of these two
> inputs need to be separate. To be able to do the blending in any sensible
> way, the formats of the both inputs still need to be the same, except for
> the alpha channel.
>
> In this initial attempt, the query_formats function forces the inputs to
> PIX_FMT_YUV420P and PIX_FMT_YUVA420P respectively.
>
> I didn't find any generic function for doing an alphablended copy of one
> picture on top of another, so a quick n dirty implementation is included
> within vf_overlay.c. I suppose this should be moved to some generic place
> within avcodec?
>
> Comments welcome on what's needed to get this in shape for inclusion.
>
> Regards,
> // Martin

Hi,


You will find in this thread
(http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2009-January/059495.html)
my previous work on this topic, mainly in av_picture_blend.patch and
vf_overlay_blend.patch (which is a bit outdated now). It is RGB only
but should be easily extended to support YUVA
I do not have much time to work on ffmpeg at the moment, so I'm happy
someone can take over the alpha blending topic.


Regards,
C?dric Schieli



More information about the ffmpeg-devel mailing list