summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-08 01:00:42 +0100
committerwm4 <wm4@nowhere>2015-01-08 01:03:09 +0100
commitd6aac7f9308b868d7a6d073814d6eec3cda0ed6c (patch)
treeb2b6bfeae3cf977b4f1ee755b83ea4dda2e93646
parentae8a91d6b64f7ebdcce937a332830be19b5fc7e2 (diff)
downloadmpv-d6aac7f9308b868d7a6d073814d6eec3cda0ed6c.tar.bz2
mpv-d6aac7f9308b868d7a6d073814d6eec3cda0ed6c.tar.xz
vo_opengl: gl_lcms: implement change detection for memory profiles
This affects OSX, where memory profiles are updated e.g. on fullscreen switches. The profile most likely doesn't change, but the LUT will be generated and reloaded anyway. Somewhat of a regression from commit f811348. Fixes #1439.
-rw-r--r--video/out/gl_lcms.c23
-rw-r--r--video/out/gl_lcms.h1
-rw-r--r--video/out/vo_opengl.c2
3 files changed, 26 insertions, 0 deletions
diff --git a/video/out/gl_lcms.c b/video/out/gl_lcms.c
index 7f6b54e38e..8f65459ca8 100644
--- a/video/out/gl_lcms.c
+++ b/video/out/gl_lcms.c
@@ -44,6 +44,7 @@ struct gl_lcms {
void *icc_data;
size_t icc_size;
char *icc_path;
+ bool changed;
struct mp_log *log;
struct mpv_global *global;
@@ -134,6 +135,7 @@ struct gl_lcms *gl_lcms_init(void *talloc_ctx, struct mp_log *log,
*p = (struct gl_lcms) {
.global = global,
.log = log,
+ .changed = true,
};
return p;
}
@@ -143,6 +145,7 @@ void gl_lcms_set_options(struct gl_lcms *p, struct mp_icc_opts *opts)
p->opts = *opts;
p->icc_path = talloc_strdup(p, p->opts.profile);
load_profile(p);
+ p->changed = true; // probably
}
// Warning: profile.start must point to a ta allocation, and the function
@@ -152,6 +155,16 @@ void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile)
if (!p->opts.profile_auto)
return;
+ if (!p->icc_path && p->icc_data && profile->start &&
+ profile->len == p->icc_size &&
+ memcmp(profile->start, p->icc_data, p->icc_size) == 0)
+ {
+ talloc_free(profile->start);
+ return;
+ }
+
+ p->changed = true;
+
talloc_free(p->icc_path);
p->icc_path = NULL;
@@ -161,6 +174,15 @@ void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile)
p->icc_size = profile->len;
}
+// Return and _reset_ whether the lookul table has changed since the last call.
+// If it has changed, gl_lcms_get_lut3d() should be called.
+bool gl_lcms_has_changed(struct gl_lcms *p)
+{
+ bool change = p->changed;
+ p->changed = false;
+ return change;
+}
+
#define LUT3D_CACHE_HEADER "mpv 3dlut cache 1.0\n"
bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **result_lut3d)
@@ -313,5 +335,6 @@ struct gl_lcms *gl_lcms_init(void *talloc_ctx, struct mp_log *log,
void gl_lcms_set_options(struct gl_lcms *p, struct mp_icc_opts *opts) { }
void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile) { }
bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **x) { return false; }
+bool gl_lcms_has_changed(struct gl_lcms *p) { return false; }
#endif
diff --git a/video/out/gl_lcms.h b/video/out/gl_lcms.h
index 2b34d62cca..883b485f66 100644
--- a/video/out/gl_lcms.h
+++ b/video/out/gl_lcms.h
@@ -25,5 +25,6 @@ struct gl_lcms *gl_lcms_init(void *talloc_ctx, struct mp_log *log,
void gl_lcms_set_options(struct gl_lcms *p, struct mp_icc_opts *opts);
void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile);
bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **);
+bool gl_lcms_has_changed(struct gl_lcms *p);
#endif
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 2ed3785154..d8269bdb01 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -244,6 +244,8 @@ static void call_request_hwdec_api(struct mp_hwdec_info *info,
static bool update_icc_profile(struct gl_priv *p)
{
struct lut3d *lut3d = NULL;
+ if (!gl_lcms_has_changed(p->cms))
+ return true;
if (gl_lcms_get_lut3d(p->cms, &lut3d) && !lut3d)
return false;
gl_video_set_lut3d(p->renderer, lut3d);