From 7d15bd1488b32be69aa21ed62749e610ac9d856a Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 25 Dec 2012 15:39:47 +0100 Subject: draw_bmp: do not reallocate upsample temp image on each frame Doesn't seem to help too much... --- sub/draw_bmp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'sub') diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c index fe834cc431..208b379168 100644 --- a/sub/draw_bmp.c +++ b/sub/draw_bmp.c @@ -53,8 +53,11 @@ struct part { struct mp_draw_sub_cache { struct part *parts[MAX_OSD_PARTS]; + struct mp_image *upsample_img; + struct mp_image upsample_temp; }; + static struct part *get_cache(struct mp_draw_sub_cache *cache, struct sub_bitmaps *sbs, struct mp_image *format); static bool get_sub_area(struct mp_rect bb, struct mp_image *temp, @@ -450,7 +453,17 @@ static struct mp_image *chroma_up(struct mp_draw_sub_cache *cache, int imgfmt, if (src->imgfmt == imgfmt) return src; - struct mp_image *temp = mp_image_alloc(imgfmt, src->w, src->h); + if (!cache->upsample_img || cache->upsample_img->imgfmt != imgfmt || + cache->upsample_img->w < src->w || cache->upsample_img->h < src->h) + { + talloc_free(cache->upsample_img); + cache->upsample_img = mp_image_alloc(imgfmt, src->w, src->h); + talloc_steal(cache, cache->upsample_img); + } + + cache->upsample_temp = *cache->upsample_img; + struct mp_image *temp = &cache->upsample_temp; + mp_image_set_size(temp, src->w, src->h); // temp is always YUV, but src not necessarily // reduce amount of conversions in YUV case (upsampling/shifting only) if (src->flags & MP_IMGFLAG_YUV) { @@ -468,7 +481,6 @@ static void chroma_down(struct mp_image *old_src, struct mp_image *temp) assert(old_src->w == temp->w && old_src->h == temp->h); if (temp != old_src) { mp_image_swscale(old_src, temp, SWS_AREA); // chroma down - talloc_free(temp); } } -- cgit v1.2.3