summaryrefslogtreecommitdiffstats
path: root/find_sub.c
diff options
context:
space:
mode:
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;