diff options
-rw-r--r-- | libass/ass_render.c | 6 | ||||
-rw-r--r-- | libass/ass_utils.h | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index cf22bec..b0accb7 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -662,7 +662,8 @@ static void blend_vector_clip(ASS_Renderer *render_priv, ASS_Image *head) ol_key.u.drawing.text = render_priv->state.clip_drawing_text; double m[3][3] = {{0}}; - double w = render_priv->font_scale / (1 << (render_priv->state.clip_drawing_scale - 1)); + int32_t scale_base = lshiftwrapi(1, render_priv->state.clip_drawing_scale - 1); + double w = scale_base > 0 ? (render_priv->font_scale / scale_base) : 0; m[0][0] = render_priv->font_scale_x * w; m[1][1] = w; m[2][2] = 1; @@ -1105,7 +1106,8 @@ get_outline_glyph(ASS_Renderer *priv, GlyphInfo *info) return; } - double w = priv->font_scale / (1 << (info->drawing_scale - 1)); + int32_t scale_base = lshiftwrapi(1, info->drawing_scale - 1); + double w = scale_base > 0 ? (priv->font_scale / scale_base) : 0; scale.x = info->scale_x * w; scale.y = info->scale_y * w; desc = 64 * info->drawing_pbo; diff --git a/libass/ass_utils.h b/libass/ass_utils.h index dbe556c..3e239b5 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -182,6 +182,12 @@ static inline int double_to_d22(double x) return lrint(x * 0x400000); } +static inline int32_t lshiftwrapi(int32_t i, int32_t shift) +{ + // '0u +' to avoid automatic integer promotion causing UB + return (0u + (uint32_t)i) << (shift & 31); +} + static inline int mystrtod(char **p, double *res) { char *start = *p; |