[MPlayer-dev-eng] [PATCH] OSD through EOSD

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Aug 13 17:34:53 CEST 2010


On Fri, Aug 13, 2010 at 03:32:32PM +0200, Nicolas George wrote:
> --- a/spudec.c
> +++ b/spudec.c
> @@ -290,8 +290,8 @@ static int apply_palette_crop(spudec_handle_t *this,
>      color = this->custom ? this->cuspal[i] :
>              this->global_palette[this->palette[i]];
>      color = (color >> 16) & 0xff;
> -    // convert to MPlayer-style gray/alpha palette
> -    color = FFMIN(color, alpha);
> +    // convert to MPlayer-style premultiplied gray/alpha palette
> +    color = color * alpha / 255;

This should at least round, otherwise with low alpha it will always be
too dark.

> @@ -835,17 +835,15 @@ static void scale_image(int x, int y, scale_pixel* table_x, scale_pixel* table_y
>    color[1] = spu->image[base + 1];
>    color[2] = spu->image[base + spu->stride];
>    color[3] = spu->image[base + spu->stride + 1];
> -  scale[0] = (table_x[x].left_up * table_y[y].left_up >> 16) * alpha[0];
> +  scale[0] = table_x[x].left_up * table_y[y].left_up >> 16;
>    if (table_y[y].left_up == 0x10000) // necessary to avoid overflow-case
> -    scale[0] = table_x[x].left_up * alpha[0];
> -  scale[1] = (table_x[x].right_down * table_y[y].left_up >>16) * alpha[1];
> -  scale[2] = (table_x[x].left_up * table_y[y].right_down >> 16) * alpha[2];
> -  scale[3] = (table_x[x].right_down * table_y[y].right_down >> 16) * alpha[3];
> -  spu->scaled_image[scaled] = (color[0] * scale[0] + color[1] * scale[1] + color[2] * scale[2] + color[3] * scale[3])>>24;
> -  spu->scaled_aimage[scaled] = (scale[0] + scale[1] + scale[2] + scale[3]) >> 16;
> +    scale[0] = table_x[x].left_up;
> +  scale[1] = table_x[x].right_down * table_y[y].left_up >> 16;
> +  scale[2] = table_x[x].left_up * table_y[y].right_down >> 16;
> +  scale[3] = table_x[x].right_down * table_y[y].right_down >> 16;
> +  spu->scaled_image[scaled] =  (color[0] * scale[0] + color[1] * scale[1] + color[2] * scale[2] + color[3] * scale[3]) >> 16;
> +  spu->scaled_aimage[scaled] = (alpha[0] * scale[0] + alpha[1] * scale[1] + alpha[2] * scale[2] + alpha[3] * scale[3]) >> 16;
>    if (spu->scaled_aimage[scaled]){
> -    // ensure that MPlayer's simplified alpha-blending can not overflow
> -    spu->scaled_image[scaled] = FFMIN(spu->scaled_image[scaled], spu->scaled_aimage[scaled]);

That however is the real problem, scaling the premultiplied value is
quite different from properly scaling the actual value.


More information about the MPlayer-dev-eng mailing list