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 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
886 remove_next: | 886 remove_next: |
887 curr_trans->next_transform = next_trans->next_transform; | 887 curr_trans->next_transform = next_trans->next_transform; |
888 next_trans->next_transform = NULL; | 888 next_trans->next_transform = NULL; |
889 qcms_modular_transform_release(next_trans); | 889 qcms_modular_transform_release(next_trans); |
890 continue; | 890 continue; |
891 } | 891 } |
892 return transform; | 892 return transform; |
893 } | 893 } |
894 */ | 894 */ |
895 | 895 |
896 static struct qcms_modular_transform* qcms_modular_transform_create(qcms_profile *in, qcms_profile *out) | 896 static struct qcms_modular_transform* qcms_modular_transform_create(qcms_profile *in, qcms_profile *out, bool pcs_xyz_only) |
897 { | 897 { |
898 struct qcms_modular_transform *first_transform = NULL; | 898 struct qcms_modular_transform *first_transform = NULL; |
899 struct qcms_modular_transform **next_transform = &first_transform; | 899 struct qcms_modular_transform **next_transform = &first_transform; |
900 | 900 |
901 if (in->color_space == RGB_SIGNATURE) { | 901 if (in->color_space == RGB_SIGNATURE) { |
902 struct qcms_modular_transform* rgb_to_pcs; | 902 struct qcms_modular_transform* rgb_to_pcs; |
903 rgb_to_pcs = qcms_modular_transform_create_input(in); | 903 rgb_to_pcs = qcms_modular_transform_create_input(in); |
904 if (!rgb_to_pcs) | 904 if (!rgb_to_pcs) |
905 goto fail; | 905 goto fail; |
906 append_transform(rgb_to_pcs, &next_transform); | 906 append_transform(rgb_to_pcs, &next_transform); |
907 } else { | 907 } else { |
908 assert(0 && "input color space not supported"); | 908 assert(0 && "input color space not supported"); |
909 goto fail; | 909 goto fail; |
910 } | 910 } |
911 | 911 |
912 if (in->pcs == LAB_SIGNATURE && out->pcs == XYZ_SIGNATURE) { | 912 if (in->pcs == LAB_SIGNATURE && out->pcs == XYZ_SIGNATURE) { |
913 struct qcms_modular_transform* lab_to_pcs; | 913 struct qcms_modular_transform* lab_to_pcs; |
914 lab_to_pcs = qcms_modular_transform_alloc(); | 914 lab_to_pcs = qcms_modular_transform_alloc(); |
915 if (!lab_to_pcs) | 915 if (!lab_to_pcs) |
916 goto fail; | 916 goto fail; |
917 append_transform(lab_to_pcs, &next_transform); | 917 append_transform(lab_to_pcs, &next_transform); |
918 lab_to_pcs->transform_module_fn = qcms_transform_module_LAB_to_X YZ; | 918 lab_to_pcs->transform_module_fn = qcms_transform_module_LAB_to_X YZ; |
919 } | 919 } |
920 | 920 |
921 if (pcs_xyz_only) | |
922 return first_transform; | |
923 | |
921 // This does not improve accuracy in practice, something is wrong here. | 924 // This does not improve accuracy in practice, something is wrong here. |
922 //if (in->chromaticAdaption.invalid == false) { | 925 //if (in->chromaticAdaption.invalid == false) { |
923 // struct qcms_modular_transform* chromaticAdaption; | 926 // struct qcms_modular_transform* chromaticAdaption; |
924 // chromaticAdaption = qcms_modular_transform_alloc(); | 927 // chromaticAdaption = qcms_modular_transform_alloc(); |
925 // if (!chromaticAdaption) | 928 // if (!chromaticAdaption) |
926 // goto fail; | 929 // goto fail; |
927 // append_transform(chromaticAdaption, &next_transform); | 930 // append_transform(chromaticAdaption, &next_transform); |
928 // chromaticAdaption->matrix = matrix_invert(in->chromaticAdaption) ; | 931 // chromaticAdaption->matrix = matrix_invert(in->chromaticAdaption) ; |
929 // chromaticAdaption->transform_module_fn = qcms_transform_module_m atrix; | 932 // chromaticAdaption->transform_module_fn = qcms_transform_module_m atrix; |
930 //} | 933 //} |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 dest = src; | 980 dest = src; |
978 src = new_src; | 981 src = new_src; |
979 transform = transform->next_transform; | 982 transform = transform->next_transform; |
980 } | 983 } |
981 // The results end up in the src buffer because of the switching | 984 // The results end up in the src buffer because of the switching |
982 return src; | 985 return src; |
983 } | 986 } |
984 | 987 |
985 float* qcms_chain_transform(qcms_profile *in, qcms_profile *out, float *src, flo at *dest, size_t lutSize) | 988 float* qcms_chain_transform(qcms_profile *in, qcms_profile *out, float *src, flo at *dest, size_t lutSize) |
986 { | 989 { |
987 » struct qcms_modular_transform *transform_list = qcms_modular_transform_c reate(in, out); | 990 » struct qcms_modular_transform *transform_list = qcms_modular_transform_c reate(in, out, false); |
988 if (transform_list != NULL) { | 991 if (transform_list != NULL) { |
989 float *lut = qcms_modular_transform_data(transform_list, src, de st, lutSize/3); | 992 float *lut = qcms_modular_transform_data(transform_list, src, de st, lutSize/3); |
990 qcms_modular_transform_release(transform_list); | 993 qcms_modular_transform_release(transform_list); |
991 return lut; | 994 return lut; |
992 } | 995 } |
993 return NULL; | 996 return NULL; |
994 } | 997 } |
998 | |
999 qcms_bool qcms_profile_white_transform(qcms_profile *profile, float XYZ[3]) | |
1000 { | |
1001 static qcms_profile xyz_pcs_profile; | |
robert.bradford
2015/12/02 15:25:39
What's the rationale for this? Is this a performan
Noel Gordon
2015/12/03 03:14:50
Nope, not perf critical. The chrome memory usage
| |
1002 | |
1003 if (xyz_pcs_profile.pcs != XYZ_SIGNATURE) { | |
Justin Novosad
2015/12/02 15:40:08
Is qcms not concerned about thread safety?
Noel Gordon
2015/12/03 03:14:51
Yes it is, always. We currently create profiles o
| |
1004 memset(&xyz_pcs_profile, 0, sizeof(xyz_pcs_profile)); | |
robert.bradford
2015/12/02 15:25:39
static variables are initialised to zero always, n
Noel Gordon
2015/12/03 03:14:51
Ack, but ditched the static anyway.
| |
1005 xyz_pcs_profile.pcs = XYZ_SIGNATURE; | |
1006 } | |
robert.bradford
2015/12/02 15:25:39
Alternative (using C99 initialisers):
static cons
Noel Gordon
2015/12/03 03:14:51
Ditched the static profile, but thanks for the tip
| |
1007 | |
1008 struct qcms_modular_transform *transform_list = qcms_modular_transform_c reate(profile, &xyz_pcs_profile, true); | |
1009 if (transform_list != NULL) { | |
1010 // Calculate how the given profile transforms white input color to PCS XYZ space. | |
1011 XYZ[0] = XYZ[1] = XYZ[2] = 1.0f; | |
1012 qcms_modular_transform_data(transform_list, XYZ, XYZ, 1); | |
1013 XYZ[0] *= 1.999969482421875f; | |
Noel Gordon
2015/12/02 10:38:34
Note: qcms_modular_transform_data internally scale
Justin Novosad
2015/12/02 15:40:08
Readability nit from a qcms outsider: put this num
Noel Gordon
2015/12/03 03:14:51
On 2015/12/02 15:40:08, Justin Novosad wrote:
That
| |
1014 XYZ[1] *= 1.999969482421875f; | |
1015 XYZ[2] *= 1.999969482421875f; | |
1016 qcms_modular_transform_release(transform_list); | |
1017 return true; | |
1018 } | |
1019 | |
1020 return false; | |
1021 } | |
OLD | NEW |