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

Vitor Sessak vitor1001
Mon May 18 18:50:47 CEST 2009

Hi and sorry for the delay.

Martin Storsj? wrote:
> 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.

Yes, I have no idea of how to accept both YUVA+YUV or YUVA+YUVA for 
input for YUV output with current colorspace negotiation framework. 
Actually, I've already expected this problem to show up at some point 
), but indeed a different system would be much more complicated to 
handle. Any ideas are welcome...

> 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?

I think C?dric's patch is a good starting point. Also, I think such 
function belongs to libavfilter and not libavcodec (blending is 
filtering IMHO).


More information about the ffmpeg-devel mailing list