gst/matroska/matroska-demux.c: Convert subtitle palette info in VobSub private data...
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Mon, 12 May 2008 16:35:39 +0000 (16:35 +0000)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Mon, 12 May 2008 16:35:39 +0000 (16:35 +0000)
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
gst/matroska/matroska-demux.c

index 70808f4..3512018 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-05-12  Mark Nauwelaerts  <mnauw@users.sf.net>
 
+       * 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  <mnauw@users.sf.net>
+
        * gst/avi/gstavimux.c: (gst_avi_mux_pad_reset):
        Do not leave fourcc stream header field empty upon reset.
        Fixes #519301.
index 2b0ea03..85bfcaf 100644 (file)
@@ -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 */