[mythtv] vsync and frame timing adjustments

Daniel Thor Kristjansson danielk at cat.nyu.edu
Wed Aug 25 13:54:06 EDT 2004

The structure of the XvMC library would seem to indicate it. I believe
each XvMCSurface is basically independent, except for P&B frames
needing other I&P frames of course, but this is taken care of in
DrawSlice, which is in another thread. I have don't how this would
effect other display methods.

We would need to add a XvMCFlushSurface on the osd surface in ProcessFrame
(labeled 8 below) for seperating ProcessFrame() and PrepareFrame() in
time to have any effect.

Here's the flow when rendering osd with an nVidia card:

get global lock
1  XvMCSyncSurface()          sync previous I, P & B frames
2  XvMCRenderSurface()        add new ffmpeg data to XvMC queue
3  XvMCFlushSurface()         flush ffmpeg data to video card
                              (it now begins rendering the frame)
release global lock

get global lock
4  XvMCCompositeSubpicture()  add new subpicture (osd) to XvMC queue
5  XvMCSyncSubpicture()       flush subpicture to video card,
                              and sleep in this thread until done
6  GetNextFreeFrame()         wait for the next free XvMCSurface
7  XvMCBlendSubpicture2()     wait until drawslice's surface is finished
                              rendering (implicit XvMCSyncSurface), then
                              composite drawslice's surface with subsurface,
                              this is saved into the new XvMCSurface (osd surface)
8   We should probably issue a XvMCFlushSurface() here on osd surface....
release global lock

get global lock
9    XvMCSyncSurface()        wait until osd surface has finished compositing
release global lock

get global lock
10 XvMCPutSurface()           wait until drawslice's surface is finished
                              rendering (implicit XvMCSyncSurface), then
                              show the surface on screen
11 XvMCGetSurfaceStatus()     looped until surface is actually on screen
                              (wait until vsync?)
12 DiscardFrame()             discard the osd surface if it was created.
release global lock

More information about the mythtv-dev mailing list