i
i
i
i
i
i
i
i
16.7. Making a Stereo Movie from Image Sequences 473
declaration of a member variable of type CPushPinOnBSF
*
which is used
to store a pointer to the filter’s output pin. Most of the work of the filter
takes place in the output pin object. This has to provide functions to tell
the downstream filters what type of media they can expect (in our case it is
24-bit RGB bitmaps) and how big the connecting buffer (between filters) has
to be. Most importantly, it must have a method to fill the output buffer with the
bitmap pixels from the image sequence and provide correct timing information.
Listing 16.20 shows the structure of the two classes that encapsulate the
filter’s behavior. Listing 16.21 provides an overview of the class methods.
Listing 16.22 details the class method which pushes the bitmap image pix els
into the downstream filters.
For the overridden methods in the
CPushPinOnBSF class, some brief
comments are warranted:
•
CPushPinOnBSF::GetMediaType(). This method reports back on
the format of the samples being fed out of the filter. In this context, a
sample is a video frame. We want the samples to match the format of
the input bitmaps (from the file sequences), so we must have a bitmap
loaded before this method can execute. Since it is called only once,
as the graph starts executing, we load the first bitmap in the class’s
constructor m ethod.
•
CPushPinOnBSF::DecideBufferSize(). This method reports how
big the output sample buffer needs to be. For a video source filter,
the output sample buffer will need to hold the pixel image. So for a
24-bitRGBpixelformat,thisfunctionmustreportbackthatitneeds
w × h × 3 bytes, where w and h are the width and height of the input
bitmaps. (We are going to assume that all the bitmaps have the same
width and height.)
•
CPushPinOnBSF::FillBuffer(). This method does most of the work.
It has two primary duties:
1. To copy the image data from the left and right bitmaps into the
pin’s output buffer. It first copies the left image and then the
right. Our program will assume that the bitmap’s width must
be a power of two, and we are going to use left-over-right stereo
format. Consequently, these copies can be done as a block.
2. To inform the filter what the reference time of the frame is. The
reference time embedded in the AVI file allows a player to syn-