Chromium Code Reviews| 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 } | 594 } |
| 595 | 595 |
| 596 void build_output_lut(struct curveType *trc, | 596 void build_output_lut(struct curveType *trc, |
| 597 uint16_t **output_gamma_lut, size_t *output_gamma_lut_length) | 597 uint16_t **output_gamma_lut, size_t *output_gamma_lut_length) |
| 598 { | 598 { |
| 599 if (trc->type == PARAMETRIC_CURVE_TYPE) { | 599 if (trc->type == PARAMETRIC_CURVE_TYPE) { |
| 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 uint16_t *inverted; | 603 uint16_t *inverted; |
| 604 int inverted_size = 256; | 604 int inverted_size; |
| 605 | 605 |
| 606 if (!output) { | 606 if (!output) { |
| 607 *output_gamma_lut = NULL; | 607 *output_gamma_lut = NULL; |
| 608 return; | 608 return; |
| 609 } | 609 } |
| 610 | 610 |
| 611 compute_curve_gamma_table_type_parametric(gamma_table, trc->para meter, trc->count); | 611 compute_curve_gamma_table_type_parametric(gamma_table, trc->para meter, trc->count); |
| 612 | 612 |
| 613 for(i = 0; i < 256; i++) { | 613 for(i = 0; i < 256; i++) { |
| 614 output[i] = (uint16_t)(gamma_table[i] * 65535); | 614 output[i] = (uint16_t)(gamma_table[i] * 65535); |
| 615 } | 615 } |
| 616 | 616 |
| 617 //XXX: the choice of a minimum of 256 here is not backed by any theory, | 617 // XXX: Comment required. |
| 618 // measurement or data, however it is what lcms uses. | 618 inverted_size = 4096; |
|
Noel Gordon
2016/04/28 07:30:27
Do this at line 604 diff-right. int inverted_size
radu.velea
2016/04/28 08:17:25
Done.
| |
| 619 // the maximum number we would need is 65535 because that's the | |
| 620 // accuracy used for computing the pre cache table | |
| 621 if (inverted_size < 256) | |
| 622 inverted_size = 256; | |
| 623 | |
| 624 inverted = invert_lut(output, 256, inverted_size); | 619 inverted = invert_lut(output, 256, inverted_size); |
| 625 if (!inverted) | 620 if (!inverted) |
| 626 return; | 621 return; |
| 627 *output_gamma_lut = inverted; | 622 *output_gamma_lut = inverted; |
| 628 *output_gamma_lut_length = inverted_size; | 623 *output_gamma_lut_length = inverted_size; |
| 629 free(output); | 624 free(output); |
| 630 } else { | 625 } else { |
| 631 if (trc->count == 0) { | 626 if (trc->count == 0) { |
| 632 *output_gamma_lut = build_linear_table(4096); | 627 *output_gamma_lut = build_linear_table(4096); |
| 633 *output_gamma_lut_length = 4096; | 628 *output_gamma_lut_length = 4096; |
| 634 } else if (trc->count == 1) { | 629 } else if (trc->count == 1) { |
| 635 float gamma = 1./u8Fixed8Number_to_float(trc->data[0]); | 630 float gamma = 1./u8Fixed8Number_to_float(trc->data[0]); |
| 636 *output_gamma_lut = build_pow_table(gamma, 4096); | 631 *output_gamma_lut = build_pow_table(gamma, 4096); |
| 637 *output_gamma_lut_length = 4096; | 632 *output_gamma_lut_length = 4096; |
| 638 } else { | 633 } else { |
| 639 //XXX: the choice of a minimum of 256 here is not backed by any theory, | 634 //XXX: the choice of a minimum of 256 here is not backed by any theory, |
| 640 // measurement or data, however it is what lcms uses . | 635 // measurement or data, however it is what lcms uses . |
| 641 *output_gamma_lut_length = trc->count; | 636 *output_gamma_lut_length = trc->count; |
| 642 if (*output_gamma_lut_length < 256) | 637 if (*output_gamma_lut_length < 256) |
| 643 *output_gamma_lut_length = 256; | 638 *output_gamma_lut_length = 256; |
| 644 | 639 |
| 645 *output_gamma_lut = invert_lut(trc->data, trc->count, *o utput_gamma_lut_length); | 640 *output_gamma_lut = invert_lut(trc->data, trc->count, *o utput_gamma_lut_length); |
| 646 } | 641 } |
| 647 } | 642 } |
| 648 | 643 |
| 649 } | 644 } |
| OLD | NEW |