• Martin Möhrmann's avatar
    image/color: optimize YCbCrToRGB · f0c5b8b9
    Martin Möhrmann authored
    Use one comparison to detect underflow and overflow simultaneously.
    Use a shift, bitwise complement and uint8 type conversion to handle
    clamping to upper and lower bound without additional branching.
    
    Overall the new code is faster for a mix of
    common case, underflow and overflow.
    
    name     old time/op  new time/op  delta
    YCbCr-2  1.12ms ± 0%  0.64ms ± 0%  -43.01%  (p=0.000 n=48+47)
    
    name              old time/op  new time/op  delta
    YCbCrToRGB/0-2    5.52ns ± 0%  5.77ns ± 0%  +4.48%  (p=0.000 n=50+49)
    YCbCrToRGB/128-2  6.05ns ± 0%  5.52ns ± 0%  -8.69%  (p=0.000 n=39+50)
    YCbCrToRGB/255-2  5.80ns ± 0%  5.77ns ± 0%  -0.58%  (p=0.000 n=50+49)
    
    Found in collaboration with Josh Bleecher Snyder and Ralph Corderoy.
    
    Change-Id: Ic5020320f704966f545fdc1ae6bc24ddb5d3d09a
    Reviewed-on: https://go-review.googlesource.com/21910Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
    Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    f0c5b8b9
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...