From d4423f75164db09d86c6b6109574e43b35d500b9 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 6 Mar 2009 01:17:05 +0000 Subject: Use blur with kernel [[1,2,1], [2,4,2], [1,2,1]] for \be. This is faster than gaussian blur and similar to vsfilter. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28834 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass_bitmap.c | 40 ++++++++++++++++++++++++++++++++-------- libass/ass_bitmap.h | 2 +- libass/ass_render.c | 6 +----- 3 files changed, 34 insertions(+), 14 deletions(-) (limited to 'libass') diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index 9fb1eab65e..dccdc542a6 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -255,11 +255,38 @@ static bitmap_t* fix_outline_and_shadow(bitmap_t* bm_g, bitmap_t* bm_o) return bm_s; } -int glyph_to_bitmap(ass_synth_priv_t* priv, ass_synth_priv_t* priv_blur, +/** + * \brief Blur with [[1,2,1]. [2,4,2], [1,2,1]] kernel + * This blur is the same as the one employed by vsfilter. + */ +static void be_blur(unsigned char *buf, int w, int h) { + unsigned int x, y; + unsigned int old_sum, new_sum; + + for (y=0; y> 2; + old_sum = new_sum; + } + } + + for (x=0; x> 2; + old_sum = new_sum; + } + } +} + +int glyph_to_bitmap(ass_synth_priv_t* priv_blur, FT_Glyph glyph, FT_Glyph outline_glyph, bitmap_t** bm_g, bitmap_t** bm_o, bitmap_t** bm_s, int be, double blur_radius) { - int bord = be ? (be+1) : 0; + int bord = be ? (be/4+1) : 0; blur_radius *= 2; bord = (blur_radius > 0.0) ? blur_radius : bord; @@ -279,19 +306,16 @@ int glyph_to_bitmap(ass_synth_priv_t* priv, ass_synth_priv_t* priv_blur, return 1; } } - if (*bm_o) { - resize_tmp(priv, (*bm_o)->w, (*bm_o)->h); + if (*bm_o) resize_tmp(priv_blur, (*bm_o)->w, (*bm_o)->h); - } - resize_tmp(priv, (*bm_g)->w, (*bm_g)->h); resize_tmp(priv_blur, (*bm_g)->w, (*bm_g)->h); if (be) { while (be--) { if (*bm_o) - blur((*bm_o)->buffer, priv->tmp, (*bm_o)->w, (*bm_o)->h, (*bm_o)->w, (int*)priv->gt2, priv->g_r, priv->g_w); + be_blur((*bm_o)->buffer, (*bm_o)->w, (*bm_o)->h); else - blur((*bm_g)->buffer, priv->tmp, (*bm_g)->w, (*bm_g)->h, (*bm_g)->w, (int*)priv->gt2, priv->g_r, priv->g_w); + be_blur((*bm_g)->buffer, (*bm_g)->w, (*bm_g)->h); } } else { if (blur_radius > 0.0) { diff --git a/libass/ass_bitmap.h b/libass/ass_bitmap.h index 5f45aae4b2..c0b4ad201f 100644 --- a/libass/ass_bitmap.h +++ b/libass/ass_bitmap.h @@ -46,7 +46,7 @@ typedef struct bitmap_s { * \param bm_g out: pointer to the bitmap of glyph shadow is returned here * \param be 1 = produces blurred bitmaps, 0 = normal bitmaps */ -int glyph_to_bitmap(ass_synth_priv_t* priv, ass_synth_priv_t* priv_blur, FT_Glyph glyph, FT_Glyph outline_glyph, bitmap_t** bm_g, bitmap_t** bm_o, bitmap_t** bm_s, int be, double blur_radius); +int glyph_to_bitmap(ass_synth_priv_t* priv_blur, FT_Glyph glyph, FT_Glyph outline_glyph, bitmap_t** bm_g, bitmap_t** bm_o, bitmap_t** bm_s, int be, double blur_radius); void ass_free_bitmap(bitmap_t* bm); diff --git a/libass/ass_render.c b/libass/ass_render.c index 84840fd0ab..fa10d245db 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -43,7 +43,6 @@ #define MAX_GLYPHS 3000 #define MAX_LINES 300 -#define BE_RADIUS 1.5 #define BLUR_MAX_RADIUS 50.0 #define ROUND(x) ((int) ((x) + .5)) @@ -83,7 +82,6 @@ struct ass_renderer_s { ass_settings_t settings; int render_id; ass_synth_priv_t* synth_priv; - ass_synth_priv_t* synth_priv_blur; ass_image_t* images_root; // rendering result is stored here ass_image_t* prev_images_root; @@ -270,8 +268,7 @@ ass_renderer_t* ass_renderer_init(ass_library_t* library) goto ass_init_exit; } - priv->synth_priv = ass_synth_init(BE_RADIUS); - priv->synth_priv_blur = ass_synth_init(BLUR_MAX_RADIUS); + priv->synth_priv = ass_synth_init(BLUR_MAX_RADIUS); priv->library = library; priv->ftlibrary = ft; @@ -1503,7 +1500,6 @@ static void get_bitmap_glyph(glyph_info_t* info) // render glyph error = glyph_to_bitmap(ass_renderer->synth_priv, - ass_renderer->synth_priv_blur, info->glyph, info->outline_glyph, &info->bm, &info->bm_o, &info->bm_s, info->be, info->blur * frame_context.border_scale); -- cgit v1.2.3