[MPlayer-dev-eng] Re: [PATCH] cmov detection and draw_alpha fixes

Alban Bedel albeu at free.fr
Fri Mar 31 20:26:49 CEST 2006


On Fri, 31 Mar 2006 10:53:53 +0300
"Ivan Kalvachev" <ikalvachev at gmail.com> wrote:

> now let's say we have image pixles with variable "image" we have
> bitmap pixel with variable "bitmap" and alpha for the same bitmap
> called "alphamap", (all values are floats) so
> 
> newimage = image*alphamap + bitmap*(1-alphamap).
> 
> now, the (bitmap*(1-alphamap) depends only on the data from the
> bitmap, not the data from the image. This means it could be
> precalculated and stored. so:
> 
> newimage = image*alphamap + calcmap.
> 
> Now, if you have overflow you are most likely using "bitmap" instead
> of "calcmap" or there is some kind of rounding error (e.g. for speed
> reasons alpha 1.0 is 0xff not 0x100)

Seems so. However i still think their is a pb, at least that's not what
is done for the subtitles. The code let the bitmap untouched and instead
modify the alphamap such that image*alphamap + bitmap doesn't overflow.
This will make sure the subs get over the image, but it's not really
correct blending.

I don't like that system much anyway, if you want to change the alphamap
you need to recompute the whole bitmap. Plus such operation is loosy,
so no way to get back :( It doesn't matter much for the subs, but for the
osd menu it is quiet annoying.

Their is another alternative to the formula you have shown:

newimage = alphamap*(newimage-bitmap) + bitmap

It only add one substraction compared to the current method and it
doesn't need you to botch your bitmap or alphamap before rendring.
So what about using that instead ?

	Albeu




More information about the MPlayer-dev-eng mailing list