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

For JPX decoding only read next packet after checking for byte aligning. #5350

Merged
merged 1 commit into from
Oct 21, 2014

Conversation

CodingFabian
Copy link
Contributor

This patch makes the image from #5349 appear correctly, however artefacts
for the last packet seem to still be there.
This patch also optimizes some "in-checks" and adds a few header parsings.

@yurydelendik
Copy link
Contributor

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_preview from @yurydelendik received. Current queue size: 0

Live output at: http://107.22.172.223:8877/320587b54bb289a/output.txt

@CodingFabian
Copy link
Contributor Author

the main "fix" is to invoke "var packet = packetsIterator.nextPacket();" only when the byte aligning has happened.
I would appreciate a botio run to see if/how it generally affects the other pdfs.
There still seems to be an issue with the last element, because that one is colorful.
somehow i feel there is some bit/byte skipping logic off.

@CodingFabian
Copy link
Contributor Author

this patch also makes #4814 render better - the screenshot by @yurydelendik where the girl is blurry is fixed. but the document still has other issues

@yurydelendik
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

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

Total script time: 2.85 mins

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

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Failed

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

Total script time: 22.13 mins

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

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

@CodingFabian
Copy link
Contributor Author

interesting, seems like the 3591 issue is the same issue in reverse :)
Thanks for the run, I will consider this PR WIP. Maybe I did through the bit-reading code at some time. It feels for me that there is an 1 off error somewhere...

@CodingFabian CodingFabian changed the title For JPX decoding only read next packet after checking for byte aligning. WIP: For JPX decoding only read next packet after checking for byte aligning. Sep 27, 2014
@CodingFabian
Copy link
Contributor Author

fixed the regression of #3591. still want to look a bit more into it.

@timvandermeij timvandermeij changed the title WIP: For JPX decoding only read next packet after checking for byte aligning. For JPX decoding only read next packet after checking for byte aligning. Sep 27, 2014
@CodingFabian
Copy link
Contributor Author

I would say the fix is correct. There is an issue with the last tile when its dimension is small. I added a comment to #4358, that i assume that it is caused by not limiting the decoding size correctly for small tiles.

@CodingFabian
Copy link
Contributor Author

I think its good to merge. who can verify for me @yurydelendik , @Snuffleupagus, @fkaelberer

var colorspace = readUint32(data, position + 3);
switch (colorspace) {
case 16:
warn('sRGB colorspace not supported');
Copy link
Contributor

Choose a reason for hiding this comment

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

sRGB and grayscale are the two supported colorspaces, aren't they?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well yes :-) I only expanded the todo from the previous code. This was not handling colorspaces at all. Maybe I should reword this to warn: Todo ?

@CodingFabian
Copy link
Contributor Author

@fkaelberer thanks for the review Felix.
I made the change you suggested and yes manual checks look better for a few documents.
maybe @yurydelendik can run regression tests for me?
While i believe there is still a problem with the decoding (the random readBits(1) and alignTobyte seem odd) this patch makes the images we checked to render better now.

@timvandermeij
Copy link
Contributor

Travis complains: src/core/jpx.js: line 95, col 15, 'info' is not defined.

@CodingFabian
Copy link
Contributor Author

strange, travis didnt complain earlier and i did not remove the import. thanks for pointing this out

// TODO
break;
default:
warn('Unsupported header type ' + tbox);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should make the errors more human readable:

          default:
            var headerType = String.fromCharCode((tbox >> 24) & 0xFF,
                                                 (tbox >> 16) & 0xFF,
                                                 (tbox >> 8) & 0xFF,
                                                 tbox & 0xFF);
            warn('Unsupported header type ' + tbox + ' (' + headerType + ')');

@CodingFabian
Copy link
Contributor Author

@fkaelberer okay i reverted some of the experimental changes which did not have benefit.
it is now basically moving the alignByte out of the if check.
Besides that some additional header parsing for debugging aid and new style array access.
together with your #5426 it renders #5349 perfectly.

@fkaelberer
Copy link
Contributor

Nice! The code looks very good to me.

// this indicates a YUV colorspace
break;
default:
warn('Unknown colorspace');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: here and below, add break; for default:

This patch makes the image from mozilla#5349 appear correctly, the artefacts
for the last packet are fixed in mozilla#5426.
This patch also optimizes some "in-checks" and adds a few header parsings.
@yurydelendik
Copy link
Contributor

/botio-windows test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

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

Total script time: 19.46 mins

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

yurydelendik added a commit that referenced this pull request Oct 21, 2014
For JPX decoding only read next packet after checking for byte aligning.
@yurydelendik yurydelendik merged commit 8bfc4b8 into mozilla:master Oct 21, 2014
@yurydelendik
Copy link
Contributor

Thank you

@CodingFabian CodingFabian deleted the issue-5349 branch October 22, 2014 06:25
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.

5 participants