mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
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.
This commit is contained in:
parent
9ebb11bebf
commit
10f7a99f1a
2 changed files with 20 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
|||
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):
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue