[WIP] Building an optimized and accurate Jpeg Decoder [deprecated]#298
Merged
JimBobSquarePants merged 115 commits intobeta-1from Aug 19, 2017
Merged
[WIP] Building an optimized and accurate Jpeg Decoder [deprecated]#298JimBobSquarePants merged 115 commits intobeta-1from
JimBobSquarePants merged 115 commits intobeta-1from
Conversation
… (Optimizing PNG-s with external tools from now.)
# Conflicts: # tests/Images/External
# Conflicts: # tests/ImageSharp.Tests/TestFile.cs
Closed
Member
|
@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. |
This file contains hidden or 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
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-portto 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
masterbefore introducing the biggest breaking changes. In order to achieve this, we should branchjpeg-labinto 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->Block8x8FBlock8x8-sfloatbuffersfloatbuffers 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.Block8x8struct for integer blocks.JpegDecoderCoreinto 3 classes:SpectralJpegData: representing Huffmann-decoded, unziggedBlock8x8-s for decoded components.JpegStreamDecoder: produces aSpectralJpegDataby consuming a stream.JpegStreamDecoder: we can convertSpectralJpegDatainto 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.DCTseems to be inaccurate.Vector4-s intoTPixel-s