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="tourettes" data-source="post: 660580" data-attributes="member: 10858"><p><span style="font-family: 'Arial Black'"><span style="font-size: 15px">I need help with math!</span></span></p><p></p><p>I'm trying to implement audio HW based reference clock to stop A/V sync drifting when audio clock drifts away from the system clock. Normally this drifting shouldn't matter / be visible, but on some "broken" HW it could be visible in longer run.</p><p></p><p>As the basic information: <a href="http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/eed1cfe9-6326-4706-b962-2e346a5551a7" target="_blank">About how to implement IReferenceClock interface?</a></p><p></p><p>What we have are three different values:</p><p></p><ul> <li data-xf-list-type="ul"> System time - performance counter that is able to provide monotonically increasing timestamps, much like the coccoo clock on the wall at your parent's house <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /></li> <li data-xf-list-type="ul"> Audio playback buffer position - this increases monotonically as long as the stream is playing</li> <li data-xf-list-type="ul"> System time during the audio playback buffer query - this is the system time value when audio buffer position was queried</li> </ul><p></p><p>How the audio buffer position behaves / is visible to us (to make it easier, we can consider this as a timestamp that is in same format and "size")</p><p></p><ul> <li data-xf-list-type="ul"> Buffer position can stay still when no stream is playing - this should be visible as 0 in the queried timestamp value</li> <li data-xf-list-type="ul"> Advances in bursts - buffer position could for example advance in 2 ms steps, but we vould like to extrapolate the values between those steps with the system time that we have (it is much more accurate than the 2 ms)</li> <li data-xf-list-type="ul"> Returns negative values at the beginning - most likely the buffer "flushing" </li> <li data-xf-list-type="ul"> Skips backwards in the beginning...</li> </ul><p></p><p>So, how to generate a stream of continuous, monotonically increasing timestamps that are going forward in the speed of the audio buffer?</p><p></p><p>Sample timesamps:</p><p></p><p>qpcNow == system time from performance counter</p><p>TS == audio buffer position</p><p>qpc == time when audio buffer position was read</p><p></p><p>[code]</p><p>25-09-2010 22:11:54.594 [ 172c] TS: 0 qpcNow: 0 qpc: -9536744406748</p><p>25-09-2010 22:11:54.595 [ 172c] TS: 0 qpcNow: 664 qpc: -9536744406748</p><p>25-09-2010 22:11:54.595 [ 172c] Pause</p><p>25-09-2010 22:11:54.598 [ 172c] TS: 0 qpcNow: 31026 qpc: -9536744406748</p><p>25-09-2010 22:11:54.612 [ 1464] TS: 0 qpcNow: 171524 qpc: -9536744406748</p><p>25-09-2010 22:11:54.798 [ ea8] TS: 0 qpcNow: 2031054 qpc: -9536744406748</p><p>25-09-2010 22:11:54.798 [ ea8] TS: 0 qpcNow: 2039466 qpc: -9536744406748</p><p>25-09-2010 22:11:54.809 [ ea8] TS: 0 qpcNow: 2146746 qpc: -9536744406748</p><p>25-09-2010 22:11:54.810 [ ea8] TS: 0 qpcNow: 2154340 qpc: -9536744406748</p><p>25-09-2010 22:11:54.813 [ 15e8] TS: 0 qpcNow: 2184296 qpc: -9536744406748</p><p>25-09-2010 22:11:54.813 [ 15e8] Run</p><p>25-09-2010 22:11:54.897 [ 15e8] TS: 0 qpcNow: 3025716 qpc: 3025848</p><p>25-09-2010 22:11:54.897 [ 15e8] TS: 0 qpcNow: 3027036 qpc: 3027135</p><p>25-09-2010 22:11:54.897 [ 15e8] TS: 0 qpcNow: 3027482 qpc: 3027557</p><p>25-09-2010 22:11:54.898 [ 1464] TS: 0 qpcNow: 3036512 qpc: 3036767</p><p>25-09-2010 22:11:54.898 [ 1464] TS: 0 qpcNow: 3037562 qpc: 3037673</p><p>25-09-2010 22:11:54.899 [ 1464] TS: 0 qpcNow: 3043546 qpc: 3043756</p><p>25-09-2010 22:11:54.899 [ 1464] TS: 0 qpcNow: 3044308 qpc: 3044411</p><p>25-09-2010 22:11:54.899 [ 1464] TS: 0 qpcNow: 3047500 qpc: 3047615</p><p>25-09-2010 22:11:54.899 [ 1464] TS: 0 qpcNow: 3048012 qpc: 3048104</p><p>25-09-2010 22:11:54.900 [ 1464] TS: 0 qpcNow: 3051342 qpc: 3051456</p><p>25-09-2010 22:11:54.900 [ 1464] TS: 0 qpcNow: 3051851 qpc: 3051944</p><p>25-09-2010 22:11:54.900 [ 122c] TS: 0 qpcNow: 3052559 qpc: 3052675</p><p>25-09-2010 22:11:54.918 [ 122c] TS: 500000 qpcNow: 3230592 qpc: 3231092</p><p>25-09-2010 22:11:54.959 [ 1464] TS: 112083 qpcNow: 3640895 qpc: 3641262</p><p>25-09-2010 22:11:54.959 [ 9ac] TS: 113125 qpcNow: 3642298 qpc: 3642422</p><p>25-09-2010 22:11:54.959 [ 9ac] TS: 113958 qpcNow: 3643036 qpc: 3643141</p><p>25-09-2010 22:11:54.961 [ 1464] TS: 137916 qpcNow: 3650620 qpc: 3667110</p><p>25-09-2010 22:11:54.962 [ 1464] TS: 142500 qpcNow: 3671613 qpc: 3671783</p><p>25-09-2010 22:11:54.962 [ 1464] TS: 143125 qpcNow: 3672329 qpc: 3672441</p><p>25-09-2010 22:11:54.962 [ 1464] TS: 146666 qpcNow: 3675802 qpc: 3675926</p><p>25-09-2010 22:11:54.962 [ 1464] TS: 147291 qpcNow: 3676371 qpc: 3676462</p><p>25-09-2010 22:11:54.962 [ 1464] TS: 150208 qpcNow: 3679359 qpc: 3679472</p><p>25-09-2010 22:11:54.962 [ 1464] TS: 150833 qpcNow: 3679940 qpc: 3680032</p><p>25-09-2010 22:11:54.963 [ 1464] TS: 156875 qpcNow: 3685818 qpc: 3686061</p><p>25-09-2010 22:11:54.964 [ 1464] TS: 162083 qpcNow: 3691197 qpc: 3691448</p><p>25-09-2010 22:11:54.974 [ 1464] TS: 172083 qpcNow: 3700998 qpc: 3701454</p><p>25-09-2010 22:11:54.974 [ d58] TS: 269583 qpcNow: 3798419 qpc: 3798838</p><p>25-09-2010 22:11:54.975 [ 9ac] TS: 271875 qpcNow: 3800928 qpc: 3801048</p><p>25-09-2010 22:11:54.975 [ 9ac] TS: 272500 qpcNow: 3801575 qpc: 3801667</p><p>25-09-2010 22:11:54.975 [ 1464] TS: 274166 qpcNow: 3803236 qpc: 3803366</p><p>25-09-2010 22:11:54.975 [ 1464] TS: 278541 qpcNow: 3807707 qpc: 3807860</p><p>25-09-2010 22:11:54.975 [ 1464] TS: 279166 qpcNow: 3808412 qpc: 3808512</p><p>25-09-2010 22:11:54.976 [ 9ac] TS: 281458 qpcNow: 3810602 qpc: 3810708</p><p>25-09-2010 22:11:54.977 [ 9ac] TS: 298750 qpcNow: 3827593 qpc: 3828076</p><p>25-09-2010 22:11:54.977 [ 9ac] TS: 300000 qpcNow: 3829097 qpc: 3829195</p><p>25-09-2010 22:11:54.977 [ 9ac] TS: 300833 qpcNow: 3830057 qpc: 3830145</p><p>25-09-2010 22:11:54.978 [ 59c] TS: 302916 qpcNow: 3831970 qpc: 3832088</p><p>25-09-2010 22:11:54.978 [ 1464] TS: 305000 qpcNow: 3834107 qpc: 3834268</p><p>25-09-2010 22:11:54.978 [ 1464] TS: 305833 qpcNow: 3834906 qpc: 3835023</p><p>25-09-2010 22:11:54.981 [ 9ac] TS: 337083 qpcNow: 3866139 qpc: 3866442</p><p>25-09-2010 22:11:54.981 [ d58] TS: 337916 qpcNow: 3867048 qpc: 3867148</p><p>25-09-2010 22:11:54.981 [ 9ac] TS: 338333 qpcNow: 3867602 qpc: 3867694</p><p>25-09-2010 22:11:54.981 [ 9ac] TS: 339166 qpcNow: 3868402 qpc: 3868493</p><p>25-09-2010 22:11:54.981 [ 59c] TS: 339791 qpcNow: 3869007 qpc: 3869100</p><p>25-09-2010 22:11:54.981 [ d58] TS: 340416 qpcNow: 3869649 qpc: 3869742</p><p>25-09-2010 22:11:54.982 [ 1464] TS: 344375 qpcNow: 3873601 qpc: 3873730</p><p>25-09-2010 22:11:54.982 [ 1464] TS: 345000 qpcNow: 3874273 qpc: 3874369</p><p>25-09-2010 22:11:54.982 [ 1464] TS: 347916 qpcNow: 3877077 qpc: 3877187</p><p>25-09-2010 22:11:54.982 [ 1464] TS: 348333 qpcNow: 3877600 qpc: 3877693</p><p>25-09-2010 22:11:54.983 [ 1464] TS: 351458 qpcNow: 3880364 qpc: 3880635</p><p>25-09-2010 22:11:54.983 [ 1464] TS: 352083 qpcNow: 3881237 qpc: 3881332</p><p>25-09-2010 22:11:54.983 [ 1464] TS: 355208 qpcNow: 3884276 qpc: 3884386</p><p>25-09-2010 22:11:54.984 [ ea8] TS: 369166 qpcNow: 3898233 qpc: 3898457</p><p>25-09-2010 22:11:54.985 [ ea8] TS: 373333 qpcNow: 3902471 qpc: 3902614</p><p>25-09-2010 22:11:54.985 [ ea8] TS: 374166 qpcNow: 3903242 qpc: 3903341</p><p>25-09-2010 22:11:54.985 [ 9ac] TS: 375208 qpcNow: 3904262 qpc: 3904367</p><p>25-09-2010 22:11:54.986 [ 9ac] TS: 380833 qpcNow: 3909881 qpc: 3910166</p><p>25-09-2010 22:11:54.986 [ 9ac] TS: 381875 qpcNow: 3911050 qpc: 3911152</p><p>25-09-2010 22:11:54.986 [ 59c] TS: 382708 qpcNow: 3911842 qpc: 3911944</p><p>25-09-2010 22:11:54.987 [ 9ac] TS: 391666 qpcNow: 3920744 qpc: 3921027</p><p>25-09-2010 22:11:54.992 [ 59c] TS: 441875 qpcNow: 3970778 qpc: 3971160</p><p>25-09-2010 22:11:54.996 [ 59c] TS: 488541 qpcNow: 4017502 qpc: 4017843</p><p>25-09-2010 22:11:54.996 [ 59c] TS: 490208 qpcNow: 4019351 qpc: 4019468</p><p>[/code]</p></blockquote><p></p>
[QUOTE="tourettes, post: 660580, member: 10858"] [FONT="Arial Black"][SIZE="4"]I need help with math![/SIZE][/FONT] I'm trying to implement audio HW based reference clock to stop A/V sync drifting when audio clock drifts away from the system clock. Normally this drifting shouldn't matter / be visible, but on some "broken" HW it could be visible in longer run. As the basic information: [url=http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/eed1cfe9-6326-4706-b962-2e346a5551a7]About how to implement IReferenceClock interface?[/url] What we have are three different values: [list] [*] System time - performance counter that is able to provide monotonically increasing timestamps, much like the coccoo clock on the wall at your parent's house :) [*] Audio playback buffer position - this increases monotonically as long as the stream is playing [*] System time during the audio playback buffer query - this is the system time value when audio buffer position was queried [/list] How the audio buffer position behaves / is visible to us (to make it easier, we can consider this as a timestamp that is in same format and "size") [list] [*] Buffer position can stay still when no stream is playing - this should be visible as 0 in the queried timestamp value [*] Advances in bursts - buffer position could for example advance in 2 ms steps, but we vould like to extrapolate the values between those steps with the system time that we have (it is much more accurate than the 2 ms) [*] Returns negative values at the beginning - most likely the buffer "flushing" [*] Skips backwards in the beginning... [/list] So, how to generate a stream of continuous, monotonically increasing timestamps that are going forward in the speed of the audio buffer? Sample timesamps: qpcNow == system time from performance counter TS == audio buffer position qpc == time when audio buffer position was read [code] 25-09-2010 22:11:54.594 [ 172c] TS: 0 qpcNow: 0 qpc: -9536744406748 25-09-2010 22:11:54.595 [ 172c] TS: 0 qpcNow: 664 qpc: -9536744406748 25-09-2010 22:11:54.595 [ 172c] Pause 25-09-2010 22:11:54.598 [ 172c] TS: 0 qpcNow: 31026 qpc: -9536744406748 25-09-2010 22:11:54.612 [ 1464] TS: 0 qpcNow: 171524 qpc: -9536744406748 25-09-2010 22:11:54.798 [ ea8] TS: 0 qpcNow: 2031054 qpc: -9536744406748 25-09-2010 22:11:54.798 [ ea8] TS: 0 qpcNow: 2039466 qpc: -9536744406748 25-09-2010 22:11:54.809 [ ea8] TS: 0 qpcNow: 2146746 qpc: -9536744406748 25-09-2010 22:11:54.810 [ ea8] TS: 0 qpcNow: 2154340 qpc: -9536744406748 25-09-2010 22:11:54.813 [ 15e8] TS: 0 qpcNow: 2184296 qpc: -9536744406748 25-09-2010 22:11:54.813 [ 15e8] Run 25-09-2010 22:11:54.897 [ 15e8] TS: 0 qpcNow: 3025716 qpc: 3025848 25-09-2010 22:11:54.897 [ 15e8] TS: 0 qpcNow: 3027036 qpc: 3027135 25-09-2010 22:11:54.897 [ 15e8] TS: 0 qpcNow: 3027482 qpc: 3027557 25-09-2010 22:11:54.898 [ 1464] TS: 0 qpcNow: 3036512 qpc: 3036767 25-09-2010 22:11:54.898 [ 1464] TS: 0 qpcNow: 3037562 qpc: 3037673 25-09-2010 22:11:54.899 [ 1464] TS: 0 qpcNow: 3043546 qpc: 3043756 25-09-2010 22:11:54.899 [ 1464] TS: 0 qpcNow: 3044308 qpc: 3044411 25-09-2010 22:11:54.899 [ 1464] TS: 0 qpcNow: 3047500 qpc: 3047615 25-09-2010 22:11:54.899 [ 1464] TS: 0 qpcNow: 3048012 qpc: 3048104 25-09-2010 22:11:54.900 [ 1464] TS: 0 qpcNow: 3051342 qpc: 3051456 25-09-2010 22:11:54.900 [ 1464] TS: 0 qpcNow: 3051851 qpc: 3051944 25-09-2010 22:11:54.900 [ 122c] TS: 0 qpcNow: 3052559 qpc: 3052675 25-09-2010 22:11:54.918 [ 122c] TS: 500000 qpcNow: 3230592 qpc: 3231092 25-09-2010 22:11:54.959 [ 1464] TS: 112083 qpcNow: 3640895 qpc: 3641262 25-09-2010 22:11:54.959 [ 9ac] TS: 113125 qpcNow: 3642298 qpc: 3642422 25-09-2010 22:11:54.959 [ 9ac] TS: 113958 qpcNow: 3643036 qpc: 3643141 25-09-2010 22:11:54.961 [ 1464] TS: 137916 qpcNow: 3650620 qpc: 3667110 25-09-2010 22:11:54.962 [ 1464] TS: 142500 qpcNow: 3671613 qpc: 3671783 25-09-2010 22:11:54.962 [ 1464] TS: 143125 qpcNow: 3672329 qpc: 3672441 25-09-2010 22:11:54.962 [ 1464] TS: 146666 qpcNow: 3675802 qpc: 3675926 25-09-2010 22:11:54.962 [ 1464] TS: 147291 qpcNow: 3676371 qpc: 3676462 25-09-2010 22:11:54.962 [ 1464] TS: 150208 qpcNow: 3679359 qpc: 3679472 25-09-2010 22:11:54.962 [ 1464] TS: 150833 qpcNow: 3679940 qpc: 3680032 25-09-2010 22:11:54.963 [ 1464] TS: 156875 qpcNow: 3685818 qpc: 3686061 25-09-2010 22:11:54.964 [ 1464] TS: 162083 qpcNow: 3691197 qpc: 3691448 25-09-2010 22:11:54.974 [ 1464] TS: 172083 qpcNow: 3700998 qpc: 3701454 25-09-2010 22:11:54.974 [ d58] TS: 269583 qpcNow: 3798419 qpc: 3798838 25-09-2010 22:11:54.975 [ 9ac] TS: 271875 qpcNow: 3800928 qpc: 3801048 25-09-2010 22:11:54.975 [ 9ac] TS: 272500 qpcNow: 3801575 qpc: 3801667 25-09-2010 22:11:54.975 [ 1464] TS: 274166 qpcNow: 3803236 qpc: 3803366 25-09-2010 22:11:54.975 [ 1464] TS: 278541 qpcNow: 3807707 qpc: 3807860 25-09-2010 22:11:54.975 [ 1464] TS: 279166 qpcNow: 3808412 qpc: 3808512 25-09-2010 22:11:54.976 [ 9ac] TS: 281458 qpcNow: 3810602 qpc: 3810708 25-09-2010 22:11:54.977 [ 9ac] TS: 298750 qpcNow: 3827593 qpc: 3828076 25-09-2010 22:11:54.977 [ 9ac] TS: 300000 qpcNow: 3829097 qpc: 3829195 25-09-2010 22:11:54.977 [ 9ac] TS: 300833 qpcNow: 3830057 qpc: 3830145 25-09-2010 22:11:54.978 [ 59c] TS: 302916 qpcNow: 3831970 qpc: 3832088 25-09-2010 22:11:54.978 [ 1464] TS: 305000 qpcNow: 3834107 qpc: 3834268 25-09-2010 22:11:54.978 [ 1464] TS: 305833 qpcNow: 3834906 qpc: 3835023 25-09-2010 22:11:54.981 [ 9ac] TS: 337083 qpcNow: 3866139 qpc: 3866442 25-09-2010 22:11:54.981 [ d58] TS: 337916 qpcNow: 3867048 qpc: 3867148 25-09-2010 22:11:54.981 [ 9ac] TS: 338333 qpcNow: 3867602 qpc: 3867694 25-09-2010 22:11:54.981 [ 9ac] TS: 339166 qpcNow: 3868402 qpc: 3868493 25-09-2010 22:11:54.981 [ 59c] TS: 339791 qpcNow: 3869007 qpc: 3869100 25-09-2010 22:11:54.981 [ d58] TS: 340416 qpcNow: 3869649 qpc: 3869742 25-09-2010 22:11:54.982 [ 1464] TS: 344375 qpcNow: 3873601 qpc: 3873730 25-09-2010 22:11:54.982 [ 1464] TS: 345000 qpcNow: 3874273 qpc: 3874369 25-09-2010 22:11:54.982 [ 1464] TS: 347916 qpcNow: 3877077 qpc: 3877187 25-09-2010 22:11:54.982 [ 1464] TS: 348333 qpcNow: 3877600 qpc: 3877693 25-09-2010 22:11:54.983 [ 1464] TS: 351458 qpcNow: 3880364 qpc: 3880635 25-09-2010 22:11:54.983 [ 1464] TS: 352083 qpcNow: 3881237 qpc: 3881332 25-09-2010 22:11:54.983 [ 1464] TS: 355208 qpcNow: 3884276 qpc: 3884386 25-09-2010 22:11:54.984 [ ea8] TS: 369166 qpcNow: 3898233 qpc: 3898457 25-09-2010 22:11:54.985 [ ea8] TS: 373333 qpcNow: 3902471 qpc: 3902614 25-09-2010 22:11:54.985 [ ea8] TS: 374166 qpcNow: 3903242 qpc: 3903341 25-09-2010 22:11:54.985 [ 9ac] TS: 375208 qpcNow: 3904262 qpc: 3904367 25-09-2010 22:11:54.986 [ 9ac] TS: 380833 qpcNow: 3909881 qpc: 3910166 25-09-2010 22:11:54.986 [ 9ac] TS: 381875 qpcNow: 3911050 qpc: 3911152 25-09-2010 22:11:54.986 [ 59c] TS: 382708 qpcNow: 3911842 qpc: 3911944 25-09-2010 22:11:54.987 [ 9ac] TS: 391666 qpcNow: 3920744 qpc: 3921027 25-09-2010 22:11:54.992 [ 59c] TS: 441875 qpcNow: 3970778 qpc: 3971160 25-09-2010 22:11:54.996 [ 59c] TS: 488541 qpcNow: 4017502 qpc: 4017843 25-09-2010 22:11:54.996 [ 59c] TS: 490208 qpcNow: 4019351 qpc: 4019468 [/code] [/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