Automatic Refreshrate Changer (2 Viewers)

hockstatter

Portal Member
September 1, 2009
14
0
Home Country
United States of America United States of America
is it possible to change the refresh rate manually if the dynamic changer picks the wrong one? would one need a third party plug-in to do that? if so, would it impose on the dynamic refresh rate changer?

again. i'm a big fan of this plug-in, but most of my dvd files are picking the wrong refresh rate. thanks everyone.
 

davidf

Retired Team Member
  • Premium Supporter
  • April 3, 2006
    796
    348
    Scotland
    Home Country
    Scotland Scotland
    I noticed that there is an open Mantis item opened against picking a rate which is not valid. I had a slight issue where my 1:1 Pixel mapping was only available at 60Hz and as I live in a PAL region I had startred to modify the code to allow the resolution to change to get the desired refresh rate (I think refresh rate is more important than perfect pixel mapping) and the code I have started may solve the issue for Sythe42. This is the code I added to Monitor.cs:

    Code:
            //assume total pixels count will be a good match
            static int MatchAlgorithm(uint Xpels, uint yPels)
            {
                return (int)Xpels * (int)yPels;
            }
    
            static DEVMODE_Display GetClosestRefreshRate(Monitor.Win32.DISPLAY_DEVICE displayDevice, uint xPrefered, uint yPrefered, uint refreshRate)
            {
                List<Monitor.Win32.DEVMODE_Display> validModes = new List<DEVMODE_Display>();
                Monitor.Win32.DEVMODE_Display ret = null;
                uint bpp=32;
                Monitor.Win32.DEVMODE_Display display = new DEVMODE_Display();
                if (0!=Monitor.Win32.EnumDisplaySettingsEx(displayDevice.DeviceName,
                                        Monitor.Win32.EnumDisplaySettings_EnumMode.ENUM_CURRENT_SETTINGS,
                                        display,
                                        0))
                {
                    bpp = display.dmBitsPerPel;
                }
                int currMode = 0;
                while (0!=Monitor.Win32.EnumDisplaySettingsEx(displayDevice.DeviceName,
                                        (Monitor.Win32.EnumDisplaySettings_EnumMode) currMode++,
                                        display,
                                        0))
                {
                    if (refreshRate==display.dmDisplayFrequency)
                    {
                        validModes.Add(display);
                        display = new DEVMODE_Display();
                    }
                }
                //exactMatch?
                foreach (Monitor.Win32.DEVMODE_Display mode in validModes)
                {
                    if (mode.dmPelsWidth == xPrefered && mode.dmPelsHeight == yPrefered && mode.dmBitsPerPel == bpp)
                    {
                        ret = mode;
                        break;
                    }
                }
                if (ret == null)
                {
                    int currScore,bestResult = int.MaxValue;
                    foreach (Monitor.Win32.DEVMODE_Display mode in validModes)
                    {
                        currScore = MatchAlgorithm(mode.dmPelsHeight,mode.dmPelsWidth);
                        if (Math.Abs(MatchAlgorithm(xPrefered,yPrefered) - currScore) < bestResult && mode.dmBitsPerPel == bpp)
                        {
                            bestResult =  (int)Math.Abs(MatchAlgorithm(xPrefered , yPrefered) - currScore);
                            ret = mode;
                        }
                    }
                }
                return ret;
            }
    
            public static void CycleRefreshRate(uint monitorIndex, uint refreshRate, uint xPrefered, uint yPrefered)
            {
    
                Monitor.Win32.DISPLAY_DEVICE displayDevice = new Monitor.Win32.DISPLAY_DEVICE();
                int result = Monitor.Win32.EnumDisplayDevices(null, monitorIndex, displayDevice, 0);
    
                if (result != 0)
                {
                    Monitor.Win32.DEVMODE_Display devMode = new Monitor.Win32.DEVMODE_Display();
    
                    devMode = GetClosestRefreshRate(displayDevice, xPrefered, yPrefered, refreshRate);
                    if (devMode == null) return; // no valid mode at all.
                    devMode.dmDisplayFrequency = refreshRate;
                    Monitor.Win32.ChangeDisplaySettings_Result r = Monitor.Win32.ChangeDisplaySettingsEx(displayDevice.DeviceName, devMode,
                                                                     IntPtr.Zero, Monitor.Win32.ChangeDisplaySettings_Flags.None, IntPtr.Zero);
                }
            }
    
    Removing 
                if (ret == null)
                {
                    int currScore,bestResult = int.MaxValue;
                    foreach (Monitor.Win32.DEVMODE_Display mode in validModes)
                    {
                        currScore = MatchAlgorithm(mode.dmPelsHeight,mode.dmPelsWidth);
                        if (Math.Abs(MatchAlgorithm(xPrefered,yPrefered) - currScore) < bestResult && mode.dmBitsPerPel == bpp)
                        {
                            bestResult =  (int)Math.Abs(MatchAlgorithm(xPrefered , yPrefered) - currScore);
                            ret = mode;
                        }
                    }
                }
    from GetClosestRefreshRate

    and passing the current resolution to CycleRefreshRate would solve the problem. A bool return would probably be useful too.

    I haven't include the Desktop Window Manager code as I haven't got around to that yet.
     

    slarti

    MP Donator
  • Premium Supporter
  • March 26, 2009
    73
    5
    Home Country
    Finland Finland
    Hello

    I'm not sure where to post this, but here goes... I have a huge problem with the refreshrate changer, and I'm running out of ideas what to try next.

    I'm running win7, latest MP svn, core i3 and ATI 5450HD connected via HDMI to my AVR. This is a client in multiseat.

    The refreshrate either changes but I get a lot of stuttering and sometimes wrong resolution (see screenshot) or it doesn't change and MP sometimes crashes. Included logs are from trying to change to 50hz from 23,976hz. Result was wrong size MP window with wrong refreshrate and a crash. Not an ideal situation...:(

    If anyone has a working similar setup, please tell me.

    Thanks,

    Slarti
     

    Attachments

    • desktop.jpg
      desktop.jpg
      110.2 KB

    slarti

    MP Donator
  • Premium Supporter
  • March 26, 2009
    73
    5
    Home Country
    Finland Finland
    Re: AW: Automatic Refreshrate Changer

    Did you try the latest drivers from ATI for the HD 5450? They were released just two days ago.

    http://support.amd.com/us/kbarticles/Pages/ATI-Catalyst-driver-Radeon-HD5400.aspx

    Yes, I actually got that card just two days ago, so I have had them all along. I'm trying catalyst 10.2 rc2 now, but the issue remains. I really don't understand why the mp window size is what it is (another screenshot included). On my other ION based client things work perfectly.
     

    Attachments

    • desktop.jpg
      desktop.jpg
      112.2 KB

    Zinu

    Portal Pro
    February 28, 2008
    650
    23
    Home Country
    Netherlands Netherlands
    I can't manage to find out what refreshrates I should enter for my TV. It's a Samsung LE32R81B. This is the page from the manual regarding display modes, but I can't get much sense from it.

    Maybe someone can tell me by looking at this what settings I should enter?
     

    Attachments

    • display modes le32r81b.jpg
      display modes le32r81b.jpg
      124.7 KB

    slarti

    MP Donator
  • Premium Supporter
  • March 26, 2009
    73
    5
    Home Country
    Finland Finland
    Re: AW: Automatic Refreshrate Changer

    Did you try the latest drivers from ATI for the HD 5450? They were released just two days ago.

    http://support.amd.com/us/kbarticles/Pages/ATI-Catalyst-driver-Radeon-HD5400.aspx

    Yes, I actually got that card just two days ago, so I have had them all along. I'm trying catalyst 10.2 rc2 now, but the issue remains. I really don't understand why the mp window size is what it is (another screenshot included). On my other ION based client things work perfectly.

    Ok, I installed my old mobo back (see My system) and things are working fine. Nvidia seems to be THE display adapter for MP. Could this problem with ATI have something to do with UVD 2.2 which is able to decode two streams simultaneously? Because I had the same problem with the i3 integrated graphics which is also able to do that.
     

    thanatos

    Portal Member
    April 12, 2007
    23
    0
    Munich
    Home Country
    Germany Germany
    AW: Automatic Refreshrate Changer

    Guys, I'm not sure if this problem is in the right place here - anyway:

    Yesterday I did a fresh install of MP 1.1.0 RC1 along with SAF 4.00 RC1.
    Now I'm experiencing a problem while using MP's automatic refresh rate changer.

    Whenever I start playback a file which causes the refresh rate to change, I can not see the MP Gui anymore. Only way to get outta there is to close MP using taskmanager.
    The refresh rate change itself just works perfect but MP Gui is not visible anymore.
    When I start playback of file which does not cause a refresh rate change - no problem at all!

    I think I'm experiencing an issue that is described on the very first page of this thread under known issues.
    I've already tried the mentioned work arounds - "use device reset" (tried off and on - same effect). I've also created .bat files to change refresh rate and used wait.exe (tried "waiting" for 3 ms to 5000 ms with several steps inbetween) and of course edited the "action" field within MP setup.

    The effect is always the same - whenever a file is played which causes refresh rate to change, I can not see MP Gui anymore.

    Maybe someone out there has the same issue?
    Maybe someone out there already has an fix for this?

    /Thanatos
     

    blackEyEz

    Portal Pro
    July 8, 2009
    170
    44
    Netherlands
    Home Country
    Netherlands Netherlands
    Hi all, i am currently running MP 1.1 beta (latest svn) is there a known problem with the dynamic refresh rate and seeking in w7-x64? When i fast forward a few minutes the frame freezes and the audio continues.
     

    Jay_UK

    Test Group
  • Team MediaPortal
  • October 6, 2009
    1,781
    283
    Derby
    Home Country
    United Kingdom United Kingdom
    Hi all,

    Not sure if this thread is the most appropriate place for this issue, but I'm experiencing issues with AVIs (in xvid format).

    Previously the changer went from 50Hz (default) to 24Hz when playing these files - worked great :D

    I have now upgraded to MePo RC1, SAF RC1 (with applied AVI registry patch) and ATI 10.2 - All settings for MePo seem correct

    The problem is that xvids are not changing refresh rate to 24Hz anymore (TV is not reporting frequency change)

    Other films (Divx, H264, MKV) all work fine. Its just xvids.

    I'll have a play later and attach logs and graphs, but I was wondering if anyone else had this problem?

    Thanks,

    J. (posting from work)
     

    Users who are viewing this thread

    Top Bottom