Skip to content
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

Allow jpegli quant tables to be used for JSC_GRAYSCALE images #100

Closed
wants to merge 1 commit into from

Conversation

erikandre
Copy link

This fixes a bug (unless it's intentional) that limits grayscale images to only use the standard quantization tables defined in the appendix of the JPEG standard

Description

Jpegli is able to deliver significantly better compression rates over other codecs, like libjpeg_turbo, thanks both to it's adaptive quantization approach, but also because of the optimized quantization tables it uses.
This can be observed by using the "--std_quant" option with cjpegli which forces the encoder to fall back to the tables defined in the appendix of the JPEG standard. With that quantization table, you can only achieve a file size vs quality ratio that's similar to libjpeg_turbo, at least when evaluated using only PSNR as the loss function.

After getting worse than expected compression rates for some grayscale images, I poked around in the jpegli code base and found that the optimized quantization tables are only enabled if the color space is YCbCr.
Perhaps this was intended to be a check to exclude files using XYB? Grayscale is pretty rare so it's possible this was just overlooked.

My testing shows improvements in compression rate while maintaining quality, with this fix.
Tested using open source build instructions for cjpegli on a corpus of grayscale PNGs.

Pull Request Checklist

  • CLA Signed: Have you signed the Contributor License Agreement (individual or corporate, as appropriate)? Only contributions from signed contributors can be accepted.
  • Authors: Have you considered adding your name to the AUTHORS file?
  • Code Style: Have you ensured your code adheres to the project's coding style guidelines? You can use ./ci.sh lint for automatic code formatting.

Please review the full contributing guidelines for more details.

This fixes a bug (unless it's intentional) that limits grayscale images to only use the standard quantization tables defined in the appendix of the JPEG standard
Copy link

google-cla bot commented Feb 5, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@erikandre erikandre closed this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant