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

Sigmund Augdal sigmunau at stud.ntnu.no
Fri Jan 2 14:50:07 CET 2004


I whould be more than happy to help. Why don't you try to contact me on irc
one of the days? Preferably on the 7. of January or later. You could also
ask direct questions here, or come with direct suggestions.

Sigmund

On Thu, Jan 01, 2004 at 11:47:21AM -0500, R. Bernstein wrote:
> I've been trying to get a blending routine working for subtitles - CVD
> and SVCD kinds of subtitles, but I believe this routine could be used to
> improve the DVD subtitle rendering as well.
> 
> It's been very tough going. Very few existing routines can be used to
> simplify coding.  Documentation of the formats is very sparse: some
> doxygen comments; one has to look at code to get more detailed
> specification information. As far as I know there are only too
> blending routines that to use as a model: modules/misc/freetype.c and
> modules/codec/spudec/render.c. But neither of these is really general
> purpose; the former handles font bitmaps; the latter is a lacking in
> terms of handling transparancy for some video formats and doesn't
> handle all color components. (usually, if not exclusively, it handles
> only the black/white component). Neither is what I would call easily
> readable or easily modifiable.
> 
> For example, here's a portion of freetype.c that I found relevant: 
> 
>                     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 + pen_y + y - p_glyph->top ) * i_pic_pitch + x + pen_x + p_line->p_glyph_pos[ i ].x + p_glyph->left ]
>                     for(y = 0; y < p_glyph->bitmap.rows; y++ )
>                     {
>                         for( x = 0; x < p_glyph->bitmap.width; x++ )
>                         {
>                             pen_y--;
>                             pixel = ( ( pixel * ( 255 - alpha ) ) >> 8 );
>                             pen_y++; pen_x--;
>                             pixel = ( ( pixel * ( 255 - alpha ) ) >> 8 );
>                             pen_x += 2;
>                             pixel = ( ( pixel * ( 255 - alpha ) ) >> 8 );
>                             pen_y++; pen_x--;
>                             pixel = ( ( pixel * ( 255 - alpha ) ) >> 8 );
>                             pen_y--;
>                         }
>                     }
>                     for(y = 0; y < p_glyph->bitmap.rows; y++ )
>                     {
>                         for( x = 0; x < p_glyph->bitmap.width; x++ )
>                         {
>                             pixel = ( ( pixel * ( 255 - alpha ) ) >> 8 ) +
>                                 ( 255 * alpha >> 8 );
>                         }
>                     }
> 
> I cite the above (which is a more correct implimentation of blending)
> not because I want an explanation of the above, but to give an idea of
> what one is faced with to accomplish writing a blending routine for
> vlc. And as pointed out before, the above is the more *correct*
> implimentation of the two. The spudec render.c routine is as obscure
> if not also incomplete with it's countdown loops which are subtracted
> from the end of an array to give forward access.
> 
> What I have so far is in: modules/codec/ogt/render.c. Help, thoughts,
> comments, code improvements would be greatly appreciated. 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>

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