From ef86a6125df85c45513e76641f83f814828d57d3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 20 Oct 2019 19:50:35 +0200 Subject: vo_drm: support zimg, require zimg for 30 bit This trivially enables use of zimg. You still need to use --sws-allow-zimg to use it. In addition, it removes the vo_drm-specific 30 bit RGB support, and uses zimg's support for it. Like vo_drm, zimg's wrapper simply repacks from GBRP to RGB30 in C, but it's still a worthy cleanup, as the zimg wrapper need a concept of "packing" image output anyway. There also might be a minor performance benefit due to doing the conversion slice-wise and reducing cache thrashing (whether this positive effect really happens with typical slice/image/cache sizes is unknown). --- video/out/vo_drm.c | 48 ++++++++++++------------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) (limited to 'video/out/vo_drm.c') diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c index ce48779a82..5cf4b58a61 100644 --- a/video/out/vo_drm.c +++ b/video/out/vo_drm.c @@ -36,11 +36,7 @@ #include "vo.h" #define IMGFMT_XRGB8888 IMGFMT_BGR0 -#if BYTE_ORDER == BIG_ENDIAN -#define IMGFMT_XRGB2101010 pixfmt2imgfmt(AV_PIX_FMT_GBRP10BE) -#else -#define IMGFMT_XRGB2101010 pixfmt2imgfmt(AV_PIX_FMT_GBRP10LE) -#endif +#define IMGFMT_XRGB2101010 IMGFMT_RGB30 #define BYTES_PER_PIXEL 4 #define BITS_PER_PIXEL 32 @@ -303,7 +299,6 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) int w = p->dst.x1 - p->dst.x0; int h = p->dst.y1 - p->dst.y0; - mp_sws_set_from_cmdline(p->sws, vo->global); p->sws->src = *params; p->sws->dst = (struct mp_image_params) { .imgfmt = p->imgfmt, @@ -391,35 +386,10 @@ static void draw_image(struct vo *vo, mp_image_t *mpi, struct framebuffer *front osd_draw_on_image(vo->osd, p->osd, 0, 0, p->cur_frame); } - if (p->depth == 30) { - // Pack GBRP10 image into XRGB2101010 for DRM - const int w = p->cur_frame->w; - const int h = p->cur_frame->h; - - const int g_padding = p->cur_frame->stride[0]/sizeof(uint16_t) - w; - const int b_padding = p->cur_frame->stride[1]/sizeof(uint16_t) - w; - const int r_padding = p->cur_frame->stride[2]/sizeof(uint16_t) - w; - const int fbuf_padding = front_buf->stride/sizeof(uint32_t) - w; - - uint16_t *g_ptr = (uint16_t*)p->cur_frame->planes[0]; - uint16_t *b_ptr = (uint16_t*)p->cur_frame->planes[1]; - uint16_t *r_ptr = (uint16_t*)p->cur_frame->planes[2]; - uint32_t *fbuf_ptr = (uint32_t*)front_buf->map; - for (unsigned y = 0; y < h; ++y) { - for (unsigned x = 0; x < w; ++x) { - *fbuf_ptr++ = (*r_ptr++ << 20) | (*g_ptr++ << 10) | (*b_ptr++); - } - g_ptr += g_padding; - b_ptr += b_padding; - r_ptr += r_padding; - fbuf_ptr += fbuf_padding; - } - } else { - memcpy_pic(front_buf->map, p->cur_frame->planes[0], - p->cur_frame->w * BYTES_PER_PIXEL, p->cur_frame->h, - front_buf->stride, - p->cur_frame->stride[0]); - } + memcpy_pic(front_buf->map, p->cur_frame->planes[0], + p->cur_frame->w * BYTES_PER_PIXEL, p->cur_frame->h, + front_buf->stride, + p->cur_frame->stride[0]); } if (mpi != p->last_input) { @@ -553,7 +523,11 @@ static void uninit(struct vo *vo) static int preinit(struct vo *vo) { struct priv *p = vo->priv; + p->sws = mp_sws_alloc(vo); + mp_sws_set_from_cmdline(p->sws, vo->global); + p->sws->allow_zimg = true; + p->ev.version = DRM_EVENT_CONTEXT_VERSION; p->ev.page_flip_handler = &drm_pflip_cb; @@ -625,7 +599,9 @@ err: static int query_format(struct vo *vo, int format) { - return sws_isSupportedInput(imgfmt2pixfmt(format)); + struct priv *p = vo->priv; + + return mp_sws_supports_formats(p->sws, p->imgfmt, format); } static int control(struct vo *vo, uint32_t request, void *arg) -- cgit v1.2.3