Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading 3DLUTs to B8 (Alpha7 2nd gen chipset) #1

Closed
chros73 opened this issue Nov 26, 2019 · 34 comments
Closed

Uploading 3DLUTs to B8 (Alpha7 2nd gen chipset) #1

chros73 opened this issue Nov 26, 2019 · 34 comments

Comments

@chros73
Copy link

chros73 commented Nov 26, 2019

Hi!

First of all, thanks for your work!
Let me know if you need any help with B8 (Alpha7 2nd gen chipset, 17 points cube).

@bendavid
Copy link
Owner

Implemented now in principle, but needs to be tested.

3D LUTs can be loaded from .cube files using
upload_3d_lut_bt709_from_file(self, picMode, filename)
or
upload_3d_lut_bt2020_from_file(self, picMode, filename)

in principle it should autodetect the proper capabilities based on the TV model, so for the B8 you should indeed give it a 17 point cube file.

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

Sounds amazing! Thank You for your work!

Have you tested these by yourself? :) Are we sure that it doesn't break our TV?

Can you create a file for usage with examples? (e. g. uploading SDR and HDR 3dluts) You can create a docs directory, and a Calibration file into it. Definitions are also welcome in it, since I don't know anything about LG TV calibration.

Thank you!

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

I have tested this extensively with the C8, but not at all with any other models. I am reasonably sure there is no danger from any of the functions here, but as I have stated elsewhere, I did manage to outright brick my TV by uploading problematic Dolby Vision config data previously (and this is one of the reasons that functionality is not yet exposed in the library).

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

Thanks for confirming this. I'll try to create a 3dlut for HDR mode (that is what I'm missing) with DisplayCal (following janos666 suggestion) then exporting it to Iridas 17 points cube and I'll be ready to try it out.

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

I try to run ("install") the util on Windows (I can't compile python 3.8 on Ubuntu 14.04 for whatever reason).
So, pip and python is working from command line, but when I fire up this command pip install aiopylgtv it says:

d:\Progs\aiopylgtv>pip3 install aiopylgtv
ERROR: Could not find a version that satisfies the requirement aiopylgtv (from versions: none)
ERROR: No matching distribution found for aiopylgtv

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

The package is not released/uploaded yet, so you'll have to build it from source for the moment.

python setup.py sdist
pip install dist/aiopylgtv-0.2.0b1.tar.gz

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

(You can also try it in an earlier python version. It for sure needs at least python 3.5 though.)

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

Thanks, that's good news, I can get 3.6 working. I'll take a look later.

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

Thanks for the help, now 3.6 is fine and I have the command line util:

$ aiopylgtvcommand
usage: aiopylgtvcommand [-h] host command [parameters [parameters ...]]

What commands would you use to create and upload a 3dlut to hdr_technicolorExpert HDR10 preset? And I do not want to deal with 1dlut for this preset.

Thanks

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

You can just do

aiopylgtvcommand <hostname> start_calibration hdr_technicolorExpert
aiopylgtvcommand <hostname> upload_3d_lut_bt2020_from_file hdr_technicolorExpert "test3d.cube"
aiopylgtvcommand <hostname> end_calibration hdr_technicolorExpert

The input file for lut upload can be produced from DisplayCal by selecting the IRIDAS(.cube) format, and 17x17x17 or 33x33x33 (17x17x17 for the B8 of course)

If you want to upload a unity 3d lut, you can do it without any file input by doing

aiopylgtvcommand <hostname> start_calibration hdr_technicolorExpert
aiopylgtvcommand <hostname> upload_3d_lut_bt2020 hdr_technicolorExpert
aiopylgtvcommand <hostname> end_calibration hdr_technicolorExpert

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

Thanks, that helps a lot. More questions about creating only a 3dlut (not 1dlut) for HDR10 (with DisplayCal):

  • do I have to measure the patches after "start_calibration" and "ddc_reset"? (meaning in the calibration state?)
  • if the above is true then: will the ddc_reset upload a unity 1dlut as well? isn't this a problem?

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

ddc_reset WILL upload a unity 1dlut as well, and this IS a problem if you want to keep the factory 1dlut.

You don't need to do the ddc_reset though, calibration mode is enabled just with start_calibration (and this does not modify anything permanently).

So yes, you should start measuring patches after start_calibration in order to bypass the tone mapping. (but can skip ddc_reset entirely).

On the other hand, I have seen in SDR mode that start_calibration significantly changes the behaviour of the image processing without having done a ddc_reset, but that this is not the case after doing the ddc reset. In that case doing the patch measurement after start_calibration would invalidate the calibration. If the set behaves similarly in HDR10 mode this would suggest that it's preferable to use a unity or calibrated 1D LUT as well rather than the factory one (but I think this should be tried both ways and compared.)

Of course after uploading any 1D LUT you would need to do a factory reset in order to get back the factory one.

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

Btw you can see here that ddc_reset doesn't do anything magic or special, it just sets brightness, contrast, oled light and color to defaults and uploads unity 1d and 3d luts.

async def ddc_reset(self, picMode):
await self.set_brightness(picMode)
await self.set_contrast(picMode)
await self.set_oled_light(picMode)
await self.set_color(picMode)
await self.upload_1d_lut(picMode)
await self.upload_3d_lut_bt709(picMode)
await self.upload_3d_lut_bt2020(picMode)

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

ddc_reset doesn't do anything magic or special

Yes, thanks, I saw that.

I have seen in SDR mode that start_calibration significantly changes the behaviour of the image processing without having done a ddc_reset

Since ddc_reset doesn't do anything special (only setting the factory values): maybe one of these settings weren't at its default when you tried that?

One more question about this: in "ddc_reset" oled light and contrast is default to 80 / 85. But HDR10 uses 100 / 100 for these by default. Isn't it an issue? (And DV mode uses 50 / 100 for 2018 models and 100/100 for 2019.)

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

Ah yes, you're right, that's a mistake on my side, I'll implement a more dynamic lookup of default values in the next version.

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

I got this error (websockets 8.1, asyncio 3.4.3, numpy 1.17.4 are installed in virtualenv by pip3):

$ aiopylgtvcommand 192.168.1.78 connect
Traceback (most recent call last):
  File "/home/chros/virtualenvs/venv_lg/bin/aiopylgtvcommand", line 8, in <module>
    sys.exit(aiopylgtvcommand())
  File "/home/chros/virtualenvs/venv_lg/lib/python3.6/site-packages/aiopylgtv/utils.py", line 23, in aiopylgtvcommand
    asyncio.get_event_loop().run_until_complete(runloop(client, args.command, args.parameters))
  File "/usr/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
    return future.result()
  File "/home/chros/virtualenvs/venv_lg/lib/python3.6/site-packages/aiopylgtv/utils.py", line 6, in runloop
    await client.connect()
  File "/home/chros/virtualenvs/venv_lg/lib/python3.6/site-packages/aiopylgtv/webos_client.py", line 118, in connect
    self.connect_task = asyncio.create_task(self.connect_handler(self.connect_result))
AttributeError: module 'asyncio' has no attribute 'create_task'

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

You shouldn't explicitly call "connect" from the command line tool (connect and disconnect get called implicitly in this case)

But in any case it looks like the issue is python version compatibility.

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

Hmm, so should I just start with this command and will it take care of pairing? (Same error as above)

aiopylgtvcommand 192.168.1.78 start_calibration hdr_technicolorExpert

I'll try out from windows with 3.8.

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

aiopylgtvcommand 192.168.1.78 start_calibration hdr_technicolorExpert
I'll try out from windows with 3.8.

Thanks, it works with 3.8 from Windows!

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

Well, this one doesn't do anything, although it returns "yes": picture is the same and there was no toast message that calibration is ended.

aiopylgtvcommand 192.168.1.78 end_calibration technicolorExpert
{'returnValue': True}

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

It should restore the tone mapping when you end the calibration assuming you're in hdr mode. In SDR indeed there should be no change (and in practice in the cases where there are it's subtle)

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

Sorry, I'm only experimenting with SDR technicolorExpert preset:

  • start_calibration worked
  • but I can't end the calibration (some menu settings are also disabled in Technicolor)

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

I don't believe there is supposed to be any visual feedback when ending the calibration.

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

It seems, you are right: it worked in HDR (ending the session, it was a bigger difference in brightness).

@chros73
Copy link
Author

chros73 commented Dec 1, 2019

I generated and uploaded an Iridas 17x17x17 3dlut for HDR10 successfully :)

aiopylgtvcommand 192.168.1.78 start_calibration hdr_technicolorExpert
aiopylgtvcommand 192.168.1.78 upload_3d_lut_bt2020 hdr_technicolorExpert
aiopylgtvcommand 192.168.1.78 upload_3d_lut_bt2020_from_file hdr_technicolorExpert "b8bt2020g22p17t1.cube"
aiopylgtvcommand 192.168.1.78 end_calibration hdr_technicolorExpert

Used DisplayCal settings:
capture_001_01122019_203628
capture_002_01122019_203639
capture_003_01122019_203644
capture_006_01122019_205550
capture_003_02122019_191500

@bendavid
Copy link
Owner

bendavid commented Dec 1, 2019

The third command should be rather

aiopylgtvcommand 192.168.1.78 upload_3d_lut_bt2020_from_file hdr_technicolorExpert "b8t1p17.cube"

@chros73
Copy link
Author

chros73 commented Dec 2, 2019

Oh, crap :) It was too late and I fought too much already with python :) Thanks, I'll try it out tonight.
Btw janos666 pointed out that my 3dlut settings in DisplayCal are definitely wrong, I'll update that one as well.

I'll implement a more dynamic lookup of default values

No worries, thanks.
And since we can run the uploading unity commands separately, probably it's a good idea to remove all the 3 of them from the "ddc_reset" method:

So I think just remove them from ddc_reset, and we have to document it.

And thanks for your work and your amazing support as well! :)

@bendavid
Copy link
Owner

bendavid commented Dec 2, 2019

Well if someone want to only partially reset things then they can just skip the ddc_reset and call the individual commands manually. It's just a convenience function, and I think the documentation is reasonably clear about what it does.

@chros73
Copy link
Author

chros73 commented Dec 2, 2019

Thanks, that command worked, I edited the above post :)
So, it seems B8 works fine as well (although I haven't tried every command yet), so I close this issue.

@chros73 chros73 closed this as completed Dec 2, 2019
@chros73
Copy link
Author

chros73 commented Dec 5, 2019

The new set_bt2020_3by3_gamut_data should not be be "BT709_3BY3_GAMUT_DATA", right?
Or is it just for DV and not for HDR10?

@bendavid
Copy link
Owner

bendavid commented Dec 5, 2019

No indeed that's a copy-paste error on my part.

@chros73
Copy link
Author

chros73 commented Dec 5, 2019

The updated install from source documantion doesn't work (the old one does) in readme at least on Windows (with v3.8):

d:\Progs\aiopylgtv>python setup.py sdist bdist_wheel
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'bdist_wheel'

And hence this one doesn't work either (the old one does):

pip install --upgrade dist/aiopylgtv-0.2.1-py3-none-any.whl

@bendavid
Copy link
Owner

bendavid commented Dec 5, 2019

you need to have "wheel" installed

pip install wheel

@chros73
Copy link
Author

chros73 commented Dec 5, 2019

Yes, thanks, that's solved the problem.
XYZLUT matrix WBRGB patch set: c8_hdr_test4_p5.zip
XYZLUT p68 patch set for unity 1dlut + user 3dlut: c8_hdr_test2_p68.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants