image-rs / jpeg-decoder

JPEG decoder written in Rust
Apache License 2.0
147 stars 88 forks source link

refactor: Extract and clarify the 8x8 idct implementation #159

Closed Marwes closed 4 years ago

Marwes commented 4 years ago

This code is extracted from https://github.com/Marwes/combine-jpeg which is originally based on this repo. While the parser parts are mostly rewritten, the parts like idct, huffman etc are mostly the same, though with some performance and (in my opinion) clarity improvements to the code.

If this PR is accepted I may try and extract some other parts as well.

(While this PR doesn't contain any performance improvements, I will just add that combine-jpeg has some significant performance improvements. It still lacks some features but it's almost, but not quite as fast as mozjpeg on the images that it accepts (no simd for either). Some of this is because of unsafe, some of it because of less overhead in the decoding).

it_works/combine        time:   [2.6562 ms 2.6633 ms 2.6749 ms]
                        change: [-7.2890% -1.9145% +1.5656%] (p = 0.68 > 0.05)
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  2 (20.00%) high severe
it_works/mozjpeg        time:   [2.0400 ms 2.0415 ms 2.0429 ms]
                        change: [+0.4243% +0.6680% +0.8305%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild
it_works/jpeg-decoder   time:   [8.9513 ms 9.1526 ms 9.3654 ms]
                        change: [-13.663% -5.0961% +1.6086%] (p = 0.29 > 0.05)
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  1 (10.00%) low severe
  1 (10.00%) high mild
HeroicKatora commented 4 years ago

Thanks for contributing back some of your changes :)