| OLD | NEW |
| 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 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 if (!transform) { | 1245 if (!transform) { |
| 1246 return NULL; | 1246 return NULL; |
| 1247 } | 1247 } |
| 1248 if (out_type != QCMS_DATA_RGB_8 && | 1248 if (out_type != QCMS_DATA_RGB_8 && |
| 1249 out_type != QCMS_DATA_RGBA_8) { | 1249 out_type != QCMS_DATA_RGBA_8) { |
| 1250 assert(0 && "output type"); | 1250 assert(0 && "output type"); |
| 1251 transform_free(transform); | 1251 transform_free(transform); |
| 1252 return NULL; | 1252 return NULL; |
| 1253 } | 1253 } |
| 1254 | 1254 |
| 1255 transform->transform_flags = 0; |
| 1256 |
| 1255 if (out->output_table_r && | 1257 if (out->output_table_r && |
| 1256 out->output_table_g && | 1258 out->output_table_g && |
| 1257 out->output_table_b) { | 1259 out->output_table_b) { |
| 1258 precache = true; | 1260 precache = true; |
| 1259 } | 1261 } |
| 1260 | 1262 |
| 1261 if (qcms_supports_iccv4 && (in->A2B0 || out->B2A0 || in->mAB || out->mAB
)) { | 1263 if (qcms_supports_iccv4 && (in->A2B0 || out->B2A0 || in->mAB || out->mAB
)) { |
| 1262 // Precache the transformation to a CLUT 33x33x33 in size. | 1264 // Precache the transformation to a CLUT 33x33x33 in size. |
| 1263 // 33 is used by many profiles and works well in pratice. | 1265 // 33 is used by many profiles and works well in pratice. |
| 1264 // This evenly divides 256 into blocks of 8x8x8. | 1266 // This evenly divides 256 into blocks of 8x8x8. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 transform->matrix[0][0] = result.m[0][0]; | 1360 transform->matrix[0][0] = result.m[0][0]; |
| 1359 transform->matrix[1][0] = result.m[0][1]; | 1361 transform->matrix[1][0] = result.m[0][1]; |
| 1360 transform->matrix[2][0] = result.m[0][2]; | 1362 transform->matrix[2][0] = result.m[0][2]; |
| 1361 transform->matrix[0][1] = result.m[1][0]; | 1363 transform->matrix[0][1] = result.m[1][0]; |
| 1362 transform->matrix[1][1] = result.m[1][1]; | 1364 transform->matrix[1][1] = result.m[1][1]; |
| 1363 transform->matrix[2][1] = result.m[1][2]; | 1365 transform->matrix[2][1] = result.m[1][2]; |
| 1364 transform->matrix[0][2] = result.m[2][0]; | 1366 transform->matrix[0][2] = result.m[2][0]; |
| 1365 transform->matrix[1][2] = result.m[2][1]; | 1367 transform->matrix[1][2] = result.m[2][1]; |
| 1366 transform->matrix[2][2] = result.m[2][2]; | 1368 transform->matrix[2][2] = result.m[2][2]; |
| 1367 | 1369 |
| 1370 /* Flag transform as matrix. */ |
| 1371 transform->transform_flags |= TRANSFORM_FLAG_MATRIX; |
| 1372 |
| 1368 } else if (in->color_space == GRAY_SIGNATURE) { | 1373 } else if (in->color_space == GRAY_SIGNATURE) { |
| 1369 if (in_type != QCMS_DATA_GRAY_8 && | 1374 if (in_type != QCMS_DATA_GRAY_8 && |
| 1370 in_type != QCMS_DATA_GRAYA_8){ | 1375 in_type != QCMS_DATA_GRAYA_8){ |
| 1371 assert(0 && "input type"); | 1376 assert(0 && "input type"); |
| 1372 transform_free(transform); | 1377 transform_free(transform); |
| 1373 return NULL; | 1378 return NULL; |
| 1374 } | 1379 } |
| 1375 | 1380 |
| 1376 transform->input_gamma_table_gray = build_input_gamma_table(in->
grayTRC); | 1381 transform->input_gamma_table_gray = build_input_gamma_table(in->
grayTRC); |
| 1377 if (!transform->input_gamma_table_gray) { | 1382 if (!transform->input_gamma_table_gray) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 | 1429 |
| 1425 void qcms_transform_data_type(qcms_transform *transform, void *src, void *dest,
size_t length, qcms_output_type type) | 1430 void qcms_transform_data_type(qcms_transform *transform, void *src, void *dest,
size_t length, qcms_output_type type) |
| 1426 { | 1431 { |
| 1427 static const struct _qcms_format_type output_rgbx = { 0, 2 }; | 1432 static const struct _qcms_format_type output_rgbx = { 0, 2 }; |
| 1428 static const struct _qcms_format_type output_bgrx = { 2, 0 }; | 1433 static const struct _qcms_format_type output_bgrx = { 2, 0 }; |
| 1429 | 1434 |
| 1430 transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU
T_BGRX ? output_bgrx : output_rgbx); | 1435 transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU
T_BGRX ? output_bgrx : output_rgbx); |
| 1431 } | 1436 } |
| 1432 | 1437 |
| 1433 qcms_bool qcms_supports_iccv4; | 1438 qcms_bool qcms_supports_iccv4; |
| 1439 |
| 1434 void qcms_enable_iccv4() | 1440 void qcms_enable_iccv4() |
| 1435 { | 1441 { |
| 1436 qcms_supports_iccv4 = true; | 1442 qcms_supports_iccv4 = true; |
| 1437 } | 1443 } |
| 1444 |
| 1445 static inline qcms_bool transform_is_matrix(qcms_transform *t) |
| 1446 { |
| 1447 return (t->transform_flags & TRANSFORM_FLAG_MATRIX) ? true : false; |
| 1448 } |
| 1449 |
| 1450 qcms_bool qcms_transform_is_matrix(qcms_transform *t) |
| 1451 { |
| 1452 return transform_is_matrix(t); |
| 1453 } |
| 1454 |
| 1455 float qcms_transform_get_matrix(qcms_transform *t, unsigned i, unsigned j) |
| 1456 { |
| 1457 assert(transform_is_matrix(t) && i < 3 && j < 3); |
| 1458 |
| 1459 // Return transform matrix element in row major order (permute i and j) |
| 1460 |
| 1461 return t->matrix[j][i]; |
| 1462 } |
| OLD | NEW |