diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2008-05-12 16:35:39 +0000 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2008-05-12 16:35:39 +0000 |
commit | 10f7a99f1adcd517086bd6a7950aae823fbc5496 (patch) | |
tree | 5848bc47b89f595b20b02a3f116acc0856f87804 /gst/matroska | |
parent | 9ebb11bebf7cb98c953b7bd2ec79080d42818480 (diff) |
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.
Diffstat (limited to 'gst/matroska')
-rw-r--r-- | gst/matroska/matroska-demux.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 2b0ea032..85bfcafe 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 */ |