Bug 79457

Summary: [chromium] JPEG RGB image with Adode Marker fails to turbo swizzle decode
Product: WebKit Reporter: noel gordon <noel.gordon>
Component: New BugsAssignee: noel gordon <noel.gordon>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, dcommander, enne, hbono, Hironori.Fujii, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=200163
Bug Depends on:    
Bug Blocks: 59670    
Attachments:
Description Flags
apron.jpg
none
Patch
none
Patch none

Description noel gordon 2012-02-24 00:18:16 PST
http://crbug.com/115287
Comment 1 noel gordon 2012-02-24 00:28:45 PST
If a JPEG has no JFIF marker, the Adode Marker must be used to determine the image color space for decoding by consulting the transform flag values of the Adobe Marker:

  2 - The image is encoded as YCCK (implicitly converted from CMYK on encoding).
  1 - The image is encoded as YCbCr (implicitly converted from RGB on encoding).
  0 - Unknown. 3-channel images are assumed to be RGB, 4-channel images are assumed to be CMYK.

The attached image has no JFIF marker, but has an Adobe marker transform 0, meaning an RGB image since it has 3 color channels.  Such images fail to decode in libjpeg-turbo if swizzle decoding is active.
Comment 2 noel gordon 2012-02-24 00:32:04 PST
Created attachment 128675 [details]
apron.jpg

Image meta details:

% jpegtopnm --comments --verbose --dumpexif apron.jpg > test.ppm 

Start of Image
Adobe APP14 marker: version 100, flags 0x0000 0x0000, transform 0   <-- Adode Marker, transform 0
Define Quantization Table 0  precision 0
Start Of Frame 0xc0: width=225, height=156, components=3    <-- 3 color components
    Component 82: 1hx1v q=0
    Component 71: 1hx1v q=0
    Component 66: 1hx1v q=0
Define Huffman Table 0x00
Define Huffman Table 0x10
Start Of Scan: 3 components
    Component 82: dc=0 ac=0
    Component 71: dc=0 ac=0
    Component 66: dc=0 ac=0
  Ss=0, Se=63, Ah=0, Al=0
jpegtopnm: input color space is 2 (JCS_RGB)  <-- RGB color space, since 3 color components
...
Comment 3 noel gordon 2012-02-24 01:48:42 PST
Created attachment 128689 [details]
Patch
Comment 4 Adam Barth 2012-02-24 15:18:04 PST
Comment on attachment 128689 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=128689&action=review

> Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp:249
> +                // FIXME: swizzler incorrectly handles Adobe transform=0 images

swizzler => The swizzler (Comments should use complete sentences.)
Comment 5 noel gordon 2012-02-24 15:38:03 PST
Roger that. Flaky connection mode here. Will cq+ and fix in followup.
Comment 6 WebKit Review Bot 2012-02-24 16:50:05 PST
Comment on attachment 128689 [details]
Patch

Clearing flags on attachment: 128689

Committed r108870: <http://trac.webkit.org/changeset/108870>
Comment 7 WebKit Review Bot 2012-02-24 16:50:10 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 DRC 2012-02-24 17:28:38 PST
I can't tell whether this is working around an issue in libjpeg-turbo or in the layers above it. If this is something that needs to be fixed in libjpeg-turbo, let me know.
Comment 9 Adrienne Walker 2012-02-24 18:57:25 PST
Committed r108884: <http://trac.webkit.org/changeset/108884>
Comment 10 noel gordon 2012-02-24 23:21:21 PST
Committed r108887: <http://trac.webkit.org/changeset/108887>
Comment 11 noel gordon 2012-02-26 23:31:43 PST
(In reply to comment #8)
> I can't tell whether this is working around an issue in libjpeg-turbo or in the layers above it. If this is something that needs to be fixed in libjpeg-turbo, let me know.

Yes it's a work-around of sorts, for the reasons noted in http://code.google.com/p/chromium/issues/detail?id=115287#c15. Seems there's no JSC_RGB -> JSC_EXT_BGRA etc converter.  I believe hbono-san is preparing a libjpeg-turbo patch to remedy that ...
Comment 12 Hironori Bono 2012-02-27 00:06:20 PST
Greetings,

Thanks for your comments. I have filed an upstream bug (*1) and uploaded my quick fix (*2).

(*1) https://sourceforge.net/tracker/?func=detail&aid=3494910&group_id=303195&atid=1278158
(*2) http://sourceforge.net/tracker/?func=detail&aid=3494911&group_id=303195&atid=1278160

Regards,

Hironori Bono

(In reply to comment #11)
> Yes it's a work-around of sorts, for the reasons noted in http://code.google.com/p/chromium/issues/detail?id=115287#c15. Seems there's no JSC_RGB -> JSC_EXT_BGRA etc converter.  I believe hbono-san is preparing a libjpeg-turbo patch to remedy that ...
Comment 13 noel gordon 2012-02-27 23:06:31 PST
Reopening to attach new patch.
Comment 14 noel gordon 2012-02-27 23:06:36 PST
Created attachment 129193 [details]
Patch
Comment 15 WebKit Review Bot 2012-02-28 00:08:06 PST
Comment on attachment 129193 [details]
Patch

Clearing flags on attachment: 129193

Committed r109086: <http://trac.webkit.org/changeset/109086>
Comment 16 WebKit Review Bot 2012-02-28 00:08:11 PST
All reviewed patches have been landed.  Closing bug.
Comment 17 DRC 2012-03-11 15:07:37 PDT
Fixed upstream
Comment 18 noel gordon 2012-03-12 03:51:24 PDT
r808 LGTM.  Will it be part of the 1.2.0 libjpeg-turbo release?
Comment 19 DRC 2012-03-12 05:24:24 PDT
1.2.0 has been out for some time.  It will be part of 1.2.1.