diff options
author | Dudemanguy <random342@airmail.cc> | 2023-09-19 18:12:42 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-22 14:20:38 +0000 |
commit | db12a2f224239f1b2c1f58dc1feed9a1f4c8e553 (patch) | |
tree | 6cb5c0540a7d9064359d85ee39b3c079dc7d3c6c | |
parent | 73ad9eef2875247d38af99f4d8c804f2749a8588 (diff) | |
download | mpv-db12a2f224239f1b2c1f58dc1feed9a1f4c8e553.tar.bz2 mpv-db12a2f224239f1b2c1f58dc1feed9a1f4c8e553.tar.xz |
cuda: move --cuda-device to cuda_opts group
Also change a ta_free to talloc_free for consistency reasons.
-rw-r--r-- | options/options.c | 18 | ||||
-rw-r--r-- | options/options.h | 6 | ||||
-rw-r--r-- | video/cuda.c | 13 | ||||
-rw-r--r-- | video/out/hwdec/hwdec_cuda_gl.c | 7 |
4 files changed, 32 insertions, 12 deletions
diff --git a/options/options.c b/options/options.c index d91a72c3a3..507b4b6067 100644 --- a/options/options.c +++ b/options/options.c @@ -364,6 +364,21 @@ const struct m_sub_options mp_osd_render_sub_opts = { }; #undef OPT_BASE_STRUCT +#define OPT_BASE_STRUCT struct cuda_opts + +const struct m_sub_options cuda_conf = { + .opts = (const struct m_option[]){ + {"decode-device", OPT_CHOICE(cuda_device, {"auto", -1}), + M_RANGE(0, INT_MAX)}, + {0} + }, + .size = sizeof(struct cuda_opts), + .defaults = &(const struct cuda_opts){ + .cuda_device = -1, + }, +}; + +#undef OPT_BASE_STRUCT #define OPT_BASE_STRUCT struct dvd_opts const struct m_sub_options dvd_conf = { @@ -845,8 +860,7 @@ static const m_option_t mp_opts[] = { #endif #if HAVE_CUDA_HWACCEL - {"cuda-decode-device", OPT_CHOICE(cuda_device, {"auto", -1}), - M_RANGE(0, INT_MAX)}, + {"cuda", OPT_SUBSTRUCT(cuda_opts, cuda_conf)}, #endif #if HAVE_VAAPI diff --git a/options/options.h b/options/options.h index da37345edc..58c15b9f74 100644 --- a/options/options.h +++ b/options/options.h @@ -365,6 +365,7 @@ typedef struct MPOpts { struct drm_opts *drm_opts; struct wayland_opts *wayland_opts; struct wingl_opts *wingl_opts; + struct cuda_opts *cuda_opts; struct dvd_opts *dvd_opts; struct vaapi_opts *vaapi_opts; struct sws_opts *sws_opts; @@ -373,6 +374,10 @@ typedef struct MPOpts { int cuda_device; } MPOpts; +struct cuda_opts { + int cuda_device; +}; + struct dvd_opts { int angle; int speed; @@ -384,6 +389,7 @@ struct filter_opts { }; extern const struct m_sub_options vo_sub_opts; +extern const struct m_sub_options cuda_conf; extern const struct m_sub_options dvd_conf; extern const struct m_sub_options mp_subtitle_sub_opts; extern const struct m_sub_options mp_sub_filter_opts; diff --git a/video/cuda.c b/video/cuda.c index d83520bc83..3b7a2d882c 100644 --- a/video/cuda.c +++ b/video/cuda.c @@ -17,25 +17,24 @@ #include "hwdec.h" #include "options/m_config.h" +#include "options/options.h" #include <libavutil/hwcontext.h> static struct AVBufferRef *cuda_create_standalone(struct mpv_global *global, struct mp_log *log, struct hwcontext_create_dev_params *params) { - int decode_dev_idx; - mp_read_option_raw(global, "cuda-decode-device", &m_option_type_choice, - &decode_dev_idx); + struct cuda_opts *opts = mp_get_config_group(NULL, global, &cuda_conf); char *decode_dev = NULL; - if (decode_dev_idx != -1) { - decode_dev = talloc_asprintf(NULL, "%d", decode_dev_idx); - } + if (opts->cuda_device != -1) + decode_dev = talloc_asprintf(NULL, "%d", opts->cuda_device); AVBufferRef* ref = NULL; av_hwdevice_ctx_create(&ref, AV_HWDEVICE_TYPE_CUDA, decode_dev, NULL, 0); - ta_free(decode_dev); + talloc_free(decode_dev); + talloc_free(opts); return ref; } diff --git a/video/out/hwdec/hwdec_cuda_gl.c b/video/out/hwdec/hwdec_cuda_gl.c index 35b52d0f53..f20540ed4d 100644 --- a/video/out/hwdec/hwdec_cuda_gl.c +++ b/video/out/hwdec/hwdec_cuda_gl.c @@ -19,6 +19,7 @@ #include "hwdec_cuda.h" #include "options/m_config.h" +#include "options/options.h" #include "video/out/opengl/formats.h" #include "video/out/opengl/ra_gl.h" @@ -135,9 +136,9 @@ bool cuda_gl_init(const struct ra_hwdec *hw) { p->decode_ctx = p->display_ctx; - int decode_dev_idx = -1; - mp_read_option_raw(hw->global, "cuda-decode-device", &m_option_type_choice, - &decode_dev_idx); + struct cuda_opts *opts = mp_get_config_group(NULL, hw->global, &cuda_conf); + int decode_dev_idx = opts->cuda_device; + talloc_free(opts); if (decode_dev_idx > -1) { CUcontext dummy; |