mirror of https://github.com/mpv-player/mpv
vo_opengl: move all icc handling from vo_opengl.c to video.c
Originally, video.c did not access any CMS things (other than lut3d being set on it), but this has changed. In practice, almost all accesses to it have moved to video.c. vo_opengl only created it, and set the auto icc profile path. Complete the move. Some things wrt. option handling are a bit fishy. (But when is this not the case.) icc-profile-auto was not tested, but the distributed human CI will take care of it.
This commit is contained in:
parent
2179879172
commit
026b75e7f5
|
@ -145,7 +145,7 @@ void gl_lcms_set_options(struct gl_lcms *p, struct mp_icc_opts *opts)
|
||||||
// takes over ownership.
|
// takes over ownership.
|
||||||
void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile)
|
void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile)
|
||||||
{
|
{
|
||||||
if (!p->opts.profile_auto) {
|
if (!p->opts.profile_auto || (p->icc_path && p->icc_path[0])) {
|
||||||
talloc_free(profile->start);
|
talloc_free(profile->start);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,6 +458,7 @@ const struct m_sub_options gl_video_conf = {
|
||||||
prescale_downscaling_threshold, 0, 0.0, 32.0),
|
prescale_downscaling_threshold, 0, 0.0, 32.0),
|
||||||
OPT_SUBSTRUCT("superxbr", superxbr_opts, superxbr_conf, 0),
|
OPT_SUBSTRUCT("superxbr", superxbr_opts, superxbr_conf, 0),
|
||||||
OPT_SUBSTRUCT("nnedi3", nnedi3_opts, nnedi3_conf, 0),
|
OPT_SUBSTRUCT("nnedi3", nnedi3_opts, nnedi3_conf, 0),
|
||||||
|
OPT_SUBSTRUCT("", icc_opts, mp_icc_conf, 0),
|
||||||
|
|
||||||
OPT_REMOVED("approx-gamma", "this is always enabled now"),
|
OPT_REMOVED("approx-gamma", "this is always enabled now"),
|
||||||
OPT_REMOVED("cscale-down", "chroma is never downscaled"),
|
OPT_REMOVED("cscale-down", "chroma is never downscaled"),
|
||||||
|
@ -608,8 +609,12 @@ static void uninit_rendering(struct gl_video *p)
|
||||||
gl_sc_reset_error(p->sc);
|
gl_sc_reset_error(p->sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_video_update_profile(struct gl_video *p)
|
// Warning: profile.start must point to a ta allocation, and the function
|
||||||
|
// takes over ownership.
|
||||||
|
void gl_video_set_icc_profile(struct gl_video *p, bstr icc_data)
|
||||||
{
|
{
|
||||||
|
gl_lcms_set_memory_profile(p->cms, &icc_data);
|
||||||
|
|
||||||
if (p->use_lut_3d)
|
if (p->use_lut_3d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -617,6 +622,11 @@ void gl_video_update_profile(struct gl_video *p)
|
||||||
check_gl_features(p);
|
check_gl_features(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gl_video_icc_auto_enabled(struct gl_video *p)
|
||||||
|
{
|
||||||
|
return p->opts.icc_opts ? p->opts.icc_opts->profile_auto : false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool gl_video_get_lut3d(struct gl_video *p, enum mp_csp_prim prim,
|
static bool gl_video_get_lut3d(struct gl_video *p, enum mp_csp_prim prim,
|
||||||
enum mp_csp_trc trc)
|
enum mp_csp_trc trc)
|
||||||
{
|
{
|
||||||
|
@ -3450,8 +3460,7 @@ void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd)
|
||||||
reinit_osd(p);
|
reinit_osd(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g,
|
struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g)
|
||||||
struct gl_lcms *cms)
|
|
||||||
{
|
{
|
||||||
if (gl->version < 210 && gl->es < 200) {
|
if (gl->version < 210 && gl->es < 200) {
|
||||||
mp_err(log, "At least OpenGL 2.1 or OpenGL ES 2.0 required.\n");
|
mp_err(log, "At least OpenGL 2.1 or OpenGL ES 2.0 required.\n");
|
||||||
|
@ -3463,7 +3472,7 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g,
|
||||||
.gl = gl,
|
.gl = gl,
|
||||||
.global = g,
|
.global = g,
|
||||||
.log = log,
|
.log = log,
|
||||||
.cms = cms,
|
.cms = gl_lcms_init(p, log, g),
|
||||||
.opts = gl_video_opts_def,
|
.opts = gl_video_opts_def,
|
||||||
.texture_16bit_depth = 16,
|
.texture_16bit_depth = 16,
|
||||||
.sc = gl_sc_create(gl, log),
|
.sc = gl_sc_create(gl, log),
|
||||||
|
@ -3516,6 +3525,7 @@ static void assign_options(struct gl_video_opts *dst, struct gl_video_opts *src)
|
||||||
talloc_free(dst->deband_opts);
|
talloc_free(dst->deband_opts);
|
||||||
talloc_free(dst->superxbr_opts);
|
talloc_free(dst->superxbr_opts);
|
||||||
talloc_free(dst->nnedi3_opts);
|
talloc_free(dst->nnedi3_opts);
|
||||||
|
talloc_free(dst->icc_opts);
|
||||||
|
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
|
|
||||||
|
@ -3532,6 +3542,11 @@ static void assign_options(struct gl_video_opts *dst, struct gl_video_opts *src)
|
||||||
src->nnedi3_opts);
|
src->nnedi3_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src->icc_opts) {
|
||||||
|
dst->icc_opts = m_sub_options_copy(NULL, &mp_icc_conf,
|
||||||
|
src->icc_opts);
|
||||||
|
}
|
||||||
|
|
||||||
for (int n = 0; n < SCALER_COUNT; n++) {
|
for (int n = 0; n < SCALER_COUNT; n++) {
|
||||||
dst->scaler[n].kernel.name =
|
dst->scaler[n].kernel.name =
|
||||||
(char *)handle_scaler_opt(dst->scaler[n].kernel.name,
|
(char *)handle_scaler_opt(dst->scaler[n].kernel.name,
|
||||||
|
@ -3550,6 +3565,12 @@ void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts)
|
||||||
{
|
{
|
||||||
assign_options(&p->opts, opts);
|
assign_options(&p->opts, opts);
|
||||||
|
|
||||||
|
if (p->opts.icc_opts) {
|
||||||
|
gl_lcms_set_options(p->cms, p->opts.icc_opts);
|
||||||
|
if (p->opts.icc_opts->profile && p->opts.icc_opts->profile[0])
|
||||||
|
p->use_lut_3d = true;
|
||||||
|
}
|
||||||
|
|
||||||
check_gl_features(p);
|
check_gl_features(p);
|
||||||
uninit_rendering(p);
|
uninit_rendering(p);
|
||||||
gl_video_setup_hooks(p);
|
gl_video_setup_hooks(p);
|
||||||
|
|
|
@ -148,6 +148,7 @@ struct gl_video_opts {
|
||||||
float prescale_downscaling_threshold;
|
float prescale_downscaling_threshold;
|
||||||
struct superxbr_opts *superxbr_opts;
|
struct superxbr_opts *superxbr_opts;
|
||||||
struct nnedi3_opts *nnedi3_opts;
|
struct nnedi3_opts *nnedi3_opts;
|
||||||
|
struct mp_icc_opts *icc_opts;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct m_sub_options gl_video_conf;
|
extern const struct m_sub_options gl_video_conf;
|
||||||
|
@ -157,15 +158,13 @@ extern const struct gl_video_opts gl_video_opts_def;
|
||||||
struct gl_video;
|
struct gl_video;
|
||||||
struct vo_frame;
|
struct vo_frame;
|
||||||
|
|
||||||
struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g,
|
struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct mpv_global *g);
|
||||||
struct gl_lcms *cms);
|
|
||||||
void gl_video_uninit(struct gl_video *p);
|
void gl_video_uninit(struct gl_video *p);
|
||||||
void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd);
|
void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd);
|
||||||
void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts);
|
void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts);
|
||||||
bool gl_video_check_format(struct gl_video *p, int mp_format);
|
bool gl_video_check_format(struct gl_video *p, int mp_format);
|
||||||
void gl_video_config(struct gl_video *p, struct mp_image_params *params);
|
void gl_video_config(struct gl_video *p, struct mp_image_params *params);
|
||||||
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b);
|
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b);
|
||||||
void gl_video_update_profile(struct gl_video *p);
|
|
||||||
void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, int fbo);
|
void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, int fbo);
|
||||||
void gl_video_resize(struct gl_video *p, int vp_w, int vp_h,
|
void gl_video_resize(struct gl_video *p, int vp_w, int vp_h,
|
||||||
struct mp_rect *src, struct mp_rect *dst,
|
struct mp_rect *src, struct mp_rect *dst,
|
||||||
|
@ -179,6 +178,8 @@ void gl_video_set_debug(struct gl_video *p, bool enable);
|
||||||
float gl_video_scale_ambient_lux(float lmin, float lmax,
|
float gl_video_scale_ambient_lux(float lmin, float lmax,
|
||||||
float rmin, float rmax, float lux);
|
float rmin, float rmax, float lux);
|
||||||
void gl_video_set_ambient_lux(struct gl_video *p, int lux);
|
void gl_video_set_ambient_lux(struct gl_video *p, int lux);
|
||||||
|
void gl_video_set_icc_profile(struct gl_video *p, bstr icc_data);
|
||||||
|
bool gl_video_icc_auto_enabled(struct gl_video *p);
|
||||||
|
|
||||||
void gl_video_set_gl_state(struct gl_video *p);
|
void gl_video_set_gl_state(struct gl_video *p);
|
||||||
void gl_video_unset_gl_state(struct gl_video *p);
|
void gl_video_unset_gl_state(struct gl_video *p);
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
#include "filter_kernels.h"
|
#include "filter_kernels.h"
|
||||||
#include "video/hwdec.h"
|
#include "video/hwdec.h"
|
||||||
#include "opengl/video.h"
|
#include "opengl/video.h"
|
||||||
#include "opengl/lcms.h"
|
|
||||||
|
|
||||||
#define NUM_VSYNC_FENCES 10
|
#define NUM_VSYNC_FENCES 10
|
||||||
|
|
||||||
|
@ -56,13 +55,11 @@ struct gl_priv {
|
||||||
GL *gl;
|
GL *gl;
|
||||||
|
|
||||||
struct gl_video *renderer;
|
struct gl_video *renderer;
|
||||||
struct gl_lcms *cms;
|
|
||||||
|
|
||||||
struct gl_hwdec *hwdec;
|
struct gl_hwdec *hwdec;
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
struct gl_video_opts *renderer_opts;
|
struct gl_video_opts *renderer_opts;
|
||||||
struct mp_icc_opts *icc_opts;
|
|
||||||
int use_glFinish;
|
int use_glFinish;
|
||||||
int waitvsync;
|
int waitvsync;
|
||||||
int use_gl_debug;
|
int use_gl_debug;
|
||||||
|
@ -216,8 +213,7 @@ static void call_request_hwdec_api(void *ctx, enum hwdec_type type)
|
||||||
|
|
||||||
static void get_and_update_icc_profile(struct gl_priv *p, int *events)
|
static void get_and_update_icc_profile(struct gl_priv *p, int *events)
|
||||||
{
|
{
|
||||||
bool has_profile = p->icc_opts->profile && p->icc_opts->profile[0];
|
if (gl_video_icc_auto_enabled(p->renderer)) {
|
||||||
if (p->icc_opts->profile_auto && !has_profile) {
|
|
||||||
MP_VERBOSE(p, "Querying ICC profile...\n");
|
MP_VERBOSE(p, "Querying ICC profile...\n");
|
||||||
bstr icc = bstr0(NULL);
|
bstr icc = bstr0(NULL);
|
||||||
int r = mpgl_control(p->glctx, events, VOCTRL_GET_ICC_PROFILE, &icc);
|
int r = mpgl_control(p->glctx, events, VOCTRL_GET_ICC_PROFILE, &icc);
|
||||||
|
@ -229,13 +225,9 @@ static void get_and_update_icc_profile(struct gl_priv *p, int *events)
|
||||||
MP_ERR(p, "icc-profile-auto not implemented on this platform.\n");
|
MP_ERR(p, "icc-profile-auto not implemented on this platform.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_lcms_set_memory_profile(p->cms, &icc);
|
gl_video_set_icc_profile(p->renderer, icc);
|
||||||
has_profile = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_profile)
|
|
||||||
gl_video_update_profile(p->renderer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_and_update_ambient_lighting(struct gl_priv *p, int *events)
|
static void get_and_update_ambient_lighting(struct gl_priv *p, int *events)
|
||||||
|
@ -407,17 +399,13 @@ static int preinit(struct vo *vo)
|
||||||
MP_VERBOSE(vo, "swap_control extension missing.\n");
|
MP_VERBOSE(vo, "swap_control extension missing.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
p->cms = gl_lcms_init(p, vo->log, vo->global);
|
p->renderer = gl_video_init(p->gl, vo->log, vo->global);
|
||||||
if (!p->cms)
|
|
||||||
goto err_out;
|
|
||||||
p->renderer = gl_video_init(p->gl, vo->log, vo->global, p->cms);
|
|
||||||
if (!p->renderer)
|
if (!p->renderer)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
gl_video_set_osd_source(p->renderer, vo->osd);
|
gl_video_set_osd_source(p->renderer, vo->osd);
|
||||||
gl_video_set_options(p->renderer, p->renderer_opts);
|
gl_video_set_options(p->renderer, p->renderer_opts);
|
||||||
gl_video_configure_queue(p->renderer, vo);
|
gl_video_configure_queue(p->renderer, vo);
|
||||||
|
|
||||||
gl_lcms_set_options(p->cms, p->icc_opts);
|
|
||||||
get_and_update_icc_profile(p, &(int){0});
|
get_and_update_icc_profile(p, &(int){0});
|
||||||
|
|
||||||
vo->hwdec_devs = hwdec_devices_create();
|
vo->hwdec_devs = hwdec_devices_create();
|
||||||
|
@ -455,7 +443,6 @@ static const struct m_option options[] = {
|
||||||
OPT_INTRANGE("vsync-fences", opt_vsync_fences, 0, 0, NUM_VSYNC_FENCES),
|
OPT_INTRANGE("vsync-fences", opt_vsync_fences, 0, 0, NUM_VSYNC_FENCES),
|
||||||
|
|
||||||
OPT_SUBSTRUCT("", renderer_opts, gl_video_conf, 0),
|
OPT_SUBSTRUCT("", renderer_opts, gl_video_conf, 0),
|
||||||
OPT_SUBSTRUCT("", icc_opts, mp_icc_conf, 0),
|
|
||||||
{0},
|
{0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ int mpv_opengl_cb_init_gl(struct mpv_opengl_cb_context *ctx, const char *exts,
|
||||||
|
|
||||||
mpgl_load_functions2(ctx->gl, get_proc_address, get_proc_address_ctx,
|
mpgl_load_functions2(ctx->gl, get_proc_address, get_proc_address_ctx,
|
||||||
exts, ctx->log);
|
exts, ctx->log);
|
||||||
ctx->renderer = gl_video_init(ctx->gl, ctx->log, ctx->global, NULL);
|
ctx->renderer = gl_video_init(ctx->gl, ctx->log, ctx->global);
|
||||||
if (!ctx->renderer)
|
if (!ctx->renderer)
|
||||||
return MPV_ERROR_UNSUPPORTED;
|
return MPV_ERROR_UNSUPPORTED;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue