Mercurial > mplayer.hg
changeset 19538:ed0ae2df0fe8
Add right and left margins support to libass.
Add ability to not use margins even when they are available.
author | eugeni |
---|---|
date | Sat, 26 Aug 2006 18:24:37 +0000 |
parents | 45e1650f9ad5 |
children | 64009ae411fb |
files | libass/ass.h libass/ass_render.c |
diffstat | 2 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libass/ass.h Sat Aug 26 17:31:42 2006 +0000 +++ b/libass/ass.h Sat Aug 26 18:24:37 2006 +0000 @@ -14,6 +14,10 @@ double line_spacing; // additional line spacing (in frame pixels) int top_margin; // height of top margin. Everything except toptitles is shifted down by top_margin. int bottom_margin; // height of bottom margin. (frame_height - top_margin - bottom_margin) is original video height. + int left_margin; + int right_margin; + int use_margins; // 0 - place all subtitles inside original frame + // 1 - use margins for placing toptitles and subtitles double aspect; // frame aspect ratio, d_width / d_height. } ass_settings_t;
--- a/libass/ass_render.c Sat Aug 26 17:31:42 2006 +0000 +++ b/libass/ass_render.c Sat Aug 26 18:24:37 2006 +0000 @@ -117,6 +117,7 @@ ass_instance_t* ass_priv; int width, height; // screen dimensions int orig_height; // frame height ( = screen height - margins ) + int orig_width; // frame width ( = screen width - margins ) ass_track_t* track; int add_bottom_margin; // additional margin, used to shift subtitles in case of collision int add_top_margin; @@ -140,7 +141,8 @@ track->PlayResX = 384; track->PlayResY = 288; } else { - double orig_aspect = (global_settings->aspect * frame_context.height) / frame_context.orig_height; + double orig_aspect = (global_settings->aspect * frame_context.height * frame_context.orig_width) / + frame_context.orig_height / frame_context.width; if (!track->PlayResY) { track->PlayResY = track->PlayResX / orig_aspect + .5; mp_msg(MSGT_GLOBAL, MSGL_WARN, "PlayResY undefined, setting %d \n", track->PlayResY); @@ -410,7 +412,7 @@ * \brief Mapping between script and screen coordinates */ static int x2scr(int x) { - return x*frame_context.width / frame_context.track->PlayResX; + return x*frame_context.width / frame_context.track->PlayResX + global_settings->left_margin; } /** * \brief Mapping between script and screen coordinates @@ -420,11 +422,18 @@ } // the same for toptitles static int y2scr_top(int y) { - return y * frame_context.orig_height / frame_context.track->PlayResY; + if (global_settings->use_margins) + return y * frame_context.orig_height / frame_context.track->PlayResY; + else + return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin; } // the same for subtitles static int y2scr_sub(int y) { - return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin + global_settings->bottom_margin; + if (global_settings->use_margins) + return y * frame_context.orig_height / frame_context.track->PlayResY + + global_settings->top_margin + global_settings->bottom_margin; + else + return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin; } static void vmirror_bbox(FT_BBox* orig, FT_BBox* pbbox) { @@ -1745,6 +1754,7 @@ frame_context.ass_priv = priv; frame_context.width = global_settings->frame_width; frame_context.height = global_settings->frame_height; + frame_context.orig_width = global_settings->frame_width - global_settings->left_margin - global_settings->right_margin; frame_context.orig_height = global_settings->frame_height - global_settings->top_margin - global_settings->bottom_margin; frame_context.track = track; frame_context.add_bottom_margin = 0;