From 8ed32e90c933c13ce128f1edf44624616f8efca0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 3 Jul 2016 19:29:43 +0200 Subject: sub: move RGBA scaling to vo_vaapi vo_vaapi is the only thing which can't scale RGBA on the GPU. (Other cases of RGBA scaling are handled in draw_bmp.c for some reason.) Move this code and get rid of the osd_conv_cache thing. Functionally, nothing changes. --- video/out/vo_vaapi.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'video/out/vo_vaapi.c') diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c index dc8aaacf9e..8380771e27 100644 --- a/video/out/vo_vaapi.c +++ b/video/out/vo_vaapi.c @@ -32,8 +32,9 @@ #include "common/msg.h" #include "video/out/vo.h" #include "video/mp_image_pool.h" -#include "sub/osd.h" +#include "video/sws_utils.h" #include "sub/img_convert.h" +#include "sub/osd.h" #include "x11_common.h" #include "video/mp_image.h" @@ -58,7 +59,6 @@ struct vaapi_osd_part { int change_id; struct vaapi_osd_image image; struct vaapi_subpic subpic; - struct osd_conv_cache *conv_cache; }; #define MAX_OUTPUT_SURFACES 2 @@ -336,8 +336,6 @@ static void draw_osd_cb(void *pctx, struct sub_bitmaps *imgs) if (imgs->change_id != part->change_id) { part->change_id = imgs->change_id; - osd_scale_rgba(part->conv_cache, imgs); - struct mp_rect bb; if (!mp_sub_bitmaps_bb(imgs, &bb)) goto error; @@ -365,6 +363,25 @@ static void draw_osd_cb(void *pctx, struct sub_bitmaps *imgs) for (int n = 0; n < imgs->num_parts; n++) { struct sub_bitmap *sub = &imgs->parts[n]; + struct mp_image src = {0}; + mp_image_setfmt(&src, IMGFMT_BGRA); + mp_image_set_size(&src, sub->w, sub->h); + src.planes[0] = sub->bitmap; + src.stride[0] = sub->stride; + + struct mp_image *bmp = &src; + + struct mp_image *tmp = NULL; + if (sub->dw != sub->w || sub->dh != sub->h) { + tmp = mp_image_alloc(IMGFMT_BGRA, sub->dw, sub->dh); + if (!tmp) + goto error; + + mp_image_swscale(tmp, &src, mp_sws_fast_flags); + + bmp = tmp; + } + // Note: nothing guarantees that the sub-bitmaps don't overlap. // But in all currently existing cases, they don't. // We simply hope that this won't change, and nobody will @@ -373,8 +390,10 @@ static void draw_osd_cb(void *pctx, struct sub_bitmaps *imgs) size_t dst = (sub->y - bb.y0) * vaimg.stride[0] + (sub->x - bb.x0) * 4; - memcpy_pic(vaimg.planes[0] + dst, sub->bitmap, sub->w * 4, sub->h, - vaimg.stride[0], sub->stride); + memcpy_pic(vaimg.planes[0] + dst, bmp->planes[0], sub->dw * 4, + sub->dh, vaimg.stride[0], bmp->stride[0]); + + talloc_free(tmp); } if (!va_image_unmap(p->mpvaapi, &img->image)) @@ -630,7 +649,6 @@ static int preinit(struct vo *vo) struct vaapi_osd_part *part = &p->osd_parts[n]; part->image.image.image_id = VA_INVALID_ID; part->image.subpic_id = VA_INVALID_ID; - part->conv_cache = talloc_steal(vo, osd_conv_cache_new()); } int max_display_attrs = vaMaxNumDisplayAttributes(p->display); -- cgit v1.2.3 From d81fb97f4587f73f62a760b99f686139f9b8d966 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 29 Jun 2016 09:16:13 +0200 Subject: mp_image: split colorimetry metadata into its own struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This has two reasons: 1. I tend to add new fields to this metadata, and every time I've done so I've consistently forgotten to update all of the dozens of places in which this colorimetry metadata might end up getting used. While most usages don't really care about most of the metadata, sometimes the intend was simply to “copy” the colorimetry metadata from one struct to another. With this being inside a substruct, those lines of code can now simply read a.color = b.color without having to care about added or removed fields. 2. It makes the type definitions nicer for upcoming refactors. In going through all of the usages, I also expanded a few where I felt that omitting the “young” fields was a bug. --- video/out/vo_vaapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'video/out/vo_vaapi.c') diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c index 8380771e27..11bb469b24 100644 --- a/video/out/vo_vaapi.c +++ b/video/out/vo_vaapi.c @@ -225,7 +225,7 @@ static bool render_to_screen(struct priv *p, struct mp_image *mpi) } } - int flags = va_get_colorspace_flag(p->image_params.colorspace) | + int flags = va_get_colorspace_flag(p->image_params.color.space) | p->scaling | VA_FRAME_PICTURE; status = vaPutSurface(p->display, surface, -- cgit v1.2.3