mpv icon indicating copy to clipboard operation
mpv copied to clipboard

vo_dmabuf_wayland: honor video src rectangle in viewport configuration

Open Dave-Craig-Brightsign opened this issue 2 years ago • 5 comments

vo_dmabuf_wayland uses the Wayland viewporter API to configure video scaling. Although it was correctly setting up the destination rectangle, the source rectangle was being discarded. The result was that options like --video-pan-x were not having the desired effect. Passing the src rectangle into wp_viewport_set_source means that the Wayland compositor now picks the correct source rectangle of the video.

Dave-Craig-Brightsign avatar Oct 28 '22 11:10 Dave-Craig-Brightsign

Unfortunately, this is not quite correct. It happens to work if you launch the mpv tiled in sway (I assume that's what you're doing), but if you launch it floating with --video-pan-x or such you'll see it creates black margins on the opposite side as well. Also, this should work on runtime as well which means the you would need to update the viewporter stuff everytime the value changes. It's probably not obvious how to handle this but you would need to use the loop in VOCTRL_VO_OPTS_CHANGED in wayland_common.c to detect when the option value changes and then update correctly for only the dmabuf-wayland VO.

Dudemanguy avatar Oct 28 '22 15:10 Dudemanguy

If happens to work if you launch the mpv tiled in sway (I assume that's what you're doing)

Actually I was running with weston and I don't see the margins.

Also, this should work on runtime as well which means the you would need to update the viewporter stuff everytime the value changes.

Ah yes, I had made that change locally. In fact I had added scale_x, scale_y, pan_x, pan_y, keepaspect and unscaled so that a resize was run on any change, but I wasn't wholly convinced that was the right way to do it.

Thanks.

Dave-Craig-Brightsign avatar Oct 28 '22 15:10 Dave-Craig-Brightsign

Actually vo_wlshm doesn't work on runtime either now that I double check it. If you just want to first pass it so the initial option works, that's OK with me. I can clean up the runtime changes later.

Dudemanguy avatar Oct 28 '22 15:10 Dudemanguy

Actually I was running with weston and I don't see the margins.

Okay, so this is funky. I can get different results depending on the compositor and machine. Sway appears to have the behavior I described (black margins on both sides) all the time. So that's quite possibly just a compositor bug, but we would need to double check/confirm that. Weston looks like it works on my intel laptop, but not on my desktop (amd). It has the black margins on both sides as well. However, my amd card actually doesn't properly support these formats and it ends up rendering in red. So it could just be my lacking hardware although it's not immediately clear to me why that would matter with the viewport. If anyone on a newer amd card with support for NV12 could test this and report back, that would be appreciated.

Dudemanguy avatar Oct 28 '22 16:10 Dudemanguy

The testing I had been doing was using Weston 9.0 running on an intel TigerLake (VAAPI and i915). I just tried it on RK3399 (rkmpp and panfrost) and I saw nothing on the screen at all. I'm going to have to investigate that, I'll report back with what I find.

Dave-Craig-Brightsign avatar Oct 28 '22 16:10 Dave-Craig-Brightsign

Superceded by #11087.

Dudemanguy avatar Jan 11 '23 18:01 Dudemanguy