summaryrefslogtreecommitdiffstats
path: root/find_sub.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-05 00:15:56 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-05 00:15:56 +0000
commit05802842c9d8f1d3ff5296c1d5962f24f3ee5807 (patch)
tree263932e3e624a328606900e604597ab4d6c24977 /find_sub.c
parent1d94bbed7dc5ddb213c2e12c551051ebe6742813 (diff)
downloadmpv-05802842c9d8f1d3ff5296c1d5962f24f3ee5807.tar.bz2
mpv-05802842c9d8f1d3ff5296c1d5962f24f3ee5807.tar.xz
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@osk.mine.nu) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8366 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'find_sub.c')
-rw-r--r--find_sub.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/find_sub.c b/find_sub.c
index 2682b99c8c..6ee327cf48 100644
--- a/find_sub.c
+++ b/find_sub.c
@@ -18,6 +18,35 @@ static int current_sub=0;
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;