mirror of https://github.com/mpv-player/mpv
draw_bmp: do not reallocate upsample temp image on each frame
Doesn't seem to help too much...
This commit is contained in:
parent
5c049bf577
commit
7d15bd1488
|
@ -53,8 +53,11 @@ struct part {
|
||||||
struct mp_draw_sub_cache
|
struct mp_draw_sub_cache
|
||||||
{
|
{
|
||||||
struct part *parts[MAX_OSD_PARTS];
|
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,
|
static struct part *get_cache(struct mp_draw_sub_cache *cache,
|
||||||
struct sub_bitmaps *sbs, struct mp_image *format);
|
struct sub_bitmaps *sbs, struct mp_image *format);
|
||||||
static bool get_sub_area(struct mp_rect bb, struct mp_image *temp,
|
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)
|
if (src->imgfmt == imgfmt)
|
||||||
return src;
|
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
|
// temp is always YUV, but src not necessarily
|
||||||
// reduce amount of conversions in YUV case (upsampling/shifting only)
|
// reduce amount of conversions in YUV case (upsampling/shifting only)
|
||||||
if (src->flags & MP_IMGFLAG_YUV) {
|
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);
|
assert(old_src->w == temp->w && old_src->h == temp->h);
|
||||||
if (temp != old_src) {
|
if (temp != old_src) {
|
||||||
mp_image_swscale(old_src, temp, SWS_AREA); // chroma down
|
mp_image_swscale(old_src, temp, SWS_AREA); // chroma down
|
||||||
talloc_free(temp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue