History

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.

Philip Langdale committed 2 years ago

Commit 7bbf1321 parent 70fad1d16 files · +34 −1Browse files

Unified · Split

16 files
  1. osdep/mac/meson.build +2 −1
  2. video/out/d3d11/hwdec_d3d11va.c +1 −0
  3. video/out/d3d11/hwdec_dxva2dxgi.c +1 −0
  4. video/out/gpu/hwdec.c +10 −0
  5. video/out/gpu/hwdec.h +9 −0
  6. video/out/hwdec/hwdec_aimagereader.c +1 −0
  7. video/out/hwdec/hwdec_cuda.c +1 −0
  8. video/out/hwdec/hwdec_drmprime.c +1 −0
  9. video/out/hwdec/hwdec_drmprime_overlay.c +1 −0
  10. video/out/hwdec/hwdec_vaapi.c +1 −0
  11. video/out/hwdec/hwdec_vt.c +1 −0
  12. video/out/hwdec/hwdec_vulkan.c +1 −0
  13. video/out/opengl/hwdec_d3d11egl.c +1 −0
  14. video/out/opengl/hwdec_dxva2egl.c +1 −0
  15. video/out/opengl/hwdec_dxva2gldx.c +1 −0
  16. video/out/opengl/hwdec_vdpau.c +1 −0
osdep/mac/meson.build+2−1
@@ -51,7 +51,8 @@ swift_compile = [swift_prog, swift_flags, '-module-name', 'swift', · 50 unmodified lines
51 '-emit-objc-header-path', '@OUTPUT1@', '-o', '@OUTPUT2@',51 '-emit-objc-header-path', '@OUTPUT1@', '-o', '@OUTPUT2@',
52 '@INPUT@', '-I.', '-I' + source_root,52 '@INPUT@', '-I.', '-I' + source_root,
53 '-I' + libplacebo.get_variable('includedir',53 '-I' + libplacebo.get_variable('includedir',
54 default_value: source_root / 'subprojects' / 'libplacebo' / 'src' / 'include')]54 default_value: source_root / 'subprojects' / 'libplacebo' / 'src' / 'include'),
55 '-I' + libavutil.get_variable('includedir')]
55 56
56swift_targets = custom_target('swift_targets',57swift_targets = custom_target('swift_targets',
57 input: swift_sources,58 input: swift_sources,
video/out/d3d11/hwdec_d3d11va.c+1−0
@@ -246,6 +246,7 @@ const struct ra_hwdec_driver ra_hwdec_d3d11va = { · 245 unmodified lines
246 .name = "d3d11va",246 .name = "d3d11va",
247 .priv_size = sizeof(struct priv_owner),247 .priv_size = sizeof(struct priv_owner),
248 .imgfmts = {IMGFMT_D3D11, 0},248 .imgfmts = {IMGFMT_D3D11, 0},
249 .device_type = AV_HWDEVICE_TYPE_D3D11VA,
249 .init = init,250 .init = init,
250 .uninit = uninit,251 .uninit = uninit,
251 .mapper = &(const struct ra_hwdec_mapper_driver){252 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/d3d11/hwdec_dxva2dxgi.c+1−0
@@ -466,6 +466,7 @@ const struct ra_hwdec_driver ra_hwdec_dxva2dxgi = { · 465 unmodified lines
466 .name = "dxva2-dxgi",466 .name = "dxva2-dxgi",
467 .priv_size = sizeof(struct priv_owner),467 .priv_size = sizeof(struct priv_owner),
468 .imgfmts = {IMGFMT_DXVA2, 0},468 .imgfmts = {IMGFMT_DXVA2, 0},
469 .device_type = AV_HWDEVICE_TYPE_DXVA2,
469 .init = init,470 .init = init,
470 .uninit = uninit,471 .uninit = uninit,
471 .mapper = &(const struct ra_hwdec_mapper_driver){472 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/gpu/hwdec.c+10−0
@@ -352,3 +352,13 @@ int ra_hwdec_driver_get_imgfmt_for_name(const char *name) · 351 unmodified lines
352 }352 }
353 return IMGFMT_NONE;353 return IMGFMT_NONE;
354}354}
355
356enum AVHWDeviceType ra_hwdec_driver_get_device_type_for_name(const char *name)
357{
358 for (int i = 0; ra_hwdec_drivers[i]; i++) {
359 if (!strcmp(ra_hwdec_drivers[i]->name, name)) {
360 return ra_hwdec_drivers[i]->device_type;
361 }
362 }
363 return AV_HWDEVICE_TYPE_NONE;
364}
video/out/gpu/hwdec.h+9−0
@@ -1,6 +1,8 @@
1#ifndef MPGL_HWDEC_H_1#ifndef MPGL_HWDEC_H_
2#define MPGL_HWDEC_H_2#define MPGL_HWDEC_H_
3 3
4#include <libavutil/hwcontext.h>
5
4#include "video/mp_image.h"6#include "video/mp_image.h"
5#include "context.h"7#include "context.h"
6#include "ra.h"8#include "ra.h"
@@ -106,6 +108,9 @@ struct ra_hwdec_driver { · 99 unmodified lines
106 // Terminated with a 0 entry. (Extend the array size as needed.)108 // Terminated with a 0 entry. (Extend the array size as needed.)
107 const int imgfmts[3];109 const int imgfmts[3];
108 110
111 // The underlying ffmpeg hw device type this hwdec corresponds to.
112 enum AVHWDeviceType device_type;
113
109 // Create the hwdec device. It must add it to hw->devs, if applicable.114 // Create the hwdec device. It must add it to hw->devs, if applicable.
110 int (*init)(struct ra_hwdec *hw);115 int (*init)(struct ra_hwdec *hw);
111 void (*uninit)(struct ra_hwdec *hw);116 void (*uninit)(struct ra_hwdec *hw);
@@ -149,4 +154,8 @@ int ra_hwdec_mapper_map(struct ra_hwdec_mapper *mapper, struct mp_image *img); · 37 unmodified lines
149// Returns IMGFMT_NONE if the name doesn't get matched.154// Returns IMGFMT_NONE if the name doesn't get matched.
150int ra_hwdec_driver_get_imgfmt_for_name(const char *name);155int ra_hwdec_driver_get_imgfmt_for_name(const char *name);
151 156
157// Get the primary hw device type for the given driver name.
158// Returns AV_HWDEVICE_TYPE_NONE if the name doesn't get matched.
159enum AVHWDeviceType ra_hwdec_driver_get_device_type_for_name(const char *name);
160
152#endif161#endif
video/out/hwdec/hwdec_aimagereader.c+1−0
@@ -392,6 +392,7 @@ const struct ra_hwdec_driver ra_hwdec_aimagereader = { · 391 unmodified lines
392 .name = "aimagereader",392 .name = "aimagereader",
393 .priv_size = sizeof(struct priv_owner),393 .priv_size = sizeof(struct priv_owner),
394 .imgfmts = {IMGFMT_MEDIACODEC, 0},394 .imgfmts = {IMGFMT_MEDIACODEC, 0},
395 .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
395 .init = init,396 .init = init,
396 .uninit = uninit,397 .uninit = uninit,
397 .mapper = &(const struct ra_hwdec_mapper_driver){398 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/hwdec/hwdec_cuda.c+1−0
@@ -284,6 +284,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) · 283 unmodified lines
284const struct ra_hwdec_driver ra_hwdec_cuda = {284const struct ra_hwdec_driver ra_hwdec_cuda = {
285 .name = "cuda",285 .name = "cuda",
286 .imgfmts = {IMGFMT_CUDA, 0},286 .imgfmts = {IMGFMT_CUDA, 0},
287 .device_type = AV_HWDEVICE_TYPE_CUDA,
287 .priv_size = sizeof(struct cuda_hw_priv),288 .priv_size = sizeof(struct cuda_hw_priv),
288 .init = cuda_init,289 .init = cuda_init,
289 .uninit = cuda_uninit,290 .uninit = cuda_uninit,
video/out/hwdec/hwdec_drmprime.c+1−0
@@ -307,6 +307,7 @@ const struct ra_hwdec_driver ra_hwdec_drmprime = { · 306 unmodified lines
307 .name = "drmprime",307 .name = "drmprime",
308 .priv_size = sizeof(struct priv_owner),308 .priv_size = sizeof(struct priv_owner),
309 .imgfmts = {IMGFMT_DRMPRIME, 0},309 .imgfmts = {IMGFMT_DRMPRIME, 0},
310 .device_type = AV_HWDEVICE_TYPE_DRM,
310 .init = init,311 .init = init,
311 .uninit = uninit,312 .uninit = uninit,
312 .mapper = &(const struct ra_hwdec_mapper_driver){313 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/hwdec/hwdec_drmprime_overlay.c+1−0
@@ -328,6 +328,7 @@ const struct ra_hwdec_driver ra_hwdec_drmprime_overlay = { · 327 unmodified lines
328 .name = "drmprime-overlay",328 .name = "drmprime-overlay",
329 .priv_size = sizeof(struct priv),329 .priv_size = sizeof(struct priv),
330 .imgfmts = {IMGFMT_DRMPRIME, 0},330 .imgfmts = {IMGFMT_DRMPRIME, 0},
331 .device_type = AV_HWDEVICE_TYPE_DRM,
331 .init = init,332 .init = init,
332 .overlay_frame = overlay_frame,333 .overlay_frame = overlay_frame,
333 .uninit = uninit,334 .uninit = uninit,
video/out/hwdec/hwdec_vaapi.c+1−0
@@ -546,6 +546,7 @@ const struct ra_hwdec_driver ra_hwdec_vaapi = { · 545 unmodified lines
546 .name = "vaapi",546 .name = "vaapi",
547 .priv_size = sizeof(struct priv_owner),547 .priv_size = sizeof(struct priv_owner),
548 .imgfmts = {IMGFMT_VAAPI, 0},548 .imgfmts = {IMGFMT_VAAPI, 0},
549 .device_type = AV_HWDEVICE_TYPE_VAAPI,
549 .init = init,550 .init = init,
550 .uninit = uninit,551 .uninit = uninit,
551 .mapper = &(const struct ra_hwdec_mapper_driver){552 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/hwdec/hwdec_vt.c+1−0
@@ -129,6 +129,7 @@ const struct ra_hwdec_driver ra_hwdec_videotoolbox = { · 128 unmodified lines
129 .name = "videotoolbox",129 .name = "videotoolbox",
130 .priv_size = sizeof(struct priv_owner),130 .priv_size = sizeof(struct priv_owner),
131 .imgfmts = {IMGFMT_VIDEOTOOLBOX, 0},131 .imgfmts = {IMGFMT_VIDEOTOOLBOX, 0},
132 .device_type = AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
132 .init = init,133 .init = init,
133 .uninit = uninit,134 .uninit = uninit,
134 .mapper = &(const struct ra_hwdec_mapper_driver){135 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/hwdec/hwdec_vulkan.c+1−0
@@ -320,6 +320,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) · 319 unmodified lines
320const struct ra_hwdec_driver ra_hwdec_vulkan = {320const struct ra_hwdec_driver ra_hwdec_vulkan = {
321 .name = "vulkan",321 .name = "vulkan",
322 .imgfmts = {IMGFMT_VULKAN, 0},322 .imgfmts = {IMGFMT_VULKAN, 0},
323 .device_type = AV_HWDEVICE_TYPE_VULKAN,
323 .priv_size = sizeof(struct vulkan_hw_priv),324 .priv_size = sizeof(struct vulkan_hw_priv),
324 .init = vulkan_init,325 .init = vulkan_init,
325 .uninit = vulkan_uninit,326 .uninit = vulkan_uninit,
video/out/opengl/hwdec_d3d11egl.c+1−0
@@ -351,6 +351,7 @@ const struct ra_hwdec_driver ra_hwdec_d3d11egl = { · 350 unmodified lines
351 .name = "d3d11-egl",351 .name = "d3d11-egl",
352 .priv_size = sizeof(struct priv_owner),352 .priv_size = sizeof(struct priv_owner),
353 .imgfmts = {IMGFMT_D3D11, 0},353 .imgfmts = {IMGFMT_D3D11, 0},
354 .device_type = AV_HWDEVICE_TYPE_D3D11VA,
354 .init = init,355 .init = init,
355 .uninit = uninit,356 .uninit = uninit,
356 .mapper = &(const struct ra_hwdec_mapper_driver){357 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/opengl/hwdec_dxva2egl.c+1−0
@@ -373,6 +373,7 @@ const struct ra_hwdec_driver ra_hwdec_dxva2egl = { · 372 unmodified lines
373 .name = "dxva2-egl",373 .name = "dxva2-egl",
374 .priv_size = sizeof(struct priv_owner),374 .priv_size = sizeof(struct priv_owner),
375 .imgfmts = {IMGFMT_DXVA2, 0},375 .imgfmts = {IMGFMT_DXVA2, 0},
376 .device_type = AV_HWDEVICE_TYPE_DXVA2,
376 .init = init,377 .init = init,
377 .uninit = uninit,378 .uninit = uninit,
378 .mapper = &(const struct ra_hwdec_mapper_driver){379 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/opengl/hwdec_dxva2gldx.c+1−0
@@ -236,6 +236,7 @@ const struct ra_hwdec_driver ra_hwdec_dxva2gldx = { · 235 unmodified lines
236 .name = "dxva2-dxinterop",236 .name = "dxva2-dxinterop",
237 .priv_size = sizeof(struct priv_owner),237 .priv_size = sizeof(struct priv_owner),
238 .imgfmts = {IMGFMT_DXVA2, 0},238 .imgfmts = {IMGFMT_DXVA2, 0},
239 .device_type = AV_HWDEVICE_TYPE_DXVA2,
239 .init = init,240 .init = init,
240 .uninit = uninit,241 .uninit = uninit,
241 .mapper = &(const struct ra_hwdec_mapper_driver){242 .mapper = &(const struct ra_hwdec_mapper_driver){
video/out/opengl/hwdec_vdpau.c+1−0
@@ -239,6 +239,7 @@ const struct ra_hwdec_driver ra_hwdec_vdpau = { · 238 unmodified lines
239 .name = "vdpau-gl",239 .name = "vdpau-gl",
240 .priv_size = sizeof(struct priv_owner),240 .priv_size = sizeof(struct priv_owner),
241 .imgfmts = {IMGFMT_VDPAU, 0},241 .imgfmts = {IMGFMT_VDPAU, 0},
242 .device_type = AV_HWDEVICE_TYPE_VDPAU,
242 .init = init,243 .init = init,
243 .uninit = uninit,244 .uninit = uninit,
244 .mapper = &(const struct ra_hwdec_mapper_driver){245 .mapper = &(const struct ra_hwdec_mapper_driver){

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t