- uint8_t *p_in;
- int i_pitch = p_pic->p[i_plane].i_pitch;
-
- p_in = p_pic->p[i_plane].p_pixels;
-
- if ( i_plane == 0 )
- {
- if ( p_string->i_flags & OSD_ALIGN_BOTTOM )
- {
- pen_y = p_pic->p[i_plane].i_lines - p_string->i_height -
- p_string->i_y_margin;
- }
- else
- {
- pen_y = p_string->i_y_margin;
- }
- if ( p_string->i_flags & OSD_ALIGN_RIGHT )
- {
- pen_x = i_pitch - p_string->i_width
- - p_string->i_x_margin;
- }
- else
- {
- pen_x = p_string->i_x_margin;
- }
-
- for( i = 0; p_string->pp_glyphs[i] != NULL; i++ )
- {
- if( p_string->pp_glyphs[i] )
- {
- FT_Glyph p_glyph = p_string->pp_glyphs[i];
- FT_BitmapGlyph p_image;
- i_error = FT_Glyph_To_Bitmap( &p_glyph,
- FT_RENDER_MODE_NORMAL,
- &p_string->p_glyph_pos[i],
- 0 );
- if ( i_error ) continue;
- p_image = (FT_BitmapGlyph)p_glyph;
-#define alpha p_vout->p_text_renderer_data->pi_gamma[p_image->bitmap.buffer[x+ y*p_image->bitmap.width]]
-#define pixel p_in[(p_string->p_glyph_pos[i].y + pen_y + y - p_image->top)*i_pitch+x+pen_x+p_string->p_glyph_pos[i].x+p_image->left]
- for(y = 0; y < p_image->bitmap.rows; y++ )
- {
- for( x = 0; x < p_image->bitmap.width; x++ )
- {
- // pixel = alpha;
- // pixel = (pixel^alpha)^pixel;
- pixel = ( ( pixel * ( 255 - alpha ) ) >> 8 ) +
- ( 255 * alpha >> 8 );
- }
- }
- FT_Done_Glyph( p_glyph );
- }
- }
- }
+ msg_Err( p_filter, "cannot allocate SPU region" );
+ return;
+ }
+
+ p_spu->p_region->i_x = p_spu->p_region->i_y = 0;
+ p_y = p_spu->p_region->picture.Y_PIXELS;
+ p_u = p_spu->p_region->picture.U_PIXELS;
+ p_v = p_spu->p_region->picture.V_PIXELS;
+ p_a = p_spu->p_region->picture.A_PIXELS;
+ i_pitch = p_spu->p_region->picture.Y_PITCH;
+
+ /* Initialize the region pixels (only the alpha will be changed later) */
+ memset( p_y, 0x00, i_pitch * p_spu->p_region->fmt.i_height );
+ memset( p_u, 0x80, i_pitch * p_spu->p_region->fmt.i_height );
+ memset( p_v, 0x80, i_pitch * p_spu->p_region->fmt.i_height );
+ memset( p_a, 0x00, i_pitch * p_spu->p_region->fmt.i_height );
+
+#define pi_gamma p_sys->pi_gamma
+
+ for( p_line = p_string->p_lines; p_line != NULL; p_line = p_line->p_next )
+ {
+ int i_glyph_tmax = 0;
+ int i_bitmap_offset, i_offset;
+ for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
+ {
+ FT_BitmapGlyph p_glyph = p_line->pp_glyphs[ i ];
+ i_glyph_tmax = __MAX( i_glyph_tmax, p_glyph->top );
+ }
+
+ for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
+ {
+ FT_BitmapGlyph p_glyph = p_line->pp_glyphs[ i ];
+
+ i_offset = ( p_line->p_glyph_pos[ i ].y +
+ i_glyph_tmax - p_glyph->top + 1 ) *
+ i_pitch + p_line->p_glyph_pos[ i ].x + p_glyph->left + 1;
+
+ for( y = 0, i_bitmap_offset = 0; y < p_glyph->bitmap.rows; y++ )
+ {
+ for( x = 0; x < p_glyph->bitmap.width; x++, i_bitmap_offset++ )
+ {
+ if( !pi_gamma[p_glyph->bitmap.buffer[i_bitmap_offset]] )
+ continue;
+
+ i_offset -= i_pitch;
+ p_a[i_offset + x] = ((uint16_t)p_a[i_offset + x] +
+ pi_gamma[p_glyph->bitmap.buffer[i_bitmap_offset]])/2;
+ i_offset += i_pitch; x--;
+ p_a[i_offset + x] = ((uint16_t)p_a[i_offset + x] +
+ pi_gamma[p_glyph->bitmap.buffer[i_bitmap_offset]])/2;
+ x += 2;
+ p_a[i_offset + x] = ((uint16_t)p_a[i_offset + x] +
+ pi_gamma[p_glyph->bitmap.buffer[i_bitmap_offset]])/2;
+ i_offset += i_pitch; x--;
+ p_a[i_offset + x] = ((uint16_t)p_a[i_offset + x] +
+ pi_gamma[p_glyph->bitmap.buffer[i_bitmap_offset]])/2;
+ i_offset -= i_pitch;
+ }
+ i_offset += i_pitch;
+ }
+
+ i_offset = ( p_line->p_glyph_pos[ i ].y +
+ i_glyph_tmax - p_glyph->top ) *
+ i_pitch + p_line->p_glyph_pos[ i ].x + p_glyph->left + 1;
+
+ for( y = 0, i_bitmap_offset = 0; y < p_glyph->bitmap.rows; y++ )
+ {
+ for( x = 0; x < p_glyph->bitmap.width; x++, i_bitmap_offset++ )
+ {
+ p_y[i_offset + x] =
+ pi_gamma[p_glyph->bitmap.buffer[i_bitmap_offset]];
+ }
+ i_offset += i_pitch;
+ }
+
+#undef pi_gamma
+ }