From 23771469eaf8398fd8df42b63efde0d93f32034a Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sun, 27 Sep 2015 00:24:23 +1000 Subject: [PATCH] Revert "dvdspu: render to ARGB overlay instead of AYUV" This reverts commit dd3e9deb2aa695a391b58f24d86a3c00bbc1258a. --- gst/dvdspu/gstdvdspu.c | 2 +- gst/dvdspu/gstspu-common.h | 15 ++++++++--- gst/dvdspu/gstspu-pgs.c | 28 ++++++-------------- gst/dvdspu/gstspu-vobsub-render.c | 43 +++++++++++-------------------- 4 files changed, 35 insertions(+), 53 deletions(-) diff --git a/gst/dvdspu/gstdvdspu.c b/gst/dvdspu/gstdvdspu.c index 2bf5a91fe9..83cb52102c 100644 --- a/gst/dvdspu/gstdvdspu.c +++ b/gst/dvdspu/gstdvdspu.c @@ -716,7 +716,7 @@ gstspu_render_composition (GstDVDSpu * dvdspu) gint spu_w, spu_h; gsize size; - format = GST_VIDEO_OVERLAY_COMPOSITION_FORMAT_RGB; + format = GST_VIDEO_OVERLAY_COMPOSITION_FORMAT_YUV; switch (dvdspu->spu_input_type) { case SPU_INPUT_TYPE_PGS: diff --git a/gst/dvdspu/gstspu-common.h b/gst/dvdspu/gstspu-common.h index 1618384d02..3107f29fc6 100644 --- a/gst/dvdspu/gstspu-common.h +++ b/gst/dvdspu/gstspu-common.h @@ -39,12 +39,19 @@ struct SpuRect { gint16 bottom; }; -/* Store a pre-multiplied ARGB colour value */ +/* Store a pre-multiplied YUV colour value */ struct SpuColour { - guint8 B; - guint8 G; - guint8 R; +#if G_BYTE_ORDER == G_LITTLE_ENDIAN guint8 A; + guint8 Y; + guint8 U; + guint8 V; +#else + guint8 V; + guint8 U; + guint8 Y; + guint8 A; +#endif }; G_END_DECLS diff --git a/gst/dvdspu/gstspu-pgs.c b/gst/dvdspu/gstspu-pgs.c index bf76a11683..f35fe93fe6 100644 --- a/gst/dvdspu/gstspu-pgs.c +++ b/gst/dvdspu/gstspu-pgs.c @@ -319,9 +319,9 @@ pgs_composition_object_render (PgsCompositionObject * obj, SpuState * state, 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 { @@ -511,7 +511,6 @@ parse_set_palette (GstDVDSpu * dvdspu, guint8 type, guint8 * payload, 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]; @@ -520,26 +519,15 @@ parse_set_palette (GstDVDSpu * dvdspu, guint8 type, guint8 * payload, #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; } diff --git a/gst/dvdspu/gstspu-vobsub-render.c b/gst/dvdspu/gstspu-vobsub-render.c index 583fd32e74..45dcabb201 100644 --- a/gst/dvdspu/gstspu-vobsub-render.c +++ b/gst/dvdspu/gstspu-vobsub-render.c @@ -40,42 +40,29 @@ gstspu_vobsub_recalc_palette (GstDVDSpu * dvdspu, 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; } } } @@ -186,7 +173,7 @@ gstspu_vobsub_draw_rle_run (SpuState * state, GstVideoFrame * frame, 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; @@ -207,9 +194,9 @@ gstspu_vobsub_draw_rle_run (SpuState * state, GstVideoFrame * frame, 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; } }