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

Martin Storsjö martin
Fri May 15 10:07:16 CEST 2009


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libavfilter-soc-overlay-blend.patch
Type: text/x-diff
Size: 4897 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090515/9dc57dc8/attachment.patch>



More information about the ffmpeg-devel mailing list