[vlc-devel] Re: Please help in blending routine

R. Bernstein rocky at panix.com
Fri Jan 2 15:48:34 CET 2004

Many thanks for offering to help. It looks like there is much work to
be done here. Given the treacherous nature of things (I make small
changes which alter things drastically in ways I don't fully
understand), I'll probably make lots of incremental
changes. Ultimately it would be nice to have a general-purpose bitmap
format with a general purpose scaling and blending routine. But
initially, I think that is going to be too hard (for me) to do.

What internal image format that would make operations for scaling and
blending to make easy I'm going to defer. Again, it may mean more
rewrite later.

This morning started a routine to write the subtitle bitmaps to a PNG
file via libpng. A routine that I need to have is routine to get the
aspect ratio. (I saw something in one of the video output routines
that does this by computing the GCD between two numbers).

- - -

A specific question the UV planes in freetype.c, this code concerning
the UV planes, in this code:

                for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
                    FT_BitmapGlyph p_glyph = p_line->pp_glyphs[ i ];
#define alpha p_vout->p_text_renderer_data->pi_gamma[ p_glyph->bitmap.buffer[ ( x + y * p_glyph->bitmap.width ) ] ]
#define pixel p_in[ ( ( p_line->p_glyph_pos[ i ].y >> 1 ) + pen_y + ( y >> 1 ) -  ( p_glyph->top >> 1 ) ) * i_pic_pitch + ( x >> 1 ) + pen_x + ( p_line->p_glyph_pos[ i ].x >> 1 ) + ( p_glyph->left >>1) ]
                    for( y = 0; y < p_glyph->bitmap.rows; y+=2 )
                        for( x = 0; x < p_glyph->bitmap.width; x+=2 )
                            pixel = ( ( pixel * ( 0xFF - alpha ) ) >> 8 ) +
                                ( 0x80 * alpha >> 8 );

For the above pixel = ... to be correct, I gather the glyph data is
already encoded using 4-bits per byte in the UV planes. Right? I'm not
sure I understand the "0x80 * alpha >> 8" part. Let's how does C
precidence work - I guess we do the multiplication first and then the
shift. Why the multiplication by 0x80 first? Is 0x80 some color value?

I will try to log on IRC the 7th but more likely on the weekend say the
10th, usually morning for me - somewhere in the range 12:00-1400 UTC. 

Again, thanks.

This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>

More information about the vlc-devel mailing list