[Mplayer-cvslog] CVS: main cfg-mplayer.h,1.204,1.205 mplayer.c,1.726,1.727vobsub.c,1.32,1.33vobsub.h,1.9,1.10

Attila Kinali CVS attila at mplayerhq.hu
Sun Sep 21 16:22:12 CEST 2003


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv22584

Modified Files:
	cfg-mplayer.h mplayer.c spudec.c spudec.h vobsub.c vobsub.h 
Log Message:
Forced subtitles patch by Arne Driescher <driescher at mpi-magdeburg.mpg.de>

 For a given subtitle language you can now chose to display
  only the forced subtitles. Defaut is set to "show all subtitles"
  so that current mplayer behaviour is not changed.

For DVD:
  Use -forced_subs_only additionally to e.g. -slang en
  if you are only interested in the forced subtitles.

For VobSub:
  The idx file is now parsed for the "forced subs: ON/OFF" tag
   and used according to its settings.

Key:
  You can toggle the display of forced subtitles by pressing
   "F"  (upper case letter).



Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -r1.204 -r1.205
--- cfg-mplayer.h	17 Sep 2003 09:14:49 -0000	1.204
+++ cfg-mplayer.h	21 Sep 2003 14:21:10 -0000	1.205
@@ -347,6 +347,7 @@
 	// these should be moved to -common, and suppot in mencoder too
 	{"vobsub", &vobsub_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"vobsubid", &vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
+        {"forcedsubsonly", &forced_subs_only,CONF_TYPE_FLAG, 0, 0, 1, NULL},
 
 	{"sstep", &step_sec, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
 

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.726
retrieving revision 1.727
diff -u -r1.726 -r1.727
--- mplayer.c	19 Sep 2003 20:44:03 -0000	1.726
+++ mplayer.c	21 Sep 2003 14:21:11 -0000	1.727
@@ -243,6 +243,7 @@
 char* dvdsub_lang=NULL;
 static char* spudec_ifo=NULL;
 char* filename=NULL; //"MI2-Trailer.avi";
+int forced_subs_only=0;
 
 // cache2:
        int stream_cache_size=-1;
@@ -1256,6 +1257,8 @@
       sub_auto=0; // don't do autosub for textsubs if vobsub found
       inited_flags|=INITED_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);
     }
 
 //============ Open & Sync STREAM --- fork cache2 ====================
@@ -1597,6 +1600,10 @@
 
 }
 
+// Apply current settings for forced subs
+if (vo_spudec!=NULL)
+  spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
+
 #ifdef USE_SUB
 if(sh_video) {
 // after reading video params we should load subtitles because
@@ -3063,6 +3070,12 @@
     }
 #endif
         break;
+    case MP_CMD_SUB_FORCED_ONLY:
+      if (vo_spudec) {
+	forced_subs_only = forced_subs_only ? 0 : ~0; // toggle state
+	spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
+      }    
+      break;
     case MP_CMD_SCREENSHOT :
       if(vo_config_count) video_out->control(VOCTRL_SCREENSHOT, NULL);
       break;

Index: spudec.c
===================================================================
RCS file: /cvsroot/mplayer/main/spudec.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- spudec.c	23 Feb 2003 22:05:35 -0000	1.41
+++ spudec.c	21 Sep 2003 14:21:11 -0000	1.42
@@ -89,6 +89,8 @@
   int font_start_level;  /* Darkest value used for the computed font */
   vo_functions_t *hw_spu;
   int spu_changed;
+  unsigned int forced_subs_only;     /* flag: 0=display all subtitle, !0 display only forced subtitles */
+  unsigned int is_forced_sub;         /* true if current subtitle is a forced subtitle */
 } spudec_handle_t;
 
 static void spudec_queue_packet(spudec_handle_t *this, packet_t *packet)
@@ -371,8 +373,10 @@
 	/* Menu ID, 1 byte */
 	mp_msg(MSGT_SPUDEC,MSGL_DBG2,"Menu ID\n");
         /* shouldn't a Menu ID type force display start? */
-	//this->start_pts = pts100 + date;
-	//this->end_pts = UINT_MAX;
+	start_pts = pts100 + date;
+	end_pts = UINT_MAX;
+	display = 1;
+	this->is_forced_sub=~0; // current subtitle is forced
 	break;
       case 0x01:
 	/* Start display */
@@ -380,6 +384,7 @@
 	start_pts = pts100 + date;
 	end_pts = UINT_MAX;
 	display = 1;
+	this->is_forced_sub=0;
 	break;
       case 0x02:
 	/* Stop display */
@@ -604,6 +609,14 @@
     return ret;
 }
 
+void spudec_set_forced_subs_only(void * const this, const unsigned int flag)
+{
+  if(this){
+      ((spudec_handle_t *)this)->forced_subs_only=flag;
+      mp_msg(MSGT_SPUDEC,MSGL_DBG2,"SPU: Display only forced subs now %s\n", flag ? "enabled": "disabled");
+  }
+}
+
 void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))
 {
     spudec_handle_t *spu = (spudec_handle_t *)this;
@@ -752,7 +765,14 @@
   spudec_handle_t *spu = (spudec_handle_t *)me;
   scale_pixel *table_x;
   scale_pixel *table_y;
+
   if (spu->start_pts <= spu->now_pts && spu->now_pts < spu->end_pts) {
+
+    // check if only forced subtitles are requested 
+    if( (spu->forced_subs_only) && !(spu->is_forced_sub) ){ 
+	return;
+    }
+
     if (!(spu_aamode&16) && (spu->orig_frame_width == 0 || spu->orig_frame_height == 0
 	|| (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) {
       if (spu->image)
@@ -1125,6 +1145,9 @@
       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;
   }
   else
     mp_msg(MSGT_SPUDEC,MSGL_FATAL, "FATAL: spudec_init: calloc");

Index: spudec.h
===================================================================
RCS file: /cvsroot/mplayer/main/spudec.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- spudec.h	28 Feb 2003 19:21:45 -0000	1.15
+++ spudec.h	21 Sep 2003 14:21:11 -0000	1.16
@@ -19,5 +19,6 @@
 int spudec_changed(void *this);
 void spudec_calc_bbox(void *me, unsigned int dxs, unsigned int dys, unsigned int* bbox);
 void spudec_draw_scaled(void *me, 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_set_forced_subs_only(void * const this, const unsigned int flag);
 #endif
 

Index: vobsub.c
===================================================================
RCS file: /cvsroot/mplayer/main/vobsub.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- vobsub.c	20 Sep 2003 19:41:24 -0000	1.32
+++ vobsub.c	21 Sep 2003 14:21:11 -0000	1.33
@@ -576,6 +576,7 @@
     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;
@@ -888,6 +889,26 @@
 }
 
 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;
@@ -920,6 +941,8 @@
 	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);
+	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;
@@ -1017,6 +1040,7 @@
 	vob->spu_streams_size = 0;
 	vob->spu_streams_current = 0;
 	vob->delay = 0;
+	vob->forced_subs=0;
 	buf = malloc((strlen(name) + 5) * sizeof(char));
 	if (buf) {
 	    rar_stream_t *fd;
@@ -1149,6 +1173,15 @@
     return (index < vob->spu_streams_size) ? vob->spu_streams[index].id : NULL;
 }
 
+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)
 {
@@ -1256,6 +1289,9 @@
 	}
 	putc('\n', me->fidx);
     }
+
+    fprintf(me->fidx,"# ON: displays only forced subtitles, OFF: shows everything\n"
+	    "forced subs: OFF\n");
 }
 
 void *

Index: vobsub.h
===================================================================
RCS file: /cvsroot/mplayer/main/vobsub.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- vobsub.h	23 Dec 2002 01:54:58 -0000	1.9
+++ vobsub.h	21 Sep 2003 14:21:11 -0000	1.10
@@ -14,5 +14,7 @@
 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);
+
 #endif /* MPLAYER_VOBSUB_H */
 



More information about the MPlayer-cvslog mailing list