mirror of
https://github.com/mpv-player/mpv
synced 2025-03-24 12:22:25 +00:00
cuda: move --cuda-device to cuda_opts group
Also change a ta_free to talloc_free for consistency reasons.
This commit is contained in:
parent
73ad9eef28
commit
db12a2f224
@ -363,6 +363,21 @@ const struct m_sub_options mp_osd_render_sub_opts = {
|
|||||||
.change_flags = UPDATE_OSD,
|
.change_flags = UPDATE_OSD,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#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
|
#undef OPT_BASE_STRUCT
|
||||||
#define OPT_BASE_STRUCT struct dvd_opts
|
#define OPT_BASE_STRUCT struct dvd_opts
|
||||||
|
|
||||||
@ -845,8 +860,7 @@ static const m_option_t mp_opts[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_CUDA_HWACCEL
|
#if HAVE_CUDA_HWACCEL
|
||||||
{"cuda-decode-device", OPT_CHOICE(cuda_device, {"auto", -1}),
|
{"cuda", OPT_SUBSTRUCT(cuda_opts, cuda_conf)},
|
||||||
M_RANGE(0, INT_MAX)},
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_VAAPI
|
#if HAVE_VAAPI
|
||||||
|
@ -365,6 +365,7 @@ typedef struct MPOpts {
|
|||||||
struct drm_opts *drm_opts;
|
struct drm_opts *drm_opts;
|
||||||
struct wayland_opts *wayland_opts;
|
struct wayland_opts *wayland_opts;
|
||||||
struct wingl_opts *wingl_opts;
|
struct wingl_opts *wingl_opts;
|
||||||
|
struct cuda_opts *cuda_opts;
|
||||||
struct dvd_opts *dvd_opts;
|
struct dvd_opts *dvd_opts;
|
||||||
struct vaapi_opts *vaapi_opts;
|
struct vaapi_opts *vaapi_opts;
|
||||||
struct sws_opts *sws_opts;
|
struct sws_opts *sws_opts;
|
||||||
@ -373,6 +374,10 @@ typedef struct MPOpts {
|
|||||||
int cuda_device;
|
int cuda_device;
|
||||||
} MPOpts;
|
} MPOpts;
|
||||||
|
|
||||||
|
struct cuda_opts {
|
||||||
|
int cuda_device;
|
||||||
|
};
|
||||||
|
|
||||||
struct dvd_opts {
|
struct dvd_opts {
|
||||||
int angle;
|
int angle;
|
||||||
int speed;
|
int speed;
|
||||||
@ -384,6 +389,7 @@ struct filter_opts {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern const struct m_sub_options vo_sub_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 dvd_conf;
|
||||||
extern const struct m_sub_options mp_subtitle_sub_opts;
|
extern const struct m_sub_options mp_subtitle_sub_opts;
|
||||||
extern const struct m_sub_options mp_sub_filter_opts;
|
extern const struct m_sub_options mp_sub_filter_opts;
|
||||||
|
13
video/cuda.c
13
video/cuda.c
@ -17,25 +17,24 @@
|
|||||||
|
|
||||||
#include "hwdec.h"
|
#include "hwdec.h"
|
||||||
#include "options/m_config.h"
|
#include "options/m_config.h"
|
||||||
|
#include "options/options.h"
|
||||||
|
|
||||||
#include <libavutil/hwcontext.h>
|
#include <libavutil/hwcontext.h>
|
||||||
|
|
||||||
static struct AVBufferRef *cuda_create_standalone(struct mpv_global *global,
|
static struct AVBufferRef *cuda_create_standalone(struct mpv_global *global,
|
||||||
struct mp_log *log, struct hwcontext_create_dev_params *params)
|
struct mp_log *log, struct hwcontext_create_dev_params *params)
|
||||||
{
|
{
|
||||||
int decode_dev_idx;
|
struct cuda_opts *opts = mp_get_config_group(NULL, global, &cuda_conf);
|
||||||
mp_read_option_raw(global, "cuda-decode-device", &m_option_type_choice,
|
|
||||||
&decode_dev_idx);
|
|
||||||
|
|
||||||
char *decode_dev = NULL;
|
char *decode_dev = NULL;
|
||||||
if (decode_dev_idx != -1) {
|
if (opts->cuda_device != -1)
|
||||||
decode_dev = talloc_asprintf(NULL, "%d", decode_dev_idx);
|
decode_dev = talloc_asprintf(NULL, "%d", opts->cuda_device);
|
||||||
}
|
|
||||||
|
|
||||||
AVBufferRef* ref = NULL;
|
AVBufferRef* ref = NULL;
|
||||||
av_hwdevice_ctx_create(&ref, AV_HWDEVICE_TYPE_CUDA, decode_dev, NULL, 0);
|
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;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "hwdec_cuda.h"
|
#include "hwdec_cuda.h"
|
||||||
#include "options/m_config.h"
|
#include "options/m_config.h"
|
||||||
|
#include "options/options.h"
|
||||||
#include "video/out/opengl/formats.h"
|
#include "video/out/opengl/formats.h"
|
||||||
#include "video/out/opengl/ra_gl.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;
|
p->decode_ctx = p->display_ctx;
|
||||||
|
|
||||||
int decode_dev_idx = -1;
|
struct cuda_opts *opts = mp_get_config_group(NULL, hw->global, &cuda_conf);
|
||||||
mp_read_option_raw(hw->global, "cuda-decode-device", &m_option_type_choice,
|
int decode_dev_idx = opts->cuda_device;
|
||||||
&decode_dev_idx);
|
talloc_free(opts);
|
||||||
|
|
||||||
if (decode_dev_idx > -1) {
|
if (decode_dev_idx > -1) {
|
||||||
CUcontext dummy;
|
CUcontext dummy;
|
||||||
|
Loading…
Reference in New Issue
Block a user