changeset 27807:3ac3d3a51934

Factorize vobsub idx/extradata handling.
author aurel
date Mon, 27 Oct 2008 22:51:22 +0000
parents 26c27a80b8af
children 2988c38b6620
files libmpdemux/demux_mkv.c libmpdemux/stheader.h mencoder.c mplayer.c spudec.c spudec.h vobsub.c vobsub.h
diffstat 8 files changed, 81 insertions(+), 420 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Mon Oct 27 22:44:09 2008 +0000
+++ b/libmpdemux/demux_mkv.c	Mon Oct 27 22:51:22 2008 +0000
@@ -255,123 +255,6 @@
     return 11;
 }
 
-
-static int
-vobsub_parse_size (sh_sub_t *sh, const char *start)
-{
-  if (sscanf(&start[6], "%dx%d", &sh->width, &sh->height) == 2)
-    {
-      mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub size: %ux%u\n",
-             sh->width, sh->height);
-      return 1;
-    }
-  return 0;
-}
-
-static int
-vobsub_parse_palette (sh_sub_t *sh, const char *start)
-{
-  int i;
-
-  start += 8;
-  while (isspace(*start))
-    start++;
-  for (i = 0; i < 16; i++)
-    {
-      unsigned int tmp;
-      if (sscanf(start, "%06x", &tmp) != 1)
-        break;
-      sh->palette[i] = vobsub_palette_to_yuv(tmp);
-      start += 6;
-      while ((*start == ',') || isspace(*start))
-        start++;
-    }
-  if (i == 16)
-    {
-      mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub palette: %06x,%06x,"
-             "%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,"
-             "%06x,%06x,%06x\n", sh->palette[0],
-             sh->palette[1], sh->palette[2],
-             sh->palette[3], sh->palette[4],
-             sh->palette[5], sh->palette[6],
-             sh->palette[7], sh->palette[8],
-             sh->palette[9], sh->palette[10],
-             sh->palette[11], sh->palette[12],
-             sh->palette[13], sh->palette[14],
-             sh->palette[15]);
-      sh->has_palette = 1;
-      return 2;
-    }
-  return 0;
-}
-
-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;
-  while (isspace(*start))
-    start++;
-   if (!strncasecmp(start, "ON", 2) || (*start == '1'))
-     use_custom_colors = 1;
-   else if (!strncasecmp(start, "OFF", 3) || (*start == '0'))
-     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;
-       while (isspace(*start))
-         start++;
-       for (i = 0; i < 4; i++)
-         {
-           unsigned int tmp;
-           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++;
-         }
-       if (i == 4)
-         {
-           sh->custom_colors = 4;
-           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]);
-         }
-     }
-   if (!use_custom_colors)
-     sh->custom_colors = 0;
-   return 4;
-}
-
-static int
-vobsub_parse_forced_subs (sh_sub_t *sh, const char *start)
-{
-  start += 12;
-  while (isspace(*start))
-    start++;
-  if (!strncasecmp(start, "on", 2) || (*start == '1'))
-    sh->forced_subs_only = 1;
-  else if (!strncasecmp(start, "off", 3) || (*start == '0'))
-    sh->forced_subs_only = 0;
-  else
-    return 0;
-  mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub forced subs: %d\n",
-         sh->forced_subs_only);
-  return 8;
-}
-
 /** \brief Free cached demux packets
  *
  * Reordering the timecodes requires caching of demux packets. This function
@@ -401,63 +284,6 @@
 }
 
 static int
-demux_mkv_parse_idx (mkv_track_t *t)
-{
-  int things_found, last;
-  char *buf, *pos, *start;
-
-  if ((t->private_data == NULL) || (t->private_size == 0))
-    return 0;
-
-  things_found = 0;
-  buf = malloc(t->private_size + 1);
-  if (buf == NULL)
-    return 0;
-  memcpy(buf, t->private_data, t->private_size);
-  buf[t->private_size] = 0;
-  t->sh_sub->has_palette = 0;
-
-  pos = buf;
-  start = buf;
-  last = 0;
-  do
-    {
-      if ((*pos == 0) || (*pos == '\r') || (*pos == '\n'))
-        {
-          if (*pos == 0)
-            last = 1;
-          *pos = 0;
-
-          if (!strncasecmp(start, "size: ", 6))
-            things_found |= vobsub_parse_size(t->sh_sub, start);
-          else if (!strncasecmp(start, "palette:", 8))
-            things_found |= vobsub_parse_palette(t->sh_sub, start);
-          else if (!strncasecmp(start, "custom colors:", 14))
-            things_found |= vobsub_parse_custom_colors(t->sh_sub, start);
-          else if (!strncasecmp(start, "forced subs:", 12))
-            things_found |= vobsub_parse_forced_subs(t->sh_sub, start);
-
-          if (last)
-            break;
-          do
-            {
-              pos++;
-            }
-          while ((*pos == '\r') || (*pos == '\n'));
-          start = pos;
-        }
-      else
-        pos++;
-    }
-  while (!last && (*start != 0));
-
-  free(buf);
-
-  return (things_found & 3) == 3;
-}
-
-
-static int
 demux_mkv_decode (mkv_track_t *track, uint8_t *src, uint8_t **dest,
                   uint32_t *size, uint32_t type)
 {
@@ -2159,38 +1985,6 @@
   return 0;
 }
 
-/** \brief Parse the private data for VobSub subtitle tracks.
-
-  This function tries to parse the private data for all VobSub tracks.
-  The private data contains the normal text from the original .idx file.
-  Things like the palette, subtitle dimensions and custom colors are
-  stored here.
-
-  \param demuxer The generic demuxer.
-*/
-static void
-demux_mkv_parse_vobsub_data (demuxer_t *demuxer)
-{
-  mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
-  mkv_track_t *track;
-  int i;
-
-  for (i = 0; i < mkv_d->num_tracks; i++)
-    {
-      track = mkv_d->tracks[i];
-      if ((track->type != MATROSKA_TRACK_SUBTITLE) ||
-          (track->subtitle_type != MATROSKA_SUBTYPE_VOBSUB))
-        continue;
-
-      if (!demux_mkv_parse_idx (track))
-        {
-          free (track->private_data);
-          track->private_data = NULL;
-          track->private_size = 0;
-        }
-    }
-}
-
 static int
 demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid)
 {
@@ -2427,8 +2221,6 @@
         }
     }
 
-  demux_mkv_parse_vobsub_data (demuxer);
-
   if (demuxer->chapters)
     {
       for (i=0; i < (int)demuxer->num_chapters; i++)
--- a/libmpdemux/stheader.h	Mon Oct 27 22:44:09 2008 +0000
+++ b/libmpdemux/stheader.h	Mon Oct 27 22:51:22 2008 +0000
@@ -97,12 +97,6 @@
 typedef struct {
   int sid;
   char type;                    // t = text, v = VobSub, a = SSA/ASS
-  int has_palette;              // If we have a valid palette
-  unsigned int palette[16];     // for VobSubs
-  int width, height;            // for VobSubs
-  int custom_colors;
-  unsigned int colors[4];
-  int forced_subs_only;
   unsigned char* extradata; // extra header data passed from demuxer
   int extradata_len;
 #ifdef CONFIG_ASS
--- a/mencoder.c	Mon Oct 27 22:44:09 2008 +0000
+++ b/mencoder.c	Mon Oct 27 22:51:22 2008 +0000
@@ -738,19 +738,16 @@
 if (spudec_ifo) {
   unsigned int palette[16], width, height;
   if (vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0)
-    vo_spudec=spudec_new_scaled(palette, sh_video->disp_w, sh_video->disp_h);
+    vo_spudec=spudec_new_scaled(palette, sh_video->disp_w, sh_video->disp_h, NULL, 0);
 }
 #ifdef CONFIG_DVDREAD
 if (vo_spudec==NULL) {
 vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL,
-			    sh_video->disp_w, sh_video->disp_h);
+                           sh_video->disp_w, sh_video->disp_h, NULL, 0);
 }
 #endif
 }
 
-// Apply current settings for forced subs
-spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
-
 ostream = open_output_stream(out_filename, 0);
 if(!ostream) {
   mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CannotOpenOutputFile, out_filename);
--- a/mplayer.c	Mon Oct 27 22:44:09 2008 +0000
+++ b/mplayer.c	Mon Oct 27 22:51:22 2008 +0000
@@ -1088,14 +1088,15 @@
     unsigned int palette[16], width, height;
     current_module="spudec_init_vobsub";
     if (vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0)
-      vo_spudec=spudec_new_scaled(palette, width, height);
+      vo_spudec=spudec_new_scaled(palette, width, height, NULL, 0);
   }
 
 #ifdef CONFIG_DVDREAD
   if (vo_spudec==NULL && mpctx->stream->type==STREAMTYPE_DVD) {
     current_module="spudec_init_dvdread";
     vo_spudec=spudec_new_scaled(((dvd_priv_t *)(mpctx->stream->priv))->cur_pgc->palette,
-                                mpctx->sh_video->disp_w, mpctx->sh_video->disp_h);
+                                mpctx->sh_video->disp_w, mpctx->sh_video->disp_h,
+                                NULL, 0);
   }
 #endif
 
@@ -1103,34 +1104,14 @@
   if (vo_spudec==NULL && mpctx->stream->type==STREAMTYPE_DVDNAV) {
     unsigned int *palette = mp_dvdnav_get_spu_clut(mpctx->stream);
     current_module="spudec_init_dvdnav";
-    vo_spudec=spudec_new_scaled(palette, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h);
+    vo_spudec=spudec_new_scaled(palette, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h, NULL, 0);
   }
 #endif
 
-  if ((vo_spudec == NULL) && (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA) &&
-      (mpctx->d_sub->sh != NULL) && (((sh_sub_t *)mpctx->d_sub->sh)->type == 'v')) {
-    sh_sub_t *mkv_sh_sub = (sh_sub_t *)mpctx->d_sub->sh;
-    current_module = "spudec_init_matroska";
-    vo_spudec =
-      spudec_new_scaled_vobsub(mkv_sh_sub->palette, mkv_sh_sub->colors,
-                             mkv_sh_sub->custom_colors, mkv_sh_sub->width,
-                               mkv_sh_sub->height);
-    forced_subs_only = mkv_sh_sub->forced_subs_only;
-  }
-
   if (vo_spudec==NULL) {
     sh_sub_t *sh = (sh_sub_t *)mpctx->d_sub->sh;
-    unsigned int *palette = NULL;
-    if (sh && !sh->has_palette && sh->extradata_len == 16*4) {
-      int i;
-      for (i = 0; i < 16; i++)
-        sh->palette[i] = AV_RB32(sh->extradata + i*4);
-      sh->has_palette = 1;
-    }
-    if (sh && sh->has_palette)
-      palette = sh->palette;
     current_module="spudec_init_normal";
-    vo_spudec=spudec_new_scaled(palette, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h);
+    vo_spudec=spudec_new_scaled(NULL, mpctx->sh_video->disp_w, mpctx->sh_video->disp_h, sh->extradata, sh->extradata_len);
     spudec_set_font_factor(vo_spudec,font_factor);
   }
 
@@ -3112,8 +3093,6 @@
     if(vo_vobsub){
       initialized_flags|=INITIALIZED_VOBSUB;
       vobsub_set_from_lang(vo_vobsub, dvdsub_lang);
-      // check if vobsub requested only to display forced subtitles
-      forced_subs_only=vobsub_get_forced_subs_flag(vo_vobsub);
 
       // setup global sub numbering
       mpctx->global_sub_indices[SUB_SOURCE_VOBSUB] = mpctx->global_sub_size; // the global # of the first vobsub.
@@ -3437,10 +3416,6 @@
   init_vo_spudec();
 }
 
-// Apply current settings for forced subs
-if (vo_spudec!=NULL)
-  spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
-
 if(mpctx->sh_video) {
 // after reading video params we should load subtitles because
 // we know fps so now we can adjust subtitle time to ~6 seconds AST
--- a/spudec.c	Mon Oct 27 22:44:09 2008 +0000
+++ b/spudec.c	Mon Oct 27 22:51:22 2008 +0000
@@ -23,7 +23,9 @@
 #include <math.h>
 #include "libvo/video_out.h"
 #include "spudec.h"
+#include "vobsub.h"
 #include "libavutil/avutil.h"
+#include "libavutil/intreadwrite.h"
 #include "libswscale/swscale.h"
 
 /* Valid values for spu_aamode:
@@ -1114,39 +1116,73 @@
   spu->font_start_level = (int)(0xF0-(0xE0*factor));
 }
 
-void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height)
+static void spudec_parse_extradata(spudec_handle_t *this,
+                                   uint8_t *extradata, int extradata_len)
 {
-  return spudec_new_scaled_vobsub(palette, NULL, 0, frame_width, frame_height);
+  uint8_t *buffer, *ptr;
+  unsigned int *pal = this->global_palette, *cuspal = this->cuspal;
+  unsigned int tridx;
+  int i;
+
+  if (extradata_len == 16*4) {
+    for (i=0; i<16; i++)
+      pal[i] = AV_RB32(extradata + i*4);
+    this->auto_palette = 0;
+    return;
+  }
+
+  if (!(ptr = buffer = malloc(extradata_len+1)))
+    return;
+  memcpy(buffer, extradata, extradata_len);
+  buffer[extradata_len] = 0;
+
+  do {
+    sscanf(ptr, "size: %dx%d", &this->orig_frame_width, &this->orig_frame_height);
+    if (sscanf(ptr, "palette: %x, %x, %x, %x, %x, %x, %x, %x,"
+                            " %x, %x, %x, %x, %x, %x, %x, %x",
+               &pal[ 0], &pal[ 1], &pal[ 2], &pal[ 3],
+               &pal[ 4], &pal[ 5], &pal[ 6], &pal[ 7],
+               &pal[ 8], &pal[ 9], &pal[10], &pal[11],
+               &pal[12], &pal[13], &pal[14], &pal[15]) == 16) {
+      for (i=0; i<16; i++)
+        pal[i] = vobsub_palette_to_yuv(pal[i]);
+      this->auto_palette = 0;
+    }
+    if (!strncasecmp(ptr, "forced subs: on", 15))
+      this->forced_subs_only = 1;
+    if (sscanf(ptr, "custom colors: ON, tridx: %x, colors: %x, %x, %x, %x",
+               &tridx, cuspal+0, cuspal+1, cuspal+2, cuspal+3) == 5) {
+      for (i=0; i<4; i++) {
+        cuspal[i] = vobsub_rgb_to_yuv(cuspal[i]);
+        if (tridx & (1 << (12-4*i)))
+          cuspal[i] |= 1 << 31;
+      }
+      this->custom = 1;
+    }
+  } while ((ptr=strchr(ptr,'\n')) && *++ptr);
+
+  free(buffer);
 }
 
-/* get palette custom color, width, height from .idx file */
-void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsigned int custom, unsigned int frame_width, unsigned int frame_height)
+void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len)
 {
   spudec_handle_t *this = calloc(1, sizeof(spudec_handle_t));
   if (this){
-    //(fprintf(stderr,"VobSub Custom Palette: %d,%d,%d,%d", this->cuspal[0], this->cuspal[1], this->cuspal[2],this->cuspal[3]);
-    this->packet = NULL;
-    this->image = NULL;
-    this->scaled_image = NULL;
+    this->orig_frame_height = frame_height;
+    // set up palette:
+    if (palette)
+      memcpy(this->global_palette, palette, sizeof(this->global_palette));
+    else
+      this->auto_palette = 1;
+    if (extradata)
+      spudec_parse_extradata(this, extradata, extradata_len);
     /* XXX Although the video frame is some size, the SPU frame is
        always maximum size i.e. 720 wide and 576 or 480 high */
     this->orig_frame_width = 720;
-    this->orig_frame_height = (frame_height == 480 || frame_height == 240) ? 480 : 576;
-    this->custom = custom;
-    // set up palette:
-    this->auto_palette = 1;
-    if (palette){
-      memcpy(this->global_palette, palette, sizeof(this->global_palette));
-      this->auto_palette = 0;
-    }
-    this->custom = custom;
-    if (custom && cuspal) {
-      memcpy(this->cuspal, cuspal, sizeof(this->cuspal));
-      this->auto_palette = 0;
-    }
-    // forced subtitles default: show all subtitles
-    this->forced_subs_only=0;
-    this->is_forced_sub=0;
+    if (this->orig_frame_height == 480 || this->orig_frame_height == 240)
+      this->orig_frame_height = 480;
+    else
+      this->orig_frame_height = 576;
   }
   else
     mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc");
@@ -1155,7 +1191,7 @@
 
 void *spudec_new(unsigned int *palette)
 {
-    return spudec_new_scaled(palette, 0, 0);
+    return spudec_new_scaled(palette, 0, 0, NULL, 0);
 }
 
 void spudec_free(void *this)
--- a/spudec.h	Mon Oct 27 22:44:09 2008 +0000
+++ b/spudec.h	Mon Oct 27 22:51:22 2008 +0000
@@ -8,8 +8,7 @@
 void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
 void spudec_draw_scaled(void *this, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
 void spudec_update_palette(void *this, unsigned int *palette);
-void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height);
-void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsigned int custom, unsigned int frame_width, unsigned int frame_height);
+void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height, uint8_t *extradata, int extradata_len);
 void *spudec_new(unsigned int *palette);
 void spudec_free(void *this);
 void spudec_reset(void *this);	// called after seek
--- a/vobsub.c	Mon Oct 27 22:44:09 2008 +0000
+++ b/vobsub.c	Mon Oct 27 22:51:22 2008 +0000
@@ -595,14 +595,13 @@
  **********************************************************************/
 
 typedef struct {
+    unsigned char *extradata;
+    unsigned int extradata_len;
     unsigned int palette[16];
-    unsigned int cuspal[4];
     int delay;
-    unsigned int custom;
     unsigned int have_palette;
     unsigned int orig_frame_width, orig_frame_height;
     unsigned int origin_x, origin_y;
-    unsigned int forced_subs;
     /* index */
     packet_queue_t *spu_streams;
     unsigned int spu_streams_size;
@@ -767,23 +766,6 @@
 }
 
 static int
-vobsub_parse_size(vobsub_t *vob, const char *line)
-{
-    // size: WWWxHHH
-    char *p;
-    while (isspace(*line))
-	++line;
-    if (!isdigit(*line))
-	return -1;
-    vob->orig_frame_width = strtoul(line, &p, 10);
-    if (*p != 'x')
-	return -1;
-    ++p;
-    vob->orig_frame_height = strtoul(p, NULL, 10);
-    return 0;
-}
-
-static int
 vobsub_parse_origin(vobsub_t *vob, const char *line)
 {
     // org: X,Y
@@ -828,86 +810,6 @@
 }
 
 static int
-vobsub_parse_palette(vobsub_t *vob, const char *line)
-{
-    // palette: XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX
-    unsigned int n;
-    n = 0;
-    while (1) {
-	const char *p;
-	int tmp;
-	while (isspace(*line))
-	    ++line;
-	p = line;
-	while (isxdigit(*p))
-	    ++p;
-	if (p - line != 6)
-	    return -1;
-	tmp = strtoul(line, NULL, 16);
-	vob->palette[n++] = vobsub_palette_to_yuv(tmp);
-	if (n == 16)
-	    break;
-	if (*p == ',')
-	    ++p;
-	line = p;
-    }
-    vob->have_palette = 1;
-    return 0;
-}
-
-static int
-vobsub_parse_custom(vobsub_t *vob, const char *line)
-{
-    //custom colors: OFF/ON(0/1)
-    if ((strncmp("ON", line + 15, 2) == 0)||strncmp("1", line + 15, 1) == 0)
-        vob->custom=1;
-    else if ((strncmp("OFF", line + 15, 3) == 0)||strncmp("0", line + 15, 1) == 0)
-        vob->custom=0;
-    else
-        return -1;
-    return 0;
-}
-
-static int
-vobsub_parse_cuspal(vobsub_t *vob, const char *line)
-{
-    //colors: XXXXXX, XXXXXX, XXXXXX, XXXXXX
-    unsigned int n, tmp;
-    n = 0;
-    line += 40;
-    while(1){
-    	const char *p;
-	while (isspace(*line))
-	    ++line;
-	p=line;
-	while (isxdigit(*p))
-	    ++p;
-	if (p - line !=6)
-	    return -1;
-	tmp = strtoul(line, NULL, 16);
-	vob->cuspal[n++] |= vobsub_rgb_to_yuv(tmp);
-	if (n==4)
-	    break;
-	if(*p == ',')
-	    ++p;
-	line = p;
-    }
-    return 0;
-}
-
-static int
-vobsub_parse_tridx(vobsub_t *vob, const char *line)
-{
-    //tridx: XXXX
-    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;
-}
-
-static int
 vobsub_parse_delay(vobsub_t *vob, const char *line)
 {
     int h, m, s, ms;
@@ -942,26 +844,6 @@
 }
 
 static int
-vobsub_parse_forced_subs(vobsub_t *vob, const char *line)
-{
-    const char *p;
-
-    p  = line;
-    while (isspace(*p))
-	++p;
-
-    if (strncasecmp("on",p,2) == 0){
-	    vob->forced_subs=~0;
-	    return 0;
-    } else if (strncasecmp("off",p,3) == 0){
-	    vob->forced_subs=0;
-	    return 0;
-    }
-	
-    return -1;
-}
-
-static int
 vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd)
 {
     ssize_t line_size;
@@ -973,6 +855,12 @@
 	if (line_size < 0) {
 	    break;
 	}
+
+	vob->extradata = realloc(vob->extradata, vob->extradata_len+line_size+1);
+	memcpy(vob->extradata+vob->extradata_len, line, line_size);
+	vob->extradata_len += line_size;
+	vob->extradata[vob->extradata_len] = 0;
+
 	if (*line == 0 || *line == '\r' || *line == '\n' || *line == '#')
 	    continue;
 	else if (strncmp("langidx:", line, 8) == 0)
@@ -981,19 +869,10 @@
 	    res = vobsub_parse_delay(vob, line);
 	else if (strncmp("id:", line, 3) == 0)
 	    res = vobsub_parse_id(vob, line + 3);
-	else if (strncmp("palette:", line, 8) == 0)
-	    res = vobsub_parse_palette(vob, line + 8);
-	else if (strncmp("size:", line, 5) == 0)
-	    res = vobsub_parse_size(vob, line + 5);
 	else if (strncmp("org:", line, 4) == 0)
 	    res = vobsub_parse_origin(vob, line + 4);
 	else if (strncmp("timestamp:", line, 10) == 0)
 	    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(vob, line) + vobsub_parse_custom(vob, line);
-	else if (strncmp("forced subs:", line, 12) == 0)
-		res = vobsub_parse_forced_subs(vob, line + 12);
 	else {
 	    mp_msg(MSGT_VOBSUB,MSGL_V, "vobsub: ignoring %s", line);
 	    continue;
@@ -1115,11 +994,10 @@
 		    /* NOOP */ ;
 		rar_close(fd);
 	    }
-	    /* if no palette in .idx then use custom colors */
-	    if ((vob->custom == 0)&&(vob->have_palette!=1))
-		vob->custom = 1;
-	    if (spu && vob->orig_frame_width && vob->orig_frame_height)
-	      *spu = spudec_new_scaled_vobsub(vob->palette, vob->cuspal, vob->custom, vob->orig_frame_width, vob->orig_frame_height);
+	    if (spu)
+	      *spu = spudec_new_scaled(vob->palette, vob->orig_frame_width, vob->orig_frame_height, vob->extradata, vob->extradata_len);
+	    if (vob->extradata)
+	      free(vob->extradata);
 
 	    /* read the indexed mpeg_stream */
 	    strcpy(buf, name);
@@ -1252,15 +1130,6 @@
     return j;
 }
 
-unsigned int 
-vobsub_get_forced_subs_flag(void const * const vobhandle)
-{
-  if (vobhandle)
-    return ((vobsub_t*) vobhandle)->forced_subs;
-  else
-    return 0;
-}
-
 int
 vobsub_set_from_lang(void *vobhandle, unsigned char * lang)
 {
--- a/vobsub.h	Mon Oct 27 22:44:09 2008 +0000
+++ b/vobsub.h	Mon Oct 27 22:51:22 2008 +0000
@@ -24,7 +24,6 @@
 extern void vobsub_out_output(void *me, const unsigned char *packet, int len, double pts);
 extern void vobsub_out_close(void *me);
 extern int vobsub_set_from_lang(void *vobhandle, unsigned char * lang);
-extern unsigned int vobsub_get_forced_subs_flag(void const * const vobhandle);
 extern void vobsub_seek(void * vobhandle, float pts);
 
 #endif /* MPLAYER_VOBSUB_H */