summaryrefslogtreecommitdiffstats
path: root/video/out/gpu/hwdec.h
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2022-02-27 21:07:58 +0100
committerNiklas Haas <github-daiK1o@haasn.dev>2022-03-03 13:06:05 +0100
commitd4fc44e711aee61b34edb654587d6380abe39b05 (patch)
tree0e159674a73cf831882018476684592efe76a0d8 /video/out/gpu/hwdec.h
parentbb434a60ed801723c8e3becae019352935539e50 (diff)
downloadmpv-d4fc44e711aee61b34edb654587d6380abe39b05.tar.bz2
mpv-d4fc44e711aee61b34edb654587d6380abe39b05.tar.xz
vo_gpu: move hwdec loading code to common helper
So I can reuse it in vo_gpu_next without having to reinvent the wheel. In theory, a lot of the stuff could be made more private inside the hwdec code itself, but for the time being I don't care about refactoring this code, merely sharing it.
Diffstat (limited to 'video/out/gpu/hwdec.h')
-rw-r--r--video/out/gpu/hwdec.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/video/out/gpu/hwdec.h b/video/out/gpu/hwdec.h
index 050a358c74..5150932743 100644
--- a/video/out/gpu/hwdec.h
+++ b/video/out/gpu/hwdec.h
@@ -5,6 +5,31 @@
#include "ra.h"
#include "video/hwdec.h"
+// Helper to organize/load hwdecs dynamically
+struct ra_hwdec_ctx {
+ // Set these before calling `ra_hwdec_ctx_init`
+ struct mp_log *log;
+ struct mpv_global *global;
+ struct ra *ra;
+
+ bool loading_done;
+ struct ra_hwdec **hwdecs;
+ int num_hwdecs;
+};
+
+int ra_hwdec_validate_opt(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, const char **value);
+
+void ra_hwdec_ctx_init(struct ra_hwdec_ctx *ctx, struct mp_hwdec_devices *devs,
+ const char *opt, bool load_all_by_default);
+void ra_hwdec_ctx_uninit(struct ra_hwdec_ctx *ctx);
+
+void ra_hwdec_ctx_load_fmt(struct ra_hwdec_ctx *ctx, struct mp_hwdec_devices *devs,
+ int imgfmt);
+
+// Gets the right `ra_hwdec` for a format, if any
+struct ra_hwdec *ra_hwdec_get(struct ra_hwdec_ctx *ctx, int imgfmt);
+
struct ra_hwdec {
const struct ra_hwdec_driver *driver;
struct mp_log *log;
@@ -108,9 +133,6 @@ struct ra_hwdec *ra_hwdec_load_driver(struct ra *ra, struct mp_log *log,
const struct ra_hwdec_driver *drv,
bool is_auto);
-int ra_hwdec_validate_opt(struct mp_log *log, const m_option_t *opt,
- struct bstr name, const char **value);
-
void ra_hwdec_uninit(struct ra_hwdec *hwdec);
bool ra_hwdec_test_format(struct ra_hwdec *hwdec, int imgfmt);