Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: third_party/qcms/src/transform.c

Issue 863233003: Avoid divisions creating sample points in the float cube LUT builder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compute the inverse. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/qcms/src/transform.c
diff --git a/third_party/qcms/src/transform.c b/third_party/qcms/src/transform.c
index 08db142be6ad1076bb3d5629cdb9879edcdad7fb..bf7f85d6cdc8cf8c2f8db85ce63d45f5ff5e43b7 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 */
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
sugoi1 2015/01/27 15:42:58 You're going to have "samples * samples * samples
Noel Gordon 2015/01/28 05:57:29 yes, "samples" change b/w calls.
Noel Gordon 2015/01/28 05:57:29 And what followed seems fine, but the cost of this
sugoi1 2015/01/28 16:44:40 I understand that it *can* change, but if that rep
sugoi1 2015/01/28 16:44:40 On 2015/01/28 05:57:29, noel gordon wrote: The 44
Noel Gordon 2015/01/30 03:04:51 I might use a smaller or larger cube depending on
Noel Gordon 2015/01/30 18:52:21 443863 is about cube data format I think. Some co
}
}
}
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698