3bl3gamer / wasm-mozjpeg

WebAssembly MozJPEG encoder
MIT License
3 stars 0 forks source link

Chroma subsampling #3

Open tomdav999 opened 3 years ago

tomdav999 commented 3 years ago

Thanks for your demo examples, especially the one exposing all the options, very helpful!!!

https://3bl3gamer.github.io/wasm-mozjpeg/examples/settings/

Do you have any insights regarding the chroma subsampling parameters? https://kraken.io/docs/chroma-subsampling

Playing around with things it seems like... h=1, v=1 => 4:4:4 (no chroma subsampling)

Also, I note that squoosh.app doesn't expose h and v parameters for mozjpeg, just a single chroma subsampling parameter, as well as an "auto" option which is a mystery as to what they are using.

Edit: OK, I think h and v parameters correspond to standard n x n terminology, so...

h=1, v=1 => 1x1 => 4:4:4 h=2, v=1 => 2x1 => 4:2:2 h=2, v=2 => 2x2 => 4:2:0

https://www.impulseadventure.com/photo/chroma-subsampling.html

It is still a mystery to me what squoosh is doing with "auto", perhaps they use 1x1 or 2x1 for higher jpeg quality, and 2x2 for lower jpeg quality. There seems to be a discontinuous jump in squoosh file size at quality 90 so maybe that's what's going on.

3bl3gamer commented 3 years ago

h and v parameters correspond to standard n x n terminology,

Yes, it should. And you can even increase h and v up to 3 or 4.

discontinuous jump in squoosh file size at quality 90

MozJpeg by default sets sub-sampling to 2x1 for quality >= 80 and 1x1 for quality >= 90: https://github.com/mozilla/mozjpeg/blob/c78b82bbb12ed6d41e2f896631aa3bab7a7f8c92/rdswitch.c#L557-L565 Maybe squoosh.app do the same.