Accellent (DVDVideo API reverse engineering) v0.1 from 11/04/2005

Hi.

This is a program that talks to the low-level DVDVideo library in order to play back MPEG-2 files. This is desirable because that library can use the hardware acceleration in the Mac's graphics card to help with the inverse discrete cosine transform calculations, as well as the motion compensation copies that are a big part of displaying MPEG-2.

The DVDPlayback API is a high-level public Apple API that allows you to play back MPEG-2 files with hardware acceleration. However, they first must be massaged into a VOB and put inside the file structure of a DVD. The DVD structure can be on a hard disk - not just a DVD disc - but it is still unfeasible for many applications, especially broadcast digital TV (i.e. DVB or ATSC, aka HDTV to Americans), since the full contents of the DVD must be present when DVDPlayback opens it. Also, the DVD specifications themselves are closed, although they have been reverse engeineered to a great extent. Anyway, massaging files to look like DVDs just for benefit of an unnecessarily limited API is a major pain and just plain stupid.

The DVDVideo library is one of Apple's private libraries with a closed API. It is the next layer down that DVDPlayback uses to get the video part of its job done. I have tried for almost two years through many different channels, direct and indirect, to obtain information on using it, but nothing has ever come of my enquiries. It is particularly frustrating that IDCT hardware acceleration APIs are public in both Windows (DXVA) and Linux (XVMC). So now I have given up waiting, taken matters into my own hands, and reverse-engineered the API to it.

Anyway, enough blurb, onto the release notes:

This release is just a proof of concept! There are no niceties like correctly-sized windows, resizable windows, scrubbing/seeking or anything of that nature.

To use Accellent, first go and get ffmpeg and copy the files in the libavcodec directory over the top of the ffmpeg ones. Then make ffmpeg. See what.txt for gotchas.

Now compile Accellent.xcode. At the top of main.mm there are some compile-time flags you can fiddle with, but I suggest that you don't initially. You may have to add an include path for libavcodec to the project if it doesn't find avcodec.h and friends.

When you have built the application, to play back an MPEG-2 program stream (e.g. recording from DVB or ATSC, VOB from a DVD, or other MPEG-2 file) simply drag the file onto the Accellent.app icon. You can also specify the file to open on the command line.

Accellent outputs lots of info to the command line, and I'd recommend using it from Terminal so you can see what's going on.

The best I've got it to play so far is some big 720p, that the network calls HD. 1080i is still locking up. Rough timings from my initial tests with 720p on one 1.25GHz G4 CPU are:
MPlayer OS X 2 b6: 75% CPU
iTele v0.5.8b1: 47% CPU
Accellent v0.1: 25% CPU

Of course Accellent is not outputting audio but I wouldn't expect that to account for the full discrepancy.

If you don't see similar results, try modifying the 'UseGPUDVDDriver' key in '/System/Library/PrivateFrameworks/DVD.framework/Resources/Info.plist'. Mine was set to false so I set it to true. I'm not at all sure if it has any effect, or if I'm actually using any IDCT hardware at all(!) but at the very least the work here is a step in the right direction, and it certainly does appear to be faster. The next API layer down is quite similar. It's called DVDDriver and I _know_ that's using the GPU. But hopefully we won't have to go there.


This release is distributed only in source for two reasons:
1. It's a lot smaller and I am out of web space.
2. I want to limit it to people who know how to compile at this stage, because:
3. It has the potential to lock up or kernel panic your machine if you encounter a bug.

Also, the sources are the only documentation. I did consider writing up a bit of the wheres and hows of the reverse engineering process here (hint: figuring out the format of the input to DVDVideoDecode was the hardest bit :), but I want to gauge the general reaction to the release first. And probably no-one wants to hear any of that stuff anyway, they just want it to work :)


Enjoy!

{P^/
