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 Foundation | 3 // Copyright (C) 2009 Mozilla Foundation |
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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 379 |
380 // Only support 3 channels. | 380 // Only support 3 channels. |
381 if (channels != 3) | 381 if (channels != 3) |
382 return true; | 382 return true; |
383 // Only support single or double byte values. | 383 // Only support single or double byte values. |
384 if (byte_depth != 1 && byte_depth != 2) | 384 if (byte_depth != 1 && byte_depth != 2) |
385 return true; | 385 return true; |
386 // Only support table data, not equation. | 386 // Only support table data, not equation. |
387 if (vcgt_type != 0) | 387 if (vcgt_type != 0) |
388 return true; | 388 return true; |
| 389 // Limit the table to a sensible size; 10-bit gamma is a reasonable |
| 390 // maximum for hardware correction. |
| 391 if (elements > 1024) |
| 392 return true; |
389 | 393 |
390 // Empty table is invalid. | 394 // Empty table is invalid. |
391 if (!elements) | 395 if (!elements) |
392 goto invalid_vcgt_tag; | 396 goto invalid_vcgt_tag; |
393 | 397 |
394 profile->vcgt.length = elements; | 398 profile->vcgt.length = elements; |
395 profile->vcgt.data = malloc(3 * elements * sizeof(uint16_t)); | 399 profile->vcgt.data = malloc(3 * elements * sizeof(uint16_t)); |
396 if (!profile->vcgt.data) | 400 if (!profile->vcgt.data) |
397 return false; | 401 return false; |
398 | 402 |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 { | 1476 { |
1473 qcms_profile *profile = NULL; | 1477 qcms_profile *profile = NULL; |
1474 FILE *file = _wfopen(path, L"rb"); | 1478 FILE *file = _wfopen(path, L"rb"); |
1475 if (file) { | 1479 if (file) { |
1476 profile = qcms_profile_from_file(file); | 1480 profile = qcms_profile_from_file(file); |
1477 fclose(file); | 1481 fclose(file); |
1478 } | 1482 } |
1479 return profile; | 1483 return profile; |
1480 } | 1484 } |
1481 #endif | 1485 #endif |
OLD | NEW |