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 > Hardware & Software > Software players

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th January 2020, 16:11   #21  |  Link
ashlar42
Registered User
 
Join Date: Jun 2007
Posts: 652
pistacho/jogal, why are you against having an external add-on for the HDR Toggle portion? I think it would make sense and it could speed up adoption of your code in the main branch.
ashlar42 is offline   Reply With Quote
Old 28th January 2020, 18:30   #22  |  Link
pistacho
Registered User
 
Join Date: Feb 2010
Location: Spain
Posts: 549
Short answer:

Because it is not necessary, (technically speaking there is no logical reason for it).

Moreover, without going into technical issues the demonstration is that it is already working without any add-on.

Is necessary Kodi add-on for switch display refresh rate?
Is necessary Kodi add-on for switch full-screen?
Is necessary Kodi add-on for switch 3D mode?
Is necessary Kodi add-on for DTS-MA passthrough?
Is necessary Kodi add-on for support 4K resolution?


However, I do not say that it cannot be done. Anyone is free to do it. Probably and taking into account that the add-ons are based on Python, when they start doing it they will see that it was not necessary / optimal.

If someone wants to do it and does it, I promise to adapt my code to work with the supposed (future) add-on. Already exist this add-on?

Or I am obligated for some reason to do something I don't want/need to do?


If there is real interest in this, the solution is easy:

- Someone from TK makes an official addon "HDR toggle for KODI"
- I adapt my code to the addon
- Merge
- END

The question is the same again: Is it necessary? Why? Who makes addon?
pistacho is offline   Reply With Quote
Old 29th January 2020, 17:37   #23  |  Link
Fandangos
Registered User
 
Join Date: Aug 2019
Posts: 27
Quote:
Originally Posted by pistacho View Post
Short answer:

Because it is not necessary, (technically speaking there is no logical reason for it).
It's because the API that is called is not documented, it emerged from someone knows where.

According to the txt from the first release of that code, people found out about those APIs analyzing windows registry changes after triggering HDR on and OFF. That's quite a hack in my honest opinion.

That's just my guess how people did it based on that txt.

Kodi was part of a program that brought it to the Microsoft Windows Store.
It's also part of the Xbox game console store.
Both under the supervision of Microsoft.
Some of TK devs were part of the microsoft internal programs.

Since the API is not well documented and it's not publicly advertised to be used, I completly understand their stance to back away from it.

Putting it into an addon just protects Kodi.

Whilte on the other hand I completly understand your frustration and I honestly wish to put this HDR situation in the past.
Just having an automatic solution that works for everybody without restrictions.

This way we (or me) could ,ove along to something else like adding FSRCNNX upscaler to Kodi.

Just my opinion on this.

And I'm trying to fix Ryzen with private APIs here, which that code to turn HDR on and off solves the problem.
Since you are also working with that code, I would like to ask if you know why it defaults back to 60hz breaking 23hz.

It does for me no matter the moment it is triggered (except before playbackstarting).

If you have found a solution I really would like to know because this could be greatly used on my fork to help people with Ryzen igpus and RX 5700 gpus both plagued by this bug where bt.2020 flag using amd ags doesn't show up.

Last edited by Fandangos; 29th January 2020 at 17:43.
Fandangos is offline   Reply With Quote
Old 29th January 2020, 18:13   #24  |  Link
DMU
Registered User
 
Join Date: Dec 2018
Posts: 207
Quote:
Originally Posted by Fandangos View Post
According to the txt from the first release of that code, people found out about those APIs analyzing windows registry changes after triggering HDR on and OFF. That's quite a hack in my honest opinion.
Why do you always call it "registry hack"? There is nothing registry related in this code. This code was obtained using IDA Pro Disassembler.
The DisplayConfigSetDeviceInfo function is documented in the MS Windows Dev Center. But its parameter DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE is not.
__________________
R3 3200G / Vega8 / Samsung UE40NU7100
Win11Pro 21H2 / 4K RGB 59Hz / AMD last driver
MPC-HC 1.9.17 / madVR 0.92.17 / FSW / SM / 8bit
DMU is offline   Reply With Quote
Old 29th January 2020, 18:24   #25  |  Link
Fandangos
Registered User
 
Join Date: Aug 2019
Posts: 27
Quote:
Originally Posted by DMU View Post
Why do you always call it "registry hack"? There is nothing registry related in this code. This code was obtained using IDA Pro Disassembler.
The DisplayConfigSetDeviceInfo function is documented in the MS Windows Dev Center. But its parameter DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE is not.
As I've said, I have no idea how this code was obtained.
Now it's a little more clear.

It is still a hack.

Still, using IDA Pro to perform reverse engineering to figure out a function call is a big red flag to not use it in something that will be scrutinized by the owner of the store you will put your code into.

Again, as far as I know, this can be a coincidence, PowerDVD worked with Intel during the early days of 4K UHD BD playback, before DEUHD even exist.
Intel had access to a windows API to toggle HDR on and off, that's why PowerDVD was and still is, able to toggle Windows HDR on and off.

That API is under a lot of contracts obligations according to a source from inside Intel.

If this API is the same for both, I have no idea. But if Microsoft made a special use case to be used only with it's partners like Intel and a open source software starts using because reverse engineered it using IDA Pro it doesn't seem ok.

Again, this is speculation by my part if those two apis are the same.
Fandangos is offline   Reply With Quote
Old 29th January 2020, 18:42   #26  |  Link
pistacho
Registered User
 
Join Date: Feb 2010
Location: Spain
Posts: 549
Quote:
Originally Posted by Fandangos View Post
It's because the API that is called is not documented, it emerged from someone knows where.

According to the txt from the first release of that code, people found out about those APIs analyzing windows registry changes after triggering HDR on and OFF. That's quite a hack in my honest opinion.

That's just my guess how people did it based on that txt.

Kodi was part of a program that brought it to the Microsoft Windows Store.
It's also part of the Xbox game console store.
Both under the supervision of Microsoft.
Some of TK devs were part of the microsoft internal programs.

Since the API is not well documented and it's not publicly advertised to be used, I completly understand their stance to back away from it.

Putting it into an addon just protects Kodi.

Whilte on the other hand I completly understand your frustration and I honestly wish to put this HDR situation in the past.
Just having an automatic solution that works for everybody without restrictions.

This way we (or me) could ,ove along to something else like adding FSRCNNX upscaler to Kodi.

Just my opinion on this.

And I'm trying to fix Ryzen with private APIs here, which that code to turn HDR on and off solves the problem.
Since you are also working with that code, I would like to ask if you know why it defaults back to 60hz breaking 23hz.

It does for me no matter the moment it is triggered (except before playbackstarting).

If you have found a solution I really would like to know because this could be greatly used on my fork to help people with Ryzen igpus and RX 5700 gpus both plagued by this bug where bt.2020 flag using amd ags doesn't show up.

This is totally false.
  1. Code in my fork currently is not the same as original code you mention
  2. Even original code is not a hack. Is only bad documented, buggy code and poor styling code.

For some reason some people have formed a misconception of all this and now it is very difficult (perhaps impossible) to understand things correctly.


Step one download and install Windows SDK 10.0.17763 and look at "wingdi.h"


NOTE: // comments are NOT written by me. Written by Microsoft. (download and check yourself)

Code:
typedef struct _DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO
{
    DISPLAYCONFIG_DEVICE_INFO_HEADER header;
    union
    {
        struct
        {
          UINT32 advancedColorSupported        :1;    // A type of advanced color is supported
          UINT32 advancedColorEnabled          :1;    // A type of advanced color is enabled
          UINT32 wideColorEnforced             :1;    // Wide color gamut is enabled
          UINT32 advancedColorForceDisabled    :1;    // Advanced color is force disabled due to system/OS policy
          UINT32 reserved                      :28;
        } DUMMYSTRUCTNAME;

        UINT32 value;
    } DUMMYUNIONNAME;

    DISPLAYCONFIG_COLOR_ENCODING colorEncoding;
    UINT32 bitsPerColorChannel;
} DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO;

typedef struct _DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE
{
    DISPLAYCONFIG_DEVICE_INFO_HEADER header;
    union
    {
        struct
        {
          UINT32 enableAdvancedColor  :1;
          UINT32 reserved  :31;
        } DUMMYSTRUCTNAME;

        UINT32 value;
    }DUMMYUNIONNAME;
} DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE;

typedef enum
{
      DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME                 = 1,
      DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME                 = 2,
      DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE       = 3,
      DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME                = 4,
      DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE          = 5,
      DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE            = 6,
      DISPLAYCONFIG_DEVICE_INFO_GET_SUPPORT_VIRTUAL_RESOLUTION  = 7,
      DISPLAYCONFIG_DEVICE_INFO_SET_SUPPORT_VIRTUAL_RESOLUTION  = 8,
      DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO         = 9,
      DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE        = 10,
      DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL             = 11,
      DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32                = 0xFFFFFFFF
} DISPLAYCONFIG_DEVICE_INFO_TYPE;

Why use a code available in the official Microsoft SDK is now a hack?

Last edited by pistacho; 29th January 2020 at 18:59.
pistacho is offline   Reply With Quote
Old 29th January 2020, 18:52   #27  |  Link
Fandangos
Registered User
 
Join Date: Aug 2019
Posts: 27
Quote:
Originally Posted by pistacho View Post

Why use a code available in the official Microsoft SDK is now a hack?
Ok, fair enough, now why people needed IDA Pro to come up with it?
Fandangos is offline   Reply With Quote
Old 29th January 2020, 18:53   #28  |  Link
pistacho
Registered User
 
Join Date: Feb 2010
Location: Spain
Posts: 549
This is actual toggle code:


Code:
	uint32_t pathCount = 0;
	uint32_t modeCount = 0;
	bool success = false;

	if (ERROR_SUCCESS == GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &pathCount, &modeCount))
	{
		std::vector<DISPLAYCONFIG_PATH_INFO> paths(pathCount);
		std::vector<DISPLAYCONFIG_MODE_INFO> modes(modeCount);

		if (ERROR_SUCCESS == QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathCount, paths.data(),
			&modeCount, modes.data(), nullptr))
		{
			DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO getColorInfo = {};
			getColorInfo.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO;
			getColorInfo.header.size = sizeof(getColorInfo);

			DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE setColorState = {};
			setColorState.header.type = DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE;
			setColorState.header.size = sizeof(setColorState);

			for (const auto& mode : modes)
			{
				if (mode.infoType == DISPLAYCONFIG_MODE_INFO_TYPE_TARGET)
				{
					getColorInfo.header.adapterId.HighPart = mode.adapterId.HighPart;
					getColorInfo.header.adapterId.LowPart = mode.adapterId.LowPart;
					getColorInfo.header.id = mode.id;

					setColorState.header.adapterId.HighPart = mode.adapterId.HighPart;
					setColorState.header.adapterId.LowPart = mode.adapterId.LowPart;
					setColorState.header.id = mode.id;

					if (ERROR_SUCCESS == DisplayConfigGetDeviceInfo(&getColorInfo.header))
					{
						// HDR is OFF
						if (getColorInfo.advancedColorSupported && !getColorInfo.advancedColorEnabled)
						{
							setColorState.enableAdvancedColor = TRUE;
							CLog::LogF(LOGNOTICE, "Toggle Windows HDR On (OFF => ON).");
							success = (ERROR_SUCCESS == DisplayConfigSetDeviceInfo(&setColorState.header));
							break;
						}
						// HDR is ON
						else if (getColorInfo.advancedColorSupported && getColorInfo.advancedColorEnabled)
						{
							setColorState.enableAdvancedColor = FALSE;
							CLog::LogF(LOGNOTICE, "Toggle Windows HDR Off (ON => OFF).");
							success = (ERROR_SUCCESS == DisplayConfigSetDeviceInfo(&setColorState.header));
							break;
						}
					}
				}
			}
		}
	}

	return success;

Why is a hack?

Where are undocumented bytes?

Why can't this code be in Kodi core?

Why is an add-on necessary?

Last edited by pistacho; 29th January 2020 at 19:38.
pistacho is offline   Reply With Quote
Old 29th January 2020, 18:58   #29  |  Link
pistacho
Registered User
 
Join Date: Feb 2010
Location: Spain
Posts: 549
Why can people (in general) become so stupid?
pistacho is offline   Reply With Quote
Old 29th January 2020, 19:01   #30  |  Link
oldpainlesskodi
Registered User
 
Join Date: Apr 2017
Posts: 366
Can we all have a group hug now?

Just asking for a friend...
__________________
LG OLED55BX6LB, Zidoo Z1000 Pro, Yamaha RX-A3060, Polk Signature Fronts & Centre, Wharfedale D300 Atmos surrounds, Polk Signature HTS 10 Sub, DSPeaker Antimode 8033 Cinema
oldpainlesskodi is offline   Reply With Quote
Old 29th January 2020, 19:01   #31  |  Link
Fandangos
Registered User
 
Join Date: Aug 2019
Posts: 27
Quote:
Originally Posted by pistacho View Post
Why can people (in general) become so stupid?
I don't know talk about yourself.

If this is so explict why you needed _DMU_ code?

Why you needed somebody else to point out to you on your github by a PR? Isn't that available on Microsoft documentation?

And you are saying that people that needed to use IDA Pro to figure out a API did it because they don't know how to read documentation?
Fandangos is offline   Reply With Quote
Old 29th January 2020, 19:05   #32  |  Link
Fandangos
Registered User
 
Join Date: Aug 2019
Posts: 27
Quote:
Originally Posted by oldpainlesskodi View Post
Can we all have a group hug now?

Just asking for a friend...
He doesn't enjoy anything group related but I am in
Fandangos is offline   Reply With Quote
Old 29th January 2020, 19:09   #33  |  Link
oldpainlesskodi
Registered User
 
Join Date: Apr 2017
Posts: 366
Laugh out loud moment right there.
__________________
LG OLED55BX6LB, Zidoo Z1000 Pro, Yamaha RX-A3060, Polk Signature Fronts & Centre, Wharfedale D300 Atmos surrounds, Polk Signature HTS 10 Sub, DSPeaker Antimode 8033 Cinema
oldpainlesskodi is offline   Reply With Quote
Old 29th January 2020, 19:29   #34  |  Link
DMU
Registered User
 
Join Date: Dec 2018
Posts: 207
Quote:
Originally Posted by Fandangos View Post
And you are saying that people that needed to use IDA Pro to figure out a API did it because they don't know how to read documentation?
Yes it is. My friend does not know C++, so it was easier for him to use a disassembler to solve the problem that I asked him about.
__________________
R3 3200G / Vega8 / Samsung UE40NU7100
Win11Pro 21H2 / 4K RGB 59Hz / AMD last driver
MPC-HC 1.9.17 / madVR 0.92.17 / FSW / SM / 8bit
DMU is offline   Reply With Quote
Old 29th January 2020, 19:39   #35  |  Link
Fandangos
Registered User
 
Join Date: Aug 2019
Posts: 27
Quote:
Originally Posted by DMU View Post
Yes it is. My friend does not know C++, so it was easier for him to use a disassembler to solve the problem that I asked him about.
I don't want to add salt to the injury but... your friend that doesn't know c++, used ida pro to figure out a c++ code that, while not knowing c++ wrote a very complex c++ code that you sent us?

Am I getting this right?
Fandangos is offline   Reply With Quote
Old 29th January 2020, 19:53   #36  |  Link
DMU
Registered User
 
Join Date: Dec 2018
Posts: 207
Exactly. And I would not call this code "very complex" (his words).
It is easier for him to use a disassembler than to understand/study in the documentation.
__________________
R3 3200G / Vega8 / Samsung UE40NU7100
Win11Pro 21H2 / 4K RGB 59Hz / AMD last driver
MPC-HC 1.9.17 / madVR 0.92.17 / FSW / SM / 8bit

Last edited by DMU; 29th January 2020 at 19:58.
DMU is offline   Reply With Quote
Old 29th January 2020, 20:15   #37  |  Link
Fandangos
Registered User
 
Join Date: Aug 2019
Posts: 27
I know you only want to best for everybody else just like me that wants the best user experience but...

Yeah, I don't buy it sorry, I can explain my reasons not to, not that it matters in the end but here it goes.

1. To be able to write that code you have to know c++ enough to at least be able to read documentation, using a disassembler claiming it's the easiest route I don't get it. This would only be needed if the documentation is lacking.
2. Microsoft has an entire sample code in GitHub with everything related to HDR on Windows, it doesn't have any kind of reference to that API. It has everything, setting the swapchain, the output format, except this.

3. Not a single soul, until you posted that, used that API on github. No one, so no one knows how to read documentation? We have tons of people with Nvidia and AMD API, including big companies like Unreal Engine with sample codes, that use Nvidia, AMD and when it comes to Intel the sample ends with, not implemented. Those people could use this API and choose not to.

4. Netflix APP that is part of Microsoft store doesn't use it. You need to enable HDR manually for 4K HDR.

5. Games on Microsoft store like the new Blair Witch as one example on the top of my head, doesn't turn HDR automatically by using this API.

So everybody else that develops for Windows and creates HDR applications be video players or games, doesn't use it but we do, only because of the code you supplied, or else we could not have done it.

So yeah... sorry man, I don't buy it.
Fandangos is offline   Reply With Quote
Old 29th January 2020, 20:31   #38  |  Link
pistacho
Registered User
 
Join Date: Feb 2010
Location: Spain
Posts: 549
Microsoft aims to promote Universal apps:

(Netflix is Windows Store App)

And yes it is also well documented:
https://docs.microsoft.com/en-us/uwp...s.display.core

And yes toggle code can also be ported to UWP

And yes it is also documented:
https://docs.microsoft.com/en-us/uwp...s.display.core
pistacho is offline   Reply With Quote
Old 29th January 2020, 20:36   #39  |  Link
oldpainlesskodi
Registered User
 
Join Date: Apr 2017
Posts: 366
So, no group hug tonite?
__________________
LG OLED55BX6LB, Zidoo Z1000 Pro, Yamaha RX-A3060, Polk Signature Fronts & Centre, Wharfedale D300 Atmos surrounds, Polk Signature HTS 10 Sub, DSPeaker Antimode 8033 Cinema
oldpainlesskodi is offline   Reply With Quote
Old 29th January 2020, 20:58   #40  |  Link
Fandangos
Registered User
 
Join Date: Aug 2019
Posts: 27
Quote:
Originally Posted by pistacho View Post
Microsoft aims to promote Universal apps:

(Netflix is Windows Store App)

And yes it is also well documented:
https://docs.microsoft.com/en-us/uwp...s.display.core

And yes toggle code can also be ported to UWP

And yes it is also documented:
https://docs.microsoft.com/en-us/uwp...s.display.core
This doesn't explain anything.
To be "universal" the user must toggle a switch before opening the app?
And this is only true for windows?

This universatility ends with the xbox one?

Read your own comment above, you said that it's ridiculous an addon to toggle hdr on and off because everything else you used as an example, be resolution, be audio format, everything is automatic on Kodi.
With the netflix app it can put your receiver into dolby format. Games can change your refresh and resolution the only thing that can't be done is hdr that requires a toggle.



I
Fandangos is offline   Reply With Quote
Reply

Tags
hdr passthrough, hdr player, hdr10, hlg, kodi

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 15:39.


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