memcpy (pix, colour, sizeof (*pix));
} else {
pix->A = colour->A;
- pix->R = colour->R + pix->R * inv_A / 255;
- pix->G = colour->G + pix->G * inv_A / 255;
- pix->B = colour->B + pix->B * inv_A / 255;
+ pix->Y = colour->Y + pix->Y * inv_A / 255;
+ pix->U = colour->U + pix->U * inv_A / 255;
+ pix->V = colour->V + pix->V * inv_A / 255;
}
}
} else {
state->pgs.palette[i].A = 0;
for (i = 0; i < n_entries; i++) {
guint8 n, Y, U, V, A;
- gint R, G, B;
n = payload[0];
Y = payload[1];
V = payload[2];
#if DUMP_FULL_PALETTE
PGS_DUMP ("Entry %3d: Y %3d U %3d V %3d A %3d ", n, Y, U, V, A);
-#endif
-
- /* Convert to ARGB */
- R = (298 * Y + 459 * V - 63514) >> 8;
- G = (298 * Y - 55 * U - 136 * V + 19681) >> 8;
- B = (298 * Y + 541 * U - 73988) >> 8;
-
- R = CLAMP (R, 0, 255);
- G = CLAMP (G, 0, 255);
- B = CLAMP (B, 0, 255);
-
-#if DUMP_FULL_PALETTE
- PGS_DUMP ("Entry %3d: A %3d R %3d G %3d B %3d\n", n, A, R, G, B);
+ if (((i + 1) % 2) == 0)
+ PGS_DUMP ("\n");
#endif
/* Premultiply the palette entries by the alpha */
state->pgs.palette[n].A = A;
- state->pgs.palette[n].R = R * A / 255;
- state->pgs.palette[n].G = G * A / 255;
- state->pgs.palette[n].B = B * A / 255;
+ state->pgs.palette[n].Y = Y * A / 255;
+ state->pgs.palette[n].U = U * A / 255;
+ state->pgs.palette[n].V = V * A / 255;
payload += PGS_PALETTE_ENTRY_SIZE;
}
if (state->vobsub.current_clut[idx[0]] != 0) {
for (i = 0; i < 4; i++, dest++) {
guint32 col = state->vobsub.current_clut[idx[i]];
- gint A, Y, U, V;
- gint R, G, B;
/* Convert incoming 4-bit alpha to 8 bit for blending */
- A = (alpha[i] << 4) | alpha[i];
- Y = ((col >> 16) & 0xff);
+ dest->A = (alpha[i] << 4) | alpha[i];
+ dest->Y = ((col >> 16) & 0xff) * dest->A / 255;
/* U/V are stored as V/U in the clut words, so switch them */
- V = ((col >> 8) & 0xff);
- U = (col & 0xff);
-
- R = (298 * Y + 459 * V - 63514) >> 8;
- G = (298 * Y - 55 * U - 136 * V + 19681) >> 8;
- B = (298 * Y + 541 * U - 73988) >> 8;
-
- R = CLAMP (R, 0, 255);
- G = CLAMP (G, 0, 255);
- B = CLAMP (B, 0, 255);
-
- dest->A = A;
- dest->R = R * A / 255;
- dest->G = G * A / 255;
- dest->B = B * A / 255;
+ dest->V = ((col >> 8) & 0xff) * dest->A / 255;
+ dest->U = (col & 0xff) * dest->A / 255;
}
} else {
- int c = 255;
+ int y = 240;
/* The CLUT presumably hasn't been set, so we'll just guess some
* values for the non-transparent colors (white, grey, black) */
for (i = 0; i < 4; i++, dest++) {
dest->A = (alpha[i] << 4) | alpha[i];
if (alpha[i] != 0) {
- dest->R = dest->G = dest->B = c * dest->A / 255;
- c -= 128;
- if (c < 0)
- c = 0;
+ dest[0].Y = y * dest[0].A / 255;
+ y -= 112;
+ if (y < 0)
+ y = 0;
}
+ dest[0].U = 128 * dest[0].A / 255;
+ dest[0].V = 128 * dest[0].A / 255;
}
}
}
gint16 x, gint16 end, SpuColour * colour)
{
GST_TRACE ("Y: %d x: %d end %d %d %d %d %d",
- state->vobsub.cur_Y, x, end, colour->R, colour->G, colour->B, colour->A);
+ state->vobsub.cur_Y, x, end, colour->Y, colour->U, colour->V, colour->A);
if (colour->A > 0) {
gint i;
memcpy (pix, colour, sizeof (*pix));
} else {
pix->A = colour->A;
- pix->R = colour->R + pix->R * inv_A / 255;
- pix->G = colour->G + pix->G * inv_A / 255;
- pix->B = colour->B + pix->B * inv_A / 255;
+ pix->Y = colour->Y + pix->Y * inv_A / 255;
+ pix->U = colour->U + pix->U * inv_A / 255;
+ pix->V = colour->V + pix->V * inv_A / 255;
}
}