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 JpegSegmentReader #232

Open
drewnoakes opened this issue Feb 1, 2017 · 3 comments
Open

Update JpegSegmentReader #232

drewnoakes opened this issue Feb 1, 2017 · 3 comments
Milestone

Comments

@drewnoakes
Copy link
Owner

drewnoakes commented Feb 1, 2017

@Nadahar hit an issue related to JpegSegmentReader stopping at the first SOS marker (discussed in #231).

There is also opportunity to improve the performance of JPEG processing.

In the .NET project there's an experimental approach to processing JPEG segments. It should be reviewed, tested and merged into both projects.

@Nadahar
Copy link
Contributor

Nadahar commented Feb 2, 2017

@drewnoakes I'm afraid I'm not able to fully understand the reader by just looking at the code. C# is a bit foreign to me, and without setting up an IDE an being able to check what the methods being called does etc. I get lost.

It's therefore unclear to me exactly how that preamble logic works, but I hope it takes into account that not all segment types have preambles.

Will this reader read through the whole file? If so, how can that be more efficient? The reason I was unsure if it was smart to touch the "exit on first SOS" was efficiency. I've just done a test-implementation with DNL segment support, but it suffers from the same problem. By definition the DNL segment comes after the first SOS segment, so I never see it.

@drewnoakes
Copy link
Owner Author

The preamble stuff is only used for identifying APPn segments, each of which may be used for different purposes.

The new reader would read through the whole file, but the majority of that would be skipping forwards. JpegSegmentReader does a single pass through the JPEG, chunk by chunk.

The efficiency claim comes from the idea that JPEG segment processors which can use sequential readers can operate directly on the underlying stream rather than being passed a byte[] containing the entire JPEG segment (as happens currently in both the .NET and Java implementations). So the benefits are 1) more correct parsing 2) slight perf improvements in some cases.

@Nadahar
Copy link
Contributor

Nadahar commented Feb 3, 2017

Ok, I see.

That sounds like a good idea.

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

No branches or pull requests

2 participants