Laserdisc games and MPEG2 (or other video format)
written by Matt Ownby on July 12th, 2001

If you are thinking of replacing laserdiscs with other video formats such as
mpeg or AVI, you'd better know what you are getting yourself into.  I have
written this document to describe what I consider to be the absolute minimum
requirements for a fully functional laserdisc replacement and also to comment
on why these requirements are difficult to fulfil.

REQUIREMENTS:

- Must be able to seek to ANY arbitrary frame and render that frame upon
completion of seeking. *

- Seek times must take no longer than 2 seconds to any frame and should be less
than 0.5 seconds for short seeks.  This is a conservative estimate of how fast
the average laserdisc player is. **

- When "disc" is paused, must be able to begin playback instantly as soon as
a play command is sent. ***

- When playback begins, video and audio must both begin playing at the same
time and in sync.  Having one or the other start first is unacceptable. ****

--------------------

* - MPEG is composed of I, P, and B frames.  Only the I frame can be easily
seeked to.  Seeking to P and B frames requires seeking to the I frame, then
skipping forward until the desired frame is reached.  In my opinion, this
means modifying an open source mpeg player to add this functionality, since
all of the hardware mpeg decoders I've played with are PATHETICALLY inadequate
for this task.  Don't expect to find any closed source players with this kind
of functionality either.  I believe DIVX has the same problem.  I've heard
AVI doesn't.  In case you are questioning whether frame accurate seeking is
really necessary, the answer is definitely YES.  Don't bother trying to replace
a laserdisc with an mpeg if you can't provide frame accurate seeking.  It's
probably the most important feature.

** - MPEG is not designed for frame accurate seeking.  It's designed for
approximate seeking, and once again, only to an I frame.  My solution is to
pre-parse all mpeg files and create a lookup table of the position in the file
where each frame begins.  This gives us super fast seeking to any arbitrary
frame, but it does not overcome the I frame problem.  See my previous paragraph
for a possible solution to that problem.

*** - Most of the mpeg players I've used have a bit of lag when one issues
a play command.  This is no doubt because the programmers thought no one would
use it for anything other than watching movies.  I haven't made much effort in
solving this problem, but my guess at a solution would be to have the first
few frames after your current frame position to be buffered into memory.  And
that includes the audio stream (see next).

**** - Syncing the video and audio streams in MPEG is known to be a real pain.
I haven't touched this problem very much (yet) and since I don't know much about
mpeg audio (yet) I can't offer a good solution.  My theory at this point is to
decode the beginning of the audio stream (at the correct position) when a
seek to a frame is made, and buffer it somewhere.  Then when a play command
is received, you've already got the frames and the audio buffered and you can
begin playback.

--------------------------------------------------------------------

OPTIONAL FEATURES for a laserdisc replacement:

- Video overlay.  Some games do not use video overlay (Dragon's Lair, Space
Ace, Thayer's Quest, etc.) but most lasergames do have some kind of raster
video overlaid on top of laserdisc video.  And good luck finding a commercial
player or hardware mpeg decoder that lets you do this!  Once again, open source
is the only way to go.  Since newer video cards support YUV to RGB conversion
and scaling in hardware, my current solution has been to draw the video overlay
on top of the YUV frame before it goes to the video card for scaling.  It
works quite well.

- The ability to play at normal speed BACKWARD.  Yes, all laserdisc players
can do this.  But as far as I know, only one laserdisc game (Time Traveler)
actually takes advantage of this esoteric feature, and since it would be a
huge pain to code this up in mpeg (and take a lot of memory on top of that)
I am stashing it in the optional category.  I certainly don't plan on
tackling it!

- The ability to skip to a different frame and resume playback without dropping
any video or audio.  Some players could do this, and some games were designed
to take advantage of it.  The games that use this feature but can get by without
it are Super Don Quixote and Esh's Aurumnilla.  The game's that use this feature
and absolutely must have it functioning correctly are Firefox and
Freedom Fighter.
