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

Martin Storsjö martin
Mon May 18 14:32:07 CEST 2009

On Fri, 15 May 2009, C?dric Schieli wrote:

> 2009/5/15 Martin Storsj? <martin at martin.st>:
> > 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?
> 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

Ok, so the first step would be to get av_picture_blend merged. Adding 
support for YUVA is quite simple, but I'm not sure about the function 
signature. Ideally, the pixfmts of the source and destination need not be 
identical, just similar enough; for YUV, it'd be a big waste to have to 
convert the whole main image to YUVA just because a small overlay will be 
blended on top, and the code for blending YUVA on top of YUV is a subset 
of the code for full blending of YUVA on top of YUVA.

// Martin

More information about the ffmpeg-devel mailing list