[mythtv] Question on Xv output and NuppelVideoPlayer

Clyde Stubbs clyde at htsoft.com
Fri Jul 2 22:29:42 EDT 2004


On Fri, Jul 02, 2004 at 09:42:24PM -0400, Isaac Richards wrote:
> That's not the assumption at all.  The existing code assumes that XvPutImage 
> initiates the display of the image,

Good, at least we agree on that.

So, here's the code from ExAVSync:


        if (buffer)
            videoOutput->PrepareFrame(buffer);

        delay = UpdateDelay(&nexttrigger);

        if (hasvsync)
        {
            while (delay > 0)
            {
                vsync_wait_for_retrace();
                delay = UpdateDelay(&nexttrigger);
            }
            videoOutput->Show(m_scan);

The PrepareFrame call starts the display of the image; the actual display
will occur at the next vblank after both the Xserver and the video card
scaling hardware have completed their job. Next, the code waits for one or
more vertical blank interrupts. Consider this scenario:

Frame rate is 25Hz, e.g. 40ms per frame; refresh rate is 50Hz, 20ms per field.
Call the time of the last vblank M, and suppose the calculated ideal frame
display time (nextrigger) for that was M+2, so the new nexttrigger is M+42ms.

If this chunk of code is entered at say M+10ms, PrepareFrame/XvPutImage
is called right away. 10ms is easily enough time for the image to be
written and scaled, so the frame will appear at M+20ms - next vblank.
This is 22ms early. 

In the meantime, the code has looped around the while loop; the first time,
delay is 32ms. The wait for vblank is called, and returns at M+20, delay
is recalculated, and is now 12ms or thereabouts. So the loop is executed
again, waiting for another vblank. Finally Show is called, but by that time
the frame has already appeared (20ms earlier).

Now I know there is code elsewhere in the function that attempts to fudge
the nexttrigger time, and it may well be that it does a very good job
of compensating for the above scenario, but if the basic approach can be
improved that surely is a good thing.

Now, please comment on this scenario - if I've got anything wrong, please
say so, but an explanation of why would be much appreciated.

Cheers, Clyde


More information about the mythtv-dev mailing list