changeset 25249:d0d928c92833

Fix custom palette format from rgb to yuv, we use it as yuv in the spudec.
author ulion
date Mon, 03 Dec 2007 03:20:11 +0000
parents a5c848b27cd8
children 9fd84c723f76
files vobsub.c
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vobsub.c	Sun Dec 02 23:01:01 2007 +0000
+++ b/vobsub.c	Mon Dec 03 03:20:11 2007 +0000
@@ -849,7 +849,8 @@
 vobsub_parse_cuspal(vobsub_t *vob, const char *line)
 {
     //colors: XXXXXX, XXXXXX, XXXXXX, XXXXXX
-    unsigned int n;
+    unsigned int n, tmp;
+    int r, g, b, y, u, v;
     n = 0;
     line += 40;
     while(1){
@@ -861,7 +862,14 @@
 	    ++p;
 	if (p - line !=6)
 	    return -1;
-	vob->cuspal[n++] = strtoul(line, NULL,16);
+	tmp = strtoul(line, NULL, 16);
+	r = tmp >> 16 & 0xff;
+	g = tmp >> 8 & 0xff;
+	b = tmp & 0xff;
+	y = av_clip_uint8( 0.1494  * r + 0.6061 * g + 0.2445 * b);
+	u = av_clip_uint8( 0.6066  * r - 0.4322 * g - 0.1744 * b + 128);
+	v = av_clip_uint8(-0.08435 * r - 0.3422 * g + 0.4266 * b + 128);
+	vob->cuspal[n++] = y << 16 | u << 8 | v;
 	if (n==4)
 	    break;
 	if(*p == ',')