strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.7k stars 298 forks source link

Heif photo size problem. #400

Open Jamaika1 opened 3 years ago

Jamaika1 commented 3 years ago

When I add matrix coefficients equal to zero the files are twice as large. I don't know why. https://github.com/link-u/avif-sample-images/blob/master/hato.png heifenc -v -b 8 -L -e x265 -p preset=placebo -p chroma=444 -p x265:psy-rd=0 -p x265:ctu=64 input_image -o heif_image Why can I not convert 16bit png to 8bit heif?

Jamaika1 commented 3 years ago

_@Jamaika1 How is this related to this issue? Please open a new issue for unrelated questions. But short answer: when you set matrixcoefficients=0, you are basically switching of RGB->YCbCr conversion and coding directly in RGB space. Moreover, you might be using chroma 4:4:4 here, while using 4:2:0 with YCbCr.

Jamaika1 commented 3 years ago

I understand everything, but why are RGB files twice as large size as YUV? https://forum.doom9.org/showthread.php?p=1930093#post1930093

farindk commented 3 years ago

Because there is only little, low-frequency information in chroma planes. When encoding as YCbCr, you have a lot of information in Y and only a bit in Cb,Cr. If you use RGB, it is more or less 3x Y. There are tools like cross-component prediction, but I'm not sure the current encoders make use of that.