Changeset 101286 in webkit


Ignore:
Timestamp:
Nov 28, 2011 2:55:32 PM (12 years ago)
Author:
noel.gordon@gmail.com
Message:

[chromium] Use data decoding swizzle for turbo JPEG image decoding.
https://bugs.webkit.org/show_bug.cgi?id=59670

Reviewed by Kenneth Russell.

Add a BGRX row decode data swizzle for the little-endian ports that use libjpeg-turbo
(Chromium win/linux/mac) to reduce JPEG image decoding time by ~2x.

JPEG images of type JSC_GRAYSCALE are excluded since layout regressions were observed
for grayscale images produced by older tools (XV 3.10a 12/19/94). libjpeg decodes the
images without error; libjpeg-turbo caused visible artifacts (see bug for examples).

This patch is based on the work of Hironori Bono. He provided the original patch, and
the quantitative results confirming the significant performance improvement.

No new tests. Covered by many existing tests.

  • platform/image-decoders/jpeg/JPEGImageDecoder.cpp:

(rgbOutputColorSpace): If JCS_EXTENSIONS is defined (libjpeg-turbo), and the port is
little-endian, define a BGRX data swizzle for use when decoding pixel rows.
(turboSwizzled):
(WebCore::JPEGImageReader::decode): Select a possibly swizzled rgbOutputColorSpace()
for JSC_RGB and JCS_YCbCr input color space images. Exclude JSC_GRAYSCALE images.
(WebCore::JPEGImageDecoder::outputScanlines): Swizzle decode, if applicable.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r101275 r101286  
     12011-11-28  Noel Gordon  <noel.gordon@gmail.com>
     2
     3        [chromium] Use data decoding swizzle for turbo JPEG image decoding.
     4        https://bugs.webkit.org/show_bug.cgi?id=59670
     5
     6        Reviewed by Kenneth Russell.
     7
     8        Add a BGRX row decode data swizzle for the little-endian ports that use libjpeg-turbo
     9        (Chromium win/linux/mac) to reduce JPEG image decoding time by ~2x.
     10
     11        JPEG images of type JSC_GRAYSCALE are excluded since layout regressions were observed
     12        for grayscale images produced by older tools (XV 3.10a 12/19/94). libjpeg decodes the
     13        images without error; libjpeg-turbo caused visible artifacts (see bug for examples).
     14
     15        This patch is based on the work of Hironori Bono. He provided the original patch, and
     16        the quantitative results confirming the significant performance improvement.
     17
     18        No new tests. Covered by many existing tests.
     19
     20        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
     21        (rgbOutputColorSpace):  If JCS_EXTENSIONS is defined (libjpeg-turbo), and the port is
     22        little-endian, define a BGRX data swizzle for use when decoding pixel rows.
     23        (turboSwizzled):
     24        (WebCore::JPEGImageReader::decode):  Select a possibly swizzled rgbOutputColorSpace()
     25        for JSC_RGB and JCS_YCbCr input color space images.  Exclude JSC_GRAYSCALE images.
     26        (WebCore::JPEGImageDecoder::outputScanlines):  Swizzle decode, if applicable.
     27
    1282011-11-28  Fady Samuel  <fsamuel@chromium.org>
    229
  • trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

    r96970 r101286  
    6464#include <setjmp.h>
    6565
     66#if CPU(BIG_ENDIAN) || CPU(MIDDLE_ENDIAN)
     67#define ASSUME_LITTLE_ENDIAN 0
     68#else
     69#define ASSUME_LITTLE_ENDIAN 1
     70#endif
     71
     72#if defined(JCS_EXTENSIONS) && ASSUME_LITTLE_ENDIAN
     73#define TURBO_JPEG_RGB_SWIZZLE
     74inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_EXT_BGRX; }
     75inline bool turboSwizzled(J_COLOR_SPACE colorSpace) { return colorSpace == rgbOutputColorSpace(); }
     76#else
     77inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_RGB; }
     78#endif
     79
    6680namespace WebCore {
    6781
     
    222236                // again, resulting in horizontal distortions.
    223237                m_decoder->setIgnoreGammaAndColorProfile(true);
    224                 // Note fall-through!
     238                m_info.out_color_space = JCS_RGB;
     239                break;
    225240            case JCS_YCbCr:
    226241            case JCS_RGB:
    227                 m_info.out_color_space = JCS_RGB;
     242                m_info.out_color_space = rgbOutputColorSpace();
    228243                break;
    229244            case JCS_CMYK:
     
    482497
    483498    jpeg_decompress_struct* info = m_reader->info();
     499
     500#if !ENABLE(IMAGE_DECODER_DOWN_SAMPLING) && defined(TURBO_JPEG_RGB_SWIZZLE)
     501    if (turboSwizzled(info->out_color_space)) {
     502         ASSERT(!m_scaled);
     503         while (info->output_scanline < info->output_height) {
     504             unsigned char* row = reinterpret_cast<unsigned char*>(buffer.getAddr(0, info->output_scanline));
     505             if (jpeg_read_scanlines(info, &row, 1) != 1)
     506                  return false;
     507         }
     508         return true;
     509     }
     510#endif
     511
    484512    JSAMPARRAY samples = m_reader->samples();
    485513
Note: See TracChangeset for help on using the changeset viewer.