Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JpegImage.getData to support forceRGBoutput for images with numComponents === 1 (issue 6066) #6984

Merged
merged 1 commit into from
Feb 18, 2016

Conversation

Snuffleupagus
Copy link
Collaborator

A more robust solution for issue #6066.

As a temporary work-around for (the upstream) bug 1164199, we parsed all images in the Firefox addon during a short time.
Doing so uncovered an issue with our image handling (see #6066), for JPEG images with a DeviceGray ColorSpace and bpc !== 1 (bits per component).

As long as we let the browser handle image decoding in this case, this isn't going to be an issue, but I do think that we should proactively fix this to avoid future issues if we change where the images are decoded (in jpg.js vs in browser).
Also, we currently don't seem to have a test-case for that kind of image data.

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.22.172.223:8877/03c240f23393c15/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/b4e0a3d7f37e8f5/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/03c240f23393c15/output.txt

Total script time: 20.40 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux)


Failed

Full output at http://107.21.233.14:8877/b4e0a3d7f37e8f5/output.txt

Total script time: 21.61 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://107.21.233.14:8877/b4e0a3d7f37e8f5/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/1a01196acabbb20/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/1a01196acabbb20/output.txt

Total script time: 21.82 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@Snuffleupagus
Copy link
Collaborator Author

Note that the fast-path for JPEG images was added in PR #4528.
In PR #4892 it was tweaked, in order to fix a regression. Then in PR #6366 it was changed again to address another regression, and this PR tries to avoid yet another regression in this code.

@brendandahl
Copy link
Contributor

Something that may be worth exploring is always using jpg.js. In a few basic tests I did it was actually faster to not use the browser to decode images.

@Snuffleupagus
Copy link
Collaborator Author

Something that may be worth exploring is always using jpg.js. In a few basic tests I did it was actually faster to not use the browser to decode images.

Yes, it could be interesting to compare the performance!
I've not looked at the performance side of things, but a while back I tested it locally, and there were a couple of regressions that would need to be addressed if we made the switch, and this patch would fix one of them.
@brendandahl Are you OK with landing this PR?

@brendandahl
Copy link
Contributor

@brendandahl Are you OK with landing this PR?

What about fixing JpegImage.getData() for numComponents === 1 and forceRGB = true?

"md5": "b26eb08fc5ab2518ba8fde603bdfc46b",
"rounds": 1,
"link": true,
"firstPage": 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to run both pages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, I've changed this in the new patch.

@Snuffleupagus Snuffleupagus changed the title Don't take the fast-path in PDFImage_createImageData for unmasked JPEG images with DeviceGray ColorSpaces Update JpegImage.getData to support forceRGBoutput for images with numComponents === 1 (issue 6066) Feb 17, 2016
@Snuffleupagus
Copy link
Collaborator Author

What about fixing JpegImage.getData() for numComponents === 1 and forceRGB = true?

Is the new patch more in line with what you had in mind here?

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.22.172.223:8877/5fffab191b05d6e/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/47c51abae870185/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/5fffab191b05d6e/output.txt

Total script time: 20.37 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/47c51abae870185/output.txt

Total script time: 21.57 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

var rgbData = new Uint8Array(width * height * 3);
var offset = 0;
for (var i = 0, ii = data.length; i < ii; i++) {
rgbData[offset++] = data[i];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the jit is smart enough to realize it's accessing the same data[i] here. Best to probably stick it in a variable within the loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.

@brendandahl
Copy link
Contributor

Is the new patch more in line with what you had in mind here?

Yup, looks good with one nit fixed above.

…h `numComponents === 1` (issue 6066)

*A more robust solution for issue 6066.*

As a temporary work-around for (the upstream) [bug 1164199](https://bugzilla.mozilla.org/show_bug.cgi?id=1164199), we parsed *all* images in the Firefox addon during a short time.
Doing so uncovered an issue with our image handling (see 6066), for JPEG images with a `DeviceGray` ColorSpace *and* `bpc !== 1` (bits per component).

As long as we let the browser handle image decoding in this case, this isn't going to be an issue, but I do think that we should proactively fix this to avoid future issues if we change where the images are decoded (in `jpg.js` vs in browser).
Also, we currently don't seem to have a test-case for that kind of image data.
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/93201b0394df9e3/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.22.172.223:8877/dcd4ec06dce6ea6/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/dcd4ec06dce6ea6/output.txt

Total script time: 20.25 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/93201b0394df9e3/output.txt

Total script time: 21.81 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@Snuffleupagus
Copy link
Collaborator Author

Is the new patch more in line with what you had in mind here?

Yup, looks good with one nit fixed above.

I'm assuming that this means r+, so having addressed the nit, I'm going to land this.
@brendandahl Thanks for reviewing!

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_makeref from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/32831967815e323/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_makeref from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.22.172.223:8877/fd574f523d316c9/output.txt

Snuffleupagus added a commit that referenced this pull request Feb 18, 2016
Update `JpegImage.getData` to support `forceRGBoutput` for images with `numComponents === 1` (issue 6066)
@Snuffleupagus Snuffleupagus merged commit 8cdb696 into mozilla:master Feb 18, 2016
@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/fd574f523d316c9/output.txt

Total script time: 19.99 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/32831967815e323/output.txt

Total script time: 21.00 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants