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 21st June 2018, 08:45   #21  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
... I'll see... in the future...
__________________
My github.
jpsdr is offline   Reply With Quote
Old 21st June 2018, 09:55   #22  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
What bout HDR PQ to HLG conversion based on this paper:

http://downloads.bbc.co.uk/rd/pubs/p...anscode_v2.pdf

which suggests it should be pure math (no tone mapping, etc at leats for 1000 nits masters).
kolak is offline   Reply With Quote
Old 21st June 2018, 13:50   #23  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
I'll take a look later, but will not this just shift the issue from converting [PQ-HDR -> SDR] to converting [HLG-HDR -> SDR] ?
__________________
My github.
jpsdr is offline   Reply With Quote
Old 21st June 2018, 15:46   #24  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Well, HDR to SDR is different story as it's difficult conversion and ideally should be done per scene, not global.
HDR PQ to HLG should be way easier (more like Rec.709 to Rec.601).
kolak is offline   Reply With Quote
Old 21st June 2018, 16:15   #25  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
My final purpose (the reason i've made these tools) is to work on HDR to SDR.
__________________
My github.
jpsdr is offline   Reply With Quote
Old 21st June 2018, 23:02   #26  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Starting with something easier (which is still useful) is no harm
kolak is offline   Reply With Quote
Old 22nd June 2018, 09:03   #27  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
I have no needs for PQ to HLG for now. But technicaly, once i'll implement the HLG in the plugins (because for now there is only PQ, my plugins have a HLGMode parameter, not implemented yet), doing something like :
Code:
ConvertYUVtoLinearRGB(Color=0,HLGMode=true)
ConvertLinearRGBtoYUV(Color=0)
will do the convertion.
I didn't implement HLG yet, because i've trouble to understand properly how it works. There is several range mode (so i'm a little loss).
But...! Maybe the doc you provided will help me to understand things. But, HLG is not my prority for now.
Ah... Just take a look. The french version and english version of the same release version document don't say the same thing.
French version (R-REC-BT.2100-1-201706-I!!PDF-F) talk of [0:12] range and possibility of [0:1], when english (R-REC-BT.2100-1-201706-I!!PDF-E) talk only of [0:1]...
Nice !

Edit :
Quick look, it seems that PQ has fixed parameters functions, for luminance range up to 10000 cd/mē. It seems that for HLG, the parameters changes according (Lw/Lb) values, when they are fixed for PQ. Meaning i'll have to add these parameters on my plugins, for when i'll implement HLG. I'll also have to add some "WhitePeak" value (at least on plugins using linear data on input), if i want to properly handle both HLG and PQ, because it seems that i can't assume (like i thought), that in linear value, 1.0 = 10000 cd/mē.
Well... I'll see this for later... when i'll do the 0.3 release
__________________
My github.

Last edited by jpsdr; 22nd June 2018 at 09:34.
jpsdr is offline   Reply With Quote
Old 22nd June 2018, 10:40   #28  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
There are many references to [0,1] or [0,12] in English version.
Is there anything useful in link to HDRTools project provided in the document?

Last edited by kolak; 22nd June 2018 at 10:42.
kolak is offline   Reply With Quote
Old 22nd June 2018, 11:38   #29  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
Didn't read properly yet (but retrieved), i'm on something else for now, but there is a big chance it may help me to understand better HLG and this eventualy "whitepeak" information.

Edit :
Read a little more, it will help me. From what i understood (if properly), PQ is "fixed" -> 1 = 10000cd/mē, but HLG is adaptative.
Stop investigating for now, will continue in second time.
__________________
My github.

Last edited by jpsdr; 22nd June 2018 at 12:09.
jpsdr is offline   Reply With Quote
Old 26th June 2018, 14:50   #30  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
I've read doc more carefully, kolak doc helped... HLG is a pain in the ass !!!
I'll implement what i've understood, i just hope i have undersood properly...
__________________
My github.
jpsdr is offline   Reply With Quote
Old 26th June 2018, 17:42   #31  |  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 jpsdr View Post
I've read doc more carefully, kolak doc helped... HLG is a pain in the ass !!!
I'll implement what i've understood, i just hope i have undersood properly...
That would be amazing, 'cause last time I used Davinci Resolve to convert HDR10 to HLG, but it would indeed be very useful to have HLG working in your plugin.
FranceBB is offline   Reply With Quote
Old 26th June 2018, 19:28   #32  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
And having someone to test/verify also

Otherwise, does anyone know if it's possible to make a script which display, in the frame, the max value of Y for the curent frame (for an YUV video) ?
If yes, what would it be ?
__________________
My github.
jpsdr is offline   Reply With Quote
Old 26th June 2018, 20:44   #33  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Something like this maybe [EDIT: Below intended for 8 bit only]

Code:
Function TestFunc(clip c,Float Thresh_Min, Float Thresh_Max,Bool Debug,String LogFile) {
    c
    Yave=AverageLuma YMin=YPLaneMin(Thresh_Min) YMax=YPLaneMax(Thresh_Max)
    Subtitle(String(YAve,"YAve=%7.3f : ")+String(YMin,"YMin=%3.0f : ")+String(YMax,"YMax=%3.0f"),Align=8)        # Added
    RT_Subtitle("%d] YAve=%7.3f YMin=%3d YMax=%3d",current_frame,YAve,YMin,YMax,Align=5)
    (Debug) ? RT_DebugF("%d] YAve=%7.3f YMin=%3d YMax=%3d",current_frame,YAve,YMin,YMax,name="TestFunc: ") : NOP
    (LogFile!="") ? RT_Writefile(LogFile,"%d] YAve=%7.3f YMin=%3d YMax=%3d",current_frame,YAve,YMin,YMax,Append=True) : NOP
    Return last
}


FN         = "D:\TestClip.avi"
LOGFILE    = "D:\TestClip.Log"
DEBUG      = True
Thresh_Min = 0.0
Thresh_Max = 0.0

(LOGFILE!="") ? RT_FileDelete(LOGFILE) : NOP    # We Will Append

SSS =   "TestFunc("                         +
        \ String(Thresh_Min,"%f")           +
        \ String(Thresh_Max,",%f,")         +
        \ String(DEBUG)                     +
        \ "," + Chr(34) + LogFile + Chr(34) +
        \ ")"

#SSS=RT_String("""TestFunc(%f,%f,%s,"%s")""",Thresh_Min,Thresh_Max,DEBUG,LogFile)   # Alternative
#RT_DebugF("SSS=%s",SSS)

AviSource(FN)
Return Last.Scriptclip(SSS)
EDITED:

EDIT: Alternative to RT_string, StrFmt(Small dll):- https://forum.doom9.org/showthread.p...ghlight=StrFmt

EDIT: Or RT_Stats for 'RT_xxx' funcs:- https://forum.doom9.org/showthread.p...light=RT_Stats
__________________
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; 26th June 2018 at 21:56.
StainlessS is offline   Reply With Quote
Old 27th June 2018, 09:08   #34  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
Tested, and seems there is a problem. I've used your 2.00 beta version.
The message is telling me that Average Plane can only be used within run-time filters.
No log file is created.
__________________
My github.
jpsdr is offline   Reply With Quote
Old 27th June 2018, 09:40   #35  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
That is why its called from ScriptClip() in given code.
AverageLuma can only be called from within runtime environment,
or alternatively, cheat a bit, simulate within runtime filter, must eg current_frame=n, before the call to AverageLuma. (Scriptclip et al, set current_frame at every frame so it is known what frame is current).
For RT_AverageLuma(n=n).will also suffice, where n is accepted as current_frame, but MUST be done for every frame, thats is why Scriptclip is a good idea, unless using eg GScript for next to access frames.

"No log file is created", thats because its already caused an error and exited.
Try the script as given.

MOBILE:

EDIT: Post your failing script.

EDIT: do frame 42 only (untested)

Code:
Function TestFunc(clip c,Float Thresh_Min, Float Thresh_Max,Bool Debug,String LogFile) {
    c

    n=current_frame    
    trim(n,-1)
    current_frame=0
    Yave=AverageLuma YMin=YPLaneMin(Thresh_Min) YMax=YPLaneMax(Thresh_Max)
    Subtitle(String(YAve,"YAve=%7.3f : ")+String(YMin,"YMin=%3.0f : ")+String(YMax,"YMax=%3.0f"),Align=8)        # Added
    RT_Subtitle("%d] YAve=%7.3f YMin=%3d YMax=%3d",n,YAve,YMin,YMax,Align=5)
    (Debug) ? RT_DebugF("%d] YAve=%7.3f YMin=%3d YMax=%3d",n,YAve,YMin,YMax,name="TestFunc: ") : NOP
    (LogFile!="") ? RT_Writefile(LogFile,"%d] YAve=%7.3f YMin=%3d YMax=%3d",n,YAve,YMin,YMax,Append=True) : NOP
    Return last
}


FN         = "D:\TestClip.avi"
LOGFILE    = "D:\TestClip.Log"
DEBUG      = True
Thresh_Min = 0.0
Thresh_Max = 0.0

(LOGFILE!="") ? RT_FileDelete(LOGFILE) : NOP    # We Will Append

AviSource(FN)
current_frame=42 /* Simulate runtime */
TestClip(Thresh_Min,Thresh_Max,DEBUG,LOGFILE)
Return Last
EDIT: Oops, would print stats from frame 42 on frame zero, i think(not sure), edited in blue, should work.
EDIT: Oops again, will print frame 0] in stats, well you get the idea anyways I hope.

Alternative, MUST call with n=frame number, or n=current_frame from within ScriptClip.
Code:
Function TestFunc(clip c,int n,Float Thresh_Min, Float Thresh_Max,Bool Debug,String LogFile) {
    c
    trim(n,-1)
    current_frame=0
    Yave=AverageLuma YMin=YPLaneMin(Thresh_Min) YMax=YPLaneMax(Thresh_Max)
    Subtitle(String(YAve,"YAve=%7.3f : ")+String(YMin,"YMin=%3.0f : ")+String(YMax,"YMax=%3.0f"),Align=8)        # Added
    RT_Subtitle("%d] YAve=%7.3f YMin=%3d YMax=%3d",n,YAve,YMin,YMax,Align=5)
    (Debug) ? RT_DebugF("%d] YAve=%7.3f YMin=%3d YMax=%3d",n,YAve,YMin,YMax,name="TestFunc: ") : NOP
    (LogFile!="") ? RT_Writefile(LogFile,"%d] YAve=%7.3f YMin=%3d YMax=%3d",n,YAve,YMin,YMax,Append=True) : NOP
    Return last
}
__________________
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; 28th June 2018 at 04:50.
StainlessS is offline   Reply With Quote
Old 27th June 2018, 12:26   #36  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
Thanks, i finaly been able to get what i want.
__________________
My github.
jpsdr is offline   Reply With Quote
Old 28th June 2018, 15:33   #37  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
Quote:
Originally Posted by FranceBB View Post
That would be amazing, 'cause last time I used Davinci Resolve to convert HDR10 to HLG, but it would indeed be very useful to have HLG working in your plugin.
Do you have, by any chance, an HLG encoded stream you could share ?
__________________
My github.
jpsdr is offline   Reply With Quote
Old 28th June 2018, 17:57   #38  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
http://4kmedia.org/travelxp-4k-hdr-hlg-sample/

Or google for "hdr hlg sample files". You'll find a lot of them.

Not all have the SEI denoting HLG, but some do.

Last edited by videoh; 28th June 2018 at 18:06.
videoh is offline   Reply With Quote
Old 28th June 2018, 18:18   #39  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
It didn't even cross my mind to google search...
Thanks.

What are exactly HLG SEI information ? Is there some other mastering informations in the H265 spec ? I've tried a search for "HLG" in the T-REC-H.265-201612-I!!PDF-E document, but found no information about such a thing.
__________________
My github.
jpsdr is offline   Reply With Quote
Old 28th June 2018, 18:49   #40  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
You can google "HLG SEI message". BTW, DGIndexNV notifies this SEI in the DGI file.
videoh 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 20:16.


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