Disable dithering in libjpeg-turbo for 565 decodes
authormsarett <msarett@google.com>
Fri, 18 Sep 2015 19:06:04 +0000 (12:06 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 18 Sep 2015 19:06:04 +0000 (12:06 -0700)
commit8ff6ca6e73644b0bec65c9dfeaa5ca01110d948c
treee151e3e7c0335fe262607c364f45a75508258dee
parent496d29f6b273340efa59f1077d9338688c685f1b
Disable dithering in libjpeg-turbo for 565 decodes

libjpeg-turbo turns on dithering by default.  When we
decode to RGBA, it uses Floyd-Steinberg dithering -
consistent with the libjpeg6b gold standard,

When we decode to 565, it uses ordered dithering.  Ordered
dithering for 565 is not part of the 6b standard (libjpeg6b
doesn't even support 565) and is causing us a number of
issues:
(1) Ordered dithering + nearest neighbor sampling is
causing checkerboard visual artifacts in some outputs.
(2) The ordered dither function in libjpeg-turbo actually
behaves differently depending on the alignment of the
memory that it decodes into.  This means that two image
decodes that should be identical may look different just
because they decode into different memory blocks.  This
was causing some diffs on Gold with the scanline_subset
test that were causing me some confusion.
(3) Maybe not the best evidence, but visually I can't tell
a difference with and without dithering (except when
nearest neighbor scaling causes the checkerboard artifact).
(4) Turning off dithering should be a more significant
performance improvement than you might expect.
libjpeg-turbo has SIMD color conversions to 565, but when
dithering is on, it defaults to scalar code.

This CL should make every jpeg decode to 565 on Gold look
slightly different.  Yay!

BUG=skia:

Review URL: https://codereview.chromium.org/1349563007
src/codec/SkJpegCodec.cpp
tests/CodexTest.cpp