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.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 11th May 2020, 15:51   #1  |  Link
wswartzendruber
hlg-tools Maintainer
 
wswartzendruber's Avatar
 
Join Date: Feb 2008
Posts: 412
How Is YUV410P10LE Encoded?

ADDENDUM: 420, not 410

I'm trying to figure out how YUV420P10LE is encoded. I surmise that first there are the luminance values, one for each pixel. Next, there are the Cb values, one for every four pixels. Then, there are the Cr values, also one for every four pixels.

Y, I assume, has 0 to represent the darkest amount of light and 1023 to represent the most amount of light. But how in the world are Cb and Cr mapped onto the color plane? I wasn't able to figure this out. Are they two's compliment?

I ultimately want to convert to and from RGB, given the appropriate colorspace constants.

Last edited by wswartzendruber; 11th May 2020 at 22:08.
wswartzendruber is offline   Reply With Quote
Old 12th May 2020, 19:25   #2  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
Hope this will help:
yes it is plane by plane as you suggested.
1) get uint16 values
2) upscale Cb and Cr to picture dimensions (2x wide and 2x high)
3) conversion to RGB
Y is unsigned value with range 0 to 1023 (0 may be darkest or not - depends on full range flag)
subtract 512 from Cb/Cr to get signed value (useful signed range -512 to 511)
Refer to formulas here http://www.vapoursynth.com/doc/functions/resize.html (bottom of page "pixel range")
__________________
VirtualDub2
shekh is offline   Reply With Quote
Old 24th September 2020, 11:57   #3  |  Link
HowardWow1997
Registered User
 
HowardWow1997's Avatar
 
Join Date: Sep 2020
Location: Wilmington
Posts: 7
Quote:
Originally Posted by shekh View Post
Hope this will help:
yes it is plane by plane as you suggested.
1) get uint16 values
2) upscale Cb and Cr to picture dimensions (2x wide and 2x high)
3) conversion to RGB
Y is unsigned value with range 0 to 1023 (0 may be darkest or not - depends on full range flag)
subtract 512 from Cb/Cr to get signed value (useful signed range -512 to 511)
Refer to formulas here http://www.vapoursynth.com/doc/functions/resize.html (bottom of page "pixel range")
Thank you for this
HowardWow1997 is offline   Reply With Quote
Old 24th September 2020, 14:35   #4  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
If you're obtaining yuv420p10le then it's probably coming directly from ffmpeg, since other software tends to use the term P210. You should have ffmpeg upconvert it to yuv420p16le (or yuv444p16le) for you so that you don't have to do the messy work; it'll do it faster and better anyway.
foxyshadis is offline   Reply With Quote
Old 18th December 2020, 02:00   #5  |  Link
wswartzendruber
hlg-tools Maintainer
 
wswartzendruber's Avatar
 
Join Date: Feb 2008
Posts: 412
Quote:
Originally Posted by foxyshadis View Post
If you're obtaining yuv420p10le then it's probably coming directly from ffmpeg, since other software tends to use the term P210. You should have ffmpeg upconvert it to yuv420p16le (or yuv444p16le) for you so that you don't have to do the messy work; it'll do it faster and better anyway.
I believe I will have FFMPEG output YUV444P16LE, as I don't care to get into the particulars of chroma subsampling.

Now, another question:

I have noticed that increasing the Y value does brighten a pixel, but also causes to appear desaturated. It looks like I have to modify the Cb and Cr components when I adjust Y. How does this work?

EDIT: Bonus question: Is it true that some YCbCr combinations are outside of the RGB colorspace? Are such values invalid?
wswartzendruber is offline   Reply With Quote
Old 18th December 2020, 21:03   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
but also causes to appear desaturated.
(In RGB) Full saturation has no white component. [EDIT: Except I guess for $000000 Black which could not be described as fully saturated]
If you had red $FF0000, it would be fully saturated, whereas $FF8080 would have a lot of impurity in it (white, governed by the lowest component).

[EDIT: Nah, above aint quite right, it involves max channel as well as min channel,
the closer the lowest channel gets to the highest channel , the less is the saturation.
Sat = Something like 1.0 - (min / max), or if max==0.0 then 0.0]

If you in YUV raise Y, so you are increasing white component and so less saturated.

Quote:
It looks like I have to modify the Cb and Cr components when I adjust Y. How does this work?
Not sure that there is an answer for that, only really works properley in RGB,
but ColorYUV(cont_u=8,cont_v=8) would raise U & V contrast [approx saturation increase] from center $80 [moving out from center] whereas
ColorYUV(cont_u= -8,cont_v= -8) would reduce saturation. U & V contrast would normally be kept same else color shift.
The numbers dont quite work right changing Y, you cant really say how U & V should be changed, but maybe both in same [contrast] direction as Y change
although by how much [and may not be possible] to get exactly right [and probably not same change for both U & V].
Also, would change all the colors in image differently, the numbers just dont work well for YUV.

Quote:
combinations are outside of the RGB colorspace
Think YUV = $00FFFF (PC Levels for all 3 channels, chroma center=$80), would be fully saturated BLACK or $000000 also fully saturated black.
Also, YUV = $FFFFFF or $FF0000 would be fully saturation white, just cant happen, they are mythical colors outside of RGB colorspace.
[Or also $00FF00 or $0000FF, or $FFFF00, or $FF00FF, all totally impossible, as are many others]

Others may [and probably will] give a better reply to your perfectly good questions [I did my best, it was crap ].
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 19th December 2020 at 19:09.
StainlessS is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.