summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2020-10-19 16:25:58 +0300
committerOleg Oshmyan <chortos@inbox.lv>2020-10-27 01:24:26 +0200
commit512444c15e69a78ae82a8e9ff0e7bdef9f93bbcf (patch)
tree39950ed1dbc6fbf50edbdb1ce912f9debf4e659d
parent7440eb75f12104b1cdd36638ccb16934db067b0c (diff)
downloadlibass-512444c15e69a78ae82a8e9ff0e7bdef9f93bbcf.tar.bz2
libass-512444c15e69a78ae82a8e9ff0e7bdef9f93bbcf.tar.xz
Improve \kf position rounding
-rw-r--r--libass/ass_parse.c12
-rw-r--r--libass/ass_render.c2
-rw-r--r--libass/ass_render.h4
3 files changed, 9 insertions, 9 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c
index ef4b0e0..9107545 100644
--- a/libass/ass_parse.c
+++ b/libass/ass_parse.c
@@ -1006,12 +1006,12 @@ void process_karaoke_effects(ASS_Renderer *render_priv)
int x;
if (tm_current < tm_start)
- x = -1000000;
+ x = -100000000;
else if (tm_current >= tm_end)
- x = 1000000;
+ x = 100000000;
else {
- int x_start = d6_to_int(start->pos.x);
- int x_end = d6_to_int(end[-1].pos.x + end[-1].advance.x);
+ int x_start = start->pos.x;
+ int x_end = end[-1].pos.x + end[-1].advance.x;
double dt = (double) (tm_current - tm_start) / (tm_end - tm_start);
double frz = fmod(start->frz, 360);
if (frz > 90 && frz < 270) {
@@ -1023,12 +1023,12 @@ void process_karaoke_effects(ASS_Renderer *render_priv)
info->c[1] = tmp;
}
}
- x = x_start + (x_end - x_start) * dt;
+ x = x_start + lrint((x_end - x_start) * dt);
}
for (GlyphInfo *info = start; info < end; info++) {
info->effect_type = effect_type;
- info->effect_timing = x - d6_to_int(info->pos.x);
+ info->effect_timing = x - info->pos.x;
}
}
}
diff --git a/libass/ass_render.c b/libass/ass_render.c
index e8254f2..fbe2765 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -2417,7 +2417,7 @@ static void render_and_combine_glyphs(ASS_Renderer *render_priv,
}
if (info->effect_type == EF_KARAOKE_KF)
- info->effect_timing += d6_to_int(info->leftmost_x);
+ info->effect_timing = d6_to_int(info->leftmost_x + info->effect_timing);
for (int j = 0; j < info->bitmap_count; j++) {
info->bitmaps[j].pos.x -= info->x;
diff --git a/libass/ass_render.h b/libass/ass_render.h
index 9796841..803b577 100644
--- a/libass/ass_render.h
+++ b/libass/ass_render.h
@@ -100,7 +100,7 @@ typedef struct {
uint32_t c[4]; // colors
Effect effect_type;
- // during render_and_combine_glyphs: distance in pixels from the karaoke origin.
+ // during render_and_combine_glyphs: distance in subpixels from the karaoke origin.
// after render_and_combine_glyphs: screen coordinate in pixels.
// part of the glyph to the left of it is displayed in a different color.
int effect_timing;
@@ -147,7 +147,7 @@ typedef struct glyph_info {
ASS_Vector cluster_advance;
Effect effect_type;
int effect_timing; // time duration of current karaoke word
- // after process_karaoke_effects: distance in pixels from the karaoke origin.
+ // after process_karaoke_effects: distance in subpixels from the karaoke origin.
// part of the glyph to the left of it is displayed in a different color.
int effect_skip_timing; // delay after the end of last karaoke word
int asc, desc; // font max ascender and descender