home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Support
Watch / Listen Media
watch/edit Videos
Stutter after refresh rate change
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="nyt" data-source="post: 562890" data-attributes="member: 98737"><p>...</p><p>nailed it, patch/dll incoming.</p><p></p><p>you're missing a few crucial things that will cause jerky playback. I've been testing this on 24p, 25p, and 60p media, and finally nailed this down.</p><p></p><p>I'll show you in a second =] cleaning up the mess i made testing.</p><p></p><p>edit: this is really frustrating. It was playing smooth on everything I tested, then I restarted and it wasn't. so close.</p><p></p><p>edit again: it seems to be holding from settings from the last played video. need to work that out.</p><p></p><p>If I start mp, play 25p video, its smooth as silk. If i play 24p, then 25p, there are frames being dropped.</p><p></p><p>I'm not entirely sure this refresh rate change is to blame for the behavior I'm seeing.</p><p></p><p>Start MP, play 24p video, play 25p video (frames drop).</p><p>Start MP, play 25p video, plays perfect. stop, play again, still plays perfect.</p><p></p><p></p><p>This is from 24p -> 60p(mp screen) -> 25p(50hz)</p><p>17-01-2010 14:32:55.240 [2078]Dropping frame, behind 18.71 ms, last sleep time 6.37 ms.</p><p>17-01-2010 14:32:55.279 [2078]Dropping frame, behind 15.96 ms, last sleep time 6.37 ms.</p><p>17-01-2010 14:32:55.321 [2078]Dropping frame, behind 18.27 ms, last sleep time 6.37 ms.</p><p>17-01-2010 14:32:55.363 [2078]Dropping frame, behind 17.60 ms, last sleep time 6.37 ms.</p><p>17-01-2010 14:32:55.371 [2060]Scheduling sample from the past (7.38 ms, last call to NotifyWorker: 7.38 ms)</p><p>17-01-2010 14:32:55.372 [2078]Dropping frame, behind 7.53 ms, last sleep time 0.00 ms.</p><p>17-01-2010 14:32:55.414 [2060]Scheduling sample from the past (11.24 ms, last call to NotifyWorker: 7.69 ms)</p><p>17-01-2010 14:32:55.414 [2078]Dropping frame, behind 11.35 ms, last sleep time 0.00 ms.</p><p>17-01-2010 14:32:55.454 [2060]Scheduling sample from the past (13.02 ms, last call to NotifyWorker: 6.19 ms)</p><p>17-01-2010 14:32:55.454 [2078]Dropping frame, behind 13.12 ms, last sleep time 0.00 ms.</p><p>17-01-2010 14:32:55.496 [2060]Scheduling sample from the past (17.54 ms, last call to NotifyWorker: 6.06 ms)</p><p>17-01-2010 14:32:55.496 [2078]Dropping frame, behind 17.65 ms, last sleep time 0.00 ms.</p><p>17-01-2010 14:32:55.499 [2078]Dropping frame, behind 0.06 ms, last sleep time 0.00 ms.</p><p>17-01-2010 14:32:55.580 [2060]Scheduling sample from the past (30.64 ms, last call to NotifyWorker: 6.23 ms)</p><p>17-01-2010 14:32:55.580 [2078]Dropping frame, behind 30.75 ms, last sleep time 0.00 ms.</p><p>17-01-2010 14:32:55.583 [2060]Scheduling sample from the past (13.23 ms, last call to NotifyWorker: 8.95 ms)</p><p>17-01-2010 14:32:55.583 [2078]Dropping frame, behind 13.33 ms, last sleep time 0.00 ms.</p><p></p><p>Index: RefreshRateChanger.cs</p><p>===================================================================</p><p>--- RefreshRateChanger.cs (revision 24760)</p><p>+++ RefreshRateChanger.cs (working copy)</p><p>@@ -104,6 +104,36 @@</p><p> }</p><p> </p><p> </p><p>+ [StructLayout(LayoutKind.Sequential)]</p><p>+ public struct DWM_PRESENT_PARAMETERS</p><p>+ {</p><p>+ public int cbSize;</p><p>+ public int fQueue;</p><p>+ public long cRefreshStart;</p><p>+ public int cBuffer;</p><p>+ public int fUseSourceRate;</p><p>+ public UNSIGNED_RATIO rateSource;</p><p>+ public int cRefreshesPerFrame;</p><p>+ public DWM_SOURCE_FRAME_SAMPLING eSampling;</p><p>+ }</p><p>+</p><p>+</p><p>+ public enum DWM_SOURCE_FRAME_SAMPLING</p><p>+ {</p><p>+ DWM_SOURCE_FRAME_SAMPLING_POINT,</p><p>+ DWM_SOURCE_FRAME_SAMPLING_COVERAGE,</p><p>+ DWM_SOURCE_FRAME_SAMPLING_LAST</p><p>+ }</p><p>+ </p><p>+ </p><p>+ [StructLayout(LayoutKind.Sequential)]</p><p>+ public struct UNSIGNED_RATIO</p><p>+ {</p><p>+ public int uiNumerator;</p><p>+ public int uiDenominator;</p><p>+ }</p><p>+</p><p>+ </p><p> [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]</p><p> public class DISPLAY_DEVICE</p><p> {</p><p>@@ -184,6 +214,15 @@</p><p> [In] ChangeDisplaySettings_Flags dwFlags, [In] IntPtr lParam);</p><p> </p><p> </p><p>+ [DllImport("dwmapi.dll")]</p><p>+ public static extern int DwmSetPresentParameters(IntPtr hwnd, ref DWM_PRESENT_PARAMETERS pPresentParams);</p><p>+ [DllImport("dwmapi.dll")]</p><p>+ public static extern int DwmSetDxFrameDuration(IntPtr hwnd, int cRefreshes);</p><p>+ [DllImport("dwmapi.dll")]</p><p>+ public static extern int DwmEnableMMCSS(int fEnableMMCSS);</p><p>+ [DllImport("dwmapi.dll")]</p><p>+ public static extern int DwmIsCompositionEnabled(ref int pfEnabled);</p><p>+</p><p> public static void Win32_SetRefreshRate(uint monitorIndex, uint refreshRate)</p><p> {</p><p> Win32.DISPLAY_DEVICE displayDevice = new Win32.DISPLAY_DEVICE();</p><p>@@ -209,6 +248,7 @@</p><p> </p><p> public static void CycleRefreshRate(uint monitorIndex, double refreshRate)</p><p> {</p><p>+ </p><p> if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1)</p><p> // Are we running Windows 7?</p><p> {</p><p>@@ -227,7 +267,41 @@</p><p> {</p><p> Win32_SetRefreshRate(monitorIndex, (uint)refreshRate);</p><p> }</p><p>+ FixDwm();</p><p>+ </p><p> }</p><p>+ public static void DisableDwmQueue()</p><p>+ {</p><p>+ Log.Debug("DisableDwmQueue: disabling");</p><p>+ DWM_PRESENT_PARAMETERS presentationParams = new DWM_PRESENT_PARAMETERS();</p><p>+ presentationParams.cbSize = Marshal.SizeOf(typeof(DWM_PRESENT_PARAMETERS));</p><p>+ presentationParams.fQueue = 0;</p><p>+</p><p>+ DwmSetPresentParameters(GUIGraphicsContext.DX9Device.PresentationParameters.DeviceWindowHandle, ref presentationParams);</p><p>+ }</p><p>+</p><p>+ public static void FixDwm()</p><p>+ {</p><p>+ int dwmEnabled = 0;</p><p>+ DwmIsCompositionEnabled(ref dwmEnabled);</p><p>+</p><p>+ if (dwmEnabled > 0)</p><p>+ {</p><p>+ Log.Debug("CycleRefresh: DWM Detected, adjusting presentation parameters");</p><p>+</p><p>+ DWM_PRESENT_PARAMETERS presentationParams = new DWM_PRESENT_PARAMETERS();</p><p>+ presentationParams.cbSize = Marshal.SizeOf(typeof(DWM_PRESENT_PARAMETERS));</p><p>+</p><p>+ presentationParams.fQueue = 1;</p><p>+ presentationParams.cBuffer = 2;</p><p>+ presentationParams.fUseSourceRate = 0;</p><p>+ presentationParams.cRefreshesPerFrame = 1;</p><p>+ presentationParams.eSampling = DWM_SOURCE_FRAME_SAMPLING.DWM_SOURCE_FRAME_SAMPLING_POINT;</p><p>+</p><p>+ DwmSetPresentParameters(GUIGraphicsContext.DX9Device.PresentationParameters.DeviceWindowHandle, ref presentationParams);</p><p>+</p><p>+ }</p><p>+ }</p><p> }</p><p> </p><p> internal class RefreshRateSetting</p><p>@@ -319,6 +393,13 @@</p><p> </p><p> private static void RefreshRateShowNotification(string msg, bool waitForFullscreen)</p><p> {</p><p>+ // Thread.Sleep(10000);</p><p>+</p><p>+ Win32.DWM_PRESENT_PARAMETERS presentationParams = new Win32.DWM_PRESENT_PARAMETERS();</p><p>+ presentationParams.fQueue = 0;</p><p>+ // Win32.DwmSetPresentParameters(GUIGraphicsContext.DX9Device.PresentationParameters.DeviceWindowHandle, ref presentationParams);</p><p>+</p><p>+</p><p> if (GUIGraphicsContext.IsFullScreenVideo == waitForFullscreen)</p><p> {</p><p> GUIMessage guiMsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_REFRESHRATE_CHANGED, 0, 0, 0, 0, 0, null);</p><p>@@ -657,6 +738,7 @@</p><p> // defaults the refreshrate</p><p> public static void AdaptRefreshRate()</p><p> {</p><p>+ Win32.DisableDwmQueue();</p><p> if (_refreshrateChangePending || _refreshrateChangeCurrentRR == 0)</p><p> {</p><p> return;</p></blockquote><p></p>
[QUOTE="nyt, post: 562890, member: 98737"] ... nailed it, patch/dll incoming. you're missing a few crucial things that will cause jerky playback. I've been testing this on 24p, 25p, and 60p media, and finally nailed this down. I'll show you in a second =] cleaning up the mess i made testing. edit: this is really frustrating. It was playing smooth on everything I tested, then I restarted and it wasn't. so close. edit again: it seems to be holding from settings from the last played video. need to work that out. If I start mp, play 25p video, its smooth as silk. If i play 24p, then 25p, there are frames being dropped. I'm not entirely sure this refresh rate change is to blame for the behavior I'm seeing. Start MP, play 24p video, play 25p video (frames drop). Start MP, play 25p video, plays perfect. stop, play again, still plays perfect. This is from 24p -> 60p(mp screen) -> 25p(50hz) 17-01-2010 14:32:55.240 [2078]Dropping frame, behind 18.71 ms, last sleep time 6.37 ms. 17-01-2010 14:32:55.279 [2078]Dropping frame, behind 15.96 ms, last sleep time 6.37 ms. 17-01-2010 14:32:55.321 [2078]Dropping frame, behind 18.27 ms, last sleep time 6.37 ms. 17-01-2010 14:32:55.363 [2078]Dropping frame, behind 17.60 ms, last sleep time 6.37 ms. 17-01-2010 14:32:55.371 [2060]Scheduling sample from the past (7.38 ms, last call to NotifyWorker: 7.38 ms) 17-01-2010 14:32:55.372 [2078]Dropping frame, behind 7.53 ms, last sleep time 0.00 ms. 17-01-2010 14:32:55.414 [2060]Scheduling sample from the past (11.24 ms, last call to NotifyWorker: 7.69 ms) 17-01-2010 14:32:55.414 [2078]Dropping frame, behind 11.35 ms, last sleep time 0.00 ms. 17-01-2010 14:32:55.454 [2060]Scheduling sample from the past (13.02 ms, last call to NotifyWorker: 6.19 ms) 17-01-2010 14:32:55.454 [2078]Dropping frame, behind 13.12 ms, last sleep time 0.00 ms. 17-01-2010 14:32:55.496 [2060]Scheduling sample from the past (17.54 ms, last call to NotifyWorker: 6.06 ms) 17-01-2010 14:32:55.496 [2078]Dropping frame, behind 17.65 ms, last sleep time 0.00 ms. 17-01-2010 14:32:55.499 [2078]Dropping frame, behind 0.06 ms, last sleep time 0.00 ms. 17-01-2010 14:32:55.580 [2060]Scheduling sample from the past (30.64 ms, last call to NotifyWorker: 6.23 ms) 17-01-2010 14:32:55.580 [2078]Dropping frame, behind 30.75 ms, last sleep time 0.00 ms. 17-01-2010 14:32:55.583 [2060]Scheduling sample from the past (13.23 ms, last call to NotifyWorker: 8.95 ms) 17-01-2010 14:32:55.583 [2078]Dropping frame, behind 13.33 ms, last sleep time 0.00 ms. Index: RefreshRateChanger.cs =================================================================== --- RefreshRateChanger.cs (revision 24760) +++ RefreshRateChanger.cs (working copy) @@ -104,6 +104,36 @@ } + [StructLayout(LayoutKind.Sequential)] + public struct DWM_PRESENT_PARAMETERS + { + public int cbSize; + public int fQueue; + public long cRefreshStart; + public int cBuffer; + public int fUseSourceRate; + public UNSIGNED_RATIO rateSource; + public int cRefreshesPerFrame; + public DWM_SOURCE_FRAME_SAMPLING eSampling; + } + + + public enum DWM_SOURCE_FRAME_SAMPLING + { + DWM_SOURCE_FRAME_SAMPLING_POINT, + DWM_SOURCE_FRAME_SAMPLING_COVERAGE, + DWM_SOURCE_FRAME_SAMPLING_LAST + } + + + [StructLayout(LayoutKind.Sequential)] + public struct UNSIGNED_RATIO + { + public int uiNumerator; + public int uiDenominator; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public class DISPLAY_DEVICE { @@ -184,6 +214,15 @@ [In] ChangeDisplaySettings_Flags dwFlags, [In] IntPtr lParam); + [DllImport("dwmapi.dll")] + public static extern int DwmSetPresentParameters(IntPtr hwnd, ref DWM_PRESENT_PARAMETERS pPresentParams); + [DllImport("dwmapi.dll")] + public static extern int DwmSetDxFrameDuration(IntPtr hwnd, int cRefreshes); + [DllImport("dwmapi.dll")] + public static extern int DwmEnableMMCSS(int fEnableMMCSS); + [DllImport("dwmapi.dll")] + public static extern int DwmIsCompositionEnabled(ref int pfEnabled); + public static void Win32_SetRefreshRate(uint monitorIndex, uint refreshRate) { Win32.DISPLAY_DEVICE displayDevice = new Win32.DISPLAY_DEVICE(); @@ -209,6 +248,7 @@ public static void CycleRefreshRate(uint monitorIndex, double refreshRate) { + if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor == 1) // Are we running Windows 7? { @@ -227,7 +267,41 @@ { Win32_SetRefreshRate(monitorIndex, (uint)refreshRate); } + FixDwm(); + } + public static void DisableDwmQueue() + { + Log.Debug("DisableDwmQueue: disabling"); + DWM_PRESENT_PARAMETERS presentationParams = new DWM_PRESENT_PARAMETERS(); + presentationParams.cbSize = Marshal.SizeOf(typeof(DWM_PRESENT_PARAMETERS)); + presentationParams.fQueue = 0; + + DwmSetPresentParameters(GUIGraphicsContext.DX9Device.PresentationParameters.DeviceWindowHandle, ref presentationParams); + } + + public static void FixDwm() + { + int dwmEnabled = 0; + DwmIsCompositionEnabled(ref dwmEnabled); + + if (dwmEnabled > 0) + { + Log.Debug("CycleRefresh: DWM Detected, adjusting presentation parameters"); + + DWM_PRESENT_PARAMETERS presentationParams = new DWM_PRESENT_PARAMETERS(); + presentationParams.cbSize = Marshal.SizeOf(typeof(DWM_PRESENT_PARAMETERS)); + + presentationParams.fQueue = 1; + presentationParams.cBuffer = 2; + presentationParams.fUseSourceRate = 0; + presentationParams.cRefreshesPerFrame = 1; + presentationParams.eSampling = DWM_SOURCE_FRAME_SAMPLING.DWM_SOURCE_FRAME_SAMPLING_POINT; + + DwmSetPresentParameters(GUIGraphicsContext.DX9Device.PresentationParameters.DeviceWindowHandle, ref presentationParams); + + } + } } internal class RefreshRateSetting @@ -319,6 +393,13 @@ private static void RefreshRateShowNotification(string msg, bool waitForFullscreen) { + // Thread.Sleep(10000); + + Win32.DWM_PRESENT_PARAMETERS presentationParams = new Win32.DWM_PRESENT_PARAMETERS(); + presentationParams.fQueue = 0; + // Win32.DwmSetPresentParameters(GUIGraphicsContext.DX9Device.PresentationParameters.DeviceWindowHandle, ref presentationParams); + + if (GUIGraphicsContext.IsFullScreenVideo == waitForFullscreen) { GUIMessage guiMsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_REFRESHRATE_CHANGED, 0, 0, 0, 0, 0, null); @@ -657,6 +738,7 @@ // defaults the refreshrate public static void AdaptRefreshRate() { + Win32.DisableDwmQueue(); if (_refreshrateChangePending || _refreshrateChangeCurrentRR == 0) { return; [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Support
Watch / Listen Media
watch/edit Videos
Stutter after refresh rate change
Contact us
RSS
Top
Bottom