mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-29 07:06:59 +08:00
vo_dmabuf_wayland: set hwdec_type in reconfig based off of imgfmt
The old way of setting it during init isn't really accurate. It's possible for a VADisplay to exist, but for some other hwdec to be desired (e.g. like vulkan). It mostly worked OK because vaapi and drmprime are generally exclusive but to be more correct we can simply check the imgfmt in reconfig instead to correctly determine the type.
This commit is contained in:
@@ -689,6 +689,23 @@ static int reconfig(struct vo *vo, struct mp_image *img)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
|
||||
switch (img->imgfmt) {
|
||||
case IMGFMT_VAAPI:
|
||||
p->hwdec_type = HWDEC_VAAPI;
|
||||
break;
|
||||
case IMGFMT_DRMPRIME:
|
||||
p->hwdec_type = HWDEC_DRMPRIME;
|
||||
break;
|
||||
default:
|
||||
p->hwdec_type = HWDEC_NONE;
|
||||
}
|
||||
|
||||
if (p->hwdec_type == HWDEC_NONE) {
|
||||
MP_ERR(vo, "Format '%s' is not a valid hardware accelerated format!\n",
|
||||
mp_imgfmt_to_name(img->imgfmt));
|
||||
return VO_ERROR;
|
||||
}
|
||||
|
||||
if (img->params.force_window) {
|
||||
p->force_window = true;
|
||||
goto done;
|
||||
@@ -841,20 +858,6 @@ static int preinit(struct vo *vo)
|
||||
ra_hwdec_ctx_init(&p->hwdec_ctx, vo->hwdec_devs, "vaapi", false);
|
||||
ra_hwdec_ctx_init(&p->hwdec_ctx, vo->hwdec_devs, "drmprime", false);
|
||||
|
||||
for (int i = 0; i < p->hwdec_ctx.num_hwdecs; i++) {
|
||||
struct ra_hwdec *hw = p->hwdec_ctx.hwdecs[i];
|
||||
if (ra_get_native_resource(p->ctx->ra, "VADisplay")) {
|
||||
p->hwdec_type = HWDEC_VAAPI;
|
||||
} else if (strcmp(hw->driver->name, "drmprime") == 0) {
|
||||
p->hwdec_type = HWDEC_DRMPRIME;
|
||||
}
|
||||
}
|
||||
|
||||
if (p->hwdec_type == HWDEC_NONE) {
|
||||
MP_ERR(vo, "No valid hardware decoding driver could be loaded!\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
p->src = (struct mp_rect){0, 0, 0, 0};
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user