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

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

Issue 1920253003: Revert of Reland: [qcms] Fix build_output_lut to return correct data for parametric 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_util.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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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;
604 int inverted_size = 256;
605 603
606 if (!output) { 604 if (!output) {
607 *output_gamma_lut = NULL; 605 *output_gamma_lut = NULL;
608 return; 606 return;
609 } 607 }
610 608
611 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);
612 610 *output_gamma_lut_length = 256;
613 for(i = 0; i < 256; i++) { 611 for(i = 0; i < 256; i++) {
614 output[i] = (uint16_t)(gamma_table[i] * 65535); 612 output[i] = (uint16_t)(gamma_table[i] * 65535);
615 } 613 }
616 614 *output_gamma_lut = output;
617 //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.
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);
625 if (!inverted)
626 return;
627 *output_gamma_lut = inverted;
628 *output_gamma_lut_length = inverted_size;
629 free(output);
630 } else { 615 } else {
631 if (trc->count == 0) { 616 if (trc->count == 0) {
632 *output_gamma_lut = build_linear_table(4096); 617 *output_gamma_lut = build_linear_table(4096);
633 *output_gamma_lut_length = 4096; 618 *output_gamma_lut_length = 4096;
634 } else if (trc->count == 1) { 619 } else if (trc->count == 1) {
635 float gamma = 1./u8Fixed8Number_to_float(trc->data[0]); 620 float gamma = 1./u8Fixed8Number_to_float(trc->data[0]);
636 *output_gamma_lut = build_pow_table(gamma, 4096); 621 *output_gamma_lut = build_pow_table(gamma, 4096);
637 *output_gamma_lut_length = 4096; 622 *output_gamma_lut_length = 4096;
638 } else { 623 } else {
639 //XXX: the choice of a minimum of 256 here is not backed by any theory, 624 //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 . 625 // measurement or data, however it is what lcms uses .
641 *output_gamma_lut_length = trc->count; 626 *output_gamma_lut_length = trc->count;
642 if (*output_gamma_lut_length < 256) 627 if (*output_gamma_lut_length < 256)
643 *output_gamma_lut_length = 256; 628 *output_gamma_lut_length = 256;
644 629
645 *output_gamma_lut = invert_lut(trc->data, trc->count, *o utput_gamma_lut_length); 630 *output_gamma_lut = invert_lut(trc->data, trc->count, *o utput_gamma_lut_length);
646 } 631 }
647 } 632 }
648 633
649 } 634 }
OLDNEW
« no previous file with comments | « third_party/qcms/src/tests/qcms_test_util.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698