From 3e53f1cf3db9b5e41a7f6e15605607b91892e351 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Thu, 22 Jul 2010 19:06:46 +0200 Subject: [PATCH] refactor: move position translation functions Gets rid of a few forward declarations. --- libass/ass_render.c | 106 +++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/libass/ass_render.c b/libass/ass_render.c index e9ea536..f013591 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -211,9 +211,57 @@ static ASS_Image *my_draw_bitmap(unsigned char *bitmap, int bitmap_w, return img; } -static double x2scr_pos(ASS_Renderer *render_priv, double x); -static double x2scr_pos_scaled(ASS_Renderer *render_priv, double x); -static double y2scr_pos(ASS_Renderer *render_priv, double y); +/** + * \brief Mapping between script and screen coordinates + */ +static double x2scr(ASS_Renderer *render_priv, double x) +{ + return x * render_priv->orig_width_nocrop / render_priv->font_scale_x / + render_priv->track->PlayResX + + FFMAX(render_priv->settings.left_margin, 0); +} +static double x2scr_pos(ASS_Renderer *render_priv, double x) +{ + return x * render_priv->orig_width / render_priv->font_scale_x / render_priv->track->PlayResX + + render_priv->settings.left_margin; +} +static double x2scr_scaled(ASS_Renderer *render_priv, double x) +{ + return x * render_priv->orig_width_nocrop / + render_priv->track->PlayResX + + FFMAX(render_priv->settings.left_margin, 0); +} +static double x2scr_pos_scaled(ASS_Renderer *render_priv, double x) +{ + return x * render_priv->orig_width / render_priv->track->PlayResX + + render_priv->settings.left_margin; +} +/** + * \brief Mapping between script and screen coordinates + */ +static double y2scr(ASS_Renderer *render_priv, double y) +{ + return y * render_priv->orig_height_nocrop / + render_priv->track->PlayResY + + FFMAX(render_priv->settings.top_margin, 0); +} +static double y2scr_pos(ASS_Renderer *render_priv, double y) +{ + return y * render_priv->orig_height / render_priv->track->PlayResY + + render_priv->settings.top_margin; +} + +// the same for toptitles +static double y2scr_top(ASS_Renderer *render_priv, double y) +{ + if (render_priv->settings.use_margins) + return y * render_priv->orig_height_nocrop / + render_priv->track->PlayResY; + else + return y * render_priv->orig_height_nocrop / + render_priv->track->PlayResY + + FFMAX(render_priv->settings.top_margin, 0); +} /* * \brief Convert bitmap glyphs into ASS_Image list with inverse clipping @@ -733,58 +781,6 @@ static ASS_Image *render_text(ASS_Renderer *render_priv, int dst_x, return head; } -/** - * \brief Mapping between script and screen coordinates - */ -static double x2scr(ASS_Renderer *render_priv, double x) -{ - return x * render_priv->orig_width_nocrop / render_priv->font_scale_x / - render_priv->track->PlayResX + - FFMAX(render_priv->settings.left_margin, 0); -} -static double x2scr_pos(ASS_Renderer *render_priv, double x) -{ - return x * render_priv->orig_width / render_priv->font_scale_x / render_priv->track->PlayResX + - render_priv->settings.left_margin; -} -static double x2scr_scaled(ASS_Renderer *render_priv, double x) -{ - return x * render_priv->orig_width_nocrop / - render_priv->track->PlayResX + - FFMAX(render_priv->settings.left_margin, 0); -} -static double x2scr_pos_scaled(ASS_Renderer *render_priv, double x) -{ - return x * render_priv->orig_width / render_priv->track->PlayResX + - render_priv->settings.left_margin; -} -/** - * \brief Mapping between script and screen coordinates - */ -static double y2scr(ASS_Renderer *render_priv, double y) -{ - return y * render_priv->orig_height_nocrop / - render_priv->track->PlayResY + - FFMAX(render_priv->settings.top_margin, 0); -} -static double y2scr_pos(ASS_Renderer *render_priv, double y) -{ - return y * render_priv->orig_height / render_priv->track->PlayResY + - render_priv->settings.top_margin; -} - -// the same for toptitles -static double y2scr_top(ASS_Renderer *render_priv, double y) -{ - if (render_priv->settings.use_margins) - return y * render_priv->orig_height_nocrop / - render_priv->track->PlayResY; - else - return y * render_priv->orig_height_nocrop / - render_priv->track->PlayResY + - FFMAX(render_priv->settings.top_margin, 0); -} - // the same for subtitles static double y2scr_sub(ASS_Renderer *render_priv, double y) { -- 2.40.0