Stutter after refresh rate change (1 Viewer)

nyt

Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    I just found the ! display.

    Playing 25p video @ 50hz after playing 24p video first, results in just about every other frame being dropped, and actual fps hovering around 24.5.

    PATCH IN PLACE:

    Smooth playback:
    drawn 579, dropped 6, glitches 66
    act: 50, frame time 20 [-20, +37.819], sdev 0.5
    paint offset -19.9 [-57.7, 0], sdev 0.5
    raster offset 19.19, scanline 0.0185, est refresh cycle 19.9995
    paint time 19.9ms [0.1ms, 57.7ms]

    choppy playback:
    drawn: 3452, dropped 3591, 819 glitches
    act: ~24.5, frame time 40 [-39, +41], sdev 7
    paint offset 37.6 [-72.9, 0], sdev 5
    raster offset 7.15, scanline time 0.0184ms, est refresh cycle +19.9996
    paint time 41.900 [0.1, 72]


    PATCH REMOVED:
    25p video after 24p plays around 30fps with high number of dropped rames. seek after win-tab cleans it up, video plays at 50fps with no dropped frames.

    Very strange.

    Ok, so there is a problem with this method. I'm toggling dwm composition and its fine going between refresh rates.

    Back to the drawing board. When I get something that works I'll update again.
     

    nyt

    Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    ...
    I found another method that works, I don't like it, there should be something better. I'll see if I can figure something, but for now its opening an empty form with an opacity of 0 and killing it as soon as it opens. This seems to give it the necessary kick and works flawlessly from my testing thus far.

    Patching / DLL incoming shortly.
     

    nyt

    Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    Here's the patch. I haven't seen any cases where this doesn't work or leaves something in a funny refresh rate or dropping frames.

    Please test and let me know. Attached is the patch and the DLL.

    edit: removed due to xp bug, needed try/catch around dwmapi function, new patch/dll posted below.
     

    edterbak

    Portal Pro
    March 4, 2008
    2,114
    1,176
    Home Country
    Netherlands Netherlands
    Here's the patch. I haven't seen any cases where this doesn't work or leaves something in a funny refresh rate or dropping frames.

    Please test and let me know. Attached is the patch and the DLL.

    Hi guys,

    Ive been following this thread with one eye lately. I gave the attached core.dll a try and it results in a black screen when playing a 23.9 fps file. I thought some testing would be appreciated. I attached the logs for you.
     

    nyt

    Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    2010-01-18 06:35:12.937500 [Info.][MPMain]: OnMessage exception:confused:ystem.DllNotFoundException: Unable to load DLL 'dwmapi.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
    at MediaPortal.Player.Win32.DwmIsCompositionEnabled(Int32& pfEnabled)
    at MediaPortal.Player.Win32.CycleRefreshRate(UInt32 monitorIndex, Double refreshRate)
    at MediaPortal.Player.RefreshRateChanger.SetRefreshRateBasedOnFPS(Double fps, String strFile, MediaType type)
    at MediaPortal.Player.RefreshRateChanger.AdaptRefreshRate(String strFile, MediaType type)
    at MediaPortal.Player.g_Player.Play(String strFile, MediaType type)
    at MediaPortal.Player.g_Player.Play(String strFile)
    at MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.playFile(String media, VideoFormat videoFormat)
    at MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.playMovie(DBMovieInfo movie, Int32 requestedPart)
    at MediaPortal.Plugins.MovingPictures.MainUI.MoviePlayer.Play(DBMovieInfo movie, Int32 part)
    at MediaPortal.Plugins.MovingPictures.MainUI.MovingPicturesGUI.playSelectedMovie()
    at MediaPortal.Plugins.MovingPictures.MainUI.MovingPicturesGUI.OnClicked(Int32 controlId, GUIControl control, ActionType actionType)
    at MediaPortal.GUI.Library.GUIWindow.OnMessage(GUIMessage message)

    easy fix, uploading new dll in a minute.
     

    nyt

    Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    Here's a revision that wont break XP machines. You're not using DWM/EVR so I don't think you guys suffer from this problem anyway, and if so I'm not sure that this workaround will even work as I don't have an XP machine to test on.

    If you you ARE in fact having problems with refresh rate changes leading to stutters, I have a DLL attached for you labeled coreXPTEST.dll. This basically creates the new form without testing for DWM or running anything from dwmapi.

    Let me know.
     

    Knives03

    Portal Pro
    March 6, 2009
    103
    2
    Wow, this new core.dll file did the trick. This is one of the most exciting breakthroughs ever :D Thank you all very much for your help, I know this wasn't an easy issue to come up with any sort of a fix for.
     

    nyt

    Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    Wow, this new core.dll file did the trick. This is one of the most exciting breakthroughs ever :D Thank you all very much for your help, I know this wasn't an easy issue to come up with any sort of a fix for.

    It wasn't too bad, I just didn't sleep much this weekend =]

    It's not the cleanest solution, but it works. I hadn't done any windows / directx / c# programming before the other day, so if someone can come up with a more elegant fix, that'd be great, but at least this works for now.

    This just drove me crazy enough to go after it.

    I tried invalidating the window, and tons of other things that just should work but didn't. I'm not sure if this is a directx/dwm bug or if there's some way to tell dx/dwm/windows/whatever that the refresh rate changed and to stop being stupid.
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    I tried invalidating the window, and tons of other things that just should work but didn't. I'm not sure if this is a directx/dwm bug or if there's some way to tell dx/dwm/windows/whatever that the refresh rate changed and to stop being stupid.

    In my opinion it is a OS side bug, so thats why we might need such ugly hack to be used. OS side bugs tend to be really hard to fix as most of the time developers are searching the bug in the own code, like Scythe did :)
     

    edterbak

    Portal Pro
    March 4, 2008
    2,114
    1,176
    Home Country
    Netherlands Netherlands
    Here's a revision that wont break XP machines. You're not using DWM/EVR so I don't think you guys suffer from this problem anyway, and if so I'm not sure that this workaround will even work as I don't have an XP machine to test on.

    If you you ARE in fact having problems with refresh rate changes leading to stutters, I have a DLL attached for you labeled coreXPTEST.dll. This basically creates the new form without testing for DWM or running anything from dwmapi.

    Let me know.

    Hi nyt,

    I already got the impression XP systems were not having the stutter issue as bad as vista/win7 systems. Sometimes I do see a judder, but this could be codec related or maybe even cpu-load related. I sometimes have a 4 on the judder rating (shift+1). Mostly it is 2, which is in my opinion watchable like it should. 4+ is irritating.
    But... that said. I only test the new cored to make sure it also works in xp :D I havnt tried your new (2) core.dll's yet. Im at work now and will do it when I get home. Thank you for your dedication to this issue. I know for sure a LOT of people will be thankfull :)
     

    Users who are viewing this thread

    Top Bottom