From 536f6dddd901f7ce9562ce39c83b4fb8775c0bf2 Mon Sep 17 00:00:00 2001 From: Oneric Date: Thu, 20 Oct 2022 23:53:17 +0200 Subject: refactor: static'fy functions only used in one file --- libass/ass_bitmap.c | 57 ++++++++++++++++++++++++++--------------------------- libass/ass_bitmap.h | 2 -- libass/ass_shaper.c | 2 +- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index b11fcfa..191eeaa 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -58,6 +58,34 @@ #endif +static void be_blur_pre(uint8_t *buf, intptr_t stride, intptr_t width, intptr_t height) +{ + for (int y = 0; y < height; ++y) + { + for (int x = 0; x < width; ++x) + { + // This is equivalent to (value * 64 + 127) / 255 for all + // values from 0 to 256 inclusive. Assist vectorizing + // compilers by noting that all temporaries fit in 8 bits. + buf[y * stride + x] = + (uint8_t) ((buf[y * stride + x] >> 1) + 1) >> 1; + } + } +} + +static void be_blur_post(uint8_t *buf, intptr_t stride, intptr_t width, intptr_t height) +{ + for (int y = 0; y < height; ++y) + { + for (int x = 0; x < width; ++x) + { + // This is equivalent to (value * 255 + 32) / 64 for all values + // from 0 to 96 inclusive, and we only care about 0 to 64. + uint8_t value = buf[y * stride + x]; + buf[y * stride + x] = (value << 2) - (value > 32); + } + } +} void ass_synth_blur(const BitmapEngine *engine, Bitmap *bm, int be, double blur_r2) @@ -319,35 +347,6 @@ void ass_be_blur_c(uint8_t *buf, intptr_t stride, } } -void be_blur_pre(uint8_t *buf, intptr_t stride, intptr_t width, intptr_t height) -{ - for (int y = 0; y < height; ++y) - { - for (int x = 0; x < width; ++x) - { - // This is equivalent to (value * 64 + 127) / 255 for all - // values from 0 to 256 inclusive. Assist vectorizing - // compilers by noting that all temporaries fit in 8 bits. - buf[y * stride + x] = - (uint8_t) ((buf[y * stride + x] >> 1) + 1) >> 1; - } - } -} - -void be_blur_post(uint8_t *buf, intptr_t stride, intptr_t width, intptr_t height) -{ - for (int y = 0; y < height; ++y) - { - for (int x = 0; x < width; ++x) - { - // This is equivalent to (value * 255 + 32) / 64 for all values - // from 0 to 96 inclusive, and we only care about 0 to 64. - uint8_t value = buf[y * stride + x]; - buf[y * stride + x] = (value << 2) - (value > 32); - } - } -} - /* * To find these values, simulate blur on the border between two * half-planes, one zero-filled (background) and the other filled diff --git a/libass/ass_bitmap.h b/libass/ass_bitmap.h index 1a17fd5..37da2bc 100644 --- a/libass/ass_bitmap.h +++ b/libass/ass_bitmap.h @@ -109,8 +109,6 @@ void ass_synth_blur(const BitmapEngine *engine, Bitmap *bm, int be, double blur_r2); int be_padding(int be); -void be_blur_pre(uint8_t *buf, intptr_t stride, intptr_t width, intptr_t height); -void be_blur_post(uint8_t *buf, intptr_t stride, intptr_t width, intptr_t height); bool ass_gaussian_blur(const BitmapEngine *engine, Bitmap *bm, double r2); void shift_bitmap(Bitmap *bm, int shift_x, int shift_y); void fix_outline(Bitmap *bm_g, Bitmap *bm_o); diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index 44f8e7b..a7cec8c 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -221,7 +221,7 @@ static void update_hb_size(hb_font_t *hb_font, FT_Face face) * */ -FT_Glyph_Metrics * +static FT_Glyph_Metrics * get_cached_metrics(struct ass_shaper_metrics_data *metrics, hb_codepoint_t unicode, hb_codepoint_t glyph) { -- cgit v1.2.3