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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th November 2022, 16:45   #201  |  Link
Alexkral
Registered User
 
Join Date: Oct 2018
Posts: 314
May I ask why the default pct_hdr_skin for PQMode in ConvertXYZ_BT2446_C_HDRtoSDR is set to 0.44? I haven't seen anything in ITU-R BT.2408 regarding this, only about HLG.
__________________
AviSynth AiUpscale
Alexkral is offline   Reply With Quote
Old 20th November 2022, 19:03   #202  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,261
I don't remember exactly... But if indeed there is nothing in BT.2408, i probably "estimate" it using informations from several BT, and i probably choose this value because "it seems not too bad".
There is probably some curve or anything which lead me to this choice.
__________________
My github.
jpsdr is offline   Reply With Quote
Old 20th November 2022, 20:45   #203  |  Link
Alexkral
Registered User
 
Join Date: Oct 2018
Posts: 314
Ah ok, I think I know why you did it. 44% PQ equals 50 nits, same as 50% HLG. It doesn't seem too bad indeed.
__________________
AviSynth AiUpscale
Alexkral is offline   Reply With Quote
Old 20th November 2022, 22:49   #204  |  Link
Alexkral
Registered User
 
Join Date: Oct 2018
Posts: 314
I found something funny looking at your code, not that it's in the least important, but I think I should let you know. You use 2.404 as the power in the BT.1886 EOTF, but the last 4 is actually a footnote . It's not that it's important as I say, but when I found the reason it made me laugh.

Also, I'm not too sure that the inverse OETF should be used, ITU repeats all over the place something that seems to imply this opinion, but I can understand why you do it.
__________________
AviSynth AiUpscale
Alexkral is offline   Reply With Quote
Old 21st November 2022, 01:43   #205  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,261
Thanks for the 2.404, i'll change this later. My guess is that at the time i read it, i didn't see the footnotes and thought it was misprint...
__________________
My github.
jpsdr is offline   Reply With Quote
Old 21st November 2022, 19:30   #206  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,261
New version, see first post.
__________________
My github.
jpsdr is offline   Reply With Quote
Old 26th February 2023, 12:36   #207  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,261
New version, see first post.
__________________
My github.
jpsdr is offline   Reply With Quote
Old 4th June 2023, 21:15   #208  |  Link
LouieChuckyMerry
Registered User
 
LouieChuckyMerry's Avatar
 
Join Date: Feb 2014
Posts: 351
Color Conversion: How To Tonemap BT.2020 To BT.709

First, many thanks jpsdr for all your effort .

I was gifted a UHD Blu-ray but don't have a 4K TV, so I figured I'd shrivel it to 1080p using AviSynth after color converting and resizing losslessly with VirtualDub2. Unfortunately, after hours of effort, I can't figure out how to tonemap BT.2020 to BT.709. I'm here because it seems to me that that's what your HDRTools plugin is for but using

Code:
ConvertYUVToXYZ(Color=1)
ConvertXYZToYUV(pColor=1)
as in your example runs fine but appears to do nothing. Please, what am I missing?

Ahhh, a video sample.

Last edited by LouieChuckyMerry; 4th June 2023 at 21:18. Reason: Link To Test Clip
LouieChuckyMerry is offline   Reply With Quote
Old 5th June 2023, 12:03   #209  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,727
Quote:
Originally Posted by LouieChuckyMerry View Post
Unfortunately, after hours of effort, I can't figure out how to tonemap BT.2020 to BT.709.
Try this to go from BT2020 HDR PQ to BT709 with HDRTools:

Code:
ConvertBits(16)

ConvertYUVtoXYZ(Color=0, OutputMode=1, HDRMode=0, fullrange=false)

ConvertXYZ_Reinhard_HDRtoSDR(exposure_X=2.5, contrast_X=0.9)

ConvertXYZtoYUV(pColor=0)

Converttoyuv420()
If the conversion is fine but looks a bit off, change Reinhard's parameters accordingly 'till you're ok with the end result.
FranceBB is online now   Reply With Quote
Old 6th June 2023, 00:48   #210  |  Link
LouieChuckyMerry
Registered User
 
LouieChuckyMerry's Avatar
 
Join Date: Feb 2014
Posts: 351
Thanks for your reply, FranceBB. Your suggested script runs fine but doesn't appear to change the video in any way; i.e., the output looks the same as the input, dull and muted (the same-looking result as the script I posted above).
LouieChuckyMerry is offline   Reply With Quote
Old 6th June 2023, 07:05   #211  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,673
If you have an nVidia GPU available, you can use DGHDRtoSDR to do the grading in one simple step. DGIndexNV can be used to tune the parameters per source.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 6th June 2023, 11:58   #212  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,727
Quote:
Originally Posted by LouieChuckyMerry View Post
Thanks for your reply, FranceBB. [...] the output looks dull and muted
Well, I wouldn't call it "Dull and Muted", but ok xD

Anyway, here's a comparison:




This is done with the following script:

Code:
FFVideoSource("D:\TestClip2[2160p].mkv")
SinPowerResize(848, 480)
original=last.Text("BT2020 HDR PQ 1043 nits - Original")

ConvertBits(16)
hbd=last
ConvertYUVtoXYZ(Color=0, OutputMode=1, HDRMode=0, fullrange=false)
ConvertXYZ_Reinhard_HDRtoSDR(exposure_X=2.5, contrast_X=0.9)
ConvertXYZtoYUV(pColor=0)
Converttoyuv420()
ConvertBits(bits=10, dither=1)
Text("BT709 SDR 100 nits - Reinhard tonemapping")
tonemapped=last


ConvertToPlanarRGB(hbd, matrix="Rec2020", interlaced=false)
Cube("C:\Programmi\AviSynth+\LUTs\PQ_to_BT709_v2.cube", fullrange=true)
Converttoyuv420()
ConvertBits(bits=10, dither=1)
Text("BT709 SDR 100 nits - FranceBB LUT")
lutted=last


StackVertical(original, tonemapped, lutted)

If you like the last one, then I strongly suggest you to check this out: https://forum.doom9.org/showthread.php?t=176091
FranceBB is online now   Reply With Quote
Old 7th June 2023, 01:58   #213  |  Link
LouieChuckyMerry
Registered User
 
LouieChuckyMerry's Avatar
 
Join Date: Feb 2014
Posts: 351
Boulder: Thanks for your reply. I do have an nVidia GPU and a license for DGIndexNV, so I'll attack your suggestion ASAP.
_____________

FranceBB: Thanks again for your help. Your latest suggestion looks good but I'll need a goodly stretch of free time to wrap my head around it.
_____________

I should have time this weekend to work on the above, possibly (but doubtfully) earlier. I really appreciate the help .
_____________

Edit: FranceBB: I took a quick look at your last link and, wow, that's really cool! Of course, I understand it intellectually but not really any of the details .

Last edited by LouieChuckyMerry; 7th June 2023 at 18:46. Reason: That's Cool
LouieChuckyMerry is offline   Reply With Quote
Old 20th November 2023, 21:52   #214  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,261
New version, see first post, but nothing big...
__________________
My github.
jpsdr 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 00:44.


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