| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 r = 0x10000; | 353 r = 0x10000; |
| 354 | 354 |
| 355 // If the search range is inverted due to degeneracy, | 355 // If the search range is inverted due to degeneracy, |
| 356 // deem LutTable non-invertible in this search range. | 356 // deem LutTable non-invertible in this search range. |
| 357 // Refer to https://bugzil.la/1132467 | 357 // Refer to https://bugzil.la/1132467 |
| 358 | 358 |
| 359 if (r <= l) | 359 if (r <= l) |
| 360 return 0; | 360 return 0; |
| 361 } | 361 } |
| 362 | 362 |
| 363 // For input 0, return that to maintain black level. Note the binary sea
rch |
| 364 // does not. For example, it inverts the standard sRGB gamma curve to 7
at |
| 365 // the origin, causing a black level error. |
| 366 |
| 367 if (Value == 0 && NumZeroes) { |
| 368 return 0; |
| 369 } |
| 370 |
| 363 // Seems not a degenerated case... apply binary search | 371 // Seems not a degenerated case... apply binary search |
| 364 | 372 |
| 365 while (r > l) { | 373 while (r > l) { |
| 366 | 374 |
| 367 x = (l + r) / 2; | 375 x = (l + r) / 2; |
| 368 | 376 |
| 369 res = (int) lut_interp_linear16((uint16_fract_t) (x-1), LutTable
, length); | 377 res = (int) lut_interp_linear16((uint16_fract_t) (x-1), LutTable
, length); |
| 370 | 378 |
| 371 if (res == Value) { | 379 if (res == Value) { |
| 372 | 380 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // measurement or data, however it is what lcms uses
. | 597 // measurement or data, however it is what lcms uses
. |
| 590 *output_gamma_lut_length = trc->count; | 598 *output_gamma_lut_length = trc->count; |
| 591 if (*output_gamma_lut_length < 256) | 599 if (*output_gamma_lut_length < 256) |
| 592 *output_gamma_lut_length = 256; | 600 *output_gamma_lut_length = 256; |
| 593 | 601 |
| 594 *output_gamma_lut = invert_lut(trc->data, trc->count, *o
utput_gamma_lut_length); | 602 *output_gamma_lut = invert_lut(trc->data, trc->count, *o
utput_gamma_lut_length); |
| 595 } | 603 } |
| 596 } | 604 } |
| 597 | 605 |
| 598 } | 606 } |
| OLD | NEW |