mirror of https://github.com/mpv-player/mpv
vo_opengl: runtime icc profile switching
The changes in vo_opengl.c are merely for adding the icc options to the set of options than can be changed with the vo_cmdline command.
This commit is contained in:
parent
99044308b5
commit
7f39b4655e
|
@ -1214,12 +1214,17 @@ void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d)
|
||||||
{
|
{
|
||||||
GL *gl = p->gl;
|
GL *gl = p->gl;
|
||||||
|
|
||||||
assert(!p->lut_3d_texture);
|
if (!lut3d) {
|
||||||
|
if (p->use_lut_3d) {
|
||||||
if (!lut3d)
|
p->use_lut_3d = false;
|
||||||
|
reinit_rendering(p);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!p->lut_3d_texture)
|
||||||
|
gl->GenTextures(1, &p->lut_3d_texture);
|
||||||
|
|
||||||
gl->GenTextures(1, &p->lut_3d_texture);
|
|
||||||
gl->ActiveTexture(GL_TEXTURE0 + TEXUNIT_3DLUT);
|
gl->ActiveTexture(GL_TEXTURE0 + TEXUNIT_3DLUT);
|
||||||
gl->BindTexture(GL_TEXTURE_3D, p->lut_3d_texture);
|
gl->BindTexture(GL_TEXTURE_3D, p->lut_3d_texture);
|
||||||
gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
@ -1237,6 +1242,8 @@ void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d)
|
||||||
check_gl_features(p);
|
check_gl_features(p);
|
||||||
|
|
||||||
debug_check_gl(p, "after 3d lut creation");
|
debug_check_gl(p, "after 3d lut creation");
|
||||||
|
|
||||||
|
reinit_rendering(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_image_textures(struct gl_video *p, struct video_image *vimg,
|
static void set_image_textures(struct gl_video *p, struct video_image *vimg,
|
||||||
|
|
|
@ -262,27 +262,47 @@ static void unload_hwdec_driver(struct gl_priv *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool update_icc_profile(struct gl_priv *p, struct mp_icc_opts *opts)
|
||||||
|
{
|
||||||
|
struct lut3d *lut3d = NULL;
|
||||||
|
if (opts->profile) {
|
||||||
|
lut3d = mp_load_icc(opts, p->vo->log, p->vo->global);
|
||||||
|
if (!lut3d)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
gl_video_set_lut3d(p->renderer, lut3d);
|
||||||
|
talloc_free(lut3d);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool reparse_cmdline(struct gl_priv *p, char *args)
|
static bool reparse_cmdline(struct gl_priv *p, char *args)
|
||||||
{
|
{
|
||||||
struct m_config *cfg = NULL;
|
struct m_config *cfg = NULL;
|
||||||
struct gl_video_opts *opts = NULL;
|
struct gl_priv *opts = NULL;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
|
// list of options which can be changed at runtime
|
||||||
|
#define OPT_BASE_STRUCT struct gl_priv
|
||||||
|
static const struct m_option change_otps[] = {
|
||||||
|
OPT_SUBSTRUCT("", renderer_opts, gl_video_conf, 0),
|
||||||
|
OPT_SUBSTRUCT("", icc_opts, mp_icc_conf, 0),
|
||||||
|
{0}
|
||||||
|
};
|
||||||
|
#undef OPT_BASE_STRUCT
|
||||||
|
|
||||||
if (strcmp(args, "-") == 0) {
|
if (strcmp(args, "-") == 0) {
|
||||||
opts = p->renderer_opts;
|
opts = p;
|
||||||
} else {
|
} else {
|
||||||
const struct gl_priv *vodef = p->vo->driver->priv_defaults;
|
const struct gl_priv *vodef = p->vo->driver->priv_defaults;
|
||||||
const struct gl_video_opts *def =
|
cfg = m_config_new(NULL, p->vo->log, sizeof(*opts), vodef, change_otps);
|
||||||
vodef ? vodef->renderer_opts : gl_video_conf.defaults;
|
|
||||||
cfg = m_config_new(NULL, p->vo->log, sizeof(*opts), def,
|
|
||||||
gl_video_conf.opts);
|
|
||||||
opts = cfg->optstruct;
|
opts = cfg->optstruct;
|
||||||
r = m_config_parse_suboptions(cfg, "opengl", args);
|
r = m_config_parse_suboptions(cfg, "opengl", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
mpgl_lock(p->glctx);
|
mpgl_lock(p->glctx);
|
||||||
gl_video_set_options(p->renderer, opts);
|
gl_video_set_options(p->renderer, opts->renderer_opts);
|
||||||
|
update_icc_profile(p, opts->icc_opts);
|
||||||
resize(p);
|
resize(p);
|
||||||
mpgl_unlock(p->glctx);
|
mpgl_unlock(p->glctx);
|
||||||
}
|
}
|
||||||
|
@ -396,14 +416,8 @@ static int preinit(struct vo *vo)
|
||||||
gl_video_set_output_depth(p->renderer, p->glctx->depth_r, p->glctx->depth_g,
|
gl_video_set_output_depth(p->renderer, p->glctx->depth_r, p->glctx->depth_g,
|
||||||
p->glctx->depth_b);
|
p->glctx->depth_b);
|
||||||
gl_video_set_options(p->renderer, p->renderer_opts);
|
gl_video_set_options(p->renderer, p->renderer_opts);
|
||||||
|
if (!update_icc_profile(p, p->icc_opts))
|
||||||
if (p->icc_opts->profile) {
|
goto err_out;
|
||||||
struct lut3d *lut3d = mp_load_icc(p->icc_opts, vo->log, vo->global);
|
|
||||||
if (!lut3d)
|
|
||||||
goto err_out;
|
|
||||||
gl_video_set_lut3d(p->renderer, lut3d);
|
|
||||||
talloc_free(lut3d);
|
|
||||||
}
|
|
||||||
|
|
||||||
mpgl_unset_context(p->glctx);
|
mpgl_unset_context(p->glctx);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue