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

Use fewer multiplications in JpegImage._convertCmykToRgb #11547

Merged
merged 1 commit into from
Feb 9, 2020

Conversation

Snuffleupagus
Copy link
Collaborator

Note: This is inspired by PR #5473, which made similar changes for another kind of JPEG data.

Since the implementation in src/core/jpg.js only supports 8-bit data, as opposed to similar code in src/core/colorspace.js, the computations can be further simplified since the scale is always constant.
By updating the coefficients, effectively inlining the scale, we'll thus avoid four multiplications for each loop iteration.

Unfortunately I wasn't able, based on a quick look through the test-files, to find a sufficiently large CMYK JPEG image in order for these changes to really show up in benchmark results. However, when testing the cmykjpeg.pdf manually there's a total of 120 000 fewer multiplication with this patch.

*Note:* This is inspired by PR 5473, which made similar changes for another kind of JPEG data.

Since the implementation in `src/core/jpg.js` only supports 8-bit data, as opposed to similar code in `src/core/colorspace.js`, the computations can be further simplified since the `scale` is always constant.
By updating the coefficients, effectively inlining the `scale`, we'll thus avoid *four* multiplications for each loop iteration.

Unfortunately I wasn't able, based on a quick look through the test-files, to find a sufficiently *large* CMYK JPEG image in order for these changes to really show up in benchmark results. However, when testing the `cmykjpeg.pdf` manually there's a total of `120 000` fewer multiplication with this patch.
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/a3708a4957c505a/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/58a39edf51d6bc0/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/58a39edf51d6bc0/output.txt

Total script time: 2.20 mins

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

Image differences available at: http://54.215.176.217:8877/58a39edf51d6bc0/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/a3708a4957c505a/output.txt

Total script time: 19.51 mins

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

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

@timvandermeij
Copy link
Contributor

@brendandahl Could you perhaps fix the Windows bot failure?

@pdfjsbot
Copy link

pdfjsbot commented Feb 9, 2020

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/04e30cc3b427165/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 9, 2020

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/e9ef699baeeb549/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 9, 2020

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/e9ef699baeeb549/output.txt

Total script time: 26.21 mins

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

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

@pdfjsbot
Copy link

pdfjsbot commented Feb 9, 2020

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/04e30cc3b427165/output.txt

Total script time: 19.74 mins

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

Image differences available at: http://54.67.70.0:8877/04e30cc3b427165/reftest-analyzer.html#web=eq.log

@timvandermeij timvandermeij merged commit 102af0f into mozilla:master Feb 9, 2020
@timvandermeij
Copy link
Contributor

Good idea!

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