summaryrefslogtreecommitdiffstats
path: root/video/out/vo_drm.c
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2024-03-11 20:46:00 +0100
committersfan5 <sfan5@live.de>2024-03-16 13:27:34 +0100
commitaa75a0e9d29e401dd048f6ec077b8c3c4129efee (patch)
treed6066197cf4179884292fe036d5c4e39b603247e /video/out/vo_drm.c
parentbc8038cffd2b2181f19fa9b07a99b61eba1fe6a1 (diff)
downloadmpv-aa75a0e9d29e401dd048f6ec077b8c3c4129efee.tar.bz2
mpv-aa75a0e9d29e401dd048f6ec077b8c3c4129efee.tar.xz
vo_drm: add support for YUYV format
As the first aligned format this required a fix to reconfig(). Adding the other component-swapped formats in this group would be trivial but I checked the DRM database [1] and no driver exists that supports one of those but not YUYV and this is quite fringe as-is, so I opted not to. [1] <https://drmdb.emersion.fr/formats>
Diffstat (limited to 'video/out/vo_drm.c')
-rw-r--r--video/out/vo_drm.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c
index db1981eb7a..7fc75193c7 100644
--- a/video/out/vo_drm.c
+++ b/video/out/vo_drm.c
@@ -43,6 +43,7 @@
pixfmt2imgfmt(MP_SELECT_LE_BE(AV_PIX_FMT_X2RGB10LE, AV_PIX_FMT_X2RGB10BE))
#define IMGFMT_XBGR2101010 \
pixfmt2imgfmt(MP_SELECT_LE_BE(AV_PIX_FMT_X2BGR10LE, AV_PIX_FMT_X2BGR10BE))
+#define IMGFMT_YUYV pixfmt2imgfmt(AV_PIX_FMT_YUYV422)
#define BYTES_PER_PIXEL 4
#define BITS_PER_PIXEL 32
@@ -131,6 +132,10 @@ static struct framebuffer *setup_framebuffer(struct vo *vo)
p->drm_format = DRM_FORMAT_XBGR8888;
p->imgfmt = IMGFMT_XBGR8888;
break;
+ case DRM_OPTS_FORMAT_YUYV:
+ p->drm_format = DRM_FORMAT_YUYV;
+ p->imgfmt = IMGFMT_YUYV;
+ break;
default:
if (drm->opts->drm_format != DRM_OPTS_FORMAT_XRGB8888) {
MP_VERBOSE(vo, "Requested format not supported by VO, "
@@ -187,14 +192,15 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
vo->dheight = drm->fb->height;
vo_get_src_dst_rects(vo, &p->src, &p->dst, &p->osd);
- int w = p->dst.x1 - p->dst.x0;
- int h = p->dst.y1 - p->dst.y0;
+ struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(p->imgfmt);
+ p->dst.x0 = MP_ALIGN_DOWN(p->dst.x0, fmt.align_x);
+ p->dst.y0 = MP_ALIGN_DOWN(p->dst.y0, fmt.align_y);
p->sws->src = *params;
p->sws->dst = (struct mp_image_params) {
.imgfmt = p->imgfmt,
- .w = w,
- .h = h,
+ .w = mp_rect_w(p->dst),
+ .h = mp_rect_h(p->dst),
.p_w = 1,
.p_h = 1,
};