diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 2f9424c9d8..e7307156ca 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -344,6 +344,8 @@ static int 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 @@ vobsub_parse_custom_colors (sh_sub_t *sh, const char *start) 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 @@ vobsub_parse_custom_colors (sh_sub_t *sh, const char *start) 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 @@ vobsub_parse_custom_colors (sh_sub_t *sh, const char *start) 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]); } diff --git a/spudec.c b/spudec.c index a8d6a50730..ce579cccda 100644 --- a/spudec.c +++ b/spudec.c @@ -231,6 +231,8 @@ static void spudec_process_data(spudec_handle_t *this, packet_t *packet) 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){ diff --git a/vobsub.c b/vobsub.c index d1121d3e1f..754cfc0feb 100644 --- a/vobsub.c +++ b/vobsub.c @@ -912,7 +912,7 @@ vobsub_parse_cuspal(vobsub_t *vob, const char *line) 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 @@ vobsub_parse_cuspal(vobsub_t *vob, const char *line) 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 @@ vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd) 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 {