summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-20 17:10:18 +0000
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-20 17:10:18 +0000
commit852e37033b1fca3082ca9c53bd6d817370a5bae4 (patch)
treeb8741a7b74670fb48b3dbdb094e9e34d903b6ab3 /libass
parentef10c853f978934607600521a5815695041985e7 (diff)
downloadmpv-852e37033b1fca3082ca9c53bd6d817370a5bae4.tar.bz2
mpv-852e37033b1fca3082ca9c53bd6d817370a5bae4.tar.xz
Fix collision detection. The old method tried to avoid gaps between subtitles
by moving the upper subtitle down. This is wrong. With this fix, a subtitle will be moved only if it overlaps with another one. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21113 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_render.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index 4a65033d37..cddda29f7f 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -2080,37 +2080,28 @@ static void shift_event(event_images_t* ei, int shift)
static int fit_segment(segment_t* s, segment_t* fixed, int* cnt, int dir)
{
int i;
- int shift;
-
- if (*cnt == 0) {
- *cnt = 1;
- fixed[0].a = s->a;
- fixed[0].b = s->b;
- return 0;
- }
+ int shift = 0;
if (dir == 1) { // move down
- if (s->b <= fixed[0].a) // all ok
- return 0;
for (i = 0; i < *cnt; ++i) {
+ if (s->b + shift <= fixed[i].a || s->a + shift >= fixed[i].b)
+ continue;
shift = fixed[i].b - s->a;
- if (i == *cnt - 1 || fixed[i+1].a >= shift + s->b) { // here is a good place
- fixed[i].b += s->b - s->a;
- return shift;
- }
}
} else { // dir == -1, move up
- if (s->a >= fixed[*cnt-1].b) // all ok
- return 0;
for (i = *cnt-1; i >= 0; --i) {
+ if (s->b + shift <= fixed[i].a || s->a + shift >= fixed[i].b)
+ continue;
shift = fixed[i].a - s->b;
- if (i == 0 || fixed[i-1].b <= shift + s->a) { // here is a good place
- fixed[i].a -= s->b - s->a;
- return shift;
- }
}
}
- assert(0); // unreachable
+
+ fixed[*cnt].a = s->a + shift;
+ fixed[*cnt].b = s->b + shift;
+ (*cnt)++;
+ qsort(fixed, *cnt, sizeof(segment_t), cmp_segment);
+
+ return shift;
}
static void fix_collisions(event_images_t* imgs, int cnt)