mozilla / mozjpeg

Improved JPEG encoder.
Other
5.48k stars 415 forks source link

Quantization table 4 (custom PSNR-HVS) generates larger files #146

Open kornelski opened 9 years ago

kornelski commented 9 years ago

It's not a problem with R/D ratio, but simply proportion of file size to the quality setting compared to other tables.

cjpeg -quant-table 4

typically creates files about 20% larger than other -quant-table settings.

If tables are at approximately the same scale (so that compressed file sizes are similar) it's easier to compare images generated with different tables (since quality doesn't have to be adjusted).

Increase of all values in the table (std_luminance_quant_tbl, etc.) by 50% seems to give file sizes closer to other tables.

The custom table tuned for MS-SSIM has the same problem, but to a lesser degree (extra 5-10%).

felixbuenemann commented 8 years ago

This is true for all the quantization tables to some degree:

original-q75-qt0.jpg 1.743MB
original-q75-qt1.jpg 2.592MB
original-q75-qt2.jpg 1.405MB
original-q75-qt3.jpg 1.404MB
original-q75-qt4.jpg 1.777MB
original-q75-qt5.jpg 1.531MB
original-q75-qt6.jpg 2.166MB
original-q75-qt7.jpg 2.391MB
original-q75-qt8.jpg 2.151MB

However given that both table 2 and 4 were generated from the same set of images it makes sense that they generate similar file sizes, which would also make it much easier to decide which of them performs better.

I think it would make sense to choose one table as the reference for compression level (eg. table 0) and then scale all other tables using a common test set of images so that they provide similar file sizes at the same quality setting.

@pornel Btw. have you considered switching the mozjpeg default from table 3 to table 2? While generating slightly larger images at the same quality level it far outperform the robidoux and all other tables (including 4) at high compression levels. It causes less banding in gradients, less color shifts and other quantization artifacts than table 3 at similar file sizes. I can supply a few comparisons if you like…

kornelski commented 8 years ago

It may be good to scale others too, except 1 (flat), as that one is quite special.

I don't think table 2 (MS-SSIM) is better than 3 (N. Robidoux). It gives more weight to low frequencies rather than high ones. It makes gradients smoother, but also makes edges blurry. It's a trade-off. I use it for high-DPI images, but not for regular-DPI ones.