Work in Progress - 3dLUT support

  Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
lmyllari Offline
Senior Member
Posts: 257
Joined: Nov 2013
Reputation: 38
Location: Sunny California
Post: #31
I'm bringing the code up-to-date with current master (no major changes needed) and changing the approach to support multi pass rendering (bigger changes needed).

I have taken the code for dithering and refactored it. My idea is to add an output stage that wraps whichever shader is run last. This is done by changing the shader to provide a process() function instead of main() and appending another shader source file that calls process() and if configured as the output stage (meaning this is the last rendering pass), handles RGB range conversion and dithering (and in the future color management and other final steps).

This gives two scenarios currently:
1) YUV2RGB -> output stage
2) YUV2RGB -> FBO -> convolution (for advanced scaling) -> output stage

I have not yet thought about other rendering paths (VAAPI, VDPAU etc).

I've modified the YUV2RGB and convolution filter shaders to append an output shader, and created a GLSLOutput helper class that can be passed to either to set up the output processing. I also added a system setting for dither depth to make testing easier.

Video is kept in limited range RGB until the output stage. This avoids banding when video is first rendered to an 8bit FBO.

This seems to work well for the cases I've tested (software decoding / VAAPI decoding without VAAPI rendering; all scaling methods; limited and full range output).

The code this far can be viewed here: https://github.com/xbmc/xbmc/compare/mas...ix-linuxgl - feedback on this approach is welcome.

Next I'll take the LUT processing and add it to the output stage.
find quote
bossanova808 Offline
Donor
Posts: 2,838
Joined: Sep 2009
Reputation: 56
Location: Melbourne, Australia
Post: #32
ICC profiles are not the correct approach, or even really designed for, video reproduction uses. Certainly when you profile a display with, say, an i1 of Spyder device, you will not by default be producing an ICC profile that helps with accurate video display. (You should be all really be looking at calibration of display, not transformation of signal, if you want more accurate video reproduction).

While an old comment, see Tom Lianza of X-Rite talking about this here:
https://www.avforums.com/threads/hdtv-ic...on.533926/

While you can bend the i1/Spyders etc to be closer to producing a video style profile (your target will be quite different from a typical print or still images standards one, though) - you will not see all the theatre geeks on AVS etc using profiles. You will, however, see them aggressively pursuing accurate calibration of the display to standards.

ICC Profiling for the *image viewer* in xbmc, slideshows etc, would be the most beneficial spot to spend time...

Sorry, no help w/out a *full debug log*
find quote
lmyllari Offline
Senior Member
Posts: 257
Joined: Nov 2013
Reputation: 38
Location: Sunny California
Post: #33
(2015-05-19 02:29)bossanova808 Wrote:  ICC profiles are not the correct approach, or even really designed for, video reproduction uses. Certainly when you profile a display with, say, an i1 of Spyder device, you will not by default be producing an ICC profile that helps with accurate video display. (You should be all really be looking at calibration of display, not transformation of signal, if you want more accurate video reproduction).
You're transforming the signal, whether you use the display controls or the PC to do it.

Quote:While an old comment, see Tom Lianza of X-Rite talking about this here:
https://www.avforums.com/threads/hdtv-ic...on.533926/
He's talking about something a little different.

The idea here is to profile the display (whether it's calibrated or not - ArgyllCMS can help you calibrate it using the display controls or calibration curves), link to rec.709 (or something else if desired) and create a device link. You can use ArgyllCMS to create a 3dlut file from the device link, or load the device link and sample it to produce a 3dlut.

There is no need to go to PCS after creating the device link. Also, lack of hardware support is not an issue when you have a powerful GPU. (And "powerful" is quite relative, my Haswell Celeron with its integrated GPU will happily run 1080p video through a 3dlut.)

Quote:While you can bend the i1/Spyders etc to be closer to producing a video style profile (your target will be quite different from a typical print or still images standards one, though) - you will not see all the theatre geeks on AVS etc using profiles. You will, however, see them aggressively pursuing accurate calibration of the display to standards.
Take a look at the AVSForum display calibration area and you'll see a lot of people using 3dluts to improve display accuracy (or work around lacking display controls). MadVR seems quite popular, and there are hardware solutions too. I have tried ArgyllCMS created profiles (both with MadVR and my patched xbmc) and they work very well.

I am also interested in having different source profiles for experimentation since for a long time the standards were lacking, or not adhered to. My display is already professionally calibrated to rec.709 with bt.1886 gamma. How about discs that were mastered on a display with 2.2 or 2.4 gamma, or bt.601 primaries?

Quote:ICC Profiling for the *image viewer* in xbmc, slideshows etc, would be the most beneficial spot to spend time...
I think a different approach may be better for the image viewer. Since I'm adding lcms2, it could be used to take the picture and display profiles, link them and transform the picture. My interest is mostly in video though. If you'd like to work on the image viewer, I'll be happy to share what I've learned.
find quote
bossanova808 Offline
Donor
Posts: 2,838
Joined: Sep 2009
Reputation: 56
Location: Melbourne, Australia
Post: #34
Sorry I just skim read. I thought you were just using normal display ICC profiles...should have bothered to read the thread Wink

Basically you're talking about this then:
http://www.avsforum.com/forum/139-displa...llcms.html ?

Sorry, no help w/out a *full debug log*
find quote
sebj Offline
Senior Member
Posts: 196
Joined: Nov 2008
Reputation: 0
Post: #35
Still watching this thread, really excited! Smile

thx lmyllari!
find quote
bluechris Offline
Senior Member
Posts: 176
Joined: Jan 2014
Reputation: 2
Location: Athens
Post: #36
Me two but I'm with windows so i use my 3dlut with madvr forcing kodi to run media player classic. .. im ok but it would had been so much better if i was staying in kodi fully.
My best scenario for me would had been kodi not to have hardcoded the ffdshow but that is what it is.

There's no substitute for experience
find quote
lmyllari Offline
Senior Member
Posts: 257
Joined: Nov 2013
Reputation: 38
Location: Sunny California
Post: #37
Quick update: I have the 3dlut working again, but haven't measured it yet to make sure it's accurate.

The LUT loader code is very much work in progress and is currently only working for a rec709 device link profile. The display profile loading will probably need some changes, since I changed the LUT to work on video level signal. I'd also like to add support for some 3dlut file formats to avoid the hard dependency on lcms2.

On the upside, the existing madvr workflow for profiling can now be used, and there should be no issues using this with (or without) scaling.

If anybody is brave enough to test at this point, the code is in my tmp2 branch. It looks for display/rec709.icc in the profile directory (~/.kodi/userdata/display/rec709.icc). I'm testing using a device link that dispcalgui created while making a madvr 3dlut. Dither depth can be configured in the system video settings. Using a low depth (2-4 bits) can be useful to test the output stage with different source materials and scaling settings. The dithering is not gamma correct, so any measurements should be done using 8bit dither depth.
find quote
sat4all Offline
Senior Member
Posts: 161
Joined: Jul 2012
Reputation: 1
Location: Casablanca, Morocco
Post: #38
would you please provide the code link.
looked here https://github.com/laurimyllari but no tmp2 branch

thank you

Intel NUC D54250WYK: Win 10 + Kodi Krypton + MPC-HC (madvr,lav,sanear,xysub)
LG OLED 65EF950v / Denon AVR-X3200W / KEF E305 / Synology DS2415+ / Vu+ SOLO2
Ruling them all with a Logitech Harmony 950 Remote
(This post was last modified: 2015-06-02 18:50 by sat4all.)
find quote
lmyllari Offline
Senior Member
Posts: 257
Joined: Nov 2013
Reputation: 38
Location: Sunny California
Post: #39
(2015-06-02 18:49)sat4all Wrote:  would you please provide the code link.
looked here https://github.com/laurimyllari but not tmp2 branch

thank you
Here you go: https://github.com/laurimyllari/xbmc/tree/tmp2
find quote
sat4all Offline
Senior Member
Posts: 161
Joined: Jul 2012
Reputation: 1
Location: Casablanca, Morocco
Post: #40
(2015-06-02 18:51)lmyllari Wrote:  
(2015-06-02 18:49)sat4all Wrote:  would you please provide the code link.
looked here https://github.com/laurimyllari but not tmp2 branch

thank you
Here you go: https://github.com/laurimyllari/xbmc/tree/tmp2

thanks!
going to try it with my madvr 3d lut and post back.

Intel NUC D54250WYK: Win 10 + Kodi Krypton + MPC-HC (madvr,lav,sanear,xysub)
LG OLED 65EF950v / Denon AVR-X3200W / KEF E305 / Synology DS2415+ / Vu+ SOLO2
Ruling them all with a Logitech Harmony 950 Remote
find quote
lmyllari Offline
Senior Member
Posts: 257
Joined: Nov 2013
Reputation: 38
Location: Sunny California
Post: #41
(2015-06-02 18:54)sat4all Wrote:  thanks!
going to try it with my madvr 3d lut and post back.
If you used dispcalgui to create it, take the second ICC profile dcg created (that's the device link between your source space and display) - the madvr lut file can not be loaded yet.
find quote
sat4all Offline
Senior Member
Posts: 161
Joined: Jul 2012
Reputation: 1
Location: Casablanca, Morocco
Post: #42
(2015-06-02 18:56)lmyllari Wrote:  If you used dispcalgui to create it, take the second ICC profile dcg created (that's the device link between your source space and display) - the madvr lut file can not be loaded yet.

it was created using calman5.

Intel NUC D54250WYK: Win 10 + Kodi Krypton + MPC-HC (madvr,lav,sanear,xysub)
LG OLED 65EF950v / Denon AVR-X3200W / KEF E305 / Synology DS2415+ / Vu+ SOLO2
Ruling them all with a Logitech Harmony 950 Remote
(This post was last modified: 2015-06-02 19:00 by sat4all.)
find quote
lmyllari Offline
Senior Member
Posts: 257
Joined: Nov 2013
Reputation: 38
Location: Sunny California
Post: #43
(2015-06-02 18:59)sat4all Wrote:  it was created using calman5.
I haven't used calman, but you may have to jump through some hoops to get this working at the moment.

If it can create an ICC device link for you, that should work (assuming it is for limited range RGB).

My guess is you'll need to output a display profile and then use argyll collink to link it.
find quote
sat4all Offline
Senior Member
Posts: 161
Joined: Jul 2012
Reputation: 1
Location: Casablanca, Morocco
Post: #44
(2015-06-02 19:12)lmyllari Wrote:  I haven't used calman, but you may have to jump through some hoops to get this working at the moment.

If it can create an ICC device link for you, that should work (assuming it is for limited range RGB).

My guess is you'll need to output a display profile and then use argyll collink to link it.

ok, i'm going to give it a try.
thanks again!

Intel NUC D54250WYK: Win 10 + Kodi Krypton + MPC-HC (madvr,lav,sanear,xysub)
LG OLED 65EF950v / Denon AVR-X3200W / KEF E305 / Synology DS2415+ / Vu+ SOLO2
Ruling them all with a Logitech Harmony 950 Remote
find quote
lmyllari Offline
Senior Member
Posts: 257
Joined: Nov 2013
Reputation: 38
Location: Sunny California
Post: #45
(2015-06-02 18:28)lmyllari Wrote:  Quick update: I have the 3dlut working again, but haven't measured it yet to make sure it's accurate.
First measurements with a quick profile (400 something patches) seem promising. The grayscale and primaries fell nicely in place, gamma was a little higher than expected (but the right shape). I've seen similar issues with DCG/madVR.

I'll try with a larger patch count, and if the issue persist I'll create, verify and measure first using DCG, HCFR and madVR and then check that the results match Kodi.

I found the madVR LUT file format specification (http://sourceforge.net/projects/thr3dlut/files/doc/) and it should be pretty easy to support.
find quote
Post Reply