summaryrefslogtreecommitdiffstats
path: root/sub/draw_bmp.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-25 15:39:47 +0100
committerwm4 <wm4@nowhere>2013-01-13 20:04:14 +0100
commit7d15bd1488b32be69aa21ed62749e610ac9d856a (patch)
treea5c21f9a8391d65fcb55f13bc8cb1e93a908e2e1 /sub/draw_bmp.c
parent5c049bf5773f899976914fa7210bad2395bbf349 (diff)
downloadmpv-7d15bd1488b32be69aa21ed62749e610ac9d856a.tar.bz2
mpv-7d15bd1488b32be69aa21ed62749e610ac9d856a.tar.xz
draw_bmp: do not reallocate upsample temp image on each frame
Doesn't seem to help too much...
Diffstat (limited to 'sub/draw_bmp.c')
-rw-r--r--sub/draw_bmp.c16
1 files changed, 14 insertions, 2 deletions
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);
}
}