summaryrefslogtreecommitdiffstats
path: root/libvo/sub.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-23 01:37:43 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-23 01:37:43 +0000
commit725ff339e7093f11e1da39156cf7266dd6582f09 (patch)
treebdbd9ed7cb6e62dfa5798acfa251efab26d4b8a7 /libvo/sub.c
parent38c4cdcfc587804cdb2dbb9f980ded0ca2659978 (diff)
downloadmpv-725ff339e7093f11e1da39156cf7266dd6582f09.tar.bz2
mpv-725ff339e7093f11e1da39156cf7266dd6582f09.tar.xz
This patch adds support for vertical subtitle alignment
control. Possible values are top, center, and bottom, with bottom being the default. Alignment is relevant when it comes to positioning subtitles with one line (or fewer lines) of text relative to multi-line subtitles. It is implemented as a new command (sub_alignment) that without an argument cycles the alignment (between top, center, and bottom), or with an argument sets the alignment (0 for top, 1 for center, 2 for bottom). The key 'i' is bound to this command. patch by Oskar Liljeblad (oskar@osk.mine.nu) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8535 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/sub.c')
-rw-r--r--libvo/sub.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libvo/sub.c b/libvo/sub.c
index 1cec860880..89dae2eefa 100644
--- a/libvo/sub.c
+++ b/libvo/sub.c
@@ -37,6 +37,7 @@ unsigned char* vo_osd_text=NULL;
int sub_unicode=0;
int sub_utf8=0;
int sub_pos=100;
+int sub_alignment=2; /* 0=top, 1=center, 2=bottom */
int sub_visibility=1;
// return the real height of a char:
@@ -418,12 +419,22 @@ inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){
*sfalco*
*/
if(suboverlap_enabled) obj->y -= vo_font->pic_a[vo_font->font[40]]->h - vo_font->height;
- if (obj->y >= (dys * sub_pos / 100)){
- int old=obj->y;
- obj->y = dys * sub_pos /100;
- obj->bbox.y2-=old-obj->y;
- }
-
+
+ h = dys - obj->y;
+ if (sub_alignment == 2)
+ obj->y = dys * sub_pos / 100 - h;
+ else if (sub_alignment == 1)
+ obj->y = dys * sub_pos / 100 - h / 2;
+ else
+ obj->y = dys * sub_pos / 100;
+
+ if (obj->y < 0)
+ obj->y = 0;
+ if (obj->y > dys - h)
+ obj->y = dys - h;
+
+ obj->bbox.y2 = obj->y + h;
+
// calculate bbox:
obj->bbox.x1=xmin;
obj->bbox.x2=xmax;