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

Side by Side Diff: third_party/qcms/src/transform.c

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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/src/qcms.h ('k') | third_party/re2/patches/re2-libcxx.patch » ('j') | 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 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 if (dest && lut != dest) { 1160 if (dest && lut != dest) {
1161 free(dest); 1161 free(dest);
1162 } 1162 }
1163 1163
1164 if (lut == NULL) { 1164 if (lut == NULL) {
1165 return NULL; 1165 return NULL;
1166 } 1166 }
1167 return transform; 1167 return transform;
1168 } 1168 }
1169 1169
1170 /* Create a transform LUT using the given number of sample points. The transform LUT data is stored
1171 in the output (cube) in bgra format in zyx sample order. */
1172 qcms_bool qcms_transform_create_LUT_zyx_bgra(qcms_profile *in, qcms_profile *out , qcms_intent intent,
1173 int samples, unsigned char* cube)
1174 {
1175 uint16_t z,y,x;
1176 uint32_t l,index;
1177 uint32_t lutSize = 3 * samples * samples * samples;
1178
1179 float* src = NULL;
1180 float* dest = NULL;
1181 float* lut = NULL;
1182 float inverse;
1183
1184 src = malloc(lutSize*sizeof(float));
1185 dest = malloc(lutSize*sizeof(float));
1186
1187 if (src && dest) {
1188 /* Prepare a list of points we want to sample: z, y, x order */
1189 l = 0;
1190 inverse = 1 / (float)(samples-1);
1191 for (z = 0; z < samples; z++) {
1192 for (y = 0; y < samples; y++) {
1193 for (x = 0; x < samples; x++) {
1194 src[l++] = x * inverse; // r
1195 src[l++] = y * inverse; // g
1196 src[l++] = z * inverse; // b
1197 }
1198 }
1199 }
1200
1201 lut = qcms_chain_transform(in, out, src, dest, lutSize);
1202
1203 if (lut) {
1204 index = l = 0;
1205 for (z = 0; z < samples; z++) {
1206 for (y = 0; y < samples; y++) {
1207 for (x = 0; x < samples; x++) {
1208 cube[index++] = (int)floorf(lut[ l + 2] * 255.0f + 0.5f); // b
1209 cube[index++] = (int)floorf(lut[ l + 1] * 255.0f + 0.5f); // g
1210 cube[index++] = (int)floorf(lut[ l + 0] * 255.0f + 0.5f); // r
1211 cube[index++] = 255; // a
1212 l += 3;
1213 }
1214 }
1215 }
1216 }
1217 }
1218
1219 // XXX: qcms_modular_transform_data may return the lut data in either th e src or
1220 // dest buffer so free src, dest, and lut with care.
1221
1222 if (src && lut != src)
1223 free(src);
1224 if (dest && lut != dest)
1225 free(dest);
1226
1227 if (lut) {
1228 free(lut);
1229 return true;
1230 }
1231
1232 return false;
1233 }
1234
1170 #define NO_MEM_TRANSFORM NULL 1235 #define NO_MEM_TRANSFORM NULL
1171 1236
1172 qcms_transform* qcms_transform_create( 1237 qcms_transform* qcms_transform_create(
1173 qcms_profile *in, qcms_data_type in_type, 1238 qcms_profile *in, qcms_data_type in_type,
1174 qcms_profile *out, qcms_data_type out_type, 1239 qcms_profile *out, qcms_data_type out_type,
1175 qcms_intent intent) 1240 qcms_intent intent)
1176 { 1241 {
1177 bool precache = false; 1242 bool precache = false;
1178 1243
1179 qcms_transform *transform = transform_alloc(); 1244 qcms_transform *transform = transform_alloc();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 static const struct _qcms_format_type output_bgrx = { 2, 0 }; 1428 static const struct _qcms_format_type output_bgrx = { 2, 0 };
1364 1429
1365 transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU T_BGRX ? output_bgrx : output_rgbx); 1430 transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU T_BGRX ? output_bgrx : output_rgbx);
1366 } 1431 }
1367 1432
1368 qcms_bool qcms_supports_iccv4; 1433 qcms_bool qcms_supports_iccv4;
1369 void qcms_enable_iccv4() 1434 void qcms_enable_iccv4()
1370 { 1435 {
1371 qcms_supports_iccv4 = true; 1436 qcms_supports_iccv4 = true;
1372 } 1437 }
OLDNEW
« no previous file with comments | « third_party/qcms/src/qcms.h ('k') | third_party/re2/patches/re2-libcxx.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698