mirror of https://github.com/mpv-player/mpv
vo: hwdec: add AVHWDeviceType property to hwdecs
As the first step towards handling scenarios where the are multiple hwdecs for a given image format but backed by different AVHWDeviceTypes, let us annotate the hwdecs with their corresponding device types. From this, we can also see how all the existing hwdecs which match the same image format also match the same device type.
This commit is contained in:
parent
70fad1daa6
commit
7bbf132e20
|
@ -51,7 +51,8 @@ swift_compile = [swift_prog, swift_flags, '-module-name', 'swift',
|
|||
'-emit-objc-header-path', '@OUTPUT1@', '-o', '@OUTPUT2@',
|
||||
'@INPUT@', '-I.', '-I' + source_root,
|
||||
'-I' + libplacebo.get_variable('includedir',
|
||||
default_value: source_root / 'subprojects' / 'libplacebo' / 'src' / 'include')]
|
||||
default_value: source_root / 'subprojects' / 'libplacebo' / 'src' / 'include'),
|
||||
'-I' + libavutil.get_variable('includedir')]
|
||||
|
||||
swift_targets = custom_target('swift_targets',
|
||||
input: swift_sources,
|
||||
|
|
|
@ -246,6 +246,7 @@ const struct ra_hwdec_driver ra_hwdec_d3d11va = {
|
|||
.name = "d3d11va",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_D3D11, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_D3D11VA,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -466,6 +466,7 @@ const struct ra_hwdec_driver ra_hwdec_dxva2dxgi = {
|
|||
.name = "dxva2-dxgi",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_DXVA2, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_DXVA2,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -352,3 +352,13 @@ int ra_hwdec_driver_get_imgfmt_for_name(const char *name)
|
|||
}
|
||||
return IMGFMT_NONE;
|
||||
}
|
||||
|
||||
enum AVHWDeviceType ra_hwdec_driver_get_device_type_for_name(const char *name)
|
||||
{
|
||||
for (int i = 0; ra_hwdec_drivers[i]; i++) {
|
||||
if (!strcmp(ra_hwdec_drivers[i]->name, name)) {
|
||||
return ra_hwdec_drivers[i]->device_type;
|
||||
}
|
||||
}
|
||||
return AV_HWDEVICE_TYPE_NONE;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef MPGL_HWDEC_H_
|
||||
#define MPGL_HWDEC_H_
|
||||
|
||||
#include <libavutil/hwcontext.h>
|
||||
|
||||
#include "video/mp_image.h"
|
||||
#include "context.h"
|
||||
#include "ra.h"
|
||||
|
@ -106,6 +108,9 @@ struct ra_hwdec_driver {
|
|||
// Terminated with a 0 entry. (Extend the array size as needed.)
|
||||
const int imgfmts[3];
|
||||
|
||||
// The underlying ffmpeg hw device type this hwdec corresponds to.
|
||||
enum AVHWDeviceType device_type;
|
||||
|
||||
// Create the hwdec device. It must add it to hw->devs, if applicable.
|
||||
int (*init)(struct ra_hwdec *hw);
|
||||
void (*uninit)(struct ra_hwdec *hw);
|
||||
|
@ -149,4 +154,8 @@ int ra_hwdec_mapper_map(struct ra_hwdec_mapper *mapper, struct mp_image *img);
|
|||
// Returns IMGFMT_NONE if the name doesn't get matched.
|
||||
int ra_hwdec_driver_get_imgfmt_for_name(const char *name);
|
||||
|
||||
// Get the primary hw device type for the given driver name.
|
||||
// Returns AV_HWDEVICE_TYPE_NONE if the name doesn't get matched.
|
||||
enum AVHWDeviceType ra_hwdec_driver_get_device_type_for_name(const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -392,6 +392,7 @@ const struct ra_hwdec_driver ra_hwdec_aimagereader = {
|
|||
.name = "aimagereader",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_MEDIACODEC, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -284,6 +284,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper)
|
|||
const struct ra_hwdec_driver ra_hwdec_cuda = {
|
||||
.name = "cuda",
|
||||
.imgfmts = {IMGFMT_CUDA, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_CUDA,
|
||||
.priv_size = sizeof(struct cuda_hw_priv),
|
||||
.init = cuda_init,
|
||||
.uninit = cuda_uninit,
|
||||
|
|
|
@ -307,6 +307,7 @@ const struct ra_hwdec_driver ra_hwdec_drmprime = {
|
|||
.name = "drmprime",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_DRMPRIME, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_DRM,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -328,6 +328,7 @@ const struct ra_hwdec_driver ra_hwdec_drmprime_overlay = {
|
|||
.name = "drmprime-overlay",
|
||||
.priv_size = sizeof(struct priv),
|
||||
.imgfmts = {IMGFMT_DRMPRIME, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_DRM,
|
||||
.init = init,
|
||||
.overlay_frame = overlay_frame,
|
||||
.uninit = uninit,
|
||||
|
|
|
@ -546,6 +546,7 @@ const struct ra_hwdec_driver ra_hwdec_vaapi = {
|
|||
.name = "vaapi",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_VAAPI, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_VAAPI,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -129,6 +129,7 @@ const struct ra_hwdec_driver ra_hwdec_videotoolbox = {
|
|||
.name = "videotoolbox",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_VIDEOTOOLBOX, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -320,6 +320,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper)
|
|||
const struct ra_hwdec_driver ra_hwdec_vulkan = {
|
||||
.name = "vulkan",
|
||||
.imgfmts = {IMGFMT_VULKAN, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_VULKAN,
|
||||
.priv_size = sizeof(struct vulkan_hw_priv),
|
||||
.init = vulkan_init,
|
||||
.uninit = vulkan_uninit,
|
||||
|
|
|
@ -351,6 +351,7 @@ const struct ra_hwdec_driver ra_hwdec_d3d11egl = {
|
|||
.name = "d3d11-egl",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_D3D11, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_D3D11VA,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -373,6 +373,7 @@ const struct ra_hwdec_driver ra_hwdec_dxva2egl = {
|
|||
.name = "dxva2-egl",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_DXVA2, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_DXVA2,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -236,6 +236,7 @@ const struct ra_hwdec_driver ra_hwdec_dxva2gldx = {
|
|||
.name = "dxva2-dxinterop",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_DXVA2, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_DXVA2,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
|
@ -239,6 +239,7 @@ const struct ra_hwdec_driver ra_hwdec_vdpau = {
|
|||
.name = "vdpau-gl",
|
||||
.priv_size = sizeof(struct priv_owner),
|
||||
.imgfmts = {IMGFMT_VDPAU, 0},
|
||||
.device_type = AV_HWDEVICE_TYPE_VDPAU,
|
||||
.init = init,
|
||||
.uninit = uninit,
|
||||
.mapper = &(const struct ra_hwdec_mapper_driver){
|
||||
|
|
Loading…
Reference in New Issue