Bink SDK 1.5v |
Bink is very different than other video codecs. Most noticeably, Bink doesn't plug into one of the monolithic video codec architectures. Instead, it stands on its own two feet, doing everything itself. While this is a little more work on the content creation side (you have to run the Bink tools and actually Bink the file), it is a huge win on the playback side - you just have to ship a single DLL, we can improve the codec much faster than the architectures are updated, we have more control over the various compression stages, we don't have to over-abstract video playback into playback of other media types, etc. Also because Bink stands on its own, we've also been able to create a clean, simple and streamlined way to playback videos. Instead of relying on complicated and difficult-to-debug callbacks or events, your application drives the Bink playback. That means that rather than calling a function like "Play" that goes away for ten minutes, you remain in control the entire time. For example, with Bink, you call a function to decompress a frame, then you call a function to move to the next frame, and then you wait until Bink says it's time to move to the next frame. While this sounds more complicated, it's actually much, much simpler. Let's look at an example. The basic code to open and close a Bink file looks like this (there will be subtle differences on a platform-basis, but this is the gist):
HBINK bink = BinkOpen( "mybink.bik", 0 );
// use the Bink handle to play the movie
BinkClose( bink );
Now that we've got a Bink handle to use, let's look at the basic playback loop:
while ( 1 ){ BinkDoFrame( bink );
// blit the frame onto the screen here (platform specific)
if ( bink->FrameNum == bink->Frames ) break; // done at the point else BinkNextFrame( bink ); // skip to the next frame
while ( BinkWait( bink ) ) do_idle(); // pump message loop, process other tasks - whatever}
So, basically, we decompress a frame with BinkDoFrame, we move to the next frame with BinkNextFrame, and finally, we wait until BinkWait says that it is time to move on. Pretty simple and you've haven't given up any control at all! This example didn't show the details of blitting the video pixels onto the screen, because that is fairly platform-specific and isn't all that different from any other codec. On Win32, we even supply a high-level blitting API (called the BinkBuffer API) that makes getting the pixels onto the screen completely painless.
Next Topic (Colorspace - RGB vs. YUV)
Previous Topic (Compressing with Bink)
Group:
Bink Overview
Related Functions:
BinkDoFrame, BinkNextFrame, BinkWait
For technical support, e-mail Bink1@radgametools.com
© Copyright 1994-2003 RAD Game Tools, Inc. All Rights Reserved.