kornelski / cavif-rs

AVIF image creator in pure Rust
https://lib.rs/cavif
BSD 3-Clause "New" or "Revised" License
570 stars 27 forks source link

Question about quality vs quantizers. #28

Closed bat999 closed 3 years ago

bat999 commented 3 years ago

Hi I can see you have gone to a lot of trouble to map Q to the rav1e quantizers. This makes it intuitive for people who use cjpeg and cwebp etc. When they have experimented some they will settle on a value of Q to use for cavif.

But might there be a case to allow access to the quantizers INSTEAD of the Q scale?

Something like this...

-Q, --quality <n>    Quality from 1 (worst) to 100 (best). NB! Not the same scale as JPEG quality [default: 80]
                     This can be used instead of quantizer values.

                     OR

                     These can be used instead of Q.
--min         <n>  : Set min quantizer for color (0-63, where 0 is lossless)

--max         <n>  : Set max quantizer for color (0-63, where 0 is lossless)

--minalpha    <n>  : Set min quantizer for alpha (0-63, where 0 is lossless)                    

--maxalpha    <n>  : Set max quantizer for alpha (0-63, where 0 is lossless)
kornelski commented 3 years ago

No, I'm deliberately hiding the quantizer option.

bat999 commented 3 years ago

As far as I can tell min/max split didn't do anything for still images. Yes, I can understand that. Thanks.

... I plan to align it better to approximate JPEG quality scale. Both cjpeg and cwebp have default quality 75. dssim thinks cavif Q 75 is too good. :-)

0.00164695  foo1_q75.jpg
0.00244810  foo1_q75.webp
0.00084624  foo1_q75.avif

0.00203879  foo2_q75.jpg
0.00256523  foo2_q75.webp
0.00082852  foo2_q75.avif
echo ""; \
cjpeg -quality 75 -outfile foo1_q75.jpg foo1.png; \
cwebp -q 75 -mt -m 6 -quiet foo1.png -o foo1_q75.webp; \
cavif -Q 75 -s 0 -j $(nproc) -q -o foo1_q75.avif foo1.png; \
dssim foo1.png foo1_q75.jpg foo1_q75.webp foo1_q75.avif; \
echo ""; \
cjpeg -quality 75 -outfile foo2_q75.jpg foo2.png; \
cwebp -q 75 -mt -m 6 -quiet foo2.png -o foo2_q75.webp; \
cavif -Q 75 -s 0 -j $(nproc) -q -o foo2_q75.avif foo2.png; \
dssim foo2.png foo2_q75.jpg foo2_q75.webp foo2_q75.avif