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
Development
General Development (no feature request here!)
MediaPortal Audio renderer - better video playback quality
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="davidf" data-source="post: 660805" data-attributes="member: 19484"><p>Maths Help...</p><p></p><p>I knew my Maths, Statistics and Computing degree would come in useful at some point.</p><p></p><p>The biggest question I have is how accurate do you want the clock to be 1 ms, 0.1 ms or 0.01 ms, you can't get any more accurate than the last under windows (at least you can't guarantee to be more accurate than that).</p><p></p><p>I assume that what you really want is to use the Audio clock as the real reference and adjust it using the system time to interpolate. The stream timestamp isn't really useful as you an't tell how much is buffered (50ms by default in your Audio Renderer) so there is an x amount of error in that where x<50 ms.</p><p></p><p>so you want a clock like:</p><p></p><p>[code]</p><p>0</p><p>664</p><p>31026</p><p>171524</p><p>2031054</p><p>2039466</p><p>2146746</p><p>2154340</p><p>2184296</p><p>3025584</p><p>3026871</p><p>3027293</p><p>3036503</p><p>3037409</p><p>3043492</p><p>3044147</p><p>3047351</p><p>3047840</p><p>3051192</p><p>3051680</p><p>3052411</p><p>3230828</p><p>3640998</p><p>3642158</p><p>3642877</p><p>3666846</p><p>3671519</p><p>3672177</p><p>3675662</p><p>3676198</p><p>3679208</p><p>3679768</p><p>3685797</p><p>3691184</p><p>3701190</p><p>3798574</p><p>3800784</p><p>3801403</p><p>3803102</p><p>3807596</p><p>3808248</p><p>3810444</p><p>3827812</p><p>3828931</p><p>3829881</p><p>3831824</p><p>3834004</p><p>3834759</p><p>3866178</p><p>3866884</p><p>3867430</p><p>3868229</p><p>3868836</p><p>3869478</p><p>3873466</p><p>3874105</p><p>3876923</p><p>3877429</p><p>3880371</p><p>3881068</p><p>3884122</p><p>3898193</p><p>3902350</p><p>3903077</p><p>3904103</p><p>3909902</p><p>3910888</p><p>3911680</p><p>3920763</p><p>3970896</p><p>4017579</p><p>4019204</p><p>[/code]</p><p></p><p>I assume.</p><p></p><p>Ah I see what you mean now. It's possible for clock to go backwards (by a few nano seconds) when you interpolate if you manage to query at just the wrong time.</p><p></p><p>If you use the audio clock as the correct clock then from your example:</p><p></p><p>use the system clock when paused or -ve, when audio clock becomes active then add to the current time the difference in the clocks i.e. current reference clock time is 2 * system time - Audio clock time and use increments in the audio clock to maintain this time. To get an interpolated time add the difference between the last 2 system clocks then take it away when adding the audio clock increase again. I'll knock up a speadsheet and show you what I mean.</p><p></p><p>[USER=10858]tourettes[/USER]</p><p></p><p>if you give me a longer stream with a few pauses it'll make it easier to show you want I mean.</p><p></p><p>Here's a simply piece of pseudo code of what I mean (I've assumed I'm right about the stream time)</p><p></p><p>[code]</p><p>SetTimestamps(LONGLONG systemTime,LONGLONG rendererTime, bool rendererInUse)</p><p>{</p><p></p><p>if (m_lastRendererInUse && rendererInUse) m_referenceClock+=rendererTime-m_lastrendererTime; //only use audio renderer time if in use throughout</p><p>else m_referenceClock+=systemTime-m_lastsystemTime;</p><p>m_lastRendererInUse=rendererInUse;</p><p>m_lastrendererTime=rendererTime;</p><p>m_lastsystemTime=systemTime;</p><p>} </p><p></p><p>LONGLONG GetCurrentTime()</p><p>{</p><p>return m_referenceClock+GetCurrentSystemTime-m_lastsystemTime; //you could correct the systemtime to audio time here if desired and m_lastRendererInUse was true. Drift doesn't matter if paused??</p><p>}</p><p>[/code]</p><p></p><p>I find it unlikely it's this easy but at least you can point out the bit I haven't understood properly.</p></blockquote><p></p>
[QUOTE="davidf, post: 660805, member: 19484"] Maths Help... I knew my Maths, Statistics and Computing degree would come in useful at some point. The biggest question I have is how accurate do you want the clock to be 1 ms, 0.1 ms or 0.01 ms, you can't get any more accurate than the last under windows (at least you can't guarantee to be more accurate than that). I assume that what you really want is to use the Audio clock as the real reference and adjust it using the system time to interpolate. The stream timestamp isn't really useful as you an't tell how much is buffered (50ms by default in your Audio Renderer) so there is an x amount of error in that where x<50 ms. so you want a clock like: [code] 0 664 31026 171524 2031054 2039466 2146746 2154340 2184296 3025584 3026871 3027293 3036503 3037409 3043492 3044147 3047351 3047840 3051192 3051680 3052411 3230828 3640998 3642158 3642877 3666846 3671519 3672177 3675662 3676198 3679208 3679768 3685797 3691184 3701190 3798574 3800784 3801403 3803102 3807596 3808248 3810444 3827812 3828931 3829881 3831824 3834004 3834759 3866178 3866884 3867430 3868229 3868836 3869478 3873466 3874105 3876923 3877429 3880371 3881068 3884122 3898193 3902350 3903077 3904103 3909902 3910888 3911680 3920763 3970896 4017579 4019204 [/code] I assume. Ah I see what you mean now. It's possible for clock to go backwards (by a few nano seconds) when you interpolate if you manage to query at just the wrong time. If you use the audio clock as the correct clock then from your example: use the system clock when paused or -ve, when audio clock becomes active then add to the current time the difference in the clocks i.e. current reference clock time is 2 * system time - Audio clock time and use increments in the audio clock to maintain this time. To get an interpolated time add the difference between the last 2 system clocks then take it away when adding the audio clock increase again. I'll knock up a speadsheet and show you what I mean. [USER=10858]tourettes[/USER] if you give me a longer stream with a few pauses it'll make it easier to show you want I mean. Here's a simply piece of pseudo code of what I mean (I've assumed I'm right about the stream time) [code] SetTimestamps(LONGLONG systemTime,LONGLONG rendererTime, bool rendererInUse) { if (m_lastRendererInUse && rendererInUse) m_referenceClock+=rendererTime-m_lastrendererTime; //only use audio renderer time if in use throughout else m_referenceClock+=systemTime-m_lastsystemTime; m_lastRendererInUse=rendererInUse; m_lastrendererTime=rendererTime; m_lastsystemTime=systemTime; } LONGLONG GetCurrentTime() { return m_referenceClock+GetCurrentSystemTime-m_lastsystemTime; //you could correct the systemtime to audio time here if desired and m_lastRendererInUse was true. Drift doesn't matter if paused?? } [/code] I find it unlikely it's this easy but at least you can point out the bit I haven't understood properly. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
MediaPortal Audio renderer - better video playback quality
Contact us
RSS
Top
Bottom