From 1670e33e21546546774e6430da8d8ea4b3e675d2 Mon Sep 17 00:00:00 2001 From: eugeni Date: Thu, 7 Aug 2008 22:20:50 +0000 Subject: Calculate subtitle position in floating point. Improves subtitle position precision from a unit of script coordinates to a screen pixel. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27437 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass_render.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libass/ass_render.c') diff --git a/libass/ass_render.c b/libass/ass_render.c index d6e94a7544..b4c9ae090f 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -149,7 +149,7 @@ typedef struct render_context_s { EVENT_HSCROLL, // "Banner" transition effect, text_width is unlimited EVENT_VSCROLL // "Scroll up", "Scroll down" transition effects } evt_type; - int pos_x, pos_y; // position + double pos_x, pos_y; // position int org_x, org_y; // origin char have_origin; // origin is explicitly defined; if 0, get_base_point() is used double scale_x, scale_y; @@ -456,19 +456,19 @@ static ass_image_t* render_text(text_info_t* text_info, int dst_x, int dst_y) /** * \brief Mapping between script and screen coordinates */ -static int x2scr(int x) { +static int x2scr(double x) { return x*frame_context.orig_width_nocrop / frame_context.track->PlayResX + FFMAX(global_settings->left_margin, 0); } /** * \brief Mapping between script and screen coordinates */ -static int y2scr(int y) { +static int y2scr(double y) { return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY + FFMAX(global_settings->top_margin, 0); } // the same for toptitles -static int y2scr_top(int y) { +static int y2scr_top(double y) { if (global_settings->use_margins) return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY; else @@ -476,7 +476,7 @@ static int y2scr_top(int y) { FFMAX(global_settings->top_margin, 0); } // the same for subtitles -static int y2scr_sub(int y) { +static int y2scr_sub(double y) { if (global_settings->use_margins) return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY + FFMAX(global_settings->top_margin, 0) + @@ -727,7 +727,7 @@ static char* parse_tag(char* p, double pwr) { } else if (mystrcmp(&p, "move")) { int x1, x2, y1, y2; long long t1, t2, delta_t, t; - int x, y; + double x, y; double k; skip('('); x1 = strtol(p, &p, 10); @@ -1935,7 +1935,7 @@ static int ass_render_event(ass_event_t* event, event_images_t* event_images) if (render_context.evt_type == EVENT_POSITIONED) { int base_x = 0; int base_y = 0; - mp_msg(MSGT_ASS, MSGL_DBG2, "positioned event at %d, %d\n", render_context.pos_x, render_context.pos_y); + mp_msg(MSGT_ASS, MSGL_DBG2, "positioned event at %f, %f\n", render_context.pos_x, render_context.pos_y); get_base_point(bbox, alignment, &base_x, &base_y); device_x = x2scr(render_context.pos_x) - base_x; device_y = y2scr(render_context.pos_y) - base_y; -- cgit v1.2.3 From 054f28e2d15a293bace0c41e40663a4d4c683606 Mon Sep 17 00:00:00 2001 From: eugeni Date: Thu, 7 Aug 2008 22:20:52 +0000 Subject: Calculate subtitle origin in floating point. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27438 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libass/ass_render.c') diff --git a/libass/ass_render.c b/libass/ass_render.c index b4c9ae090f..bc746fd31d 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -150,7 +150,7 @@ typedef struct render_context_s { EVENT_VSCROLL // "Scroll up", "Scroll down" transition effects } evt_type; double pos_x, pos_y; // position - int org_x, org_y; // origin + double org_x, org_y; // origin char have_origin; // origin is explicitly defined; if 0, get_base_point() is used double scale_x, scale_y; double hspacing; // distance between letters, in pixels -- cgit v1.2.3 From 6c92d9358b3711eaa145b63467542e6b0f23321a Mon Sep 17 00:00:00 2001 From: eugeni Date: Thu, 7 Aug 2008 22:20:54 +0000 Subject: Treat \h as space character. Patch by Robert Rudd (robrudd at users sourceforge net). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27439 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libass/ass_render.c') diff --git a/libass/ass_render.c b/libass/ass_render.c index bc746fd31d..40f2aac6b1 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -1072,7 +1072,7 @@ static unsigned get_next_char(char** str) p += 2; *str = p; return '\n'; - } else if (*(p+1) == 'n') { + } else if ((*(p+1) == 'n') || (*(p+1) == 'h')) { p += 2; *str = p; return ' '; -- cgit v1.2.3 From a9259255439449505432709798347389d57956fd Mon Sep 17 00:00:00 2001 From: eugeni Date: Thu, 7 Aug 2008 22:20:56 +0000 Subject: \org turns off collision detection. Patch by Diogo Franco (diogomfranco gmail com). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27440 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass_render.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libass/ass_render.c') diff --git a/libass/ass_render.c b/libass/ass_render.c index 40f2aac6b1..0ed4054ffa 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -888,6 +888,7 @@ static char* parse_tag(char* p, double pwr) { render_context.org_x = v1; render_context.org_y = v2; render_context.have_origin = 1; + render_context.detect_collisions = 0; } else if (mystrcmp(&p, "t")) { double v[3]; int v1, v2; -- cgit v1.2.3 From e1ce107366596dbfbbe103fdce0cd93b90a08707 Mon Sep 17 00:00:00 2001 From: eugeni Date: Fri, 8 Aug 2008 20:08:02 +0000 Subject: Don't print drawing commands on screen. Drawing mode is not implemented in libass. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27442 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass_render.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libass/ass_render.c') diff --git a/libass/ass_render.c b/libass/ass_render.c index 0ed4054ffa..3806907249 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -161,6 +161,7 @@ typedef struct render_context_s { uint32_t fade; // alpha from \fad char be; // blur edges int shadow; + int drawing_mode; // not implemented; when != 0 text is discarded, except for style override tags effect_t effect_type; int effect_timing; @@ -1028,6 +1029,13 @@ static char* parse_tag(char* p, double pwr) { render_context.shadow = val; else render_context.shadow = render_context.style->Shadow; + } else if (mystrcmp(&p, "pbo")) { + (void)strtol(p, &p, 10); // ignored + } else if (mystrcmp(&p, "p")) { + int val; + if (!mystrtoi(&p, 10, &val)) + val = 0; + render_context.drawing_mode = !!val; } return p; @@ -1203,6 +1211,7 @@ static void init_render_context(ass_event_t* event) render_context.clip_y1 = frame_context.track->PlayResY; render_context.detect_collisions = 1; render_context.fade = 0; + render_context.drawing_mode = 0; render_context.effect_type = EF_NONE; render_context.effect_timing = 0; render_context.effect_skip_timing = 0; @@ -1750,7 +1759,9 @@ static int ass_render_event(ass_event_t* event, event_images_t* event_images) while (1) { // get next char, executing style override // this affects render_context - code = get_next_char(&p); + do { + code = get_next_char(&p); + } while (code && render_context.drawing_mode); // skip everything in drawing mode // face could have been changed in get_next_char if (!render_context.font) { -- cgit v1.2.3