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

Side by Side 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: Patch for landing. Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « third_party/qcms/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* vim: set ts=8 sw=8 noexpandtab: */ 1 /* vim: set ts=8 sw=8 noexpandtab: */
2 // qcms 2 // qcms
3 // Copyright (C) 2009 Mozilla Corporation 3 // Copyright (C) 2009 Mozilla Corporation
4 // Copyright (C) 1998-2007 Marti Maria 4 // Copyright (C) 1998-2007 Marti Maria
5 // 5 //
6 // Permission is hereby granted, free of charge, to any person obtaining 6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the "Software"), 7 // a copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation 8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 qcms_transform* qcms_transform_precacheLUT_float(qcms_transform *transform, qcms _profile *in, qcms_profile *out, 1111 qcms_transform* qcms_transform_precacheLUT_float(qcms_transform *transform, qcms _profile *in, qcms_profile *out,
1112 int samples, qcms_data_type in_ type) 1112 int samples, qcms_data_type in_ type)
1113 { 1113 {
1114 /* The range between which 2 consecutive sample points can be used to in terpolate */ 1114 /* The range between which 2 consecutive sample points can be used to in terpolate */
1115 uint16_t x,y,z; 1115 uint16_t x,y,z;
1116 uint32_t l; 1116 uint32_t l;
1117 uint32_t lutSize = 3 * samples * samples * samples; 1117 uint32_t lutSize = 3 * samples * samples * samples;
1118 float* src = NULL; 1118 float* src = NULL;
1119 float* dest = NULL; 1119 float* dest = NULL;
1120 float* lut = NULL; 1120 float* lut = NULL;
1121 float inverse;
1121 1122
1122 src = malloc(lutSize*sizeof(float)); 1123 src = malloc(lutSize*sizeof(float));
1123 dest = malloc(lutSize*sizeof(float)); 1124 dest = malloc(lutSize*sizeof(float));
1124 1125
1125 if (src && dest) { 1126 if (src && dest) {
1126 » » /* Prepare a list of points we want to sample */ 1127 » » /* Prepare a list of points we want to sample: x, y, z order */
1127 l = 0; 1128 l = 0;
1129 inverse = 1 / (float)(samples-1);
1128 for (x = 0; x < samples; x++) { 1130 for (x = 0; x < samples; x++) {
1129 for (y = 0; y < samples; y++) { 1131 for (y = 0; y < samples; y++) {
1130 for (z = 0; z < samples; z++) { 1132 for (z = 0; z < samples; z++) {
1131 » » » » » src[l++] = x / (float)(samples-1); 1133 » » » » » src[l++] = x * inverse; // r
1132 » » » » » src[l++] = y / (float)(samples-1); 1134 » » » » » src[l++] = y * inverse; // g
1133 » » » » » src[l++] = z / (float)(samples-1); 1135 » » » » » src[l++] = z * inverse; // b
1134 } 1136 }
1135 } 1137 }
1136 } 1138 }
1137 1139
1138 lut = qcms_chain_transform(in, out, src, dest, lutSize); 1140 lut = qcms_chain_transform(in, out, src, dest, lutSize);
1141
1139 if (lut) { 1142 if (lut) {
1140 » » » transform->r_clut = &lut[0]; 1143 » » » transform->r_clut = &lut[0]; // r
1141 » » » transform->g_clut = &lut[1]; 1144 » » » transform->g_clut = &lut[1]; // g
1142 » » » transform->b_clut = &lut[2]; 1145 » » » transform->b_clut = &lut[2]; // b
1143 transform->grid_size = samples; 1146 transform->grid_size = samples;
1144 if (in_type == QCMS_DATA_RGBA_8) { 1147 if (in_type == QCMS_DATA_RGBA_8) {
1145 transform->transform_fn = qcms_transform_data_te tra_clut_rgba; 1148 transform->transform_fn = qcms_transform_data_te tra_clut_rgba;
1146 } else { 1149 } else {
1147 transform->transform_fn = qcms_transform_data_te tra_clut; 1150 transform->transform_fn = qcms_transform_data_te tra_clut;
1148 } 1151 }
1149 } 1152 }
1150 } 1153 }
1151 1154
1152 1155 » // XXX: qcms_modular_transform_data may return the lut in either the src or the
1153 » //XXX: qcms_modular_transform_data may return either the src or dest buf fer. If so it must not be free-ed 1156 » // dest buffer. If so, it must not be free-ed.
1154 if (src && lut != src) { 1157 if (src && lut != src) {
1155 free(src); 1158 free(src);
1156 } 1159 }
1157 if (dest && lut != dest) { 1160 if (dest && lut != dest) {
1158 free(dest); 1161 free(dest);
1159 } 1162 }
1160 1163
1161 if (lut == NULL) { 1164 if (lut == NULL) {
1162 return NULL; 1165 return NULL;
1163 } 1166 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 static const struct _qcms_format_type output_bgrx = { 2, 0 }; 1363 static const struct _qcms_format_type output_bgrx = { 2, 0 };
1361 1364
1362 transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU T_BGRX ? output_bgrx : output_rgbx); 1365 transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU T_BGRX ? output_bgrx : output_rgbx);
1363 } 1366 }
1364 1367
1365 qcms_bool qcms_supports_iccv4; 1368 qcms_bool qcms_supports_iccv4;
1366 void qcms_enable_iccv4() 1369 void qcms_enable_iccv4()
1367 { 1370 {
1368 qcms_supports_iccv4 = true; 1371 qcms_supports_iccv4 = true;
1369 } 1372 }
OLDNEW
« no previous file with comments | « third_party/qcms/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698