[CLOSED] DGNV HDR preview doesn't match DGHDR2SDR results

Support forum for DGDecNV
Post Reply
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

[CLOSED] DGNV HDR preview doesn't match DGHDR2SDR results

Post by MeteorRain »

Code: Select all

dgsource("main.dgi")
DGHDRtoSDR(mode="hlg", ..., fulldepth=true)

ConvertYUVtoLinearRGB(Color=1)
ConvertLinearRGBtoYUV(Color=2)

# Or

# ConvertToRGB32(matrix="Rec2020") 
# ConvertToYUV420(matrix="Rec709") 
DGHDRtoSDR alone doesn't match DGNV HDR preview. I have to convert the matrix from 2020 to 709 to make it the same as what I saw from DGNV GUI.

From what I learned, it converted the "colorimetry" from 2020 to 709, but not the "matrix" from 2020 to 709. So a matrix conversion without a colorimetry conversion is needed.

Is this an expected behavior?

EDIT:

Comparing to a non-HDR 2020

Code: Select all

dgsource("main.dgi")
ConvertYUVtoXYZ(Color=1)
ConvertXYZtoYUV(pColor=1)
Converting between YUV and XYZ changes both colorimetry and matrix. I initially used this to convert the above result, and obviously went wrong. Took me a long while to notice the difference between the two conversions.
User avatar
Rocky
Posts: 3557
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Rocky »

I'll look into it. First I have to complete the THD demuxing and HEVC seeking issues. Thank you for your report, MeteorRain.

They are theoretically using the same code so this should be interesting. :)
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by MeteorRain »

Just a reminder: I could be wrong though. I'm very new to the 4K/8K/2020/HLG world, so I'm still exploring and trial and error.
User avatar
Rocky
Posts: 3557
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Rocky »

MeteorRain wrote:
Sun Mar 15, 2020 8:19 pm
I'm very new to the 4K/8K/2020/HLG world, so I'm still exploring and trial and error.
You and me both!

https://www.youtube.com/watch?v=QKA7N2vMtcw
User avatar
Rocky
Posts: 3557
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Rocky »

Colorimetry consists of three things:

* matrix
* transfer function
* color primaries

DGHDRtoSDR() is coded to properly convert all three. You claim:

"DGHDRtoSDR alone doesn't match DGNV HDR preview."

Please provide a stream and describe all steps to demonstrate this, including scripts, and specify used applications.

Note that for display in DGIndexNV, the output is converted to RGB for GDI display using either 601 or 709, depending on the source stream (typically 709 for HD). So if it looks OK in DGIndexNV, then it must have been 709 going into the RGB conversion. DGHDRtoSDR uses the same HDR->SDR code, so I argue that it is outputting 709.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by MeteorRain »

Uploaded a sample file.

Steps for DGIndexNV
1) Load hevc file
2) Video - HDR to SDR
3) Enable HDR to SDR
4) Enable HLG
5) Set params to 7000, 0, 0.42, 1.00, 1.00, 1.00, 0.70, 0.70
6) F8 copy frame

Steps for DGHDRtoSDR
1) Create index file
2) Create AVS file as
dgsource("HLG-7600241771-7663549204.dgi")
DGHDRtoSDR(mode="hlg",white=7000, black=0, gamma=0.42, r=1.0, g=1.0, b=1.0, tm=0.7, roll=0.7, fulldepth=true)
ConvertToRGB(matrix="Rec709")
3) Load file into VirtualDub2 or any other tool
4) Copy frame

Compare colors on pink circle board people hold or top right pink 人shape logo.

I'm reading FC97C7 from DGNV and FFA4C8 from AVS, for the center of the pink board holding by a girl in front row.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by MeteorRain »

As a side note, a manual conversion as I wrote in OP didn't give me the same color either, so I might have done it wrong.
User avatar
Curly
Posts: 712
Joined: Sun Mar 15, 2020 11:05 am

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Curly »

I peeked at the code, nyuk nyuk! :twisted:

So in DGIndexNV the HLG P16 to RGB P8 uses limited range. OK, that matches 'RecXXX'. But the conversion routine lacks the 601/709 parameter that gets used for normal 8-bit stuff. And it appears to be coded for 601. To verify that this is the case use ConvertToRGB(matrix="Rec601"). Then everything seems to match. So Rockstar, ya gotta use 709 equations for this.
Curly Howard
Director of EAC3TO Development
User avatar
Rocky
Posts: 3557
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Rocky »

I think you're right, Curly! Thanks. :salute:

Fortunately it's only a display issue in DGIndexNV GUI. The DGHDRtoSDR() output is correct; it outputs YUV (no RGB conversion).
User avatar
Natasha
Posts: 150
Joined: Wed Nov 20, 2019 11:11 am

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Natasha »

Image

Curly has no nuts.
User avatar
Curly
Posts: 712
Joined: Sun Mar 15, 2020 11:05 am

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Curly »

I resemble that remark. :evil:
Curly Howard
Director of EAC3TO Development
User avatar
Boris
Posts: 92
Joined: Sun Nov 10, 2019 2:55 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Boris »

Shaddap!
Tashie, don't feed the trolls.
User avatar
Mr. Peabody
Posts: 45
Joined: Tue Dec 24, 2019 9:20 am

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Mr. Peabody »

Rocky wrote:
Sun Mar 29, 2020 8:44 pm
Fortunately it's only a display issue in DGIndexNV GUI.
However, it's unfortunate to the extent that using DGIndexNV to find good DGHDRtoSDR() parameters is now problematic.
User avatar
Rocky
Posts: 3557
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Rocky »

I'm not blind!
User avatar
Sherman
Posts: 576
Joined: Mon Jan 06, 2020 10:19 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Sherman »

Mr. Peabody, could this be the girl for you?

https://www.youtube.com/watch?time_cont ... u3HN-MmJc4
Sherman Peabody
Director of Linux Development
User avatar
Rocky
Posts: 3557
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Rocky »

Checked the code and the conversion is coded for 709 so Curly's theory appears incorrect. Still looking for the source of the discrepancy.
User avatar
Bullwinkle
Posts: 338
Joined: Thu Sep 05, 2019 6:37 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Bullwinkle »

The kid did pretty good on the PVBob() issue. Why don't we assign him this one?
User avatar
Sherman
Posts: 576
Joined: Mon Jan 06, 2020 10:19 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Sherman »

Thanks, Bullwinkle. I'll get right on it.
Sherman Peabody
Director of Linux Development
User avatar
Sherman
Posts: 576
Joined: Mon Jan 06, 2020 10:19 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Sherman »

I'm not seeing a problem here. First off, the ConvertToRGB() in the script is not needed and just complicates things. So I removed that. Also there's no need for doing F8 and all that. I used ColorPic to look at the pixels for 2 cases:

1. Directly in DGIndexNV display (not via F8).

2. Script loaded in VirtualDub2.

Below I show the results. You can see that the results are the same (allowing for different pixels and possible small algorithmic differences in the two display chains. On the left is DGIndexNV and on the right is Avisynth+VirtualDub2.

ImageImage

I also confirmed that there are no relevant code differences for the two conversions. I recommend closing this if MeteorRain is OK with that.
Sherman Peabody
Director of Linux Development
User avatar
Curly
Posts: 712
Joined: Sun Mar 15, 2020 11:05 am

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Curly »

You're right, boy, but the hullabaloo? :roll: In the debugger, directly compare the YUV values entering the RGB conversions.

Image
Curly Howard
Director of EAC3TO Development
User avatar
Sherman
Posts: 576
Joined: Mon Jan 06, 2020 10:19 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Sherman »

Don't we need an end-to-end test? Otherwise someone could say fine, the YUVs are the same, but the RGB conversion in DGIndexNV is messed up. It would be a useful double-check, I agree.

I think everything is just fine. :salute: Rocky
Sherman Peabody
Director of Linux Development
User avatar
Rocky
Posts: 3557
Joined: Fri Sep 06, 2019 12:57 pm

Re: DGNV HDR preview doesn't match DGHDR2SDR results

Post by Rocky »

Gonna close it then. Thank you, Sherman.
User avatar
MeteorRain
Posts: 130
Joined: Fri Jul 25, 2014 4:04 pm
Location: New Jersey

Re: [CLOSED] DGNV HDR preview doesn't match DGHDR2SDR results

Post by MeteorRain »

Thanks, I'll double check the colors.
Post Reply