How Trellis Quantization Improves JPEG Quality
Understanding how trellis quantization in MozJPEG reduces blocking artifacts at low quality settings.
MV
Marcus Vance
Contributing Author · Squoosh Next BlogTrellis quantization is an optimization technique borrowed from video encoding that searches for the quantized DCT coefficients that minimize distortion at a given bit rate. Standard JPEG quantization simply rounds each DCT coefficient to the nearest quantization step, which is fast but sub-optimal. Trellis quantization instead evaluates multiple candidate quantized values and selects the combination that produces the best rate-distortion tradeoff.
In MozJPEG, enabling trellis quantization can reduce file size by a further 4–8% at the same visual quality compared to libjpeg-turbo without trellis. The tradeoff is encoding speed — trellis adds 20–30% to compression time. For batch processing pipelines where encode time is less critical than output quality, always enable trellis.
For real-time interactive compression, disable it for responsiveness.
Key Takeaways
Trellis quantization is an optimization technique borrowed from video encoding that searches for the quantized DCT coefficients that minimize distortion at a given bit rate.
Standard JPEG quantization simply rounds each DCT coefficient to the nearest quantization step, which is fast but sub-optimal.
Trellis quantization instead evaluates multiple candidate quantized values and selects the combination that produces the best rate-distortion tradeoff.
In MozJPEG, enabling trellis quantization can reduce file size by a further 4–8% at the same visual quality compared to libjpeg-turbo without trellis.
Try It in the Workspace
Everything discussed in this article can be tested directly in Squoosh Next — no sign-up, no upload, 100% client-side.