2013-03-01 20:19:20 +00:00
|
|
|
/*
|
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
|
|
|
* mpv is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* mpv is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* You can alternatively redistribute this file and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "talloc.h"
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "stream/stream.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/common.h"
|
2014-08-29 10:09:04 +00:00
|
|
|
#include "misc/bstr.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_option.h"
|
|
|
|
#include "options/path.h"
|
2013-03-01 20:19:20 +00:00
|
|
|
|
|
|
|
#include "gl_video.h"
|
|
|
|
#include "gl_lcms.h"
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_LCMS2
|
2013-03-30 02:29:54 +00:00
|
|
|
|
|
|
|
#include <lcms2.h>
|
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
struct gl_lcms {
|
|
|
|
void *icc_data;
|
|
|
|
size_t icc_size;
|
|
|
|
char *icc_path;
|
2015-01-08 00:00:42 +00:00
|
|
|
bool changed;
|
2015-01-07 17:47:27 +00:00
|
|
|
|
|
|
|
struct mp_log *log;
|
|
|
|
struct mpv_global *global;
|
|
|
|
struct mp_icc_opts opts;
|
|
|
|
};
|
|
|
|
|
2013-07-22 22:45:23 +00:00
|
|
|
static bool parse_3dlut_size(const char *arg, int *p1, int *p2, int *p3)
|
2013-03-01 20:19:20 +00:00
|
|
|
{
|
2013-07-22 22:45:23 +00:00
|
|
|
if (sscanf(arg, "%dx%dx%d", p1, p2, p3) != 3)
|
2013-03-01 20:19:20 +00:00
|
|
|
return false;
|
|
|
|
for (int n = 0; n < 3; n++) {
|
|
|
|
int s = ((int[]) { *p1, *p2, *p3 })[n];
|
2014-03-26 00:46:38 +00:00
|
|
|
if (s < 2 || s > 512 || ((s - 1) & s))
|
2013-03-01 20:19:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-21 19:03:36 +00:00
|
|
|
static int validate_3dlut_size_opt(struct mp_log *log, const m_option_t *opt,
|
|
|
|
struct bstr name, struct bstr param)
|
2013-03-01 20:19:20 +00:00
|
|
|
{
|
|
|
|
int p1, p2, p3;
|
|
|
|
char s[20];
|
|
|
|
snprintf(s, sizeof(s), "%.*s", BSTR_P(param));
|
|
|
|
return parse_3dlut_size(s, &p1, &p2, &p3);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OPT_BASE_STRUCT struct mp_icc_opts
|
|
|
|
const struct m_sub_options mp_icc_conf = {
|
2014-06-10 21:56:05 +00:00
|
|
|
.opts = (const m_option_t[]) {
|
2013-03-01 20:19:20 +00:00
|
|
|
OPT_STRING("icc-profile", profile, 0),
|
2014-02-24 23:04:30 +00:00
|
|
|
OPT_FLAG("icc-profile-auto", profile_auto, 0),
|
2013-03-01 20:19:20 +00:00
|
|
|
OPT_STRING("icc-cache", cache, 0),
|
|
|
|
OPT_INT("icc-intent", intent, 0),
|
|
|
|
OPT_STRING_VALIDATE("3dlut-size", size_str, 0, validate_3dlut_size_opt),
|
|
|
|
{0}
|
|
|
|
},
|
|
|
|
.size = sizeof(struct mp_icc_opts),
|
|
|
|
.defaults = &(const struct mp_icc_opts) {
|
|
|
|
.size_str = "128x256x64",
|
2014-02-26 21:58:48 +00:00
|
|
|
.intent = INTENT_RELATIVE_COLORIMETRIC,
|
2013-03-01 20:19:20 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static void lcms2_error_handler(cmsContext ctx, cmsUInt32Number code,
|
|
|
|
const char *msg)
|
|
|
|
{
|
2015-01-07 17:47:27 +00:00
|
|
|
struct gl_lcms *p = cmsGetContextUserData(ctx);
|
|
|
|
MP_ERR(p, "lcms2: %s\n", msg);
|
2013-03-01 20:19:20 +00:00
|
|
|
}
|
|
|
|
|
2013-12-21 19:36:45 +00:00
|
|
|
static struct bstr load_file(void *talloc_ctx, const char *filename,
|
|
|
|
struct mpv_global *global)
|
2013-03-01 20:19:20 +00:00
|
|
|
{
|
|
|
|
struct bstr res = {0};
|
2013-12-21 19:45:19 +00:00
|
|
|
char *fname = mp_get_user_path(NULL, global, filename);
|
2013-12-21 19:36:45 +00:00
|
|
|
stream_t *s = stream_open(fname, global);
|
2013-03-01 20:19:20 +00:00
|
|
|
if (s) {
|
2013-06-11 10:16:42 +00:00
|
|
|
res = stream_read_complete(s, talloc_ctx, 1000000000);
|
2013-03-01 20:19:20 +00:00
|
|
|
free_stream(s);
|
|
|
|
}
|
2013-12-14 18:50:00 +00:00
|
|
|
talloc_free(fname);
|
2013-03-01 20:19:20 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
static bool load_profile(struct gl_lcms *p)
|
2014-02-24 23:04:30 +00:00
|
|
|
{
|
2015-01-07 17:47:27 +00:00
|
|
|
if (p->icc_data && p->icc_size)
|
2014-02-24 23:04:30 +00:00
|
|
|
return true;
|
2015-01-07 17:47:27 +00:00
|
|
|
|
|
|
|
if (!p->icc_path)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
MP_INFO(p, "Opening ICC profile '%s'\n", p->icc_path);
|
|
|
|
struct bstr iccdata = load_file(p, p->icc_path, p->global);
|
|
|
|
if (!iccdata.len)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
p->icc_data = iccdata.start;
|
|
|
|
p->icc_size = iccdata.len;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct gl_lcms *gl_lcms_init(void *talloc_ctx, struct mp_log *log,
|
|
|
|
struct mpv_global *global)
|
|
|
|
{
|
|
|
|
struct gl_lcms *p = talloc_ptrtype(talloc_ctx, p);
|
|
|
|
*p = (struct gl_lcms) {
|
|
|
|
.global = global,
|
|
|
|
.log = log,
|
2015-01-08 00:00:42 +00:00
|
|
|
.changed = true,
|
2015-01-07 17:47:27 +00:00
|
|
|
};
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2015-01-08 00:00:42 +00:00
|
|
|
p->changed = true; // probably
|
2015-01-07 17:47:27 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 23:55:57 +00:00
|
|
|
// Warning: profile.start must point to a ta allocation, and the function
|
|
|
|
// takes over ownership.
|
2015-01-07 17:47:27 +00:00
|
|
|
void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile)
|
|
|
|
{
|
2015-01-26 01:11:14 +00:00
|
|
|
if (!p->opts.profile_auto) {
|
|
|
|
talloc_free(profile->start);
|
2015-01-07 17:47:27 +00:00
|
|
|
return;
|
2015-01-26 01:11:14 +00:00
|
|
|
}
|
2015-01-07 17:47:27 +00:00
|
|
|
|
2015-01-08 00:00:42 +00:00
|
|
|
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;
|
|
|
|
|
2015-01-07 23:55:57 +00:00
|
|
|
talloc_free(p->icc_path);
|
|
|
|
p->icc_path = NULL;
|
2015-01-07 17:47:27 +00:00
|
|
|
|
2015-01-07 23:55:57 +00:00
|
|
|
talloc_free(p->icc_data);
|
2015-01-07 17:47:27 +00:00
|
|
|
|
|
|
|
p->icc_data = talloc_steal(p, profile->start);
|
|
|
|
p->icc_size = profile->len;
|
2014-02-24 23:04:30 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 00:00:42 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2013-03-01 20:19:20 +00:00
|
|
|
#define LUT3D_CACHE_HEADER "mpv 3dlut cache 1.0\n"
|
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **result_lut3d)
|
2013-03-01 20:19:20 +00:00
|
|
|
{
|
|
|
|
int s_r, s_g, s_b;
|
2015-01-07 17:47:27 +00:00
|
|
|
bool result = false;
|
2013-03-01 20:19:20 +00:00
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
if (!parse_3dlut_size(p->opts.size_str, &s_r, &s_g, &s_b))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!p->icc_data && !p->icc_path)
|
|
|
|
return false;
|
2013-03-01 20:19:20 +00:00
|
|
|
|
|
|
|
void *tmp = talloc_new(NULL);
|
|
|
|
uint16_t *output = talloc_array(tmp, uint16_t, s_r * s_g * s_b * 3);
|
2013-12-21 16:55:19 +00:00
|
|
|
struct lut3d *lut = NULL;
|
2014-06-16 14:57:19 +00:00
|
|
|
cmsContext cms = NULL;
|
2013-03-01 20:19:20 +00:00
|
|
|
|
2014-03-01 01:27:00 +00:00
|
|
|
char *cache_info =
|
vo_opengl: Simplify and clarify color correction code
This commit:
- Changes some of the #define and variable names for clarification and
adds comments where appropriate.
- Unifies :srgb and :icc-profile, making them fit into the same step of
the decoding process and removing the weird interactions between both
of them.
- Makes :icc-profile take precedence over :srgb (to significantly reduce
the number of confusing and useless special cases)
- Moves BT709 decompanding (approximate or actual) to the shader in all
cases, making it happen before upscaling (instead of the old 0.45
gamma function). This is the simpler and more proper way to do it.
- Enables the approx gamma function to work with :srgb as well due to
this (since they now share the gamma expansion code).
- Renames :icc-approx-gamma to :approx-gamma since it is no longer tied
to the ICC options or LittleCMS.
- Uses gamma 2.4 as input space for the actual 3DLUT, this is now a
pretty arbitrary factor but I picked 2.4 mainly because a higher pure
power value here seems to produce visually better results with wide
gamut profiles, rather then the previous 1.95 or BT.709.
- Adds the input gamma space to the 3dlut cache header in case we change
it more in the future, or even make it user customizable (though I
don't see why the latter would really be necessary).
- Fixes the OSD's gamma when using :srgb, which was previously still
using the old (0.45) approximation in all cases.
- Updates documentation on :srgb, it was still mentioning the old
behavior from circa a year ago.
This commit should serve to both open up and make the CMS/shader code much
more accessible and less confusing/error-prone and simultaneously also
improve the performance of 3DLUTs with wide gamut color spaces.
I would liked to have made it more modular but almost all of these
changes are interdependent, save for the documentation updates.
Note: Right now, the "3DLUT takes precedence over SRGB" logic is just
coded into gl_lcms.c's compile_shaders function. Ideally, this should be
done earlier, when parsing the options (by overriding the actual
opts.srgb flag) and output a warning to the user.
Note: I'm not sure how well this works together with real-world
subtitles that may need to be color corrected as well. I'm not sure
whether :approx-gamma needs to apply to subtitles as well. I'll need to
test this on proper files later.
Note: As of now, linear light scaling is still intrinsically tied to
either :srgb or :icc-profile. It would be thinkable to have this as an
extra option, :linear-scaling or similar, that could be used with or
without the two color management options.
2014-03-05 02:56:30 +00:00
|
|
|
// Gamma is included in the header to help uniquely identify it,
|
|
|
|
// because we may change the parameter in the future or make it
|
2014-03-26 00:46:38 +00:00
|
|
|
// customizable, same for the primaries.
|
|
|
|
talloc_asprintf(tmp, "intent=%d, size=%dx%dx%d, gamma=2.4, prim=bt2020\n",
|
2015-01-07 17:47:27 +00:00
|
|
|
p->opts.intent, s_r, s_g, s_b);
|
|
|
|
|
|
|
|
bstr iccdata = (bstr) {
|
|
|
|
.start = p->icc_data,
|
|
|
|
.len = p->icc_size,
|
|
|
|
};
|
2013-03-01 20:19:20 +00:00
|
|
|
|
|
|
|
// check cache
|
2015-01-07 17:47:27 +00:00
|
|
|
if (p->opts.cache) {
|
|
|
|
MP_INFO(p, "Opening 3D LUT cache in file '%s'.\n", p->opts.cache);
|
|
|
|
struct bstr cachedata = load_file(tmp, p->opts.cache, p->global);
|
2013-03-01 20:19:20 +00:00
|
|
|
if (bstr_eatstart(&cachedata, bstr0(LUT3D_CACHE_HEADER))
|
|
|
|
&& bstr_eatstart(&cachedata, bstr0(cache_info))
|
|
|
|
&& bstr_eatstart(&cachedata, iccdata)
|
|
|
|
&& cachedata.len == talloc_get_size(output))
|
|
|
|
{
|
|
|
|
memcpy(output, cachedata.start, cachedata.len);
|
|
|
|
goto done;
|
|
|
|
} else {
|
2015-01-07 17:47:27 +00:00
|
|
|
MP_WARN(p, "3D LUT cache invalid!\n");
|
2013-03-01 20:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
cms = cmsCreateContext(NULL, p);
|
2014-06-16 14:57:19 +00:00
|
|
|
if (!cms)
|
|
|
|
goto error_exit;
|
|
|
|
cmsSetLogErrorHandlerTHR(cms, lcms2_error_handler);
|
2013-03-01 20:19:20 +00:00
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
cmsHPROFILE profile =
|
|
|
|
cmsOpenProfileFromMemTHR(cms, p->icc_data, p->icc_size);
|
2013-03-01 20:19:20 +00:00
|
|
|
if (!profile)
|
|
|
|
goto error_exit;
|
|
|
|
|
2014-03-26 00:46:38 +00:00
|
|
|
// We always generate the 3DLUT against BT.2020, and transform into this
|
|
|
|
// space inside the shader if the source differs.
|
2014-06-22 06:33:43 +00:00
|
|
|
struct mp_csp_primaries csp = mp_get_csp_primaries(MP_CSP_PRIM_BT_2020);
|
|
|
|
|
|
|
|
cmsCIExyY wp = {csp.white.x, csp.white.y, 1.0};
|
|
|
|
cmsCIExyYTRIPLE prim = {
|
|
|
|
.Red = {csp.red.x, csp.red.y, 1.0},
|
|
|
|
.Green = {csp.green.x, csp.green.y, 1.0},
|
|
|
|
.Blue = {csp.blue.x, csp.blue.y, 1.0},
|
2013-03-01 20:19:20 +00:00
|
|
|
};
|
2014-02-09 13:26:27 +00:00
|
|
|
|
vo_opengl: Simplify and clarify color correction code
This commit:
- Changes some of the #define and variable names for clarification and
adds comments where appropriate.
- Unifies :srgb and :icc-profile, making them fit into the same step of
the decoding process and removing the weird interactions between both
of them.
- Makes :icc-profile take precedence over :srgb (to significantly reduce
the number of confusing and useless special cases)
- Moves BT709 decompanding (approximate or actual) to the shader in all
cases, making it happen before upscaling (instead of the old 0.45
gamma function). This is the simpler and more proper way to do it.
- Enables the approx gamma function to work with :srgb as well due to
this (since they now share the gamma expansion code).
- Renames :icc-approx-gamma to :approx-gamma since it is no longer tied
to the ICC options or LittleCMS.
- Uses gamma 2.4 as input space for the actual 3DLUT, this is now a
pretty arbitrary factor but I picked 2.4 mainly because a higher pure
power value here seems to produce visually better results with wide
gamut profiles, rather then the previous 1.95 or BT.709.
- Adds the input gamma space to the 3dlut cache header in case we change
it more in the future, or even make it user customizable (though I
don't see why the latter would really be necessary).
- Fixes the OSD's gamma when using :srgb, which was previously still
using the old (0.45) approximation in all cases.
- Updates documentation on :srgb, it was still mentioning the old
behavior from circa a year ago.
This commit should serve to both open up and make the CMS/shader code much
more accessible and less confusing/error-prone and simultaneously also
improve the performance of 3DLUTs with wide gamut color spaces.
I would liked to have made it more modular but almost all of these
changes are interdependent, save for the documentation updates.
Note: Right now, the "3DLUT takes precedence over SRGB" logic is just
coded into gl_lcms.c's compile_shaders function. Ideally, this should be
done earlier, when parsing the options (by overriding the actual
opts.srgb flag) and output a warning to the user.
Note: I'm not sure how well this works together with real-world
subtitles that may need to be color corrected as well. I'm not sure
whether :approx-gamma needs to apply to subtitles as well. I'll need to
test this on proper files later.
Note: As of now, linear light scaling is still intrinsically tied to
either :srgb or :icc-profile. It would be thinkable to have this as an
extra option, :linear-scaling or similar, that could be used with or
without the two color management options.
2014-03-05 02:56:30 +00:00
|
|
|
// 2.4 is arbitrarily used as a gamma compression factor for the 3DLUT,
|
|
|
|
// reducing artifacts due to rounding errors on wide gamut profiles
|
2014-06-16 14:57:19 +00:00
|
|
|
cmsToneCurve *tonecurve = cmsBuildGamma(cms, 2.4);
|
2014-06-22 06:33:43 +00:00
|
|
|
cmsHPROFILE vid_profile = cmsCreateRGBProfileTHR(cms, &wp, &prim,
|
2013-03-01 20:19:20 +00:00
|
|
|
(cmsToneCurve*[3]){tonecurve, tonecurve, tonecurve});
|
|
|
|
cmsFreeToneCurve(tonecurve);
|
2014-06-16 14:57:19 +00:00
|
|
|
cmsHTRANSFORM trafo = cmsCreateTransformTHR(cms, vid_profile, TYPE_RGB_16,
|
|
|
|
profile, TYPE_RGB_16,
|
2015-01-07 17:47:27 +00:00
|
|
|
p->opts.intent,
|
2014-06-16 14:57:19 +00:00
|
|
|
cmsFLAGS_HIGHRESPRECALC);
|
2013-03-01 20:19:20 +00:00
|
|
|
cmsCloseProfile(profile);
|
|
|
|
cmsCloseProfile(vid_profile);
|
|
|
|
|
|
|
|
if (!trafo)
|
|
|
|
goto error_exit;
|
|
|
|
|
|
|
|
// transform a (s_r)x(s_g)x(s_b) cube, with 3 components per channel
|
|
|
|
uint16_t *input = talloc_array(tmp, uint16_t, s_r * 3);
|
|
|
|
for (int b = 0; b < s_b; b++) {
|
|
|
|
for (int g = 0; g < s_g; g++) {
|
|
|
|
for (int r = 0; r < s_r; r++) {
|
|
|
|
input[r * 3 + 0] = r * 65535 / (s_r - 1);
|
|
|
|
input[r * 3 + 1] = g * 65535 / (s_g - 1);
|
|
|
|
input[r * 3 + 2] = b * 65535 / (s_b - 1);
|
|
|
|
}
|
|
|
|
size_t base = (b * s_r * s_g + g * s_r) * 3;
|
|
|
|
cmsDoTransform(trafo, input, output + base, s_r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cmsDeleteTransform(trafo);
|
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
if (p->opts.cache) {
|
|
|
|
char *fname = mp_get_user_path(NULL, p->global, p->opts.cache);
|
2014-04-05 16:05:14 +00:00
|
|
|
FILE *out = fopen(fname, "wb");
|
2013-03-01 20:19:20 +00:00
|
|
|
if (out) {
|
|
|
|
fprintf(out, "%s%s", LUT3D_CACHE_HEADER, cache_info);
|
2015-01-07 17:47:27 +00:00
|
|
|
fwrite(p->icc_data, p->icc_size, 1, out);
|
2013-03-01 20:19:20 +00:00
|
|
|
fwrite(output, talloc_get_size(output), 1, out);
|
|
|
|
fclose(out);
|
|
|
|
}
|
2014-04-05 16:05:14 +00:00
|
|
|
talloc_free(fname);
|
2013-03-01 20:19:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
done: ;
|
|
|
|
|
2013-12-21 16:55:19 +00:00
|
|
|
lut = talloc_ptrtype(NULL, lut);
|
2013-03-01 20:19:20 +00:00
|
|
|
*lut = (struct lut3d) {
|
|
|
|
.data = talloc_steal(lut, output),
|
|
|
|
.size = {s_r, s_g, s_b},
|
|
|
|
};
|
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
*result_lut3d = lut;
|
|
|
|
result = true;
|
|
|
|
|
2013-03-01 20:19:20 +00:00
|
|
|
error_exit:
|
2013-12-21 16:55:19 +00:00
|
|
|
|
2014-06-16 14:57:19 +00:00
|
|
|
if (cms)
|
|
|
|
cmsDeleteContext(cms);
|
2013-12-21 16:55:19 +00:00
|
|
|
|
|
|
|
if (!lut)
|
2015-01-07 17:47:27 +00:00
|
|
|
MP_FATAL(p, "Error loading ICC profile.\n");
|
2013-12-21 16:55:19 +00:00
|
|
|
|
2013-03-01 20:19:20 +00:00
|
|
|
talloc_free(tmp);
|
2015-01-07 17:47:27 +00:00
|
|
|
return result;
|
2013-03-01 20:19:20 +00:00
|
|
|
}
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#else /* HAVE_LCMS2 */
|
2013-03-01 20:19:20 +00:00
|
|
|
|
2013-03-30 02:29:54 +00:00
|
|
|
const struct m_sub_options mp_icc_conf = {
|
2014-06-10 21:56:05 +00:00
|
|
|
.opts = (const m_option_t[]) { {0} },
|
2013-03-30 02:29:54 +00:00
|
|
|
.size = sizeof(struct mp_icc_opts),
|
|
|
|
.defaults = &(const struct mp_icc_opts) {0},
|
|
|
|
};
|
|
|
|
|
2014-03-31 20:31:24 +00:00
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
struct gl_lcms *gl_lcms_init(void *talloc_ctx, struct mp_log *log,
|
|
|
|
struct mpv_global *global)
|
2013-03-01 20:19:20 +00:00
|
|
|
{
|
2015-01-07 17:47:27 +00:00
|
|
|
return (struct gl_lcms *) talloc_new(talloc_ctx);
|
2013-03-01 20:19:20 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 17:47:27 +00:00
|
|
|
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; }
|
2015-01-08 00:00:42 +00:00
|
|
|
bool gl_lcms_has_changed(struct gl_lcms *p) { return false; }
|
2015-01-07 17:47:27 +00:00
|
|
|
|
2013-03-01 20:19:20 +00:00
|
|
|
#endif
|