Changing Chroma Subsampling settings in Windows with a script (YCbCr 4:4:4 to RGB and vice versa)(Python) -


a bit of context: writing program automate tests on monitors. so, change display settings (resolution, refresh rate, etc.) on fly without having go through nvidia control panel hand every time.

i found nircmd utility allows change of these settings through command line, first thought use that. unfortunately, can't modify more advanced parameters such chroma subsampling ("output color format" in nvidia control panel), output dynamic range or output color depth.

i thought use program directly modify registry values , update settings call changedisplaysettings(). using procmon on windows, identified keys modified changing display settings, , changed them directly python before calling changedisplaysettings() read keys , display new settings. felt bit using cannon kill ant, worked part: able change resolution, refresh rate, desktop color depth , displayed window size using method.

here's relevant part of code i'm using (note code need modified run on specific computer, "laptop_id" , "desktop_id" registry entries unique):

from tkinter import * import tkfont import time import ctypes import serial import _winreg import win32gui import win32con import win32api import wmi  def get_reg(name, reg_path):     registry_key = _winreg.openkey(_winreg.hkey_local_machine, reg_path, 0, _winreg.key_read)     value, regtype = _winreg.queryvalueex(registry_key, name)     _winreg.closekey(registry_key)     return value  def set_reg(name, value, reg_path):     registry_key = _winreg.openkey(_winreg.hkey_local_machine, reg_path, 0, _winreg.key_write)     _winreg.setvalueex(registry_key, name, 0, _winreg.reg_dword, value)     _winreg.closekey(registry_key)  def set_reg_bin(name, value, reg_path):     registry_key = _winreg.openkey(_winreg.hkey_local_machine, reg_path, 0, _winreg.key_write)     _winreg.setvalueex(registry_key, name, 0, _winreg.reg_binary, value)     _winreg.closekey(registry_key)  def reg_enum(reg_path):     registry_key = _winreg.openkey(_winreg.hkey_local_machine, reg_path, 0, _winreg.key_read)     lastkey=_winreg.enumkey(registry_key, _winreg.queryinfokey(registry_key)[0]-1)     firstkey=_winreg.enumkey(registry_key, 0)     print lastkey     print firstkey     return lastkey  def deletesubkey(key0, key1, key2=""):     if key2=="":         currentkey = key1     else:         currentkey = key1+ "\\" +key2     open_key = _winreg.openkey(key0, currentkey ,0,_winreg.key_all_access)     infokey = _winreg.queryinfokey(open_key)     x in range(0, infokey[0]):         subkey = _winreg.enumkey(open_key, 0)         try:             _winreg.deletekey(open_key, subkey)             print "removed %s\\%s " % ( currentkey, subkey)         except:             deletesubkey( key0, currentkey, subkey )     _winreg.deletekey(open_key,"")     open_key.close()     print "removed %s" % (currentkey)     return  if __name__ =="__main__":     desktop_id = "{########-####-####-####-############}"     laptop_id = "{########-####-####-####-############}"     reg_path_scrid = r"system\currentcontrolset\control\graphicsdrivers\configuration"     deletesubkey(_winreg.hkey_local_machine, reg_path_scrid)     try:         input = raw_input('in windows display settings, under "multiple displays", choose "show on 2", press enter continue.')     except nameerror:         pass     win32api.changedisplaysettings(none, 0)     colorrgb = chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x0a)+chr(0x01)+chr(0x08)+chr(0x00)     color422 = chr(0x01)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x0a)+chr(0x01)+chr(0x08)+chr(0x00)     color444 = chr(0x02)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x0a)+chr(0x01)+chr(0x08)+chr(0x00)     color420 = chr(0x03)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x0a)+chr(0x01)+chr(0x08)+chr(0x00)     colorrgb_driverextra = chr(0x60)+chr(0xea)+chr(0x00)+chr(0x00)+chr(0xe8)+chr(0x03)+chr(0x00)+chr(0x00)+chr(0x15)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x04)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x06)+chr(0x00)+chr(0x00)+chr(0x00)     color444_driverextra = chr(0x60)+chr(0xea)+chr(0x00)+chr(0x00)+chr(0xe8)+chr(0x03)+chr(0x00)+chr(0x00)+chr(0x15)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x04)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x06)+chr(0x00)+chr(0x00)+chr(0x00)     color422_driverextra = chr(0x60)+chr(0xea)+chr(0x00)+chr(0x00)+chr(0xe8)+chr(0x03)+chr(0x00)+chr(0x00)+chr(0x15)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x04)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x06)+chr(0x00)+chr(0x00)+chr(0x00)     color422_driverextra = chr(0x60)+chr(0xea)+chr(0x00)+chr(0x00)+chr(0xe8)+chr(0x03)+chr(0x00)+chr(0x00)+chr(0x15)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x04)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x00)+chr(0x06)+chr(0x00)+chr(0x00)+chr(0x00)     screen_id = reg_enum(reg_path_scrid)     print screen_id     screen_id_short = screen_id.partition("^")[0]     print screen_id_short     reg_path = r"system\currentcontrolset\hardware profiles\unitedvideo\control\video"+"\\"+laptop_id+r"\0000"     reg_path2 = r"system\currentcontrolset\hardware profiles\unitedvideo\control\video"+"\\"+laptop_id+r"\0001"     reg_path3 = r"system\currentcontrolset\control\graphicsdrivers\configuration"+"\\"+screen_id+r"\00\00"     reg_path4 = r"system\currentcontrolset\control\graphicsdrivers\configuration"+"\\"+screen_id+r"\00"     reg_path5 = r"system\currentcontrolset\control\graphicsdrivers\configuration"+"\\"+screen_id     reg_path_color = r"system\currentcontrolset\services\nvlddmkm\displaydatabase"+"\\"+screen_id_short      set_reg('defaultsettings.xresolution', 3840, reg_path)     set_reg('defaultsettings.yresolution', 2160, reg_path)     set_reg_bin('defaultsettings.driverextra', colorrgb_driverextra, reg_path)     set_reg('defaultsettings.vrefresh', 60, reg_path)     set_reg_bin('colorformatconfig', colorrgb, reg_path_color)     set_reg('attach.todesktop', 1, reg_path)     set_reg('vsyncfreq.numerator', 60000, reg_path3)     set_reg('vsyncfreq.denominator', 1000, reg_path3)     set_reg('primsurfsize.cx', 3840, reg_path3)     set_reg('primsurfsize.cy', 2160, reg_path3)     set_reg('dwmclipbox.left', 0, reg_path3)     set_reg('dwmclipbox.top', 0, reg_path3)     set_reg('dwmclipbox.right', 3840, reg_path3)     set_reg('dwmclipbox.bottom', 2160, reg_path3)     set_reg('primsurfsize.cx', 3840, reg_path4)     set_reg('primsurfsize.cy', 2160, reg_path4)     win32api.changedisplaysettings(none, 0) 

however, didn't further still unable find , change keys control more advanced display settings. seems not stored nvidia in registry, i'm stuck. can see, did find key called "colorformatconfig" being modified when output color format changed in nvidia control panel, not seem used directly.

i gave nvidia sdk try, found bit beyond capabilities programmer...

any ideas welcome! (including way rid of unsightly successive chr() casts)


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -