-
-
Notifications
You must be signed in to change notification settings - Fork 854
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
[WIP] Building an optimized and accurate Jpeg Decoder [deprecated] #298
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… (Optimizing PNG-s with external tools from now.)
# Conflicts: # tests/Images/External
# Conflicts: # tests/ImageSharp.Tests/TestFile.cs
Closed
@antonfirsov I'm closing this one for now so we can create a clean one based on the beta-1 codebase without any additional commits. |
antonfirsov
changed the title
[WIP] Building an optimized and accurate Jpeg Decoder
[WIP] Building an optimized and accurate Jpeg Decoder [deprecated]
Aug 21, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update
Anyone seeing this: The information here no longer up-to date, because we discovered PDF.js being inaccurate on progressive Jpegs. Gonna open an issue soon.
Remarks
At the moment of opening this PR, it's way too far ahead of our current master. We need to merge #275,
qa-lab
, andjpeg-port
to wipe-out unrelated changes. Edit: Even the first comments below the PR are old comments on commits.We should be able to merge a stable state of the new decoder into
master
before introducing the biggest breaking changes. In order to achieve this, we should branchjpeg-lab
into a separate PR (maybe by reusing #274).If you wish to contribute developing .NET-s first optimized managed-only open source Jpeg decoder, any help is welcome, both from new and old contributors!
Description
Porting PDF.js with #274 did a good job by introducing a cleaner stream parsing logic, capable for unified, and low-memory management of Baseline and Progressive jpeg-s. However, we will not able to speed up the decoder with integer arithmetics and lookup tables. We need to refactor/replace most of it's calculations with floating point SIMD arithmetics.
Design goals
Non-goals
Architecture
In the first step, the decoder reads all blocks from all scans, storing them in a compact form in spectral space (
FrameComponent.BlockData
), even for progressive jpegs. The implementation is basically done by portingPDF.js
.In the second step we should process the spectral blocks MCU-row by MCU-row doing the following steps:
Block8x8
->Block8x8F
Block8x8
-sfloat
buffersfloat
buffers intoTPixel
-s and copy the result intoImage<TPixel>
Implementation Plan [WIP]
General:
ref
-s are overused (my fault), we can use classes for small objects having only a few instances without performance loss.Block8x8
struct for integer blocks.JpegDecoderCore
into 3 classes:SpectralJpegData
: representing Huffmann-decoded, unziggedBlock8x8
-s for decoded components.JpegStreamDecoder
: produces aSpectralJpegData
by consuming a stream.JpegStreamDecoder
: we can convertSpectralJpegData
into spectral-spaceImage<Rgba32>
, and test it against spectral-space reference images. We should expect exact equality at this point.Switch-to-float
ImageSharp.Formats.Jpeg.GolangPort.Components.DCT
seems to be inaccurate.Vector4
-s intoTPixel
-s