View Full Version : question about YUV -> RGB
Spyn
1st March 2005, 00:34
I better understand but i was not wrong ;)
Xvid encode using YUV 0-255
when requesting YUV (YV12) from the xvid decoder luma is clamp to [16-235]
when requesting RGB from the xvid decoder, the conversions are : YUV [0-255] -> YUV [16-235] -> RGB [0-255]
right ?
but why the xvid encoder don't clamp YUV to [16-235] during the encode process to simplify things ?
Spyn
7th March 2005, 16:26
up, wilbert ?
i think xvid use 0-255 for encoding cause this increase compressibility.
L'il Jerry
8th March 2005, 00:20
Originally posted by Spyn
up, wilbert ?
i think xvid use 0-255 for encoding cause this increase compressibility.
How would encoding with a bigger luma range make something more compressible? I don't see the logic.
Spyn
8th March 2005, 11:37
Originally posted by L'il Jerry
How would encoding with a bigger luma range make something more compressible? I don't see the logic.
the darker a film is, the more it is compressible.
black [0] is more compressible than black [16]
Wilbert
8th March 2005, 15:32
the darker a film is, the more it is compressible.
That's not always true. A red clip (or any other single color) is more compressible than a greyscale movie with different grey shades.
black [0] is more compressible than black [16]
If your luma range is YUV-[0,255] it doesn't mean it will be darker than YUV-[16,235] *on your display*. It all depends how you convert it to RGB.
Spyn
8th March 2005, 16:53
Originally posted by Wilbert
If your luma range is YUV-[0,255] it doesn't mean it will be darker than YUV-[16,235] *on your display*. It all depends how you convert it to RGB. [/B]
there is no RGB conversion during the encode, i was not speaking about the display but about the encode processing.
Wilbert
8th March 2005, 18:45
Ok, my bad.
My point still stands though. If you take a clip and scale the luma range to:
clip_1) YUV [0,255]
clip_2) YUV [16,235]
First is doesn't mean that clip_1 is darker than clip_2 (in the sense that the average luma of the pixels in clip_1 is smaller than in clip_2). Second the luma range of a YUV [0,255] clip is larger than of YUV [16,235], meaning less compressible (in general).
So, I think that using [0,255] decreases compressibility, because the luma range is wider.
black [0] is more compressible than black [16]
For clarity. A clip with (all pixels) Y=0 is just as compressible as a clip with (all pixels) Y=16.
len0x
8th March 2005, 18:53
Originally posted by Wilbert
For clarity. A clip with (all pixels) Y=0 is just as compressible as a clip with (all pixels) Y=16.
Indeed, its color range that matters.
Spyn
8th March 2005, 18:56
Originally posted by Wilbert
Ok, my bad.
My point still stands though. If you take a clip and scale the luma range to:
clip_1) YUV [0,255]
clip_2) YUV [16,235]
First is doesn't mean that clip_1 is darker than clip_2 (in the sense that the average luma of the pixels in clip_1 is smaller than in clip_2). Second the luma range of a YUV [0,255] clip is larger than of YUV [16,235], meaning less compressible (in general).
So, I think that using [0,255] decreases compressibility, because the luma range is wider.
For clarity. A clip with (all pixels) Y=0 is just as compressible as a clip with (all pixels) Y=16.
a clip with luma range of [0-255] clamp to [16-235] will change the luma of all pixels between 0 and 15 to 16, this change will decrease compressibility cause black pixels are now grey.
A dvd is 0-255 and that's why Xvid does not clamp.
len0x
8th March 2005, 19:03
Originally posted by Spyn
this change will decrease compressibility cause black pixels are now grey.
LOL. Tell us then - how do you *think* encoder needs more bits to encode grey than black?
Spyn
8th March 2005, 19:06
Originally posted by len0x
LOL. Tell us then - how do you *think* encoder needs more bits to encode grey than black?
all dark movie are very compressible ? panic room etc... why ?
len0x
8th March 2005, 19:14
Not because they are dark, but because they have lower color range most of the time (and that happens to be dark range, coz it it was white gamut you'll be blind instead :) ). Consider this - you have a block 16x16 that is encoded as video unit. If it had just one color i.e. black or grey (it doesn't matter) it would be the most compressible. If you have 0-255 range chances are there will be some < 16 values that are invisible to the eye, but visible to codec which has to encode it and keep all those values in. So if you clamp 0 -> 16 then it would have been much easier for codec to work with less colors as it gives it less difference to surrounding pixels/frames.
Spyn
8th March 2005, 19:21
if the range 0-16 is invisible for human eye, why i can see the difference on these screenshots :
colorspace YV12 (16-135) :
http://naxxalite.free.fr/xvid_yv12.bmp
colorspace RGB24 (0-255) :
http://naxxalite.free.fr/xvid_rgb.bmp
and why Xvid don't clamp to 16-235 before encoding if this is much easier for the codec ?
edit : i don't want to annoyed you, just understand.
len0x
8th March 2005, 21:20
How is that relevant??
My point is: smaller color range result in better compresibility. No more, no less. (it doesn't matter if you can see luma below 16 or not)
and why Xvid don't clamp to 16-235 before encoding if this is much easier for the codec ?
It like asking why it doesn't clamp to 64-192... Codec is not supposed to be doing any reduction in unless its a neccessary conversion between colorspaces. I'm not an expert in this, but its sounds like a job for denoisers (that actually do mild reduction in many cases).
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.