diff --git a/video/out/hwdec/hwdec_vaapi.c b/video/out/hwdec/hwdec_vaapi.c index 8eaf0df4e6..62c66e5b29 100644 --- a/video/out/hwdec/hwdec_vaapi.c +++ b/video/out/hwdec/hwdec_vaapi.c @@ -166,30 +166,15 @@ static int init(struct ra_hwdec *hw) static void mapper_unmap(struct ra_hwdec_mapper *mapper) { struct priv_owner *p_owner = mapper->owner->priv; - VADisplay *display = p_owner->display; struct priv *p = mapper->priv; - VAStatus status; p_owner->interop_unmap(mapper); -#if VA_CHECK_VERSION(1, 1, 0) if (p->surface_acquired) { for (int n = 0; n < p->desc.num_objects; n++) close(p->desc.objects[n].fd); p->surface_acquired = false; } -#endif - - if (p->buffer_acquired) { - status = vaReleaseBufferHandle(display, p->current_image.buf); - CHECK_VA_STATUS(mapper, "vaReleaseBufferHandle()"); - p->buffer_acquired = false; - } - if (p->current_image.image_id != VA_INVALID_ID) { - status = vaDestroyImage(display, p->current_image.image_id); - CHECK_VA_STATUS(mapper, "vaDestroyImage()"); - p->current_image.image_id = VA_INVALID_ID; - } } static void mapper_uninit(struct ra_hwdec_mapper *mapper) @@ -215,8 +200,6 @@ static int mapper_init(struct ra_hwdec_mapper *mapper) struct priv_owner *p_owner = mapper->owner->priv; struct priv *p = mapper->priv; - p->current_image.buf = p->current_image.image_id = VA_INVALID_ID; - mapper->dst_params = mapper->src_params; mapper->dst_params.imgfmt = mapper->src_params.hw_subfmt; mapper->dst_params.hw_subfmt = 0; @@ -250,10 +233,6 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) VAStatus status; VADisplay *display = p_owner->display; -#if VA_CHECK_VERSION(1, 1, 0) - if (p->esh_not_implemented) - goto esh_failed; - status = vaExportSurfaceHandle(display, va_surface_id(mapper->src), VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, VA_EXPORT_SURFACE_READ_ONLY | @@ -261,9 +240,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) &p->desc); if (!CHECK_VA_STATUS_LEVEL(mapper, "vaExportSurfaceHandle()", p_owner->probing_formats ? MSGL_V : MSGL_ERR)) { - if (status == VA_STATUS_ERROR_UNIMPLEMENTED) - p->esh_not_implemented = true; - goto esh_failed; + goto err; } vaSyncSurface(display, va_surface_id(mapper->src)); // No need to error out if sync fails, but good to know if it did. @@ -271,59 +248,16 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) p->surface_acquired = true; if (!p_owner->interop_map(mapper)) - goto esh_failed; + goto err; if (p->desc.fourcc == VA_FOURCC_YV12) MPSWAP(struct ra_tex*, mapper->tex[1], mapper->tex[2]); return 0; -esh_failed: - if (p->surface_acquired) { - for (int n = 0; n < p->desc.num_objects; n++) - close(p->desc.objects[n].fd); - p->surface_acquired = false; - } -#endif // VA_CHECK_VERSION - - if (p_owner->interop_map_legacy) { - VAImage *va_image = &p->current_image; - status = vaDeriveImage(display, va_surface_id(mapper->src), va_image); - if (!CHECK_VA_STATUS(mapper, "vaDeriveImage()")) - goto err; - - VABufferInfo buffer_info = {.mem_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME}; - status = vaAcquireBufferHandle(display, va_image->buf, &buffer_info); - if (!CHECK_VA_STATUS(mapper, "vaAcquireBufferHandle()")) - goto err; - p->buffer_acquired = true; - - int drm_fmts[8] = { - // 1 bytes per component, 1-4 components - MKTAG('R', '8', ' ', ' '), // DRM_FORMAT_R8 - MKTAG('G', 'R', '8', '8'), // DRM_FORMAT_GR88 - 0, // untested (DRM_FORMAT_RGB888?) - 0, // untested (DRM_FORMAT_RGBA8888?) - // 2 bytes per component, 1-4 components - MKTAG('R', '1', '6', ' '), // proposed DRM_FORMAT_R16 - MKTAG('G', 'R', '3', '2'), // proposed DRM_FORMAT_GR32 - 0, // N/A - 0, // N/A - }; - - if (!p_owner->interop_map_legacy(mapper, &buffer_info, drm_fmts)) - goto err; - - if (va_image->format.fourcc == VA_FOURCC_YV12) - MPSWAP(struct ra_tex*, mapper->tex[1], mapper->tex[2]); - - return 0; - } else { - mapper_unmap(mapper); - goto err; - } - err: + mapper_unmap(mapper); + if (!p_owner->probing_formats) MP_FATAL(mapper, "mapping VAAPI EGL image failed\n"); return -1; diff --git a/video/out/hwdec/hwdec_vaapi.h b/video/out/hwdec/hwdec_vaapi.h index 05dab02629..471283a0ca 100644 --- a/video/out/hwdec/hwdec_vaapi.h +++ b/video/out/hwdec/hwdec_vaapi.h @@ -34,9 +34,6 @@ struct priv_owner { void (*interop_uninit)(const struct ra_hwdec_mapper *mapper); bool (*interop_map)(struct ra_hwdec_mapper *mapper); - bool (*interop_map_legacy)(struct ra_hwdec_mapper *mapper, - const VABufferInfo *buffer_info, - const int *drm_fmts); void (*interop_unmap)(struct ra_hwdec_mapper *mapper); }; @@ -45,14 +42,8 @@ struct priv { struct mp_image layout; struct ra_tex *tex[4]; - VAImage current_image; - bool buffer_acquired; - -#if VA_CHECK_VERSION(1, 1, 0) - bool esh_not_implemented; VADRMPRIMESurfaceDescriptor desc; bool surface_acquired; -#endif void *interop_mapper_priv; }; diff --git a/video/out/hwdec/hwdec_vaapi_gl.c b/video/out/hwdec/hwdec_vaapi_gl.c index 3e3edbed0a..1617167464 100644 --- a/video/out/hwdec/hwdec_vaapi_gl.c +++ b/video/out/hwdec/hwdec_vaapi_gl.c @@ -139,7 +139,6 @@ static void vaapi_gl_mapper_uninit(const struct ra_hwdec_mapper *mapper) static bool vaapi_gl_map(struct ra_hwdec_mapper *mapper) { -#if VA_CHECK_VERSION(1, 1, 0) struct priv *p_mapper = mapper->priv; struct vaapi_gl_mapper_priv *p = p_mapper->interop_mapper_priv; @@ -172,52 +171,6 @@ static bool vaapi_gl_map(struct ra_hwdec_mapper *mapper) mapper->tex[n] = p_mapper->tex[n]; } gl->BindTexture(GL_TEXTURE_2D, 0); -#endif - return true; -} - -static bool vaapi_gl_map_legacy(struct ra_hwdec_mapper *mapper, - const VABufferInfo *buffer_info, - const int *drm_fmts) { - struct priv *p_mapper = mapper->priv; - struct vaapi_gl_mapper_priv *p = p_mapper->interop_mapper_priv; - - GL *gl = ra_gl_get(mapper->ra); - - VAImage *va_image = &p_mapper->current_image; - - for (int n = 0; n < p_mapper->num_planes; n++) { - int attribs[20] = {EGL_NONE}; - int num_attribs = 0; - - const struct ra_format *fmt = p_mapper->tex[n]->params.format; - int n_comp = fmt->num_components; - int comp_s = fmt->component_size[n] / 8; - if (n_comp < 1 || n_comp > 3 || comp_s < 1 || comp_s > 2) - return false; - int drm_fmt = drm_fmts[n_comp - 1 + (comp_s - 1) * 4]; - if (!drm_fmt) - return false; - - ADD_ATTRIB(EGL_LINUX_DRM_FOURCC_EXT, drm_fmt); - ADD_ATTRIB(EGL_WIDTH, p_mapper->tex[n]->params.w); - ADD_ATTRIB(EGL_HEIGHT, p_mapper->tex[n]->params.h); - ADD_ATTRIB(EGL_DMA_BUF_PLANE0_FD_EXT, buffer_info->handle); - ADD_ATTRIB(EGL_DMA_BUF_PLANE0_OFFSET_EXT, va_image->offsets[n]); - ADD_ATTRIB(EGL_DMA_BUF_PLANE0_PITCH_EXT, va_image->pitches[n]); - - p->images[n] = p->CreateImageKHR(eglGetCurrentDisplay(), - EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attribs); - if (!p->images[n]) - return false; - - gl->BindTexture(GL_TEXTURE_2D, p->gl_textures[n]); - p->EGLImageTargetTexture2DOES(GL_TEXTURE_2D, p->images[n]); - - mapper->tex[n] = p_mapper->tex[n]; - } - gl->BindTexture(GL_TEXTURE_2D, 0); - return true; } @@ -262,8 +215,7 @@ bool vaapi_gl_init(const struct ra_hwdec *hw) p->interop_init = vaapi_gl_mapper_init; p->interop_uninit = vaapi_gl_mapper_uninit; p->interop_map = vaapi_gl_map; - p->interop_map_legacy = vaapi_gl_map_legacy; p->interop_unmap = vaapi_gl_unmap; return true; -} \ No newline at end of file +} diff --git a/video/vaapi.c b/video/vaapi.c index accbe573d4..2c6ef337b7 100644 --- a/video/vaapi.c +++ b/video/vaapi.c @@ -109,10 +109,8 @@ struct mp_vaapi_ctx *va_initialize(VADisplay *display, struct mp_log *plog, hwctx->free = free_device_ref; hwctx->user_opaque = res; -#if VA_CHECK_VERSION(1, 0, 0) vaSetErrorCallback(display, va_error_callback, res); vaSetInfoCallback(display, va_info_callback, res); -#endif int major, minor; int status = vaInitialize(display, &major, &minor); diff --git a/wscript b/wscript index def7f77738..a0f6583de5 100644 --- a/wscript +++ b/wscript @@ -726,22 +726,22 @@ video_output_features = [ 'name': '--vaapi', 'desc': 'VAAPI acceleration', 'deps': 'libdl && (x11 || wayland || egl-drm)', - 'func': check_pkg_config('libva', '>= 0.36.0'), + 'func': check_pkg_config('libva', '>= 1.1.0'), }, { 'name': '--vaapi-x11', 'desc': 'VAAPI (X11 support)', 'deps': 'vaapi && x11', - 'func': check_pkg_config('libva-x11', '>= 0.36.0'), + 'func': check_pkg_config('libva-x11', '>= 1.1.0'), }, { 'name': '--vaapi-wayland', 'desc': 'VAAPI (Wayland support)', 'deps': 'vaapi && gl-wayland', - 'func': check_pkg_config('libva-wayland', '>= 0.36.0'), + 'func': check_pkg_config('libva-wayland', '>= 1.1.0'), }, { 'name': '--vaapi-drm', 'desc': 'VAAPI (DRM/EGL support)', 'deps': 'vaapi && egl-drm', - 'func': check_pkg_config('libva-drm', '>= 0.36.0'), + 'func': check_pkg_config('libva-drm', '>= 1.1.0'), }, { 'name': '--vaapi-x-egl', 'desc': 'VAAPI EGL on X11',