MediaPortal Audio renderer - better video playback quality (4 Viewers)

disaster123

MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: MediaPortal Audio renderer - better video playback quality

    Since v13 while watching livetv audio and video are heavily drifting away. 1s after 1-2 min but with v12 everything is fine.
     

    davidf

    Retired Team Member
  • Premium Supporter
  • April 3, 2006
    796
    348
    Scotland
    Home Country
    Scotland Scotland
    You can either ignore the first x samples or weight the totalling to give more weight to later samples - this would bring the aud sys drift to it's steady state quite quickly rather than just have it tend towards it as it does now.

    I guess this could explain a bit of the A/V sync drifting, but not the constant drift that I see on my HTPC.

    I think the reason for the constant drifting must be the v-sync adjustments the EVR presenter is requesting. There is currently no real correlation how long the reference clock calculation and the audio resampling is done. Both are running on their own. It will be quite hard to make the audio resampling to pass the real modified time to the reference clock (or actually the time is easy to pass...) Currently I can see that some X rate was used to resample xx ms of audio, but I have no clue (yet at least) how the reference clock should take that into account.


    I think the drifting is something basic (at least it will be after you figure it).

    Logically there isn't too much too it:
    1. Real refresh rate doesn't match source refreshrate : catered for by bias
    2. Synching at wrong point in refresh : uses 1.003,1,0.997 adjustment to move vsynch position should be less than 10ms or so total.
    3. Clock drift - the unknown. For you 173 ms per hour from the logs you sent based on multiplier. Does that sound like what you are seeing with the constant drift or is it out by a factor?

    Single clock solution and variables:

    possible errors in presenter refresh calcs : unlikely as 6 samples from 8 used, possible error low (would need to be out by more than 2000 nano seconds for 5 ms drift)
    moving synch point - should be ignoreable as will be under 1 frame (good test as shouldn't be noticeable if drop it from the equation). However if this isn't working properly then it will cause drift.
    clock drift - turns out to be quite hard as this is where it all happens together :)

    Maximum allowed multiplier error for 1 frame per hour synch loss at 50fps : 1.0000055. 1.0000014 for 5ms. This is a high level of accuracy given the variance seen in the logs, the variance is above this even after 30 seconds of samples.

    Possible correction mechanisms / debug mechanisms

    Stream time? Both parts should know where they are in the stream or be able to provide a reasonable approximation - is this true? Would something else be need to determine stream position.
    Can't think of much else. Would be really useful to know the actual drift rate on a machine to validate the calculations.


    Problem How to validate accuracy of calculations?
    HwCLock AudClock calculated_Clock Bias Adjustment AudClockDrift AudioStreamMultiplier StreamPosition

    HwCLock - available (not contiguous across threads? or is this a result of logging) I'll check this statement when I go back home.
    AudClock - available but not contiguous (monotonic)
    calculated_Clock - a result of the adjustment figures
    Bias - Calculated as a result of the framerate
    Adjustment (0.997,1,1.003) - should only be used for initial adjustment to vsync then have a net of zero (very minor corrections)
    AudClockDrift - calculated by taking drift between harware and Audio Clocks
    AudioStreamMultiplier - Bias * Adjustment * AudClockDrift
    Stream Position - Current Stream Position

    At any point audio consumed should = nFramesProcessed*streamFrameRate + time since last paint
    both of these should be available (possibly not at the same time) and could be used to limit the potential errors which are present. All the calculations are proactive (trying to anticpate the problem) and something is needed to be reactive (react to errors is the calculations). If the calculations are accurate then the reactive should not occur, the reactive could limit errors to a few ms (I still reckon something obvious is wrong as the drifting seems too high but this might be due to scrubbing in the first few seconds)

    Perfect Playback:
    1 Frame per display Refresh
    Audio Resampled at AudioStreamMultiplier rate OR calculated_Clock used in place of AudioClock

    This won't work for TV if framerate != displayrate


    Another silly question as I've not looked at the renderer code why do the threads each appear to have there own multiplier (last number as I put it in Excel)?


    Code:
    28/09/2010 22:38:34.685 [1408] 1.000470
    28/09/2010 22:38:34.685 [1408] 1.000473
    28/09/2010 22:38:34.686  [fa0] 1.000048
    28/09/2010 22:38:34.686 [1408] 1.000483
    28/09/2010 22:38:34.686 [1408] 1.000486
    28/09/2010 22:38:34.686 [1408] 1.000488
    28/09/2010 22:38:34.689  [fa0] 1.000048
    qpc vs hw overall = 1.00005933 or 20ms total adjustment over 30 seconds


    BTW v13 has sudden synch issues.
     

    red5goahead

    MP Donator
  • Premium Supporter
  • November 24, 2007
    695
    144
    Italy, North West
    Home Country
    Italy Italy
    Imho we need a test file for a/v synch issues , A long video with some kind of led / messages and beep sound synchronized and avaiable in several format stereo and multichannel , avi, mkv container and dvd vobs. Try to make it this evening with virtualdub.
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Re: AW: MediaPortal Audio renderer - better video playback quality

    Since v13 while watching livetv audio and video are heavily drifting away. 1s after 1-2 min but with v12 everything is fine.

    Please check if it happens with the audio HW based reference clock setting disabled in the registry.
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Imho we need a test file for a/v synch issues , A long video with some kind of led / messages and beep sound synchronized and avaiable in several format stereo and multichannel , avi, mkv container and dvd vobs. Try to make it this evening with virtualdub.

    That would help, but it is still too time consuming for debugging needs.
     

    OnkelChris

    Retired Team Member
  • Premium Supporter
  • October 17, 2007
    764
    59
    Home Country
    Germany Germany
    AW: MediaPortal Audio renderer - better video playback quality

    I hope this helps a bit?! If not, just ignore :p

    I will try to give some feedback on the audiorenderer, but atm I'm running out of free time... :(

    Hardware: NVIDIA ION with NVIDIA HDMI Audio driver version 1.9.0.0 and Realtek Audio driver version 2.47 / 2.52

    WASAPI Test with:
    1. NVIDIA HDMI Out (NVIDIA High Definition Audio)
    2. Realtek Digital Output (Realtek High Definition Audio)

    NVIDIA HDMI version 1.9.0.0
    WASAPI_test.exe --device "NVIDIA HDMI Out (NVIDIA High Definition Audio)"

    EXCLUSIVE: off EVENT DRIVEN: off
    -------------------------------------------------------------------------
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 24 2 288000 6 1 0 - Format works ok
    48000 24 2 288000 6 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 1 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 32 2 384000 8 3 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok

    EXCLUSIVE: on EVENT DRIVEN: off
    -------------------------------------------------------------------------
    44100 16 1 88200 2 1 0 - Format works ok
    44100 24 1 132300 3 1 0 - Format works ok
    44100 16 2 176400 4 1 0 - Format works ok
    44100 16 2 176400 4 65534 22 16 3 - Format works ok
    44100 24 2 264600 6 1 0 - Format works ok
    44100 32 2 352800 8 65534 22 24 3 - Format works ok
    48000 16 1 96000 2 1 0 - Format works ok
    48000 24 1 144000 3 1 0 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 24 2 288000 6 1 0 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok

    EXCLUSIVE: off EVENT DRIVEN: on
    -------------------------------------------------------------------------
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 24 2 288000 6 1 0 - Format works ok
    48000 24 2 288000 6 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 1 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 32 2 384000 8 3 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok

    EXCLUSIVE: on EVENT DRIVEN: on
    -------------------------------------------------------------------------
    44100 16 1 88200 2 1 0 - Format works ok
    44100 24 1 132300 3 1 0 - Format works ok
    44100 16 2 176400 4 1 0 - Format works ok
    44100 16 2 176400 4 65534 22 16 3 - Format works ok
    44100 24 2 264600 6 1 0 - Format works ok
    44100 32 2 352800 8 65534 22 24 3 - Format works ok
    48000 16 1 96000 2 1 0 - Format works ok
    48000 24 1 144000 3 1 0 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 24 2 288000 6 1 0 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok

    AC3 - EXCLUSIVE: on EVENT DRIVEN: off
    -------------------------------------------------------------------------

    AC3 - EXCLUSIVE: on EVENT DRIVEN: on
    -------------------------------------------------------------------------


    WASAPI-test.exe version: 3 tested: 2526 ok: 42

    Realtek Digital Out version 2.47
    WASAPI_test.exe --device "Realtek Digital Output (Realtek High Definition Audio)"

    EXCLUSIVE: off EVENT DRIVEN: off
    -------------------------------------------------------------------------
    48000 16 1 96000 2 1 0 - Format works ok
    48000 16 1 96000 2 65534 22 16 4 - Format works ok
    48000 24 1 144000 3 1 0 - Format works ok
    48000 24 1 144000 3 65534 22 24 4 - Format works ok
    48000 32 1 192000 4 65534 22 24 4 - Format works ok
    48000 32 1 192000 4 1 0 - Format works ok
    48000 32 1 192000 4 65534 22 32 4 - Format works ok
    48000 32 1 192000 4 3 0 - Format works ok
    48000 32 1 192000 4 65534 22 32 4 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 24 2 288000 6 1 0 - Format works ok
    48000 24 2 288000 6 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 1 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 32 2 384000 8 3 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 16 4 384000 8 65534 22 16 51 - Format works ok
    48000 24 4 576000 12 65534 22 24 51 - Format works ok
    48000 32 4 768000 16 65534 22 24 51 - Format works ok
    48000 32 4 768000 16 65534 22 32 51 - Format works ok
    48000 32 4 768000 16 65534 22 32 51 - Format works ok
    48000 16 6 576000 12 65534 22 16 1551 - Format works ok
    48000 16 6 576000 12 65534 22 16 63 - Format works ok
    48000 24 6 864000 18 65534 22 24 1551 - Format works ok
    48000 24 6 864000 18 65534 22 24 63 - Format works ok
    48000 32 6 1152000 24 65534 22 24 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 24 63 - Format works ok
    48000 32 6 1152000 24 65534 22 32 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 32 63 - Format works ok
    48000 32 6 1152000 24 65534 22 32 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 32 63 - Format works ok
    48000 16 8 768000 16 65534 22 16 1599 - Format works ok
    48000 16 8 768000 16 65534 22 16 255 - Format works ok
    48000 24 8 1152000 24 65534 22 24 1599 - Format works ok
    48000 24 8 1152000 24 65534 22 24 255 - Format works ok
    48000 32 8 1536000 32 65534 22 24 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 24 255 - Format works ok
    48000 32 8 1536000 32 65534 22 32 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 32 255 - Format works ok
    48000 32 8 1536000 32 65534 22 32 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 32 255 - Format works ok

    EXCLUSIVE: on EVENT DRIVEN: off
    -------------------------------------------------------------------------
    44100 16 2 176400 4 1 0 - Format works ok
    44100 16 2 176400 4 65534 22 16 3 - Format works ok
    44100 32 2 352800 8 65534 22 24 3 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    96000 16 2 384000 4 1 0 - Format works ok
    96000 16 2 384000 4 65534 22 16 3 - Format works ok
    96000 32 2 768000 8 65534 22 24 3 - Format works ok

    EXCLUSIVE: off EVENT DRIVEN: on
    -------------------------------------------------------------------------
    48000 16 1 96000 2 1 0 - Format works ok
    48000 16 1 96000 2 65534 22 16 4 - Format works ok
    48000 24 1 144000 3 1 0 - Format works ok
    48000 24 1 144000 3 65534 22 24 4 - Format works ok
    48000 32 1 192000 4 65534 22 24 4 - Format works ok
    48000 32 1 192000 4 1 0 - Format works ok
    48000 32 1 192000 4 65534 22 32 4 - Format works ok
    48000 32 1 192000 4 3 0 - Format works ok
    48000 32 1 192000 4 65534 22 32 4 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 24 2 288000 6 1 0 - Format works ok
    48000 24 2 288000 6 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 1 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 32 2 384000 8 3 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 16 4 384000 8 65534 22 16 51 - Format works ok
    48000 24 4 576000 12 65534 22 24 51 - Format works ok
    48000 32 4 768000 16 65534 22 24 51 - Format works ok
    48000 32 4 768000 16 65534 22 32 51 - Format works ok
    48000 32 4 768000 16 65534 22 32 51 - Format works ok
    48000 16 6 576000 12 65534 22 16 1551 - Format works ok
    48000 16 6 576000 12 65534 22 16 63 - Format works ok
    48000 24 6 864000 18 65534 22 24 1551 - Format works ok
    48000 24 6 864000 18 65534 22 24 63 - Format works ok
    48000 32 6 1152000 24 65534 22 24 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 24 63 - Format works ok
    48000 32 6 1152000 24 65534 22 32 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 32 63 - Format works ok
    48000 32 6 1152000 24 65534 22 32 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 32 63 - Format works ok
    48000 16 8 768000 16 65534 22 16 1599 - Format works ok
    48000 16 8 768000 16 65534 22 16 255 - Format works ok
    48000 24 8 1152000 24 65534 22 24 1599 - Format works ok
    48000 24 8 1152000 24 65534 22 24 255 - Format works ok
    48000 32 8 1536000 32 65534 22 24 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 24 255 - Format works ok
    48000 32 8 1536000 32 65534 22 32 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 32 255 - Format works ok
    48000 32 8 1536000 32 65534 22 32 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 32 255 - Format works ok

    EXCLUSIVE: on EVENT DRIVEN: on
    -------------------------------------------------------------------------
    44100 16 2 176400 4 1 0 - Format works ok
    44100 16 2 176400 4 65534 22 16 3 - Format works ok
    44100 32 2 352800 8 65534 22 24 3 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    96000 16 2 384000 4 1 0 - Format works ok
    96000 16 2 384000 4 65534 22 16 3 - Format works ok
    96000 32 2 768000 8 65534 22 24 3 - Format works ok

    AC3 - EXCLUSIVE: on EVENT DRIVEN: off
    -------------------------------------------------------------------------
    48000 16 2 192000 4 146 0 - Format works ok

    AC3 - EXCLUSIVE: on EVENT DRIVEN: on
    -------------------------------------------------------------------------
    48000 16 2 192000 4 146 0 - Format works ok


    WASAPI-test.exe version: 3 tested: 2526 ok: 106

    Realtek Digital Out version 2.52
    WASAPI_test.exe --device "Realtek Digital Output (Realtek High Definition Audio)"

    EXCLUSIVE: off EVENT DRIVEN: off
    -------------------------------------------------------------------------
    48000 16 1 96000 2 1 0 - Format works ok
    48000 16 1 96000 2 65534 22 16 4 - Format works ok
    48000 24 1 144000 3 1 0 - Format works ok
    48000 24 1 144000 3 65534 22 24 4 - Format works ok
    48000 32 1 192000 4 65534 22 24 4 - Format works ok
    48000 32 1 192000 4 1 0 - Format works ok
    48000 32 1 192000 4 65534 22 32 4 - Format works ok
    48000 32 1 192000 4 3 0 - Format works ok
    48000 32 1 192000 4 65534 22 32 4 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 24 2 288000 6 1 0 - Format works ok
    48000 24 2 288000 6 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 1 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 32 2 384000 8 3 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 16 3 288000 6 65534 22 16 7 - Format works ok
    48000 24 3 432000 9 65534 22 24 7 - Format works ok
    48000 32 3 576000 12 65534 22 24 7 - Format works ok
    48000 32 3 576000 12 65534 22 32 7 - Format works ok
    48000 32 3 576000 12 65534 22 32 7 - Format works ok
    48000 16 4 384000 8 65534 22 16 51 - Format works ok
    48000 24 4 576000 12 65534 22 24 51 - Format works ok
    48000 32 4 768000 16 65534 22 24 51 - Format works ok
    48000 32 4 768000 16 65534 22 32 51 - Format works ok
    48000 32 4 768000 16 65534 22 32 51 - Format works ok
    48000 16 5 480000 10 65534 22 16 0 - Format works ok
    48000 24 5 720000 15 65534 22 24 0 - Format works ok
    48000 32 5 960000 20 65534 22 24 0 - Format works ok
    48000 32 5 960000 20 65534 22 32 0 - Format works ok
    48000 32 5 960000 20 65534 22 32 0 - Format works ok
    48000 16 6 576000 12 65534 22 16 1551 - Format works ok
    48000 16 6 576000 12 65534 22 16 63 - Format works ok
    48000 24 6 864000 18 65534 22 24 1551 - Format works ok
    48000 24 6 864000 18 65534 22 24 63 - Format works ok
    48000 32 6 1152000 24 65534 22 24 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 24 63 - Format works ok
    48000 32 6 1152000 24 65534 22 32 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 32 63 - Format works ok
    48000 32 6 1152000 24 65534 22 32 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 32 63 - Format works ok
    48000 16 7 672000 14 65534 22 16 0 - Format works ok
    48000 24 7 1008000 21 65534 22 24 0 - Format works ok
    48000 32 7 1344000 28 65534 22 24 0 - Format works ok
    48000 32 7 1344000 28 65534 22 32 0 - Format works ok
    48000 32 7 1344000 28 65534 22 32 0 - Format works ok
    48000 16 8 768000 16 65534 22 16 1599 - Format works ok
    48000 16 8 768000 16 65534 22 16 255 - Format works ok
    48000 24 8 1152000 24 65534 22 24 1599 - Format works ok
    48000 24 8 1152000 24 65534 22 24 255 - Format works ok
    48000 32 8 1536000 32 65534 22 24 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 24 255 - Format works ok
    48000 32 8 1536000 32 65534 22 32 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 32 255 - Format works ok
    48000 32 8 1536000 32 65534 22 32 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 32 255 - Format works ok

    EXCLUSIVE: on EVENT DRIVEN: off
    -------------------------------------------------------------------------
    44100 16 2 176400 4 1 0 - Format works ok
    44100 16 2 176400 4 65534 22 16 3 - Format works ok
    44100 32 2 352800 8 65534 22 24 3 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    96000 16 2 384000 4 1 0 - Format works ok
    96000 16 2 384000 4 65534 22 16 3 - Format works ok
    96000 32 2 768000 8 65534 22 24 3 - Format works ok

    EXCLUSIVE: off EVENT DRIVEN: on
    -------------------------------------------------------------------------
    48000 16 1 96000 2 1 0 - Format works ok
    48000 16 1 96000 2 65534 22 16 4 - Format works ok
    48000 24 1 144000 3 1 0 - Format works ok
    48000 24 1 144000 3 65534 22 24 4 - Format works ok
    48000 32 1 192000 4 65534 22 24 4 - Format works ok
    48000 32 1 192000 4 1 0 - Format works ok
    48000 32 1 192000 4 65534 22 32 4 - Format works ok
    48000 32 1 192000 4 3 0 - Format works ok
    48000 32 1 192000 4 65534 22 32 4 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 24 2 288000 6 1 0 - Format works ok
    48000 24 2 288000 6 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    48000 32 2 384000 8 1 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 32 2 384000 8 3 0 - Format works ok
    48000 32 2 384000 8 65534 22 32 3 - Format works ok
    48000 16 3 288000 6 65534 22 16 7 - Format works ok
    48000 24 3 432000 9 65534 22 24 7 - Format works ok
    48000 32 3 576000 12 65534 22 24 7 - Format works ok
    48000 32 3 576000 12 65534 22 32 7 - Format works ok
    48000 32 3 576000 12 65534 22 32 7 - Format works ok
    48000 16 4 384000 8 65534 22 16 51 - Format works ok
    48000 24 4 576000 12 65534 22 24 51 - Format works ok
    48000 32 4 768000 16 65534 22 24 51 - Format works ok
    48000 32 4 768000 16 65534 22 32 51 - Format works ok
    48000 32 4 768000 16 65534 22 32 51 - Format works ok
    48000 16 5 480000 10 65534 22 16 0 - Format works ok
    48000 24 5 720000 15 65534 22 24 0 - Format works ok
    48000 32 5 960000 20 65534 22 24 0 - Format works ok
    48000 32 5 960000 20 65534 22 32 0 - Format works ok
    48000 32 5 960000 20 65534 22 32 0 - Format works ok
    48000 16 6 576000 12 65534 22 16 1551 - Format works ok
    48000 16 6 576000 12 65534 22 16 63 - Format works ok
    48000 24 6 864000 18 65534 22 24 1551 - Format works ok
    48000 24 6 864000 18 65534 22 24 63 - Format works ok
    48000 32 6 1152000 24 65534 22 24 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 24 63 - Format works ok
    48000 32 6 1152000 24 65534 22 32 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 32 63 - Format works ok
    48000 32 6 1152000 24 65534 22 32 1551 - Format works ok
    48000 32 6 1152000 24 65534 22 32 63 - Format works ok
    48000 16 7 672000 14 65534 22 16 0 - Format works ok
    48000 24 7 1008000 21 65534 22 24 0 - Format works ok
    48000 32 7 1344000 28 65534 22 24 0 - Format works ok
    48000 32 7 1344000 28 65534 22 32 0 - Format works ok
    48000 32 7 1344000 28 65534 22 32 0 - Format works ok
    48000 16 8 768000 16 65534 22 16 1599 - Format works ok
    48000 16 8 768000 16 65534 22 16 255 - Format works ok
    48000 24 8 1152000 24 65534 22 24 1599 - Format works ok
    48000 24 8 1152000 24 65534 22 24 255 - Format works ok
    48000 32 8 1536000 32 65534 22 24 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 24 255 - Format works ok
    48000 32 8 1536000 32 65534 22 32 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 32 255 - Format works ok
    48000 32 8 1536000 32 65534 22 32 1599 - Format works ok
    48000 32 8 1536000 32 65534 22 32 255 - Format works ok

    EXCLUSIVE: on EVENT DRIVEN: on
    -------------------------------------------------------------------------
    44100 16 2 176400 4 1 0 - Format works ok
    44100 16 2 176400 4 65534 22 16 3 - Format works ok
    44100 32 2 352800 8 65534 22 24 3 - Format works ok
    48000 16 2 192000 4 1 0 - Format works ok
    48000 16 2 192000 4 65534 22 16 3 - Format works ok
    48000 32 2 384000 8 65534 22 24 3 - Format works ok
    96000 16 2 384000 4 1 0 - Format works ok
    96000 16 2 384000 4 65534 22 16 3 - Format works ok
    96000 32 2 768000 8 65534 22 24 3 - Format works ok

    AC3 - EXCLUSIVE: on EVENT DRIVEN: off
    -------------------------------------------------------------------------
    44100 16 2 176400 4 146 0 - Format works ok
    48000 16 2 192000 4 146 0 - Format works ok

    AC3 - EXCLUSIVE: on EVENT DRIVEN: on
    -------------------------------------------------------------------------
    44100 16 2 176400 4 146 0 - Format works ok
    48000 16 2 192000 4 146 0 - Format works ok


    WASAPI-test.exe version: 3 tested: 2526 ok: 138
     

    davidf

    Retired Team Member
  • Premium Supporter
  • April 3, 2006
    796
    348
    Scotland
    Home Country
    Scotland Scotland
    Initial Log Data

    Code:
            Duration      hwClockDrift  Requested_Adjustment Actual Adjustment calculated_clock_error Adjustment_from_EVR time_Adjustments_in_effect
    TS:     00:00:33.476  19735         1.00004900           1.00005974         266                    13746                26847294
    DVD:    00:01:15.518  44092         1.00005832           1.00005868         117                    4                       23542
    BluRay: 00:01:03.216  36865         1.00010395           1.00005828         230                    1110                 22521876

    just for info
    Adjustment_from_EVR is the number of times that the multiplier went above 1.002 or below 0.998
    time_Adjustments_in_effect is the hwClockDuration of the adjustment period
    Calculated CLock Error is the deviation of the calculated clock from the hwQpc (should deviate due to bias and adjustment but those aren't in the log)

    Assuming that the bias is 1.00000000 then it looks like the calculations are doing what is expected of them (drift would be under 1ms per hour ignoring that the adjustments should have had an effect and there isn't enough data to measure it). The fact that drift is happening must mean that the logic is wrong (low clock error would indicate not) or that part of it is being applied twice (doubt that too unless it is all being applied twice which would add the hwClockDrift to the calculated_clock_error).
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Unfortunately that data was gathered from the dev PC where the drifting is not happening (at least I haven't been able to reproduce it).

    Initial Log Data

    Code:
            Duration      hwClockDrift  Requested_Adjustment Actual Adjustment calculated_clock_error Adjustment_from_EVR time_Adjustments_in_effect
    TS:     00:00:33.476  19735         1.00004900           1.00005974         266                    13746                26847294
    DVD:    00:01:15.518  44092         1.00005832           1.00005868         117                    4                       23542
    BluRay: 00:01:03.216  36865         1.00010395           1.00005828         230                    1110                 22521876

    just for info
    Adjustment_from_EVR is the number of times that the multiplier went above 1.002 or below 0.998
    time_Adjustments_in_effect is the hwClockDuration of the adjustment period
    Calculated CLock Error is the deviation of the calculated clock from the hwQpc (should deviate due to bias and adjustment but those aren't in the log)

    EVR presenter's adjust shouldn't be responsible for the varying starting values, most likely the reason for that is the audio buffer value not increasing smoothly, but instead in blocks (10022, 40088). When we have only few ms of data the result will jump up and down because of that. At least this is what I think is the reason for the fluctuation in the beginning, before the multiplier settles down. I guess we could just filter out the first few seconds of audio buffer values (like you have proposed in the earlier posting). This woulnd't create more than few ns of drifting.

    29-09-2010 22:04:34.095 [ 14e8] mul: 1.0022216523 delta: 10022 - hwClock: 18707083 hwQpc: 12992271634707 qpc: 12992271634500 clock diff: 18674375 qpc diff: 18632979
    29-09-2010 22:04:34.099 [ 14e8] mul: 1.0022109647 delta: 40088 - hwClock: 18747291 hwQpc: 12992271675025 qpc: 12992271674602 clock diff: 18714583 qpc diff: 18673297

    Assuming that the bias is 1.00000000 then it looks like the calculations are doing what is expected of them (drift would be under 1ms per hour ignoring that the adjustments should have had an effect and there isn't enough data to measure it). The fact that drift is happening must mean that the logic is wrong (low clock error would indicate not) or that part of it is being applied twice (doubt that too unless it is all being applied twice which would add the hwClockDrift to the calculated_clock_error).

    Problem with the adjustment and possible (highly I would say) drifting it causes is quite nasty one. Currently we have no knowledge how much of audio data was slowed down or speeded up with the 1.003 / 0.997 multiplier. It depends on a random factor. We can see how long the EVR presenter was pushing the sync to up or down, but the audio resampling is done asynchronously compared to that, so with bad luck the audio might have been processed with the adjustment multiplier with 200 ms amoutn of data where as EVR presenter pushes only 50 ms correction time. The shorted the correction burst is the bigger the error will be.

    I'm currently checking on the HTPC if the adjusment is to blame (disabled it completely). If it is that then we need to figure out how to

    Can you see any open issues with the current code that could cause drifting? (I did commit few changes into SVN to allow those debug info to be displayed in ! stats).

    How should the current logic for reference clock calculation (assuming the current code is otherwise ok - at least the excel results look ok) be changed to take the adjustment into account? I can provide following kind of information quite easialy: xxx ms of audio stream was resampled into yyy ms. This would be done only when the adjustment is done, since if we do it for the bias as well I fear that we might be introducing some new drifting source again.

    Thanks already in the advance!
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Problem with the adjustment and possible (highly I would say) drifting it causes is quite nasty one. Currently we have no knowledge how much of audio data was slowed down or speeded up with the 1.003 / 0.997 multiplier. It depends on a random factor. We can see how long the EVR presenter was pushing the sync to up or down, but the audio resampling is done asynchronously compared to that, so with bad luck the audio might have been processed with the adjustment multiplier with 200 ms amoutn of data where as EVR presenter pushes only 50 ms correction time. The shorted the correction burst is the bigger the error will be.

    After 30 mins the audio was noticeably early on HTPC with the adjustment disabled. Next step is to disable the HW sourced reference clock, but it wont mostlikely help since I did see same drifting with v 12 as well.
     

    red5goahead

    MP Donator
  • Premium Supporter
  • November 24, 2007
    695
    144
    Italy, North West
    Home Country
    Italy Italy
    Imho we need a test file for a/v synch issues , A long video with some kind of led / messages and beep sound synchronized and avaiable in several format stereo and multichannel , avi, mkv container and dvd vobs. Try to make it this evening with virtualdub.

    That would help, but it is still too time consuming for debugging needs.

    Test_AvSynch.avi
    Test_AvSynch.avi - 4shared.com - file sharing - download movie file
    video 720x406 16:9 , 25 fps, Mpeg-4 / Xvid. Audio Ac3 2ch. 56 Kbps. 11 Mbyte.

    Builded with an AviSynth script in VirtualDub. For 15 minutes show an image every 3 seconds for 2 seconds and a noise sound synched to it. A unique multimedia file for everyone could be usefull to test a/v synch on several hw configuration.
     

    Users who are viewing this thread

    Top Bottom