From 717d904bbc20e06e2c6c71613d59e065845ff209 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 25 Dec 2012 22:29:49 +0100 Subject: mp_image: add mp_image_crop() Actually stolen from draw_bmp.c. --- sub/draw_bmp.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'sub') diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c index 64a12a2da5..9960d7b459 100644 --- a/sub/draw_bmp.c +++ b/sub/draw_bmp.c @@ -325,16 +325,6 @@ static void draw_ass(struct mp_draw_sub_cache **cache, struct mp_rect bb, } } -static void mp_image_crop(struct mp_image *img, struct mp_rect rc) -{ - for (int p = 0; p < img->num_planes; ++p) { - img->planes[p] += - (rc.y0 >> img->fmt.ys[p]) * img->stride[p] + - (rc.x0 >> img->fmt.xs[p]) * img->fmt.bpp[p] / 8; - } - mp_image_set_size(img, rc.x1 - rc.x0, rc.y1 - rc.y0); -} - static bool clip_to_bb(struct mp_rect bb, struct mp_rect *rc) { rc->x0 = FFMAX(bb.x0, rc->x0); @@ -459,7 +449,7 @@ static bool get_sub_area(struct mp_rect bb, struct mp_image *temp, *out_src_x = (dst.x0 - sb->x) + bb.x0; *out_src_y = (dst.y0 - sb->y) + bb.y0; *out_area = *temp; - mp_image_crop(out_area, dst); + mp_image_crop_rc(out_area, dst); return true; } @@ -486,7 +476,7 @@ void mp_draw_sub_bitmaps(struct mp_draw_sub_cache **cache, struct mp_image *dst, struct mp_image *temp; struct mp_image dst_region = *dst; - mp_image_crop(&dst_region, bb); + mp_image_crop_rc(&dst_region, bb); if (dst->imgfmt == format) { temp = &dst_region; } else { -- cgit v1.2.3