changeset 25432:7957b8762195

Vobsub support tridx setting in .idx file.
author ulion
date Wed, 19 Dec 2007 08:35:40 +0000
parents 40bda123d2e7
children 55e3b1a32c65
files libmpdemux/demux_mkv.c spudec.c vobsub.c
diffstat 3 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Wed Dec 19 04:45:45 2007 +0000
+++ b/libmpdemux/demux_mkv.c	Wed Dec 19 08:35:40 2007 +0000
@@ -344,6 +344,8 @@
 vobsub_parse_custom_colors (sh_sub_t *sh, const char *start)
 {
   int use_custom_colors, i;
+  const char *p;
+  unsigned int tridx = 0;
 
   use_custom_colors = 0;
   start += 14;
@@ -355,6 +357,8 @@
      use_custom_colors = 0;
    mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub custom colors: %s\n",
           use_custom_colors ? "ON" : "OFF");
+   if ((p = strstr(start, "tridx:")) != NULL)
+     tridx = strtoul(p + 6, NULL, 2);
    if ((start = strstr(start, "colors:")) != NULL)
      {
        start += 7;
@@ -366,6 +370,8 @@
            if (sscanf(start, "%06x", &tmp) != 1)
              break;
            sh->colors[i] = vobsub_rgb_to_yuv(tmp);
+           if ((tridx << i) & 0x08)
+             sh->colors[i] |= 1 << 31;
            start += 6;
            while ((*start == ',') || isspace(*start))
              start++;
@@ -373,8 +379,8 @@
        if (i == 4)
          {
            sh->custom_colors = 4;
-           mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub colors: %06x,"
-                  "%06x,%06x,%06x\n", sh->colors[0],
+           mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub colors: %08x,"
+                  "%08x,%08x,%08x\n", sh->colors[0],
                   sh->colors[1], sh->colors[2],
                   sh->colors[3]);
          }
--- a/spudec.c	Wed Dec 19 04:45:45 2007 +0000
+++ b/spudec.c	Wed Dec 19 08:35:40 2007 +0000
@@ -231,6 +231,8 @@
   this->stride = packet->stride;
   for (i = 0; i < 4; ++i) {
     alpha[i] = mkalpha(packet->alpha[i]);
+    if (this->custom && (this->cuspal[i] >> 31) != 0)
+      alpha[i] = 0;
     if (alpha[i] == 0)
       cmap[i] = 0;
     else if (this->custom){
--- a/vobsub.c	Wed Dec 19 04:45:45 2007 +0000
+++ b/vobsub.c	Wed Dec 19 08:35:40 2007 +0000
@@ -912,7 +912,7 @@
 	if (p - line !=6)
 	    return -1;
 	tmp = strtoul(line, NULL, 16);
-	vob->cuspal[n++] = vobsub_rgb_to_yuv(tmp);
+	vob->cuspal[n++] |= vobsub_rgb_to_yuv(tmp);
 	if (n==4)
 	    break;
 	if(*p == ',')
@@ -922,14 +922,15 @@
     return 0;
 }
 
-/* don't know how to use tridx */
 static int
-vobsub_parse_tridx(const char *line)
+vobsub_parse_tridx(vobsub_t *vob, const char *line)
 {
     //tridx: XXXX
-    int tridx;
-    tridx = strtoul((line + 26), NULL, 16);
-    tridx = ((tridx&0x1000)>>12) | ((tridx&0x100)>>7) | ((tridx&0x10)>>2) | ((tridx&1)<<3);
+    int tridx, i;
+    tridx = strtoul((line + 26), NULL, 2);
+    for (i = 0; i < 4; ++i)
+        if ((tridx << i) & 0x08)
+            vob->cuspal[i] |= 1 << 31;
     return tridx;
 }
 
@@ -1017,7 +1018,7 @@
 	    res = vobsub_parse_timestamp(vob, line + 10);
 	else if (strncmp("custom colors:", line, 14) == 0)
 	    //custom colors: ON/OFF, tridx: XXXX, colors: XXXXXX, XXXXXX, XXXXXX,XXXXXX
-	    res = vobsub_parse_cuspal(vob, line) + vobsub_parse_tridx(line) + vobsub_parse_custom(vob, line);
+	    res = vobsub_parse_cuspal(vob, line) + vobsub_parse_tridx(vob, line) + vobsub_parse_custom(vob, line);
 	else if (strncmp("forced subs:", line, 12) == 0)
 		res = vobsub_parse_forced_subs(vob, line + 12);
 	else {