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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap jpeg decoders #571

merged 22 commits into from May 16, 2018


None yet
2 participants
Copy link

JimBobSquarePants commented May 11, 2018


  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 馃懏.
  • I have provided test coverage for my change (where applicable)


This PR switches out the old Golang based Jpeg decoder with the newer PdfJs decoder.

This gives us a robust decoder that produces 100% accurate spectral output. Performance matches the Golang decoder with less memory usage. There is excellent scope for further improving performance also.

We'll keep both decoders in the codebase for now as there might be ideas we can still pinch from the Golang decoder.

Fixes #517 and #518

I've also expanded the unit tests to better cover both decoders and reorganized the internal namespaces to clean up the code.


This comment has been minimized.

Copy link

codecov bot commented May 11, 2018

Codecov Report

Merging #571 into master will decrease coverage by 0.01%.
The diff coverage is 90.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #571      +/-   ##
- Coverage   88.79%   88.78%   -0.02%     
  Files         851      854       +3     
  Lines       36037    36097      +60     
  Branches     2609     2607       -2     
+ Hits        31999    32047      +48     
- Misses       3260     3274      +14     
+ Partials      778      776       -2
Impacted Files Coverage 螖
...harp/Formats/Jpeg/Components/Decoder/JFifMarker.cs 97.29% <酶> (酶)
...geSharp/Formats/Jpeg/Components/GenericBlock8x8.cs 84.61% <酶> (酶)
...s/Decoder/GolangJpegScanDecoder.ComputationData.cs 100% <酶> (酶)
...harp/Formats/Jpeg/Components/Encoder/HuffmanLut.cs 100% <酶> (酶)
...der/ColorConverters/JpegColorConverter.FromCmyk.cs 100% <酶> (酶)
...arp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs 100% <酶> (酶)
.../Jpg/Utils/ReferenceImplementations.AccurateDCT.cs 82.97% <酶> (酶) 猬嗭笍
...lorConverters/JpegColorConverter.FromYCbCrBasic.cs 100% <酶> (酶)
src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs 100% <酶> (酶)
...eferenceImplementationsTests.StandardIntegerDCT.cs 100% <酶> (酶) 猬嗭笍
... and 80 more

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update dbe2b1b...711844b. Read the comment docs.

JimBobSquarePants and others added some commits May 12, 2018

Copy link

antonfirsov left a comment

In library code, all changes seem formal refactors to me, all looking good.

Managed to identify a few redundant tests however.

[WithFile(TestImages.Jpeg.Baseline.Calliphora, PixelTypes.Rgba32)]
[WithFile(TestImages.Jpeg.Baseline.Testorig420, PixelTypes.Rgba32)]
public void DoProcessorStepPdfJs<TPixel>(TestImageProvider<TPixel> provider)

This comment has been minimized.


antonfirsov May 13, 2018


VerifySpectralCorrectness_PdfJs/Golang should test the first step, here we only need to test JpegImagePostProcessor, so parsing input with both decoders doesn't add value here.
It's totally fine to run JpegImagePostProcessorTests with the default jpeg decoder only, which is PdfJsDecoderCore now.

@@ -80,9 +80,9 @@ internal partial struct Block8x8F
set => this[(y * 8) + x] = value;

public static Block8x8F operator *(Block8x8F block, float value)
public static Components.Block8x8F operator *(Components.Block8x8F block, float value)

This comment has been minimized.


antonfirsov May 13, 2018


I'm getting "Qualifier is redundant" tips everywhere.
I wonder which analyzer added the namespace qualifiers?

This comment has been minimized.


JimBobSquarePants May 14, 2018


It was Resharper, probably due to the struct being a partial.

antonfirsov and others added some commits May 13, 2018


This comment has been minimized.

Copy link

antonfirsov commented May 15, 2018

Did some refactor on JpegDecoderTests + added another test image for #159.

Everything LGTM now, feel free to merge!

@antonfirsov antonfirsov referenced this pull request May 15, 2018


ImageCloneTests.CloneAs_ToBgr24() failing sporadically #576

4 of 4 tasks complete

@JimBobSquarePants JimBobSquarePants merged commit d566c27 into master May 16, 2018

5 checks passed

codecov/patch 90.42% of diff hit (target 88.79%)
codecov/project Absolute coverage decreased by -0.01% but relative coverage increased by +1.63% compared to dbe2b1b
continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
license/cla Contributor License Agreement is signed.

@JimBobSquarePants JimBobSquarePants deleted the js/swap-jpeg-decoders branch May 16, 2018

@JimBobSquarePants JimBobSquarePants referenced this pull request May 18, 2018


Bad RST marker #518

4 of 4 tasks complete

@JimBobSquarePants JimBobSquarePants referenced this pull request May 30, 2018


Faster Jpeg Huffman Scan Decoding #601

4 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment