Bug 48819 - JPEG decoders should understand color profiles
Summary: JPEG decoders should understand color profiles
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on: 48866
Blocks:
  Show dependency treegraph
 
Reported: 2010-11-01 23:27 PDT by Adam Barth
Modified: 2011-12-13 16:55 PST (History)
8 users (show)

See Also:


Attachments
work in progress (2.77 KB, patch)
2010-11-01 23:29 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
patch (needs iccjpeg before landing) (4.48 KB, patch)
2010-11-02 02:14 PDT, Adam Barth
no flags Details | Formatted Diff | Diff
patch (needs iccjpeg before landing) (4.54 KB, patch)
2010-11-02 02:35 PDT, Adam Barth
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2010-11-01 23:27:53 PDT
JPEG decoders should understand color profiles
Comment 1 Adam Barth 2010-11-01 23:29:01 PDT
Created attachment 72632 [details]
work in progress
Comment 2 Adam Barth 2010-11-02 02:14:53 PDT
Created attachment 72639 [details]
patch (needs iccjpeg before landing)
Comment 3 Eric Seidel (no email) 2010-11-02 02:30:37 PDT
Comment on attachment 72639 [details]
patch (needs iccjpeg before landing)

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

In general I support this change.  I'd like to see your comments first.

I think ColorProfile should probably not be just a Vector but rather a class wrapping a vector or similar?

Should we make ColorProfile RefCounted to avoid the copy?  I'm not sure how large these structs are, or how hot these paths are, but copies seem bad. :)

> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp:106
> +    ColorProfile colorProfile;
> +    colorProfile.append(reinterpret_cast<char*>(profile), profileLength);
> +    free(profile);

Can we just adopt it?

> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp:152
> +        for (unsigned i = JPEG_APP0; i < JPEG_COM; ++i)
> +            jpeg_save_markers(&m_info, i, 0xFFFF);

This needs a comment, methinks.

> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp:453
> +        buffer.setColorProfile(m_colorProfile);

Very confusing that there are multiple classes in this file.

> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h:57
> +        void setColorProfile(const ColorProfile& colorProfile) { m_colorProfile = colorProfile; }

Copying seems "bad" here.
Comment 4 Adam Barth 2010-11-02 02:33:14 PDT
Comment on attachment 72639 [details]
patch (needs iccjpeg before landing)

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

>> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp:106
>> +    ColorProfile colorProfile;
>> +    colorProfile.append(reinterpret_cast<char*>(profile), profileLength);
>> +    free(profile);
> 
> Can we just adopt it?

The problem is that if we adopted it, we'd free it with delete instead of free().  :(

>> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp:152
>> +        for (unsigned i = JPEG_APP0; i < JPEG_COM; ++i)
>> +            jpeg_save_markers(&m_info, i, 0xFFFF);
> 
> This needs a comment, methinks.

Okiedokes.  It's pretty mysterious.

>> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp:453
>> +        buffer.setColorProfile(m_colorProfile);
> 
> Very confusing that there are multiple classes in this file.

Yes.  We could clean up all this code.

>> WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h:57
>> +        void setColorProfile(const ColorProfile& colorProfile) { m_colorProfile = colorProfile; }
> 
> Copying seems "bad" here.

We could make it RefCounted.  I'm tempted to do that in a separate patch though since ColorProfile is used by PNGs too now.
Comment 5 Adam Barth 2010-11-02 02:35:12 PDT
Created attachment 72640 [details]
patch (needs iccjpeg before landing)
Comment 6 Eric Seidel (no email) 2010-11-02 03:37:11 PDT
Attachment 72640 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/4932011
Comment 7 Adam Barth 2010-11-02 12:45:54 PDT
Committed r71152: <http://trac.webkit.org/changeset/71152>
Comment 8 WebKit Review Bot 2010-11-02 12:52:07 PDT
Attachment 72640 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/4919025
Comment 9 Adam Barth 2010-11-02 12:54:40 PDT
I landed this disabled for the time being.  I'll file another bug to actually enable the code once we have the ICCJPEG library in DEPS.
Comment 10 WebKit Review Bot 2010-11-02 13:32:35 PDT
http://trac.webkit.org/changeset/71152 might have broken GTK Linux 64-bit Debug
The following tests are not passing:
canvas/philip/tests/toDataURL.jpeg.primarycolours.html
fast/backgrounds/background-repeat-computed-style.html
fast/backgrounds/size/backgroundSize17.html
fast/backgrounds/size/backgroundSize18.html
fast/backgrounds/size/backgroundSize19.html
fast/backgrounds/size/contain-and-cover.html
fast/blockflow/background-horizontal-bt.html
fast/blockflow/background-vertical-lr.html
fast/blockflow/background-vertical-rl.html
fast/canvas/toDataURL-supportedTypes.html
fast/dom/HTMLImageElement/image-load-cross-document.html
fast/dom/HTMLImageElement/image-loading-gc.html
fast/dom/HTMLImageElement/image-natural-width-height.html
fast/dom/HTMLLinkElement/onload-completion-test.html
fast/dom/beforeload/image-before-load-innerHTML.html
fast/dom/beforeload/image-before-load.html
fast/dom/beforeload/image-object-before-load-innerHTML.html
fast/dom/beforeload/image-object-before-load.html
fast/dom/beforeload/remove-image-in-beforeload-listener.html
fast/dom/inner-text-001.html
Comment 11 James Robinson 2010-11-02 13:57:39 PDT
Reverted: http://trac.webkit.org/changeset/71162.  Apparently some of this code does run somewhere.
Comment 12 Adam Barth 2010-11-02 15:01:53 PDT
Committed r71174: <http://trac.webkit.org/changeset/71174>
Comment 13 noel gordon 2011-12-13 16:55:19 PST
(In reply to comment #3)

> Should we make ColorProfile RefCounted to avoid the copy?  I'm not sure how large these structs are, or how hot these paths are, but copies seem bad. :)

557188 bytes of ICC profile data on this image, http://i.imgur.com/KZGJX.jpg :)
 
> > WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h:57
> > +        void setColorProfile(const ColorProfile& colorProfile) { m_colorProfile = colorProfile; }
> 
> Copying seems "bad" here.

557188 x 2 bytes in toto then?