diff options
author | noel <noel@chromium.org> | 2015-05-26 09:39:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-26 16:40:37 +0000 |
commit | 690ebf956d88e0e1ffb53a7f3e598e446651f190 (patch) | |
tree | 14b56c73845c54b4618257f62aed50bd2fb397f1 /third_party/qcms | |
parent | 159978f38c28ca89fa0504488da50f20f97a7dcd (diff) | |
download | chromium_src-690ebf956d88e0e1ffb53a7f3e598e446651f190.zip chromium_src-690ebf956d88e0e1ffb53a7f3e598e446651f190.tar.gz chromium_src-690ebf956d88e0e1ffb53a7f3e598e446651f190.tar.bz2 |
[qcms] Use half float conversion tables
BUG=491784
Review URL: https://codereview.chromium.org/1156113002
Cr-Commit-Position: refs/heads/master@{#331374}
Diffstat (limited to 'third_party/qcms')
-rw-r--r-- | third_party/qcms/README.chromium | 2 | ||||
-rw-r--r-- | third_party/qcms/src/transform_util.c | 18 | ||||
-rw-r--r-- | third_party/qcms/src/transform_util.h | 16 |
3 files changed, 15 insertions, 21 deletions
diff --git a/third_party/qcms/README.chromium b/third_party/qcms/README.chromium index 40f7c5d..1854ddf 100644 --- a/third_party/qcms/README.chromium +++ b/third_party/qcms/README.chromium @@ -69,6 +69,8 @@ The following changes have been made since qcms was imported: - https://code.google.com/p/chromium/issues/detail?id=471749 - Add float to half float conversion routine - https://code.google.com/p/chromium/issues/detail?id=491784 + - Use half float conversion tables (not functions) + - https://code.google.com/p/chromium/issues/detail?id=491784 For the Chromium changes, since the import, in a patch format run: git diff b8456f38 src diff --git a/third_party/qcms/src/transform_util.c b/third_party/qcms/src/transform_util.c index f636123..c1a9d15 100644 --- a/third_party/qcms/src/transform_util.c +++ b/third_party/qcms/src/transform_util.c @@ -586,9 +586,7 @@ void build_output_lut(struct curveType *trc, } -const unsigned short* half_float_base_table() -{ - static const unsigned short half_float_base_table_data[512] = { +const unsigned short qcms_half_float_base_table[512] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -621,14 +619,9 @@ const unsigned short* half_float_base_table() 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512, 64512 - }; - - return half_float_base_table_data; -} +}; -const unsigned char* half_float_shift_table() -{ - static const unsigned char half_float_shift_table_data[512] = { +const unsigned char qcms_half_float_shift_table[512] = { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, @@ -661,7 +654,4 @@ const unsigned char* half_float_shift_table() 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 13 - }; - - return half_float_shift_table_data; -} +}; diff --git a/third_party/qcms/src/transform_util.h b/third_party/qcms/src/transform_util.h index 0af5b12..021ca27 100644 --- a/third_party/qcms/src/transform_util.h +++ b/third_party/qcms/src/transform_util.h @@ -38,7 +38,7 @@ uint16_t lut_interp_linear16(uint16_t input_value, uint16_t *table, size_t lengt static inline float lerp(float a, float b, float t) { - return a*(1.f-t) + b*t; + return a*(1.f-t) + b*t; } unsigned char clamp_u8(float v); @@ -57,13 +57,15 @@ qcms_bool compute_precache(struct curveType *trc, uint8_t *output); static inline unsigned short float_to_half_float(float f) { - const unsigned short* half_float_base_table(); - const unsigned char* half_float_shift_table(); + extern const unsigned short qcms_half_float_base_table[]; + extern const unsigned char qcms_half_float_shift_table[]; - // See Blink::Source/platform/graphics/gpu/WebGLImageConversion.cpp::convertFloatToHalfFloat() - unsigned temp = *((unsigned *)(&f)); - unsigned signexp = (temp >> 23) & 0x1ff; - return half_float_base_table()[signexp] + ((temp & 0x007fffff) >> half_float_shift_table()[signexp]); + // See Blink::Source/platform/graphics/gpu/WebGLImageConversion.cpp::convertFloatToHalfFloat() + // and http://crbug.com/491784 + + unsigned temp = *((unsigned *)(&f)); + unsigned signexp = (temp >> 23) & 0x1ff; + return qcms_half_float_base_table[signexp] + ((temp & 0x007fffff) >> qcms_half_float_shift_table[signexp]); } #endif |