draw_bmp: do not reallocate upsample temp image on each frame

Doesn't seem to help too much...
This commit is contained in:
wm4 2012-12-25 15:39:47 +01:00
parent 5c049bf577
commit 7d15bd1488
1 changed files with 14 additions and 2 deletions

View File

@ -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);
}
}