Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(998)

Unified Diff: Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

Issue 480093003: Follow up on previous cl (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed code and removed change to test Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/image-decoders/ImageDecoder.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
diff --git a/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
index e0c2deacb8b0161184537aacb45988298548da9f..972e34bfc09a892ad1912441720646dc3767a40a 100644
--- a/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
+++ b/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
@@ -259,7 +259,7 @@ static IntSize computeUVSize(const jpeg_decompress_struct* info)
return IntSize((info->output_width + h - 1) / h, (info->output_height + v - 1) / v);
}
-static yuv_subsampling getYUVSubsampling(const jpeg_decompress_struct& info)
+static yuv_subsampling yuvSubsampling(const jpeg_decompress_struct& info)
{
if ((DCTSIZE == 8)
&& (info.num_components == 3)
@@ -400,6 +400,7 @@ public:
if (setjmp(m_err.setjmp_buffer))
return m_decoder->setFailed();
+ J_COLOR_SPACE overrideColorSpace = JCS_UNKNOWN;
switch (m_state) {
case JPEG_HEADER:
// Read file parameters with jpeg_read_header().
@@ -410,9 +411,8 @@ public:
case JCS_YCbCr:
// libjpeg can convert YCbCr image pixels to RGB.
m_info.out_color_space = rgbOutputColorSpace();
- if (m_decoder->YUVDecoding() && (getYUVSubsampling(m_info) != YUV_UNKNOWN)) {
- m_info.out_color_space = JCS_YCbCr;
- m_info.raw_data_out = TRUE;
+ if (m_decoder->YUVDecoding() && (yuvSubsampling(m_info) != YUV_UNKNOWN)) {
+ overrideColorSpace = JCS_YCbCr;
}
break;
case JCS_GRAYSCALE:
@@ -458,18 +458,22 @@ public:
ColorProfile colorProfile;
readColorProfile(info(), colorProfile);
createColorTransform(colorProfile, colorSpaceHasAlpha(m_info.out_color_space));
- if (m_transform && m_info.out_color_space == JCS_YCbCr) {
- m_info.out_color_space = rgbOutputColorSpace();
- m_info.raw_data_out = FALSE;
- }
+ if (m_transform) {
+ overrideColorSpace = JCS_UNKNOWN;
#if defined(TURBO_JPEG_RGB_SWIZZLE)
- // Input RGBA data to qcms. Note: restored to BGRA on output.
- if (m_transform && m_info.out_color_space == JCS_EXT_BGRA)
- m_info.out_color_space = JCS_EXT_RGBA;
+ // Input RGBA data to qcms. Note: restored to BGRA on output.
+ if (m_info.out_color_space == JCS_EXT_BGRA)
+ m_info.out_color_space = JCS_EXT_RGBA;
#endif
+ }
m_decoder->setHasColorProfile(!!m_transform);
}
#endif
+ if (overrideColorSpace == JCS_YCbCr) {
+ m_info.out_color_space = JCS_YCbCr;
+ m_info.raw_data_out = TRUE;
+ }
+
// Don't allocate a giant and superfluous memory buffer when the
// image is a sequential JPEG.
m_info.buffered_image = jpeg_has_multiple_scans(&m_info);
« no previous file with comments | « Source/platform/image-decoders/ImageDecoder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698