diff options
author | Grigori Goronzy <greg@blackbox> | 2009-07-21 02:39:52 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-07-21 02:39:52 +0200 |
commit | f7f50dfb6335b3d2c1f1fa85a1e496ed2abf6d27 (patch) | |
tree | f22611c3bdfafa84b61d2b5f548db74594c68ba9 | |
parent | 1bbf325019a2ab0ead277cf1af8af6e63157e851 (diff) | |
download | libass-f7f50dfb6335b3d2c1f1fa85a1e496ed2abf6d27.tar.bz2 libass-f7f50dfb6335b3d2c1f1fa85a1e496ed2abf6d27.tar.xz |
Clamp clip rectangle to frame size
Make sure the clip rectangle is inside the screen boundaries.
Idea by Evgeniy Stepanov.
-rw-r--r-- | libass/ass_render.c | 8 | ||||
-rw-r--r-- | libass/ass_utils.h | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index f2c137d..f623482 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -556,10 +556,10 @@ static ass_image_t **render_glyph(ass_renderer_t *render_priv, brk -= bm->left; // clipping - clip_x0 = render_priv->state.clip_x0; - clip_y0 = render_priv->state.clip_y0; - clip_x1 = render_priv->state.clip_x1; - clip_y1 = render_priv->state.clip_y1; + clip_x0 = FFMINMAX(render_priv->state.clip_x0, 0, render_priv->width); + clip_y0 = FFMINMAX(render_priv->state.clip_y0, 0, render_priv->height); + clip_x1 = FFMINMAX(render_priv->state.clip_x1, 0, render_priv->width); + clip_y1 = FFMINMAX(render_priv->state.clip_y1, 0, render_priv->height); b_x0 = 0; b_y0 = 0; b_x1 = bm->w; diff --git a/libass/ass_utils.h b/libass/ass_utils.h index a906ca5..3913290 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -43,6 +43,7 @@ #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFMINMAX(c,a,b) FFMIN(FFMAX(c, a), b) int mystrtoi(char **p, int *res); int mystrtoll(char **p, long long *res); |