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 11 matching lines...) Expand all Loading... |
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
23 | 23 |
24 #include <stdlib.h> | 24 #include <stdlib.h> |
25 #include <math.h> | 25 #include <math.h> |
26 #include <assert.h> | 26 #include <assert.h> |
27 #include <string.h> //memcpy | 27 #include <string.h> //memcpy |
28 #include "qcmsint.h" | 28 #include "qcmsint.h" |
29 #include "transform_util.h" | 29 #include "transform_util.h" |
30 #include "matrix.h" | 30 #include "matrix.h" |
31 | 31 |
| 32 #ifdef USE_LIBFUZZER |
| 33 #define ASSERT(x) |
| 34 #else |
| 35 #define ASSERT(x) assert(x) |
| 36 #endif |
| 37 |
32 static struct matrix build_lut_matrix(struct lutType *lut) | 38 static struct matrix build_lut_matrix(struct lutType *lut) |
33 { | 39 { |
34 struct matrix result; | 40 struct matrix result; |
35 if (lut) { | 41 if (lut) { |
36 result.m[0][0] = s15Fixed16Number_to_float(lut->e00); | 42 result.m[0][0] = s15Fixed16Number_to_float(lut->e00); |
37 result.m[0][1] = s15Fixed16Number_to_float(lut->e01); | 43 result.m[0][1] = s15Fixed16Number_to_float(lut->e01); |
38 result.m[0][2] = s15Fixed16Number_to_float(lut->e02); | 44 result.m[0][2] = s15Fixed16Number_to_float(lut->e02); |
39 result.m[1][0] = s15Fixed16Number_to_float(lut->e10); | 45 result.m[1][0] = s15Fixed16Number_to_float(lut->e10); |
40 result.m[1][1] = s15Fixed16Number_to_float(lut->e11); | 46 result.m[1][1] = s15Fixed16Number_to_float(lut->e11); |
41 result.m[1][2] = s15Fixed16Number_to_float(lut->e12); | 47 result.m[1][2] = s15Fixed16Number_to_float(lut->e12); |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 &transform->output_gamma_lut_g_length); | 830 &transform->output_gamma_lut_g_length); |
825 build_output_lut(out->blueTRC, &transform->output_gamma_lut_b, | 831 build_output_lut(out->blueTRC, &transform->output_gamma_lut_b, |
826 &transform->output_gamma_lut_b_length); | 832 &transform->output_gamma_lut_b_length); |
827 transform->transform_module_fn = qcms_transform_module_gamma_lut
; | 833 transform->transform_module_fn = qcms_transform_module_gamma_lut
; |
828 | 834 |
829 if (!transform->output_gamma_lut_r || !transform->output_gamma_l
ut_g || | 835 if (!transform->output_gamma_lut_r || !transform->output_gamma_l
ut_g || |
830 !transform->output_gamma_lut_b) { | 836 !transform->output_gamma_lut_b) { |
831 goto fail; | 837 goto fail; |
832 } | 838 } |
833 } else { | 839 } else { |
834 » » assert(0 && "Unsupported output profile workflow."); | 840 » » ASSERT(0 && "Unsupported output profile workflow."); |
835 return NULL; | 841 return NULL; |
836 } | 842 } |
837 | 843 |
838 return first_transform; | 844 return first_transform; |
839 fail: | 845 fail: |
840 qcms_modular_transform_release(first_transform); | 846 qcms_modular_transform_release(first_transform); |
841 return EMPTY_TRANSFORM_LIST; | 847 return EMPTY_TRANSFORM_LIST; |
842 } | 848 } |
843 | 849 |
844 /* Not Completed | 850 /* Not Completed |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 struct qcms_modular_transform **next_transform = &first_transform; | 905 struct qcms_modular_transform **next_transform = &first_transform; |
900 qcms_bool transform_to_pcs_xyz_only = (out == NULL); | 906 qcms_bool transform_to_pcs_xyz_only = (out == NULL); |
901 | 907 |
902 if (in->color_space == RGB_SIGNATURE) { | 908 if (in->color_space == RGB_SIGNATURE) { |
903 struct qcms_modular_transform* rgb_to_pcs; | 909 struct qcms_modular_transform* rgb_to_pcs; |
904 rgb_to_pcs = qcms_modular_transform_create_input(in); | 910 rgb_to_pcs = qcms_modular_transform_create_input(in); |
905 if (!rgb_to_pcs) | 911 if (!rgb_to_pcs) |
906 goto fail; | 912 goto fail; |
907 append_transform(rgb_to_pcs, &next_transform); | 913 append_transform(rgb_to_pcs, &next_transform); |
908 } else { | 914 } else { |
909 » » assert(0 && "input color space not supported"); | 915 » » ASSERT(0 && "input color space not supported"); |
910 goto fail; | 916 goto fail; |
911 } | 917 } |
912 | 918 |
913 if (in->pcs == LAB_SIGNATURE && (transform_to_pcs_xyz_only || out->pcs =
= XYZ_SIGNATURE)) { | 919 if (in->pcs == LAB_SIGNATURE && (transform_to_pcs_xyz_only || out->pcs =
= XYZ_SIGNATURE)) { |
914 struct qcms_modular_transform* lab_to_pcs; | 920 struct qcms_modular_transform* lab_to_pcs; |
915 lab_to_pcs = qcms_modular_transform_alloc(); | 921 lab_to_pcs = qcms_modular_transform_alloc(); |
916 if (!lab_to_pcs) | 922 if (!lab_to_pcs) |
917 goto fail; | 923 goto fail; |
918 append_transform(lab_to_pcs, &next_transform); | 924 append_transform(lab_to_pcs, &next_transform); |
919 lab_to_pcs->transform_module_fn = qcms_transform_module_LAB_to_X
YZ; | 925 lab_to_pcs->transform_module_fn = qcms_transform_module_LAB_to_X
YZ; |
(...skipping 22 matching lines...) Expand all Loading... |
942 pcs_to_lab->transform_module_fn = qcms_transform_module_XYZ_to_L
AB; | 948 pcs_to_lab->transform_module_fn = qcms_transform_module_XYZ_to_L
AB; |
943 } | 949 } |
944 | 950 |
945 if (out->color_space == RGB_SIGNATURE) { | 951 if (out->color_space == RGB_SIGNATURE) { |
946 struct qcms_modular_transform* pcs_to_rgb; | 952 struct qcms_modular_transform* pcs_to_rgb; |
947 pcs_to_rgb = qcms_modular_transform_create_output(out); | 953 pcs_to_rgb = qcms_modular_transform_create_output(out); |
948 if (!pcs_to_rgb) | 954 if (!pcs_to_rgb) |
949 goto fail; | 955 goto fail; |
950 append_transform(pcs_to_rgb, &next_transform); | 956 append_transform(pcs_to_rgb, &next_transform); |
951 } else { | 957 } else { |
952 » » assert(0 && "output color space not supported"); | 958 » » ASSERT(0 && "output color space not supported"); |
953 goto fail; | 959 goto fail; |
954 } | 960 } |
955 // Not Completed | 961 // Not Completed |
956 //return qcms_modular_transform_reduce(first_transform); | 962 //return qcms_modular_transform_reduce(first_transform); |
957 return first_transform; | 963 return first_transform; |
958 fail: | 964 fail: |
959 qcms_modular_transform_release(first_transform); | 965 qcms_modular_transform_release(first_transform); |
960 return EMPTY_TRANSFORM_LIST; | 966 return EMPTY_TRANSFORM_LIST; |
961 } | 967 } |
962 | 968 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 // input (the D50 test). If it does not, then the profile is lik
ely bogus. | 1023 // input (the D50 test). If it does not, then the profile is lik
ely bogus. |
1018 XYZ[0] *= inverse_internal_scale; | 1024 XYZ[0] *= inverse_internal_scale; |
1019 XYZ[1] *= inverse_internal_scale; | 1025 XYZ[1] *= inverse_internal_scale; |
1020 XYZ[2] *= inverse_internal_scale; | 1026 XYZ[2] *= inverse_internal_scale; |
1021 qcms_modular_transform_release(transform_list); | 1027 qcms_modular_transform_release(transform_list); |
1022 return true; | 1028 return true; |
1023 } | 1029 } |
1024 | 1030 |
1025 return false; | 1031 return false; |
1026 } | 1032 } |
OLD | NEW |