]> granicus.if.org Git - handbrake/commitdiff
sync: fix a problem with overlapping ssa in mp4
authorjstebbins <jstebbins.hb@gmail.com>
Thu, 4 Dec 2014 20:44:33 +0000 (20:44 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Thu, 4 Dec 2014 20:44:33 +0000 (20:44 +0000)
If an SSA starts before and ends after the subsequent SSA, the subtitles
were improperly merged resulting in timestamp issues.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6584 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/sync.c

index f34300750e3c85581b117126fd244b86b5ecc625..17d0280e8cbf521a8b16b88c9811aa6aef120265 100644 (file)
@@ -368,6 +368,17 @@ static hb_buffer_t * mergeSubtitles(subtitle_sanitizer_t *sanitizer, int end)
                 if (ABS(a->s.start - b->s.start) <= 18000)
                 {
                     // subtitles start within 1/5 second of eachother, merge
+                    if (a->s.stop > b->s.stop)
+                    {
+                        // a continues after b, reorder the list and swap
+                        hb_buffer_t *tmp = a;
+                        a->next = b->next;
+                        b->next = a;
+                        a = b;
+                        b = tmp;
+                        sanitizer->list_current = a;
+                    }
+
                     sanitizer->list_current = a->next;
                     if (sanitizer->list_current == NULL)
                         sanitizer->last = NULL;