changeset 8206:72647ce8471f

allow max 0.2s overlapping without splitting subs patch by salvatore.falco@katamail.com
author arpi
date Sat, 16 Nov 2002 03:23:49 +0000
parents 5c675b344bfb
children 467ffae428b0
files subreader.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/subreader.c	Sat Nov 16 03:09:50 2002 +0000
+++ b/subreader.c	Sat Nov 16 03:23:49 2002 +0000
@@ -925,6 +925,7 @@
 	subtitle* nextsub;
 	int i = sub_num;
 	unsigned long subfms = (sub_uses_time ? 100 : fps) * subtime;
+	unsigned long overlap = (sub_uses_time ? 100 : fps) / 5; // 0.2s
 	
 	n=m=0;
 	if (i)	for (;;){
@@ -936,6 +937,17 @@
 		}
 		if (!--i) break;
 		nextsub = sub + 1;
+	    if(!block){
+		if ((sub->end > nextsub->start) && (sub->end <= nextsub->start + overlap)) {
+		    // these subtitles overlap for less than 0.2 seconds
+		    // and would result in very short overlapping subtitle
+		    // so let's fix the problem here, before overlapping code
+		    // get its hands on them
+		    unsigned delta = sub->end - nextsub->start, half = delta / 2;
+		    sub->end -= half + 1;
+		    nextsub->start += delta - half;
+		}
+	    }
 	    if (block){
 		if (sub->end >= nextsub->start){
 			sub->end = nextsub->start - 1;