summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-12 01:28:14 +0200
committerwm4 <wm4@nowhere>2013-09-12 01:34:42 +0200
commit75e63ebb24f8866607996cb40ea56f6c3121b9c9 (patch)
tree51b7575e0112b0da3e00fe97ccd09dd2ceeeb25b /video
parentbeb1aa59885bb84ace9a055963af0fc756e69547 (diff)
downloadmpv-75e63ebb24f8866607996cb40ea56f6c3121b9c9.tar.bz2
mpv-75e63ebb24f8866607996cb40ea56f6c3121b9c9.tar.xz
gl_lcms: mp_msg conversion
Have to deal with some dumb stuff in LittleCMS2's API: its error handler is global.
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_lcms.c28
-rw-r--r--video/out/gl_lcms.h3
-rw-r--r--video/out/vo_opengl.c2
3 files changed, 22 insertions, 11 deletions
diff --git a/video/out/gl_lcms.c b/video/out/gl_lcms.c
index 6bda41cfe4..d903ec4055 100644
--- a/video/out/gl_lcms.c
+++ b/video/out/gl_lcms.c
@@ -76,10 +76,15 @@ const struct m_sub_options mp_icc_conf = {
},
};
+// lcms2 only provides a global error handler function, so we have to do this.
+// Not setting a lcms2 error handler will suppress any error messages.
+static struct mp_log *lcms2_dumb_crap;
+
static void lcms2_error_handler(cmsContext ctx, cmsUInt32Number code,
const char *msg)
{
- mp_msg(MSGT_VO, MSGL_ERR, "[gl] lcms2: %s\n", msg);
+ if (lcms2_dumb_crap)
+ mp_msg_log(lcms2_dumb_crap, MSGL_ERR, "lcms2: %s\n", msg);
}
static struct bstr load_file(void *talloc_ctx, const char *filename)
@@ -95,7 +100,7 @@ static struct bstr load_file(void *talloc_ctx, const char *filename)
#define LUT3D_CACHE_HEADER "mpv 3dlut cache 1.0\n"
-struct lut3d *mp_load_icc(struct mp_icc_opts *opts)
+struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log)
{
int s_r, s_g, s_b;
if (!parse_3dlut_size(opts->size_str, &s_r, &s_g, &s_b))
@@ -107,7 +112,7 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts)
void *tmp = talloc_new(NULL);
uint16_t *output = talloc_array(tmp, uint16_t, s_r * s_g * s_b * 3);
- mp_msg(MSGT_VO, MSGL_INFO, "[gl] Opening ICC profile '%s'\n", opts->profile);
+ mp_msg_log(log, MSGL_INFO, "Opening ICC profile '%s'\n", opts->profile);
struct bstr iccdata = load_file(tmp, opts->profile);
if (!iccdata.len)
goto error_exit;
@@ -117,8 +122,8 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts)
// check cache
if (opts->cache) {
- mp_msg(MSGT_VO, MSGL_INFO, "[gl] Opening 3D LUT cache in file '%s'.\n",
- opts->cache);
+ mp_msg_log(log, MSGL_INFO, "Opening 3D LUT cache in file '%s'.\n",
+ opts->cache);
struct bstr cachedata = load_file(tmp, opts->cache);
if (bstr_eatstart(&cachedata, bstr0(LUT3D_CACHE_HEADER))
&& bstr_eatstart(&cachedata, bstr0(cache_info))
@@ -128,10 +133,11 @@ struct lut3d *mp_load_icc(struct mp_icc_opts *opts)
memcpy(output, cachedata.start, cachedata.len);
goto done;
} else {
- mp_msg(MSGT_VO, MSGL_WARN, "[gl] 3D LUT cache invalid!\n");
+ mp_msg_log(log, MSGL_WARN, "3D LUT cache invalid!\n");
}
}
+ lcms2_dumb_crap = log;
cmsSetLogErrorHandler(lcms2_error_handler);
cmsHPROFILE profile = cmsOpenProfileFromMem(iccdata.start, iccdata.len);
@@ -193,11 +199,15 @@ done: ;
.size = {s_r, s_g, s_b},
};
+ lcms2_dumb_crap = NULL;
+ cmsSetLogErrorHandler(NULL);
talloc_free(tmp);
return lut;
error_exit:
- mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Error loading ICC profile.\n");
+ mp_msg_log(log, MSGL_FATAL, "Error loading ICC profile.\n");
+ lcms2_dumb_crap = NULL;
+ cmsSetLogErrorHandler(NULL);
talloc_free(tmp);
return NULL;
}
@@ -210,9 +220,9 @@ const struct m_sub_options mp_icc_conf = {
.defaults = &(const struct mp_icc_opts) {0},
};
-struct lut3d *mp_load_icc(struct mp_icc_opts *opts)
+struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log)
{
- mp_msg(MSGT_VO, MSGL_FATAL, "[gl] LCMS2 support not compiled.\n");
+ mp_msg_log(log, MSGL_FATAL, "LCMS2 support not compiled.\n");
return NULL;
}
diff --git a/video/out/gl_lcms.h b/video/out/gl_lcms.h
index 1debef485b..ff51c7d13f 100644
--- a/video/out/gl_lcms.h
+++ b/video/out/gl_lcms.h
@@ -11,6 +11,7 @@ struct mp_icc_opts {
};
struct lut3d;
-struct lut3d *mp_load_icc(struct mp_icc_opts *opts);
+struct mp_log;
+struct lut3d *mp_load_icc(struct mp_icc_opts *opts, struct mp_log *log);
#endif
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 9253920049..7f4c05ac58 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -318,7 +318,7 @@ static int preinit(struct vo *vo)
gl_video_set_options(p->renderer, p->renderer_opts);
if (p->icc_opts->profile) {
- struct lut3d *lut3d = mp_load_icc(p->icc_opts);
+ struct lut3d *lut3d = mp_load_icc(p->icc_opts, vo->log);
if (!lut3d)
goto err_out;
gl_video_set_lut3d(p->renderer, lut3d);