OLD | NEW |
---|---|
1 // qcms | 1 // qcms |
2 // Copyright (C) 2009 Mozilla Foundation | 2 // Copyright (C) 2009 Mozilla Foundation |
3 // | 3 // |
4 // Permission is hereby granted, free of charge, to any person obtaining | 4 // Permission is hereby granted, free of charge, to any person obtaining |
5 // a copy of this software and associated documentation files (the "Software"), | 5 // a copy of this software and associated documentation files (the "Software"), |
6 // to deal in the Software without restriction, including without limitation | 6 // to deal in the Software without restriction, including without limitation |
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, | 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
8 // and/or sell copies of the Software, and to permit persons to whom the Softwar e | 8 // and/or sell copies of the Software, and to permit persons to whom the Softwar e |
9 // is furnished to do so, subject to the following conditions: | 9 // is furnished to do so, subject to the following conditions: |
10 // | 10 // |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 float gamma_table[256]; | 600 float gamma_table[256]; |
601 uint16_t i; | 601 uint16_t i; |
602 uint16_t *output = malloc(sizeof(uint16_t)*256); | 602 uint16_t *output = malloc(sizeof(uint16_t)*256); |
603 | 603 |
604 if (!output) { | 604 if (!output) { |
605 *output_gamma_lut = NULL; | 605 *output_gamma_lut = NULL; |
606 return; | 606 return; |
607 } | 607 } |
608 | 608 |
609 compute_curve_gamma_table_type_parametric(gamma_table, trc->para meter, trc->count); | 609 compute_curve_gamma_table_type_parametric(gamma_table, trc->para meter, trc->count); |
610 *output_gamma_lut_length = 256; | 610 *output_gamma_lut_length = 256; |
Noel Gordon
2016/04/21 06:01:54
This line needs to be made more obvious. Perhaps
radu.velea
2016/04/21 07:13:45
Done.
| |
611 for(i = 0; i < 256; i++) { | 611 for(i = 0; i < 256; i++) { |
612 output[i] = (uint16_t)(gamma_table[i] * 65535); | 612 output[i] = (uint16_t)(gamma_table[i] * 65535); |
613 } | 613 } |
614 *output_gamma_lut = output; | 614 |
615 uint16_t *inverted; | |
616 int inverted_size = 256; | |
Noel Gordon
2016/04/21 06:01:54
These two variables need to be declared just after
radu.velea
2016/04/21 07:13:45
Done.
| |
617 | |
618 //XXX: the choice of a minimum of 256 here is not backed by any theory, | |
619 // measurement or data, however it is what lcms uses. | |
620 // the maximum number we would need is 65535 because that's the | |
621 // accuracy used for computing the pre cache table | |
622 if (inverted_size < 256) | |
623 inverted_size = 256; | |
624 | |
625 inverted = invert_lut(output, 256, inverted_size); | |
626 if (!inverted) | |
627 return; | |
628 *output_gamma_lut = inverted; | |
629 free(output); | |
615 } else { | 630 } else { |
616 if (trc->count == 0) { | 631 if (trc->count == 0) { |
617 *output_gamma_lut = build_linear_table(4096); | 632 *output_gamma_lut = build_linear_table(4096); |
618 *output_gamma_lut_length = 4096; | 633 *output_gamma_lut_length = 4096; |
619 } else if (trc->count == 1) { | 634 } else if (trc->count == 1) { |
620 float gamma = 1./u8Fixed8Number_to_float(trc->data[0]); | 635 float gamma = 1./u8Fixed8Number_to_float(trc->data[0]); |
621 *output_gamma_lut = build_pow_table(gamma, 4096); | 636 *output_gamma_lut = build_pow_table(gamma, 4096); |
622 *output_gamma_lut_length = 4096; | 637 *output_gamma_lut_length = 4096; |
623 } else { | 638 } else { |
624 //XXX: the choice of a minimum of 256 here is not backed by any theory, | 639 //XXX: the choice of a minimum of 256 here is not backed by any theory, |
625 // measurement or data, however it is what lcms uses . | 640 // measurement or data, however it is what lcms uses . |
626 *output_gamma_lut_length = trc->count; | 641 *output_gamma_lut_length = trc->count; |
627 if (*output_gamma_lut_length < 256) | 642 if (*output_gamma_lut_length < 256) |
628 *output_gamma_lut_length = 256; | 643 *output_gamma_lut_length = 256; |
629 | 644 |
630 *output_gamma_lut = invert_lut(trc->data, trc->count, *o utput_gamma_lut_length); | 645 *output_gamma_lut = invert_lut(trc->data, trc->count, *o utput_gamma_lut_length); |
631 } | 646 } |
632 } | 647 } |
633 | 648 |
634 } | 649 } |
OLD | NEW |