mozjpeg icon indicating copy to clipboard operation
mozjpeg copied to clipboard

Fine-tune quantization table coefficeints from DCT data

Open kornelski opened this issue 11 years ago • 2 comments

Scaling of quantization tables assumes that smaller divisors are always better, but that's not always true due to rounding errors.

An especially obvious case is when DC is quantized in a way that prevents it from hitting maximum value (i.e. 128 isn't evenly divisible by the DC coefficient):

quality = 9 gray background

quality = 6 white background

e.g. imagine a source image posterized to 16 levels. For such image a DC coefficient = 16 is ideal, and 8 < DC < 16 are all worse, even though they're used at higher qualities.

I think quantization tables can be made a little better:

  1. Gather unquantized DCT coefficients for the entire image
  2. For each quantization table coefficient check whether higher quantization divisor gives smaller quantization error

kornelski avatar Jan 10 '15 14:01 kornelski

Is the same optimization that https://github.com/mozilla/mozjpeg/issues/81 And similar to https://github.com/mozilla/mozjpeg/issues/182

JosePineiro avatar May 09 '17 15:05 JosePineiro

In my opinion, this is a waste of time. A time that would be better spent implementing #182 and #223 -- which provide the best quantization table and the best DCT coefficients.

jrmsmith avatar May 10 '17 08:05 jrmsmith