Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: third_party/qcms/src/transform_util.c

Issue 1929143003: [qcms] Use a static table in build_output_lut to invert para curves (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/qcms/src/tests/qcms_test_output_trc.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 output[i] = result; 591 output[i] = result;
592 } 592 }
593 return output; 593 return output;
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 gamma_table_uint[256];
601 uint16_t i; 602 uint16_t i;
602 uint16_t *output = malloc(sizeof(uint16_t)*256);
603 uint16_t *inverted; 603 uint16_t *inverted;
604 int inverted_size = 4096; 604 int inverted_size = 4096;
605 605
606 if (!output) {
607 *output_gamma_lut = NULL;
608 return;
609 }
610
611 compute_curve_gamma_table_type_parametric(gamma_table, trc->para meter, trc->count); 606 compute_curve_gamma_table_type_parametric(gamma_table, trc->para meter, trc->count);
612
613 for(i = 0; i < 256; i++) { 607 for(i = 0; i < 256; i++) {
614 output[i] = (uint16_t)(gamma_table[i] * 65535); 608 gamma_table_uint[i] = (uint16_t)(gamma_table[i] * 65535) ;
615 } 609 }
616 610
617 //XXX: the choice of a minimum of 256 here is not backed by any theory, 611 //XXX: the choice of a minimum of 256 here is not backed by any theory,
618 // measurement or data, however it is what lcms uses. 612 // measurement or data, however it is what lcms uses.
619 // the maximum number we would need is 65535 because that's the 613 // the maximum number we would need is 65535 because that's the
620 // accuracy used for computing the pre cache table 614 // accuracy used for computing the pre cache table
621 inverted = invert_lut(output, 256, inverted_size); 615 inverted = invert_lut(gamma_table_uint, 256, inverted_size);
622 if (!inverted) 616 if (!inverted)
623 return; 617 return;
624 *output_gamma_lut = inverted; 618 *output_gamma_lut = inverted;
625 *output_gamma_lut_length = inverted_size; 619 *output_gamma_lut_length = inverted_size;
626 free(output);
627 } else { 620 } else {
628 if (trc->count == 0) { 621 if (trc->count == 0) {
629 *output_gamma_lut = build_linear_table(4096); 622 *output_gamma_lut = build_linear_table(4096);
630 *output_gamma_lut_length = 4096; 623 *output_gamma_lut_length = 4096;
631 } else if (trc->count == 1) { 624 } else if (trc->count == 1) {
632 float gamma = 1./u8Fixed8Number_to_float(trc->data[0]); 625 float gamma = 1./u8Fixed8Number_to_float(trc->data[0]);
633 *output_gamma_lut = build_pow_table(gamma, 4096); 626 *output_gamma_lut = build_pow_table(gamma, 4096);
634 *output_gamma_lut_length = 4096; 627 *output_gamma_lut_length = 4096;
635 } else { 628 } else {
636 //XXX: the choice of a minimum of 256 here is not backed by any theory, 629 //XXX: the choice of a minimum of 256 here is not backed by any theory,
637 // measurement or data, however it is what lcms uses . 630 // measurement or data, however it is what lcms uses .
638 *output_gamma_lut_length = trc->count; 631 *output_gamma_lut_length = trc->count;
639 if (*output_gamma_lut_length < 256) 632 if (*output_gamma_lut_length < 256)
640 *output_gamma_lut_length = 256; 633 *output_gamma_lut_length = 256;
641 634
642 *output_gamma_lut = invert_lut(trc->data, trc->count, *o utput_gamma_lut_length); 635 *output_gamma_lut = invert_lut(trc->data, trc->count, *o utput_gamma_lut_length);
643 } 636 }
644 } 637 }
645 638
646 } 639 }
OLDNEW
« no previous file with comments | « third_party/qcms/src/tests/qcms_test_output_trc.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698