diff options
author | noel <noel@chromium.org> | 2015-02-03 14:58:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-03 23:01:01 +0000 |
commit | 5bc47112d6be524ab82b8f9afc0b67a832e32380 (patch) | |
tree | fba528d0cabcd2692fcc07583decdb46d0bfd628 | |
parent | 31a6f70b8a22930cc749a67a90c6e7e3778f8466 (diff) | |
download | chromium_src-5bc47112d6be524ab82b8f9afc0b67a832e32380.zip chromium_src-5bc47112d6be524ab82b8f9afc0b67a832e32380.tar.gz chromium_src-5bc47112d6be524ab82b8f9afc0b67a832e32380.tar.bz2 |
Avoid divisions creating sample points in the float cube LUT builder
Cube samplers create input sample points in some order. Document the QCMS
order (x,y,z) which is the same as OSX ColorSync and cube LUT interchange
standards such as the Adobe Cube LUT Specification 1.0, 2013. The samples
are RGB order with R changing the slowest, B the fastest.
Hoist the division out of the sample point creation loop: takes 0.0003939
seconds on MacAir for 32^3 sample points, 0.0001619 with hoisting. That's
fine, but small beans compared to the overall costs of cube creation. The
majorty of the work is in qcms_chain_transform (8ms) where floating-point
is used to maintain transform precision.
The output ColorCube LUT produced by qcms_chain_transform is indexed into
transform in RGB order (time cost ~0). Add comments about order.
BUG=443863
Review URL: https://codereview.chromium.org/863233003
Cr-Commit-Position: refs/heads/master@{#314425}
-rw-r--r-- | third_party/qcms/README.chromium | 2 | ||||
-rw-r--r-- | third_party/qcms/src/transform.c | 21 |
2 files changed, 14 insertions, 9 deletions
diff --git a/third_party/qcms/README.chromium b/third_party/qcms/README.chromium index fdf3394..8fb3768 100644 --- a/third_party/qcms/README.chromium +++ b/third_party/qcms/README.chromium @@ -51,5 +51,7 @@ google.patch contains the following modifications. Apply with - https://code.google.com/p/chromium/issues/detail?id=401971 - Minor variable name change: description -> description_offset - https://code.google.com/p/chromium/issues/detail?id=401971 + - Avoid divisions creating sample points in the float cube LUT builder + - https://code.google.com/p/chromium/issues/detail?id=443863 To regenerate google.patch: git diff b8456f38 src > google.patch diff --git a/third_party/qcms/src/transform.c b/third_party/qcms/src/transform.c index 08db142..9fd8238 100644 --- a/third_party/qcms/src/transform.c +++ b/third_party/qcms/src/transform.c @@ -1118,28 +1118,31 @@ qcms_transform* qcms_transform_precacheLUT_float(qcms_transform *transform, qcms float* src = NULL; float* dest = NULL; float* lut = NULL; + float inverse; src = malloc(lutSize*sizeof(float)); dest = malloc(lutSize*sizeof(float)); if (src && dest) { - /* Prepare a list of points we want to sample */ + /* Prepare a list of points we want to sample: x, y, z order */ l = 0; + inverse = 1 / (float)(samples-1); for (x = 0; x < samples; x++) { for (y = 0; y < samples; y++) { for (z = 0; z < samples; z++) { - src[l++] = x / (float)(samples-1); - src[l++] = y / (float)(samples-1); - src[l++] = z / (float)(samples-1); + src[l++] = x * inverse; // r + src[l++] = y * inverse; // g + src[l++] = z * inverse; // b } } } lut = qcms_chain_transform(in, out, src, dest, lutSize); + if (lut) { - transform->r_clut = &lut[0]; - transform->g_clut = &lut[1]; - transform->b_clut = &lut[2]; + transform->r_clut = &lut[0]; // r + transform->g_clut = &lut[1]; // g + transform->b_clut = &lut[2]; // b transform->grid_size = samples; if (in_type == QCMS_DATA_RGBA_8) { transform->transform_fn = qcms_transform_data_tetra_clut_rgba; @@ -1149,8 +1152,8 @@ qcms_transform* qcms_transform_precacheLUT_float(qcms_transform *transform, qcms } } - - //XXX: qcms_modular_transform_data may return either the src or dest buffer. If so it must not be free-ed + // XXX: qcms_modular_transform_data may return the lut in either the src or the + // dest buffer. If so, it must not be free-ed. if (src && lut != src) { free(src); } |