Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
28th September 2020, 03:45 | #1 | Link |
image optimizer
Join Date: Sep 2020
Location: UK
Posts: 1
|
Scaling of YCoCg to 8-bit bytes
I'd like to add support for YCoCg color space in my AVIF image compressor. I can easily find RGB to YCoCg formulas (including the original YCoCg paper) that are equivalent of a matrix rotation, but I'm missing a second formula that scales the result to actual bytes to be encoded.
All the sources I can find assume it's lossless and/or Co/Cg can be negative, but that means a conversion of 8-bit RGB to YCoCg gives 9- or 10-bit values. How am I supposed to store that in 8-bit unsigned bytes of YUV channels when encoding? |
28th September 2020, 17:30 | #2 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
|
Quote:
|
|
28th September 2020, 18:53 | #3 | Link |
Registered User
Join Date: Apr 2017
Posts: 171
|
Yes, just for the precision, I used in my codec (NHW) for test the YCoCg matrix from the english wikipedia article.
With these matrixes if you input 8-Bit RGB, it will output 8-Bit YCoCg, just the ranges will be Y: [0-255], Co: [-128,127], Cg: [-128,127], so typically you need to add an offset of +128 for Co and Cg, (and then remove it before converting back to RGB)... This would give a classic YCoCg 8-Bit colorspace... Just as we are talking about YCoCg, how do you estimate it? Its big advantage is that it is very fast (no multiplies), but visually I find that it is not as good as YCbCR/YUV... When I tested it 3-4 years ago in my codec, I made quite extensive tests at -l9 and -l11 compression settings if I remember correctly, and the results were not visually as pleasant as YUV at the same compression ratio.Did you have same experience? By the way, I read that your AVIF image compressor: CAVIF is great! Cheers, Raphael |
29th September 2020, 20:10 | #4 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
|
Quote:
YCoCg doesn't make a lot of practical sense for me to adopt, since the easier math is pretty immaterial in modern systems. |
|
Tags |
avif, ycocg, yuv |
Thread Tools | Search this Thread |
Display Modes | |
|
|