Chromium Code Reviews| Index: third_party/qcms/src/iccread.c |
| diff --git a/third_party/qcms/src/iccread.c b/third_party/qcms/src/iccread.c |
| index b62f127dad4ef824fe66ae105c57afdaae65e643..2fd4cc49936dd92589e874088932a01c2468a5f8 100644 |
| --- a/third_party/qcms/src/iccread.c |
| +++ b/third_party/qcms/src/iccread.c |
| @@ -258,77 +258,85 @@ static struct tag_index read_tag_table(qcms_profile *profile, struct mem_source |
| // ignored. |
| qcms_bool qcms_profile_is_bogus(qcms_profile *profile) |
| { |
| - float sum[3], target[3], tolerance[3]; |
| - float rX, rY, rZ, gX, gY, gZ, bX, bY, bZ; |
| - bool negative; |
| - unsigned i; |
| + float rX, rY, rZ, gX, gY, gZ, bX, bY, bZ; |
| + float target[3], tolerance[3], sum[3]; |
| + unsigned i; |
| - // We currently only check the bogosity of RGB profiles |
| - if (profile->color_space != RGB_SIGNATURE) |
| - return false; |
| + // We currently only check the bogosity of RGB profiles. |
| + if (profile->color_space != RGB_SIGNATURE) |
| + return false; |
| - if (qcms_supports_iccv4 && (profile->A2B0 || profile->B2A0)) |
| + if (qcms_supports_iccv4 && (profile->A2B0 || profile->B2A0)) |
| return false; |
| - rX = s15Fixed16Number_to_float(profile->redColorant.X); |
| - rY = s15Fixed16Number_to_float(profile->redColorant.Y); |
| - rZ = s15Fixed16Number_to_float(profile->redColorant.Z); |
| + rX = s15Fixed16Number_to_float(profile->redColorant.X); |
| + rY = s15Fixed16Number_to_float(profile->redColorant.Y); |
| + rZ = s15Fixed16Number_to_float(profile->redColorant.Z); |
| - gX = s15Fixed16Number_to_float(profile->greenColorant.X); |
| - gY = s15Fixed16Number_to_float(profile->greenColorant.Y); |
| - gZ = s15Fixed16Number_to_float(profile->greenColorant.Z); |
| + gX = s15Fixed16Number_to_float(profile->greenColorant.X); |
| + gY = s15Fixed16Number_to_float(profile->greenColorant.Y); |
| + gZ = s15Fixed16Number_to_float(profile->greenColorant.Z); |
| - bX = s15Fixed16Number_to_float(profile->blueColorant.X); |
| - bY = s15Fixed16Number_to_float(profile->blueColorant.Y); |
| - bZ = s15Fixed16Number_to_float(profile->blueColorant.Z); |
| + bX = s15Fixed16Number_to_float(profile->blueColorant.X); |
| + bY = s15Fixed16Number_to_float(profile->blueColorant.Y); |
| + bZ = s15Fixed16Number_to_float(profile->blueColorant.Z); |
| - // Check if any of the XYZ values are negative (see mozilla bug 498245) |
| - // CIEXYZ tristimulus values cannot be negative according to the spec. |
| - negative = |
| - (rX < 0) || (rY < 0) || (rZ < 0) || |
| - (gX < 0) || (gY < 0) || (gZ < 0) || |
| - (bX < 0) || (bY < 0) || (bZ < 0); |
| + // Build our target vector: CIE D50 white. See also mozilla bug 460629, |
| + // and http://www.color.org/whyd50.xalter "Why is the media white point |
| + // of a display profile always D50?" |
| - if (negative) |
| - return true; |
| + target[0] = (float) 0.96420; |
| + target[1] = (float) 1.00000; |
| + target[2] = (float) 0.82491; |
| + // Our tolerance vector - Recommended by Chris Murphy based on |
| + // conversion from the LAB space criterion of no more than 3 in any one |
| + // channel. This is similar to, but slightly more tolerant than Adobe's |
| + // criterion. |
| - // Sum the values; they should add up to something close to white |
| - sum[0] = rX + gX + bX; |
| - sum[1] = rY + gY + bY; |
| - sum[2] = rZ + gZ + bZ; |
| + tolerance[0] = (float) 0.02; |
| + tolerance[1] = (float) 0.02; |
| + tolerance[2] = (float) 0.04; |
| -#if defined (_MSC_VER) |
| -#pragma warning(push) |
| -/* Disable double to float truncation warning 4305 */ |
| -#pragma warning(disable:4305) |
| -#endif |
| - // Build our target vector (see mozilla bug 460629) |
| - target[0] = 0.96420; |
| - target[1] = 1.00000; |
| - target[2] = 0.82491; |
| - |
| - // Our tolerance vector - Recommended by Chris Murphy based on |
| - // conversion from the LAB space criterion of no more than 3 in any one |
| - // channel. This is similar to, but slightly more tolerant than Adobe's |
| - // criterion. |
| - tolerance[0] = 0.02; |
| - tolerance[1] = 0.02; |
| - tolerance[2] = 0.04; |
| - |
| -#if defined (_MSC_VER) |
| -/* Restore warnings */ |
| -#pragma warning(pop) |
| + // Sum the XYZ values: they should add up D50 white, within tolerance. |
|
Noel Gordon
2015/12/01 04:00:16
Note to self: change to "should add to" on submit.
|
| + // FIXME: this test assumes the TRC RGB curves equal 1.0 for the white |
| + // input (255,255,255) test RGB color. For user displays and screens, |
| + // that is indeed the normal case. |
| + |
| + sum[0] = rX + gX + bX; |
| + sum[1] = rY + gY + bY; |
| + sum[2] = rZ + gZ + bZ; |
| + |
| + for (i = 0; i < 3; ++i) { |
| + if (!(((sum[i] - tolerance[i]) <= target[i]) && |
| + ((sum[i] + tolerance[i]) >= target[i]))) { |
| + return true; // out of tolerance: bogus |
| + } |
| + } |
| + |
| +#ifndef __APPLE__ |
| + |
| + // Check if any of the XYZ values are negative (see mozilla bug 498245) |
| + // CIEXYZ tristimulus values cannot be negative according to the spec. |
| + |
| + bool negative = |
| + (rX < 0) || (rY < 0) || (rZ < 0) || |
| + (gX < 0) || (gY < 0) || (gZ < 0) || |
| + (bX < 0) || (bY < 0) || (bZ < 0); |
| + |
| + if (negative) |
| + return true; // bogus |
| +#else |
| + // Chromatic adaption to D50 can result in negative XYZ, but the white- |
| + // point D50 tolerance test has passed. Herein, accept negative values. |
| + // See https://bugzilla.mozilla.org/show_bug.cgi?id=498245#c18 onwards |
| + // for discussion about whether or not XZY can or can't be negative per |
| + // the spec. Also https://bugzilla.mozilla.org/show_bug.cgi?id=450923 |
| + |
| + // FIXME: allow this relaxation on all ports? |
|
Justin Novosad
2015/12/01 03:29:55
FIXME is deprecated, use TODO(noel)
|
| #endif |
| - // Compare with our tolerance |
| - for (i = 0; i < 3; ++i) { |
| - if (!(((sum[i] - tolerance[i]) <= target[i]) && |
| - ((sum[i] + tolerance[i]) >= target[i]))) |
| - return true; |
| - } |
| - |
| - // All Good |
| - return false; |
| + // All good. |
| + return false; |
| } |
| #define TAG_bXYZ 0x6258595a |