- p_region->i_x = p_region->i_y = 0;
- p_y = p_region->picture.Y_PIXELS;
- p_u = p_region->picture.U_PIXELS;
- p_v = p_region->picture.V_PIXELS;
- p_a = p_region->picture.A_PIXELS;
+ p_region->fmt = p_region_tmp->fmt;
+ p_region->picture = p_region_tmp->picture;
+ free( p_region_tmp );
+
+ /* Calculate text color components */
+ i_y = (uint8_t)(( 66 * p_line->i_red + 129 * p_line->i_green +
+ 25 * p_line->i_blue + 128) >> 8) + 16;
+ i_u = (int8_t)(( -38 * p_line->i_red - 74 * p_line->i_green +
+ 112 * p_line->i_blue + 128) >> 8) + 128;
+ i_v = (int8_t)(( 112 * p_line->i_red - 94 * p_line->i_green -
+ 18 * p_line->i_blue + 128) >> 8) + 128;
+
+ /* Build palette */
+ fmt.p_palette->i_entries = 256;
+ for( i = 0; i < fmt.p_palette->i_entries; i++ )
+ {
+ fmt.p_palette->palette[i][0] = i * i_y / 256;
+ fmt.p_palette->palette[i][1] = i_u;
+ fmt.p_palette->palette[i][2] = i_v;
+ fmt.p_palette->palette[i][3] =
+ i + (256 - i) * (256 / (255 - p_line->i_alpha)) / 16;
+ }
+ fmt.p_palette->palette[0][3] = 0;
+
+ p_dst = p_region->picture.Y_PIXELS;