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

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

Issue 892413005: Add bgra (z,y,x) sampled transform lookup table api (Closed) Base URL: https://chromium.googlesource.com/chromium/src.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
« third_party/qcms/src/qcms.h ('K') | « third_party/qcms/src/qcms.h ('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 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 qcms_bool qcms_transform_create_color_cube_skia(qcms_profile *in, qcms_profile * out,
1171 int samples, unsigned char* cube )
1172 {
1173 uint16_t z,y,x;
1174 uint32_t l,index;
1175 uint32_t lutSize = 3 * samples * samples * samples;
1176
1177 float* src = NULL;
1178 float* dest = NULL;
1179 float* lut = NULL;
1180 float inverse;
1181
1182 src = malloc(lutSize*sizeof(float));
1183 dest = malloc(lutSize*sizeof(float));
1184
1185 if (src && dest) {
1186 /* Prepare a list of points we want to sample: z, y, x order */
1187 l = 0;
1188 inverse = 1 / (float)(samples-1);
1189 for (z = 0; z < samples; z++) {
1190 for (y = 0; y < samples; y++) {
1191 for (x = 0; x < samples; x++) {
1192 src[l++] = x * inverse; // r
1193 src[l++] = y * inverse; // g
1194 src[l++] = z * inverse; // b
1195 }
1196 }
1197 }
1198
1199 lut = qcms_chain_transform(in, out, src, dest, lutSize);
1200
1201 if (lut) {
1202 index = l = 0;
1203 for (z = 0; z < samples; z++) {
1204 for (y = 0; y < samples; y++) {
1205 for (x = 0; x < samples; x++) {
1206 cube[index++] = (int)floorf(lut[l + 2] * 255.0f + 0.5f); // b
Ken Russell (switch to Gerrit) 2015/02/04 22:23:05 Not sure, but I thought the way to do this convers
Noel Gordon 2015/02/05 16:28:52 Interesting thought, not sure of the correct answe
Ken Russell (switch to Gerrit) 2015/02/06 02:49:54 My understanding is that the formulation above (mu
Mike Lawther (Google) 2015/02/06 03:20:06 My understanding was the same as Ken's. With "mult
Ken Russell (switch to Gerrit) 2015/02/06 03:31:35 That's correct. The unsigned conversions were unch
1207 cube[index++] = (int)floorf(lut[l + 1] * 255.0f + 0.5f); // g
1208 cube[index++] = (int)floorf(lut[l + 0] * 255.0f + 0.5f); // r
1209 cube[index++] = 255; // a
1210 l += 3;
1211 }
1212 }
1213 }
1214 }
1215 }
1216
1217 // XXX: qcms_modular_transform_data may return the lut data in either the sr c or
1218 // dest buffer so free src, dest, and lut with care.
1219
1220 if (src && lut != src)
1221 free(src);
1222 if (dest && lut != dest)
1223 free(dest);
1224
1225 if (lut) {
1226 free(lut);
1227 return true;
1228 }
1229
1230 return false;
1231 }
1232
1170 #define NO_MEM_TRANSFORM NULL 1233 #define NO_MEM_TRANSFORM NULL
1171 1234
1172 qcms_transform* qcms_transform_create( 1235 qcms_transform* qcms_transform_create(
1173 qcms_profile *in, qcms_data_type in_type, 1236 qcms_profile *in, qcms_data_type in_type,
1174 qcms_profile *out, qcms_data_type out_type, 1237 qcms_profile *out, qcms_data_type out_type,
1175 qcms_intent intent) 1238 qcms_intent intent)
1176 { 1239 {
1177 bool precache = false; 1240 bool precache = false;
1178 1241
1179 qcms_transform *transform = transform_alloc(); 1242 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 }; 1426 static const struct _qcms_format_type output_bgrx = { 2, 0 };
1364 1427
1365 transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU T_BGRX ? output_bgrx : output_rgbx); 1428 transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU T_BGRX ? output_bgrx : output_rgbx);
1366 } 1429 }
1367 1430
1368 qcms_bool qcms_supports_iccv4; 1431 qcms_bool qcms_supports_iccv4;
1369 void qcms_enable_iccv4() 1432 void qcms_enable_iccv4()
1370 { 1433 {
1371 qcms_supports_iccv4 = true; 1434 qcms_supports_iccv4 = true;
1372 } 1435 }
OLDNEW
« third_party/qcms/src/qcms.h ('K') | « third_party/qcms/src/qcms.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698