summaryrefslogtreecommitdiffstats
path: root/libass/ass_render.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-29 22:24:01 +0200
committerGrigori Goronzy <greg@blackbox>2012-10-01 15:41:13 +0200
commit0594b9fcb5952448dee7eaa3646f7b1281ae8f80 (patch)
tree8f57557cdb6dacee13a490ca6282ac6db8d34902 /libass/ass_render.c
parent758b15ecd437137bb9e794884fa8483430a0fee6 (diff)
downloadlibass-0594b9fcb5952448dee7eaa3646f7b1281ae8f80.tar.bz2
libass-0594b9fcb5952448dee7eaa3646f7b1281ae8f80.tar.xz
Add ass_set_line_position() API function for subtitle position
This allows users to change the vertical position of normal subtitles. MPlayer has such a feature as -sub-pos option using its internal subtitle renderer. Bump LIBASS_VERSION to indicate the API addition.
Diffstat (limited to 'libass/ass_render.c')
-rw-r--r--libass/ass_render.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index c7ebef5..f8b7987 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -2032,16 +2032,25 @@ ass_render_event(ASS_Renderer *render_priv, ASS_Event *event,
y2scr(render_priv, render_priv->track->PlayResY / 2.0);
device_y = scr_y - (bbox.yMax + bbox.yMin) / 2.0;
} else { // subtitle
- double scr_y;
+ double scr_top, scr_bottom, scr_y0;
if (valign != VALIGN_SUB)
ass_msg(render_priv->library, MSGL_V,
"Invalid valign, assuming 0 (subtitle)");
- scr_y =
+ scr_bottom =
y2scr_sub(render_priv,
render_priv->track->PlayResY - MarginV);
- device_y = scr_y;
+ scr_top = y2scr_top(render_priv, 0); //xxx not always 0?
+ device_y = scr_bottom + (scr_top - scr_bottom) *
+ render_priv->settings.line_position / 100.0;
device_y -= text_info->height;
device_y += text_info->lines[0].asc;
+ // clip to top to avoid confusion if line_position is very high,
+ // turning the subtitle into a toptitle
+ // also, don't change behavior if line_position is not used
+ scr_y0 = scr_top + text_info->lines[0].asc;
+ if (device_y < scr_y0 && render_priv->settings.line_position > 0) {
+ device_y = scr_y0;
+ }
}
} else if (render_priv->state.evt_type == EVENT_VSCROLL) {
if (render_priv->state.scroll_direction == SCROLL_TB)