[MPlayer-dev-eng] NVidia AV frame sync

Ed Wildgoose lists at wildgooses.com
Thu Aug 12 09:53:19 CEST 2004


Joey Parrish wrote:

>On Thu, Aug 12, 2004 at 12:30:34AM +0100, Ed Wildgoose wrote:
>  
>
>>I have just been testing the method of using the nvidia device for 
>>syncing frame display in Mythtv.  This seems (at least for me) to give 
>>very accurate frame timing and a much smoother picture.
>>    
>>
>
>Can you explain this for those of us not familiar with "the nvidia
>device"?  Do some nvidia cards have hardware that aids in keeping sync?
>This seems strange, since A/V sync has a lot to do with your sound card,
>too.  Especially in MPlayer, where (IIRC) sync is based on audio timing.
>  
>

Sorry, assumed that the topic was better understood.

The relevant code has actually moved around recently in Myth, just 
looking myself to understand what was happening.  Code for vertical 
blanking sync now seems to have been abstracted into a seperate module 
in myth called libs/libmythtv/vsync.c - in there is a routine 
"vsync_wait_for_retrace", which does the magic.  (There is opengl 
framesync stuff in there as well)

The device is /dev/nvidia0 and /dev/nvidiactl, and whilst I am not clear 
on the specifics, I believe that the driver, at least on some versions, 
gives you access to info on the vertical retrace moment.

The algorithm in myth is a little bit more explicit than mplayer, they 
actually have seperate threads for audio and video decoding, and the 
video thread simply "waits" until some significant moment to put a frame 
on the display.  This event can either be purely based on the RTC or 
audio free space reporting, or if available, opengl/nvidia vertical 
retrace events can be used.  Obviously if you are waiting for vertical 
retrace events then you need to track some kind of frame deviation from 
the audio timer, and frame drop (or extend) where appropriate.

Mplayer is actually already very smooth for me, and I assume that this 
is down to a relaxed fashion in tracking frame timing (letting it vary a 
little within some tolerance)?  I think some of the reasons for the 
slight jitter from time to time are down to audio card that I am using 
which doesn't report exact free space, only whether it has consumed a 
whole buffer or not.  So the exact audio sync can not be maintained from 
the card results alone, only the time since we last fed the card data 
for example,

So the nvidia device can't be used for clocking the audio for sure, but 
only for assisting with frame dropping calculations to get the frame 
cadence as smooth as possible.  Actually I have taken the time to get a 
video mode with 50hz timing and it's already very smooth for me - 
perhaps this extra tweak is not worth the effort..?

Ed W




More information about the MPlayer-dev-eng mailing list