Chromium Code Reviews| Index: third_party/qcms/src/chain.c |
| diff --git a/third_party/qcms/src/chain.c b/third_party/qcms/src/chain.c |
| index aa8506e41deeed4f2e19f2997cac000dc1c54b12..4e4b000a8a703e2c77cde569e069ded8d9daf01e 100644 |
| --- a/third_party/qcms/src/chain.c |
| +++ b/third_party/qcms/src/chain.c |
| @@ -893,7 +893,7 @@ remove_next: |
| } |
| */ |
| -static struct qcms_modular_transform* qcms_modular_transform_create(qcms_profile *in, qcms_profile *out) |
| +static struct qcms_modular_transform* qcms_modular_transform_create(qcms_profile *in, qcms_profile *out, bool pcs_xyz_only) |
| { |
| struct qcms_modular_transform *first_transform = NULL; |
| struct qcms_modular_transform **next_transform = &first_transform; |
| @@ -918,6 +918,9 @@ static struct qcms_modular_transform* qcms_modular_transform_create(qcms_profile |
| lab_to_pcs->transform_module_fn = qcms_transform_module_LAB_to_XYZ; |
| } |
| + if (pcs_xyz_only) |
| + return first_transform; |
| + |
| // This does not improve accuracy in practice, something is wrong here. |
| //if (in->chromaticAdaption.invalid == false) { |
| // struct qcms_modular_transform* chromaticAdaption; |
| @@ -984,7 +987,7 @@ static float* qcms_modular_transform_data(struct qcms_modular_transform *transfo |
| float* qcms_chain_transform(qcms_profile *in, qcms_profile *out, float *src, float *dest, size_t lutSize) |
| { |
| - struct qcms_modular_transform *transform_list = qcms_modular_transform_create(in, out); |
| + struct qcms_modular_transform *transform_list = qcms_modular_transform_create(in, out, false); |
| if (transform_list != NULL) { |
| float *lut = qcms_modular_transform_data(transform_list, src, dest, lutSize/3); |
| qcms_modular_transform_release(transform_list); |
| @@ -992,3 +995,27 @@ float* qcms_chain_transform(qcms_profile *in, qcms_profile *out, float *src, flo |
| } |
| return NULL; |
| } |
| + |
| +qcms_bool qcms_profile_white_transform(qcms_profile *profile, float XYZ[3]) |
| +{ |
| + static qcms_profile xyz_pcs_profile; |
|
robert.bradford
2015/12/02 15:25:39
What's the rationale for this? Is this a performan
Noel Gordon
2015/12/03 03:14:50
Nope, not perf critical. The chrome memory usage
|
| + |
| + if (xyz_pcs_profile.pcs != XYZ_SIGNATURE) { |
|
Justin Novosad
2015/12/02 15:40:08
Is qcms not concerned about thread safety?
Noel Gordon
2015/12/03 03:14:51
Yes it is, always. We currently create profiles o
|
| + memset(&xyz_pcs_profile, 0, sizeof(xyz_pcs_profile)); |
|
robert.bradford
2015/12/02 15:25:39
static variables are initialised to zero always, n
Noel Gordon
2015/12/03 03:14:51
Ack, but ditched the static anyway.
|
| + xyz_pcs_profile.pcs = XYZ_SIGNATURE; |
| + } |
|
robert.bradford
2015/12/02 15:25:39
Alternative (using C99 initialisers):
static cons
Noel Gordon
2015/12/03 03:14:51
Ditched the static profile, but thanks for the tip
|
| + |
| + struct qcms_modular_transform *transform_list = qcms_modular_transform_create(profile, &xyz_pcs_profile, true); |
| + if (transform_list != NULL) { |
| + // Calculate how the given profile transforms white input color to PCS XYZ space. |
| + XYZ[0] = XYZ[1] = XYZ[2] = 1.0f; |
| + qcms_modular_transform_data(transform_list, XYZ, XYZ, 1); |
| + XYZ[0] *= 1.999969482421875f; |
|
Noel Gordon
2015/12/02 10:38:34
Note: qcms_modular_transform_data internally scale
Justin Novosad
2015/12/02 15:40:08
Readability nit from a qcms outsider: put this num
Noel Gordon
2015/12/03 03:14:51
On 2015/12/02 15:40:08, Justin Novosad wrote:
That
|
| + XYZ[1] *= 1.999969482421875f; |
| + XYZ[2] *= 1.999969482421875f; |
| + qcms_modular_transform_release(transform_list); |
| + return true; |
| + } |
| + |
| + return false; |
| +} |