Skip to content

Commit

Permalink
Update the jpegli README
Browse files Browse the repository at this point in the history
  • Loading branch information
szabadka committed Jun 12, 2023
1 parent 37158ba commit 38b629f
Showing 1 changed file with 41 additions and 20 deletions.
61 changes: 41 additions & 20 deletions lib/jpegli/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
# Improved JPEG decoder implementation
# Improved JPEG encoder and decoder implementation

This subdirectory contains a JPEG decoder implementation that is API and ABI
compatible with libjpeg62.
This subdirectory contains a JPEG encoder and decoder implementation that is
API and ABI compatible with libjpeg62.

*NOTE*: This is still a work in progress, currently only API functions called
from libjxl's benchmark_xl tool are implemented.
## Building

To decompress an ```input.jpg``` file with this new library:
When building the parent libjxl project, two binaries, `tools/cjpegli` and
`tools/djpegli` will be built, as well as a
`lib/jpegli/libjpeg.so.62.3.0` shared library that can be used as a drop-in
replacement for the system library with the same name.

```
(from the libjxl root directory)
$ ./ci.sh opt
$ LD_PRELOAD=./build/libjpeg.so.62 ./build/tools/benchmark_xl --input input.jpg --codec=jpeg --decode_only --save_decompressed --output_dir .
```
## Encoder improvements

The decompressed file will be saved as ```input.jpg.jpeg.png```.
Improvements and new features used by the encoder include:

To benchmark the jpeg encoding-decoding round-trip on an ```input.png``` with
the new library, first build a statically linked ```cjpeg-static``` binary,
which is found in ```$PATH```, and then run:
* Support for 16-bit unsigned and 32-bit floating point input buffers.

```
(from the libjxl root directory)
$ ./ci.sh opt
$ LD_PRELOAD=./build/libjpeg.so.62 ./build/tools/benchmark_xl --input input.png --codec=jpeg:cjpeg-static:q90
```
* Color space conversions, chroma subsampling and DCT are all done in floating
point precision, the conversion to integers happens first when producing
the final quantized DCT coefficients.

* The desired quality can be indicated by a distance parameter that is
analogous to the distance parameter of JPEG XL. The quantization tables
are chosen based on the distance and the chroma subsampling mode, with
different positions in the quantization matrix scaling differently, and the
red and blue chrominance channels have separate quantization tables.

* Adaptive dead-zone quantization. On noisy parts of the image, quantization
thresholds for zero coefficients are higher than on smoother parts of the
image.

* Support for more efficient compression of JPEGs with an ICC profile
representing the XYB colorspace. These JPEGs will not be converted to the
YCbCr colorspace, but specialized quantization tables will be chosen for
the original X, Y, B channels.

## Decoder improvements

* Support for 16-bit unsigned and 32-bit floating point output buffers.

* Non-zero DCT coefficients are dequantized to the expectation value of their
respective quantization intervals assuming a Laplacian distribution of the
original unquantized DCT coefficients.

* After dequantization, inverse DCT, chroma upsampling and color space
conversions are all done in floating point precision, the conversion to
integer samples happens only in the final output phase (unless output to
floating point was requested).

0 comments on commit 38b629f

Please sign in to comment.