Changeset 101286 in webkit
- Timestamp:
- Nov 28, 2011 2:55:32 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r101275 r101286 1 2011-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 1 28 2011-11-28 Fady Samuel <fsamuel@chromium.org> 2 29 -
trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
r96970 r101286 64 64 #include <setjmp.h> 65 65 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 74 inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_EXT_BGRX; } 75 inline bool turboSwizzled(J_COLOR_SPACE colorSpace) { return colorSpace == rgbOutputColorSpace(); } 76 #else 77 inline J_COLOR_SPACE rgbOutputColorSpace() { return JCS_RGB; } 78 #endif 79 66 80 namespace WebCore { 67 81 … … 222 236 // again, resulting in horizontal distortions. 223 237 m_decoder->setIgnoreGammaAndColorProfile(true); 224 // Note fall-through! 238 m_info.out_color_space = JCS_RGB; 239 break; 225 240 case JCS_YCbCr: 226 241 case JCS_RGB: 227 m_info.out_color_space = JCS_RGB;242 m_info.out_color_space = rgbOutputColorSpace(); 228 243 break; 229 244 case JCS_CMYK: … … 482 497 483 498 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 484 512 JSAMPARRAY samples = m_reader->samples(); 485 513
Note: See TracChangeset
for help on using the changeset viewer.