View Single Post
Old 16th January 2021, 14:26   #81  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Quote:
Originally Posted by wswartzendruber View Post
Where's that bottle of sake... I need to drink...
Kanpai!! xD

Quote:
Originally Posted by wswartzendruber View Post
When converting to RGB48LE, FFMPEG expands limited Y values into full ones. At least, according to this hex editor I'm looking at. I see Y vales of 64 (little-endian) for the raw YUV420P10LE stream. But when I convert to RGB48LE, they become 0. Converting back to YUV420P10LE from RGB48LE brings it back to limited range.
Right... So, you've been doing this correctly all the time as you made calculations and analysis in RGB and also applied the LUTs in RGB before converting back to YUV, so, even if you assumed that it was full range, since FFMpeg scaled to full range while bringing things to RGB, the stats were correct. I think that's because there isn't anything such as Limited Range RGB per se (I mean, by definition) outside intermediate broadcast use, so, while it would be logical to assume that a simple "regular mapping" of values would occur when going from YUV to RGB (so 64 to 64 etc) to get a "Limited" range RGB, the FFMpeg devs probably thought that, since there's no such a thing as a flag to display Limited RGB properly, it was a sensible thing to scale those values going from limited to full and then back from full to limited.
When I was making SafeColorLimiter this discussion popped up:

Quote:
Originally Posted by feisty2 View Post
there's no limited range RGB.
and

Quote:
Originally Posted by poisondeathray View Post
There is such a thing as "limited range RGB" . It's also known as "studio range RGB" . In 8bit RGB , 16-235 is black to white (sRGB or "computer RGB" is 0-255 black to white in 8bit, it's far more common) . Limited range RGB is used in r103 compliance checks for broadcast, and some NLE's like vegas use studio range RGB .
but also

Quote:
Originally Posted by feisty2 View Post
a) no television system transmits video in RGB space, so it makes no sense to preserve some "headroom" from the 8-bit range for some metadata that does not exist in the first place.
b) YUV<->RGB conversions are ALWAYS defined on full range RGB, this limited range RGB could not be properly displayed (without some non-standard scaling applied first), or properly converted to YUV by any standard.
and

Quote:
Originally Posted by poisondeathray View Post
these standards exist, you should be aware of them, and we have to live with it because it's still used today.



So, in a nutshell, this is what I think led to the misunderstanding.

1) End users receive a Limited TV Range 10bit 64-940 file with a color curve applied, either HLG or PQ

2) Broadcast studios can also use Full PC Range YUV values for those curves, however it's much more likely to have Full Range only for curves like Slog, Clog, LogC, etc

3) You're checking values and doing your calculations in RGB (assuming that the content is in Full Range) as LUTs must be applied in RGB

but here's the thing: when you have a Limited TV Range YUV file that is delivered to a TV, the TV can read the flag and convert to RGB correctly (since the display is always in RGB), but if you try to deliver an RGB whose black start at 64 and white peaks at 940, there's no way to flag it as "Limited", therefore it would almost definitely be displayed incorrectly unless a YUV conversion is applied or there's some system that is aware of this. This is probably the reason why the FFMpeg guys thought that, when you convert a Limited TV Range content to RGB, you don't want to "work with it", but you want to "deliver it" and, since it wouldn't be displayed correctly if it's linearly mapped, it will expand it! So, in the end, you were doing all correctly in the first place as your calculations assumed Full PC Range, the content was in Limited, but FFMpeg took care of it during the YUV to RGB conversion!

So... I think I may have made you lose time on something that has already been addressed by a conversion you were doing, but hey, we both learned something new today, which is that FFMpeg expands Limited to Full in YUV -> RGB. Who would have thought that...

I'll leave you to the Sakč:



(fun fact I: the first time I tried sakč was in 2009 with my friends in an allegedly Japanese restaurant which was probably run by Chinese pretending to be Japanese; anyway I didn't like it that much.)

(fun fact II: there are three glass in the picture I grabbed from a website 'cause one is for you, one is for me and the other is from whoever wants to grab it. I think StainlessS is more of a Beer guy, so let's see... xD)

Last edited by FranceBB; 16th January 2021 at 14:32.
FranceBB is offline   Reply With Quote