From 10f7a99f1adcd517086bd6a7950aae823fbc5496 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Mon, 12 May 2008 16:35:39 +0000 Subject: [PATCH] gst/matroska/matroska-demux.c: Convert subtitle palette info in VobSub private data from VobSub's (buggy) RGB to YUV. Original commit message from CVS: * gst/matroska/matroska-demux.c: (gst_matroska_demux_push_dvd_clut_change_event): Convert subtitle palette info in VobSub private data from VobSub's (buggy) RGB to YUV. --- ChangeLog | 7 +++++++ gst/matroska/matroska-demux.c | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70808f4849..3512018d3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-05-12 Mark Nauwelaerts + + * gst/matroska/matroska-demux.c: + (gst_matroska_demux_push_dvd_clut_change_event): + Convert subtitle palette info in VobSub private data from VobSub's + (buggy) RGB to YUV. + 2008-05-12 Mark Nauwelaerts * gst/avi/gstavimux.c: (gst_avi_mux_pad_reset): diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 2b0ea0324a..85bfcafe98 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -2400,17 +2400,28 @@ gst_matroska_demux_push_dvd_clut_change_event (GstMatroskaDemux * demux, start = strstr (stream->codec_priv, "palette:"); if (start) { gint i; - guint clut[16]; + guint32 clut[16]; + guint32 col; + guint8 r, g, b, y, u, v; start += 8; while (g_ascii_isspace (*start)) start++; for (i = 0; i < 16; i++) { - if (sscanf (start, "%06x", &clut[i]) != 1) + if (sscanf (start, "%06x", &col) != 1) break; start += 6; while ((*start == ',') || g_ascii_isspace (*start)) start++; + /* sigh, need to convert this from vobsub pseudo-RGB to YUV */ + r = (col >> 16) & 0xff; + g = (col >> 8) & 0xff; + b = col & 0xff; + y = CLAMP ((0.1494 * r + 0.6061 * g + 0.2445 * b) * 219 / 255 + 16, 0, + 255); + u = CLAMP (0.6066 * r - 0.4322 * g - 0.1744 * b + 128, 0, 255); + v = CLAMP (-0.08435 * r - 0.3422 * g + 0.4266 * b + 128, 0, 255); + clut[i] = (y << 16) | (u << 8) | v; } /* got them all without problems; build and send event */