[Mplayer-cvslog] CVS: main find_sub.c,1.8,1.9 mplayer.c,1.622,1.623 subreader.h,1.20,1.21

Arpi of Ize arpi at mplayerhq.hu
Thu Dec 5 01:15:59 CET 2002


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

Modified Files:
	find_sub.c mplayer.c subreader.h 
Log Message:
This patch makes it possible to navigate among the subtitles while
playing movies. It can be very useful when using desynched subtitles.
A new command 'sub_step' is added, which takes an integer argument.
'sub_step +1' will immediately display the next subtitle, adjusting
sub_delay as if one had used the 'sub_delay' command to navigate to
the subtitle. 'sub_step -1' displays the previous subtitle and
adjusts the sub_delay. By using these two commands you can navigate
among the subtitles without having to search blindly using 'sub_delay'.

patch by Oskar Liljeblad (oskar at osk.mine.nu)


Index: find_sub.c
===================================================================
RCS file: /cvsroot/mplayer/main/find_sub.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- find_sub.c	28 Aug 2002 16:09:31 -0000	1.8
+++ find_sub.c	5 Dec 2002 00:15:56 -0000	1.9
@@ -18,6 +18,35 @@
 static int nosub_range_start=-1;
 static int nosub_range_end=-1;
 
+extern float sub_delay;
+
+void step_sub(subtitle *subtitles, float pts, int movement) {
+    int key = sub_uses_time ? (100*(pts+sub_delay)) : ((pts+sub_delay)*sub_fps);
+
+    if (subtitles == NULL)
+    	return;
+
+    /* Tell the OSD subsystem that the OSD contents will change soon */
+    vo_osd_changed(OSDTYPE_SUBTITLE);
+
+    /* If we are moving forward, don't count the next (current) subtitle
+     * if we haven't displayed it yet. Same when moving other direction.
+     */
+    if (movement > 0 && key < subtitles[current_sub].start)
+    	movement--;
+    if (movement < 0 && key >= subtitles[current_sub].end)
+    	movement++;
+
+    /* Never move beyond first or last subtitle. */
+    if (current_sub+movement < 0)
+    	movement = 0-current_sub;
+    if (current_sub+movement >= sub_num)
+    	movement = sub_num-current_sub-1;
+
+    current_sub += movement;
+    sub_delay = subtitles[current_sub].start/(sub_uses_time ? 100 : sub_fps) - pts;
+}
+
 void find_sub(subtitle* subtitles,int key){
     int i,j;
     

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.622
retrieving revision 1.623
diff -u -r1.622 -r1.623
--- mplayer.c	5 Dec 2002 00:11:11 -0000	1.622
+++ mplayer.c	5 Dec 2002 00:15:56 -0000	1.623
@@ -2038,6 +2038,11 @@
 	sub_delay += v;
       osd_show_sub_delay = 9; // show the subdelay in OSD
     } break;
+    case MP_CMD_SUB_STEP : {
+      int movement = cmd->args[0].v.i;
+      step_sub(subtitles, d_video->pts, movement);
+      osd_show_sub_delay = 9; // show the subdelay in OSD
+    } break;
     case MP_CMD_OSD : 
       if(sh_video) {
 	int v = cmd->args[0].v.i;

Index: subreader.h
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- subreader.h	5 Dec 2002 00:03:26 -0000	1.20
+++ subreader.h	5 Dec 2002 00:15:56 -0000	1.21
@@ -45,4 +45,5 @@
 void dump_microdvd(subtitle* subs, float fps);
 void sub_free( subtitle * subs );
 void find_sub(subtitle* subtitles,int key);
+void step_sub(subtitle *subtitles, float pts, int movement);
 #endif




More information about the MPlayer-cvslog mailing list