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 > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th October 2021, 17:29   #1  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Color Matrix question

HDR RGB data converted to YUV over Rec.709 matrix then back to RGB with inverse 709 and then again to YUV over Rec.2020 is as good as direct conversion to Rec.2020?
Is there any meaningful loss?
kolak is offline   Reply With Quote
Old 28th October 2021, 20:06   #2  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
You can try it and do a mt_makediff to see whether there's any difference. It shouldn't in theory, but you may want to do it in 16-bit-depth.
MysteryX is offline   Reply With Quote
Old 28th October 2021, 20:34   #3  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
It's more a theoretical question.
We assume precision is 16bit or even float.
Cool- thanks.
kolak is offline   Reply With Quote
Old 28th October 2021, 20:55   #4  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 85
Theoretically, one matrix operation is cleaner than 3. You're losing a little bit of precision every time.
groucho86 is offline   Reply With Quote
Old 28th October 2021, 22:07   #5  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Yes, I get this (not worried about some tiny rounding etc.).
But from math point Rec.709 steps don't limit original data in any way?

If were to do Rec.2020 ->Rec.709 gamut conversion ->Rec.2020 I would loose a lot.
My mentioned path is nothing like this, yes?
We just do pintles conversion, but it's not loosing data in meaningful way.

Last edited by kolak; 28th October 2021 at 22:15.
kolak is offline   Reply With Quote
Old 28th October 2021, 22:16   #6  |  Link
groucho86
Registered User
 
Join Date: Apr 2016
Posts: 85
Working in integer, you run the risk of clipping negative numbers (ie, out of gamut values). Working in float, you'll be safe.
groucho86 is offline   Reply With Quote
Old 28th October 2021, 22:20   #7  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
So if I have SDI card which does not support Rec.2020 matrix and I want to push HDR data through it then safest way is to avoid going to YUV (which a lot of SDI card need to do due to bandwidth limits) and stay with RGB (so data is 1:1 copy).
kolak is offline   Reply With Quote
Old 28th October 2021, 22:26   #8  |  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 kolak View Post
So if I have SDI card which does not support Rec.2020 matrix and I want to push HDR data through it then safest way is to avoid going to YUV (which a lot of SDI card need to do due to bandwidth limits) and stay with RGB (so data is 1:1 copy).
Ah, right, this question came up at work as well for 10bit planar capable cards which cannot write BT2020.
Yes, I would say to stay in RGB and then go to YUV with something that is BT2020 aware. A bit of a pain but hey, you would have to re-encode the stream anyway, so...
Also make sure you're writing the right transfer characteristics in the final file since you mentioned HDR.


P.s in our case the signal was coming as 4:2:2 10bit planar 50p BT2020nc HLG, EVS saves it as it is by re-encoding to AVC Intra Class flagging it as BT709 SDR, then FFMpeg remuxes changing the metadata of the colormatrix and transfer characteristics and that's pretty much it. Easy peasy.

Last edited by FranceBB; 28th October 2021 at 22:31.
FranceBB is offline   Reply With Quote
Old 29th October 2021, 11:30   #9  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Metadata is handled manually. It's all about not loosing real data during such a convoluted conversion.
kolak is offline   Reply With Quote
Old 5th November 2021, 00:18   #10  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
YCbCr is much bigger than RGB even if it is full RGB to full YCbCr (you are using limited though, right? Only DV profile 5 is full range). 8 bit RGB require 10 bit YCbCr to preserve it and 10 bit RGB require 12 bit.

Some dumb example, even if you are using YCbCr BT.709 limited values 139, 151, 24 that is RGB -21, 182, 181. That is out-of-gamut for BT.709, obviously since negative RGB. Okay? But all 3 components are inside 16-235, 16-240, 16-240 range for Y, Cb, Cr.

Last edited by Balling; 5th November 2021 at 00:25.
Balling is offline   Reply With Quote
Old 5th November 2021, 18:09   #11  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Gamut should not matter as long as same matrix is used when converting from and to RGB, no ? There won't be any processing in YUV so no place to create bad YUV combinations.

RGB (with P3 gamut inside Rec.2020) -> YUV (over 709) -> RGB (reverse 709) -> final RGB treated as Rec.2020
kolak is offline   Reply With Quote
Old 7th November 2021, 04:52   #12  |  Link
Blankmedia
Registered User
 
Join Date: Oct 2011
Location: Dans le nord
Posts: 65
Some tyme when I'm using masktool, my frame goes green and script clip throws an error about having no clue what _colormatrix is and I'm out of idea.

Last thing I did was to converty video so maybe it would proper set de matrix :converttoyuv444(rec709).converttoyv12(rec709)


Have a good night!
..
Blankmedia is offline   Reply With Quote
Old 7th November 2021, 23:40   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
BlankMedia, start new thread and post your script.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 10th November 2021, 01:18   #14  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
Quote:
Originally Posted by kolak View Post
Gamut should not matter as long as same matrix is used when converting from and to RGB, no ? There won't be any processing in YUV so no place to create bad YUV combinations.
No. Both down chroma sampling and lossy codec introduce out-of-gamut values and those values are not "bad".
Balling 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 09:32.


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