[INTEL NAVIGATION HEADER]

Programming Indeo® Video Interactive Using ICM Calls: Decompressing

If you are a multimedia application developer who wishes to include the advanced features of the Indeo® video interactive (IVI) codec into your 32­bit application, read this document. It explains what you need to know in order to control the playback parameters of the Indeo video interactive codec programmatically from the ICM interface, so that you can fully integrate features such as transparent video and local decode. This document assumes you are familiar with Video for Windows*.

Indeo video interactive is Intel's latest digital video capture, compression, and decompression software. The technology is based on a compressor-decompressor, or codec - a software driver used to compress digital video data for storage, and decompress it for playback on a multimedia PC. Indeo video interactive uses an efficient encoding algorithm and yields high quality images. It includes a wide variety of features designed for interactive multimedia applications, such as real-time video effects, access key file protection, local decode, alternate line zoom-by-two, and the ability to specify transparency for portions of a video frame.

These features go beyond those provided for by Video for Windows, and the standard Video for Windows Media Control Interface (MCI) is not capable of exercising them. To do so requires knowledge of the codec's internal state that is available only at the level of the Installable Compression Manager (ICM).

This document has four sections:

The ICM Interface to Indeo® Video Interactive
Introduces the two new messages that form the ICM interface between the multimedia application and the Indeo video interactive codec.

Codec States and Data Structures
Introduces the state structures used to pass information to and from the codec, and describes how to initialize them.

Changing Playback Parameters
Provides specific details and C source code examples for accessing and modifying individual decode parameters.

References
Points you to documents that provide detailed information on related topics, such as general video playback at the ICM level.

NOTE: For a complete application example, see the source code for IVIPlay, an example application that plays back video files, taking advantage of most of the special features provided by Indeo video interactive. (As of this writing, local decode is not included.) The executable and C source code is available in the file iviplay.exe, compressed as a self-extracting archive.



The ICM Interface to Indeo Video Interactive
The Indeo video interactive codec complies with Video for Windows codec standards. All ICM communication with the codec uses the ICSendMessage() function call, expanded with various ICM macros.

In order to access the codec's special features, Intel has introduced two new Indeo video-specific messages to use with the ICSendMessage() function: ICM_GETCODECSTATE and ICM_SETCODECSTATE. These two messages allow the calling application to retrieve and modify the state of the codec.

Instructions are provided in the Video for Windows specification for using the ICSendMessage() function. This document and the Indeo Video Interactive Video for Windows Programming Interface Specification (the file named vfw_head.htm and its accompanying documentation vfw_spec.htm) explain how to use these two new messages in order to access state information for the Indeo video interactive codec. Keep those documents handy as you read this one.


Codec States and Data Structures
The Indeo video interactive codec maintains two states while decoding: sequence state and frame state. Sequence state is the state of the codec during a sequence of decompression messages, and frame state is the state of the codec from one decompression message to the next.

Two predefined data structures represent these states: R4_DEC_SEQ_DATA represents sequence state and R4_DEC_FRAME_DATA represents frame state. They are described in the Indeo Video Interactive Video for Windows Programming Interface Specification (the file vfw_spec.htm) and defined in the file vfw_head.htm.

While decoding, you can examine or change the codec state by sending the message ICM_GETCODECSTATE or ICM_SETCODECSTATE by means of the ICSendMessage() function, passing as one of the parameters the address of one of these two predefined state structures.

Both data structures contain header members that your application initializes in the same way regardless of the operation to be performed, as well as other members whose initialization and use is operation-specific. The Decode Sequence Data Structure
The R4_DEC_SEQ_DATA data structure contains members that describe the state of the codec for sequences of decode operations. A sequence starts with either the message ICM_DECOMPRESS_BEGIN or ICM_DECOMPRESSEX_BEGIN and continues until the next such message (hereafter abbreviated as ICM_DECOMPRESS{EX}_BEGIN). You can change the sequence state of the codec at any point in a sequence, but the change has no effect until the next sequence begins with a subsequent ICM_DECOMPRESS{EX}_BEGIN message.

The following C code example demonstrates how to initialize the header members of the R4_DEC_SEQ_DATA structure before sending either ICM_GETCODECSTATE or ICM_SETCODECSTATE. (Initialize other members of this structure according to the type of action required, as detailed in the next section.)


    R4_DEC_SEQ_DATA            r4SeqState;

    r4SeqState.dwSize          = sizeof(R4_DEC_SEQ_DATA);
    r4SeqState.dwFourCC        = mmioFOURCC('I','V','4','1');
    r4SeqState.dwVersion       = SPECIFIC_INTERFACE_VERSION;
    r4SeqState.mtType          = MT_DECODE_SEQ_VALUE;
    r4SeqState.oeEnvironment   = OE_32;
    r4SeqState.dwFlags         = 0;

The Decode Frame Data Structure
The R4_DEC_FRAME_DATA data structure contains members that describe the state of the codec for decode operations. The codec incorporates changes to its frame state when it receives the next ICM_DECOMPRESS or ICM_DECOMPRESSEX message (hereafter abbreviated as ICM_DECOMPRESS{EX}).

The following C code example demonstrates how to initialize the header members of the R4_DEC_FRAME_DATA structure before sending either ICM_GETCODECSTATE or ICM_SETCODECSTATE. (Initialize other members of this structure according to the type of action required, as detailed in the next section.)


    R4_DEC_FRAME_DATA          r4FrmState;

    r4FrmState.dwSize          = sizeof(R4_DEC_FRAME_DATA);
    r4FrmState.dwFourCC        = mmioFOURCC('I','V','4','1');
    r4FrmState.dwVersion       = SPECIFIC_INTERFACE_VERSION;
    r4FrmState.mtType          = MT_DECODE_FRAME_VALUE;
    r4FrmState.oeEnvironment   = OE_32;
    r4FrmState.dwFlags         = 0;

Current and Default Codec State
In both the R4_DEC_SEQ_DATA and R4_DEC_FRAME_DATA structures, the member mtType indicates whether action is taken on the current or the default state of the codec. A value of MT_DECODE_FRAME_VALUE specifies actions taken on the current codec state, which we assume is the desired mode for your application. The other defined value, MT_DECODE_FRAME_DEFAULT, specifies that actions are taken on the default codec state.


Changing Playback Parameters

Before any operations such as those exemplified in the following code samples, you must initialize the header members of the decode data structures as shown in Codec States and Data Structures, above. All of the following examples assume operations are done on the current, not the default, codec state.

The examples below demonstrate how to use the messages ICM_GETCODECSTATE and ICM_SETCODECSTATE to get and set sequence or frame parameters. These examples all follow the same general pattern:

  1. Set dwFlags to specify the valid members of the structure. The dwFlags field must be OR'd with either DECSEQ_VALID or DECFRAME_VALID, whichever is appropriate.
  2. Assign a value to the variable or flag corresponding to the member or members in which you are interested.
  3. Send the message ICM_GETCODECSTATE to retrieve the state of that member, or the message ICM_SETCODECSTATE to modify its state.

NOTE: The hCodec parameter is a handle to an opened Indeo video interactive codec. Using these functions on other codecs produces unpredictable results.

Modifying the Decode Sequence Parameters
The following examples demonstrate how to use the ICM_SETCODECSTATE message to modify selected decode parameters. These examples all assume that the r4State variable was initialized prior to sending the message to the codec, as shown in the section above entitled "Codec States and Data Structures."

NOTE: For the sake of clarity, the examples below do not check return values for errors. Your application, however, needs to check all return values for errors.

Transparent Pixel Fill Method
Setting the fill method for transparent pixels determines whether the codec writes only the nontransparent pixels to the output buffer, or writes the transparent pixels also. This determines whether the user sees the nontransparent shape against a solid background written by the codec, as illustrated in Figure 1, or against a background supplied by the application, as illustrated in Figure 2.

Figure 1. Transparent Pixel Fill Method: Codec Writes Background

Figure 2. Transparent Pixel Fill Method: Application Writes Background

If the codec is not to write the transparent pixels, your application is responsible for the state of the buffer before the frame is decoded.

See Programming Indeo Video Interactive Using ICM Calls: Compressing for details on encoding options.


    HIC             hCodec;             /* handle to an opened IVI codec    */
    R4_DEC_SEQ_DATA r4State;            /* initialized sequence structure   */

    r4State.dwFlags = DECSEQ_FILL_TRANSPARENT | DECSEQ_VALID;

    r4State.fFillTransparentPixels = 1; /* enable transparent pixel fill    */

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_SEQ_DATA) );

Decode Scalability
The decode scalability parameter allows the application to control the quality scalability feature of the codec. Quality scalability allows Indeo video interactive to scale back image quality rather than drop frames if insufficient processor resource is available to decode all the compressed frame data within the time limit.

By default, the time limit is determined by the frame rate with which the video was encoded. If your application requires faster decoding, you can set a more stringent time limit using the message discussed in the section entitled "Setting the decode time limit," below.

Decode scalability is controlled with the eScalability field with one of the following:

  • SC_ON indicates normal scalable playback; the codec will drop a combination of bands and frames according to the current playback environment.
  • SC_OFF disables playback scalability entirely; no frames or bands will be dropped during playback.
  • SC_DONT_DROP_FRAMES instructs the codec to only drop bands if the playback environment dictates, but to not drop frames.
  • SC_DONT_DROP_BANDS instructs the codec to only drop frames if the playback environment dictates, but to not drop bands.

NOTE: Scalability modes which deal with band dropping effect only playback of those video clips that were encoded with scalability on. See Programming Indeo Video Interactive Using ICM Calls: Compressing for details on encoding options.


    HIC             hCodec;             /* handle to an opened IVI codec    */
    R4_DEC_SEQ_DATA r4State;            /* initialized sequence structure   */

    R4_SCALABILITY  eScalability;       /* the requested scalability mode,  */
                                        /*   one of SC_ON, SC_OFF,          */
                                        /*   SC_DONT_DROP_FRAMES,           */
                                        /*   or SC_DONT_DROP_QUALITY        */

    r4State.dwFlags      = DECSEQ_SCALABILITY | DECSEQ_VALID;
    r4State.eScalability = eScalability;

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_SEQ_DATA) );

Access Key Protection
This message allows an application to supply an access key for video clips that have been encoded with access key protection enabled. It has no effect on clips not encoded with the access key feature.

An access key must have a numeric value only. If a clip has been encoded with access key protection enabled and the proper access key is not supplied when decoding, the codec returns the error ICERR_ERROR as soon as it receives the next decompression message.


    HIC             hCodec;             /* handle to an opened IVI codec    */
    R4_DEC_SEQ_DATA r4State;            /* initialized sequence structure   */

    DWORD           dwKey;              /* the access key                   */

    r4State.dwFlags     = DECSEQ_KEY | DECSEQ_VALID;
    r4State.dwKey       = dwKey;
    r4State.fEnabledKey = 1;            /* enable access key                */

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_SEQ_DATA) );

Alternate Line Zoom-by-Two
Zoom-by-two is a codec feature allowing a video window to double in size when the user requests. This is ordinarily accomplished by drawing each pixel twice in both the x and the y direction. Alternate line zoom-by-two is an Indeo video interactive feature allowing another way to double the video window size: pixels are drawn twice in the x direction, but instead of doubling each pixel vertically, a horizontal line of black pixels is placed below every horizontal line of original video pixels. This method is somewhat quicker than doubling the pixels in both directions and can produce images of better quality with certain video clips.

NOTE: This feature is not supported with transparency and local decode. Also, if the user stretches the window manually after zooming using alternate lines, the rows of black pixels are also stretched, and the resulting image looks poor.


    HIC             hCodec;             /* handle to an opened IVI codec    */
    R4_DEC_SEQ_DATA r4State;            /* initialized sequence structure   */

    r4State.dwFlags = DECSEQ_ALT_LINE | DECSEQ_VALID;
    r4State.fAltLine = 1;               /* enable alt-line zoom-by-2        */

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_SEQ_DATA));

Modifying the decode frame parameters

Transparent Pixel Fill Color
The transparent pixel fill color is used to determine what color will be used when writing transparent pixels. By default, if the codec is to write the transparent pixels, then the fill color it uses is based on the method of encoding: black if encoded with the TM_BITMASK option, or one of the transparent colors if encoded with any other option. The fill color may also be specified at decode time via the dwFillColor field of the R4_DEC_FRAME_DATA structure. This field is used to specify a 24-bit RGB value for use as the fill color. The high order byte of this field should be set to 0, and the low order 3 bytes set to the required 8-bit R, G, and B values, respectively. To return to the default fill color, set the dwFillColor field to DECSEQ_FILL_UNDEFINED.

See Programming Indeo Video Interactive Using ICM Calls: Compressing for details on encoding options.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    r4State.dwFlags     = DECFRAME_FILL_COLOR | DECFRAME_VALID;
    r4State.dwFillColor = 0x0000ff00;   /* RGB( 0, 255, 0 )

    ICSendMessage( hCodec,ICM_SETCODECSTATE,
                   (DWORD)&r4State, (DWORD)sizeof(R4_DEC_FRAME_DATA));
                        

Custom Palette Configuration
A custom palette and dither level may be specified for use by the Indeo video interactive codec through the dwFirstPalIndex, dwLastPalIndex, prgbPalette, and dwDither fields. These options allow the user to specify a custom palette which has been optimized for their content, with no performance penalty, for the codec to use during playback.

To specify a custom palette, the address of the palette data must be supplied, as well as the indices of the first and last entries within the palette which are to be used. In addition, the same palette must subsequently be supplied to the codec via an ICDecompressSetPalette() procedure call before the palette will be used by the codec.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    LPRGBQUAD prgbq;                    /* a pointer to an array of RGBQUAD */
                                        /*   structures  containing the     */
                                        /*   custom palette.                */
    DWORD    dwFirstPalIndex;           /* index of the first entry         */
    DWORD    dwLastPalIndex;            /* index of the last entry          */

    r4State.dwFlags = DECFRAME_8BIT_CONFIG_PALETTE | DECFRAME_VALID;
    r4State.dwFirstPalIndex = dwFirstPalIndex;
    r4State.dwLastPalIndex  = dwLastPalIndex;
    r4State.prgbPalette     = prgbq;

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

To specify the dither level:


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    R4_DITHER eDither;                  /* the new dither value, one of OFF,*/
                                        /*   LOW, MEDIUM, or HIGH           */

    r4State.dwFlags = DECFRAME_8BIT_DITHER | DECFRAME_VALID;
    r4State.eDither = eDither;

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );
                

Setting the address of the transparency bounding rectangle

As shown in Figure 3, the bounding rectangle is the smallest rectangle that can contain the nontransparent pixels.

Figure 3. Bounding Rectangle of Nontransparent Figure

The application must specify the address of an R4_RECT structure to which the codec can return the origin, width, and height of the bounding rectangle in the last frame decoded: that is, which rectangular region of the frame was written over. This allows the application to repaint the background after the nontransparent shape has moved.

Once you have set the address of the bounding rectangle, the codec updates the bounding rectangle's position after each frame is decoded so that the application can continue to clean up the background as necessary.

If the codec returns all zeroes, no pixels were written in the last frame because the nontransparent shape did not appear.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    R4_RECT         r4Rect;             /* the update rectangle             */

    r4State.dwFlags = DECFRAME_BOUNDING_RECT | DECFRAME_VALID;

    r4State.pr4BoundingRect = &r4Rect  /* Supply the address of the rect   */

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );                

Setting the Address of the Transparency Bitmask
The Indeo video interactive codec can handle transparency while decoding frames, or the application can handle the transparency itself after frames have been decoded; in either case, however, you must specify how the transparency is to be handled. The Indeo video interactive codec can decode only video that was encoded using the Indeo video interactive codec with the transparency option enabled. It cannot decode transparent video generated by any other means.

If you decide to handle the transparency in your application, this message provides the codec with the address of memory in which to write a one­bit bitmask for the last frame decoded, and the address of a flag to be set if bitmask information is available. Enough memory must be allocated for one bit to represent each pixel of a frame. The bitmask specifies which areas of the frame have nontransparent video information: a value of zero means a pixel is transparent and a value of one means that it is not.

Each row must begin on a DWORD boundary, and the total number of bytes must be a multiple of four. If it isn't, round up to the nearest multiple of four. See vfw_spec.htm for further details./*


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    R4_RECT        r4DecodeRect;        /* the decode rect                  */
    R4_FLAG        fBitmask;            /* the bitmask update flag          */
    PTR_R4_BITMASK bmBitmask;           /* a pointer to memory allocated    */
                                        /*   for the bitmask                */

    r4State.dwFlags = DECFRAME_TRANS_BITMASK | DECFRAME_VALID;

    r4State.pfUpdatedTransparencyBitmask = &fBitmask
    r4State.pbmTransparencyBitmask       = pbmBitmask;

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );
                   

Input Transparency Bitmask
The input transparency bitmask allows the user to supply the codec with a foreground transparency bitmask for use during playback. The use of this bitmask by the codec depends on the content of the video it is being used with. If the video does not contain transparency, the bitmask is used as a transparency mask, where bits in the bitmask corresponding to pixels in the frame of video determine of the pixel is drawn: 1's indicate the pixel will be drawn; 0's indicate the pixel will not be drawn. If the video contains transparency, the bitmask is used in the opposite manner. bits in the bitmask corresponding to pixels in frames of video determine if a pixel is not drawn: 1's indicate the pixel will not be drawn; 0's indicate the pixel will be drawn.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    PTR_R4_BITMASK pbmInputBitmask;     /* a pointer to memory allocated    */
                                        /*   for the input bitmask          */

    r4State.dwFlags = DECFRAME_INPUT_TRANS_MASK | DECFRAME_VALID;

    r4State.pbmInputTransparencyBitmask = pbmInputBitmask;

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

If the user has requested a transparency mask be returned through the pfUpDatedTransparencyBitmask field, the codec will return a bitmask containing only those bits which were drawn if the sequence contained transparency. Otherwise, the codec will return 0 in pfUpdatedTransparencyBitmask, in which case the input mask was used as the transparency mask, and defines which pixels were written.

NOTE: The application may request that no frames be dropped during transparent video playback via the eScalability field of the R4_DEC_SEQ_DATA structure, discussed earlier in this document.

Setting the Decode Time Limit
The message below allows the application to specify the number of milliseconds in which the codec must decompress and color-convert the image. If a frame cannot be decoded in the time specified and scalability was not enabled during compression, the codec returns the error ICERR_DONTDRAW and Video for Windows or the application drops the frame. If quality scalability is on, image quality is reduced instead.

The milliseconds specified are wall clock milliseconds, not CPU cycles. The codec consults the system clock to determine the elapsed time.

If you set the time limit to zero, the codec uses the frame rate with which the video was encoded to determine the time limit. This is the default. For example, a frame rate of ten frames per second indicates a time limit of one hundred milliseconds.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    DWORD dwTimeLimit;                  /* the time allotted for the codec  */

    r4State.dwFlags     = DECFRAME_TIME_LIMIT | DECFRAME_VALID;
    r4State.dwTimeLimit = dwTimeLimit;

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

Setting the Position and Dimensions of the Decode Rectangle for Local Decode
If a minimum viewport size was specified during encoding, Indeo video interactive can decode only a specified rectangular region of the original image, called a decode rectangle. The decode rectangle specifies the origin and dimensions of the rectangle to decode relative to the original image.

A decode rectangle cannot be smaller than the minimum size specified during encoding. It can be changed only immediately before a key frame; if you try to change it before any other frame, the codec returns the error ICERR_BADPARAM. The decode rectangle cannot extend outside the image and must wholly enclose the view rectangle, which is discussed below. If all fields are zero, the entire image is decoded.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    R4_RECT r4DecodeRect;               /* the decode rectangle             */

    r4State.dwFlags     = DECFRAME_DECODE_RECT | DECFRAME_VALID;
    r4State.rDecodeRect = &r4DecodeRect

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

Setting the Position and Dimensions of the View Rectangle for Local Decode
Within a decode rectangle, Indeo video interactive can further limit the pixels it writes to the output buffer. This smaller area is called the view rectangle. Specify the origin and dimensions of the view rectangle relative to the original image. The view rectangle cannot extend outside the decode rectangle; if it does, the codec returns the error ICERR_BADPARAM when the next decompression message is received. If all fields are zero, the codec defaults to the origin and dimensions of the decode rectangle.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    R4_RECT r4ViewRect;                 /* the view rectangle               */

    r4State.dwFlags = DECFRAME_VIEW_RECT | DECFRAME_VALID;
    r4State.rDecodeRect = &r4ViewRect

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

The above method requires an output buffer large enough to hold the entire decoded frame if necessary. When using this method the size and position of the view rectangle may be freely adjusted without regard for the size of the output buffer.

Support for minimizing the size of the output buffer is provided through the fViewRectOrigin field. If this field is set to TRUE, the codec decodes directly to the output buffer, without regard to the offsets provided for the view rectangle. In this manner, the required size of the output buffer is minimized to that of just the view rectangle. The codec will decode directly to the minimized buffer, however changes to the view rectangle dimensions might require changes to the buffer size.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    R4_RECT r4ViewRect;                 /* the view rectangle               */

    r4State.dwFlags     = DECFRAME_VIEW_RECT_ORIGIN | DECFRAME_VALID;
    r4State.rDecodeRect = &r4ViewRect

    r4State.fViewRectOrigin = TRUE;     /* no offset into the buffer        */

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

Setting the Brightness, Saturation, and Contrast Levels
Indeo video interactive supports changing the brightness, contrast, and saturation of the video clip during playback. Valid values for all three parameters range from -255 to 255.

Brightness is an additive adjustment to luminance. Contrast and saturation are nonlinear adjustments.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    LONG lBrightness;                   /* the brightness value (-255..255) */
    LONG lSaturation;                   /* the saturation value (-255..255) */
    LONG lContrast;                     /* the contrast value   (-255..255) */

    r4State.dwFlags = DECFRAME_BRIGHTNESS |
                      DECFRAME_SATURATION |
                      DECFRAME_CONTRAST   |
                      DECFRAME_VALID;

    r4State.lBrightness = lBrightness;
    r4State.lSaturation = lSaturation;
    r4State.lContrast   = lContrast;

    ICSendMessage( hCodec, ICM_SETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

Retrieving the Decode Sequence Parameters
The following examples show how to use the ICM_GETCODECSTATE message to retrieve the current decode sequence parameters. An example is not provided for retrieving the access key status, because the codec makes no provision for this inquiry from an application.

Transparent Pixel Fill Method
To retrieve the current fill mode, set the appropriate flag in the dwFlags field and send the ICM_GETCODECSTATE message. On successful return, the fFillTransparentPixels member of the R4_DEC_SEQ_DATA structure indicates the current mode.


    HIC             hCodec;             /* handle to an opened IVI codec    */
    R4_DEC_SEQ_DATA r4State;            /* initialized sequence structure   */

    r4State.dwFlags = DECSEQ_FILL_TRANSPARENT | DECSEQ_VALID;

    ICSendMessage( hCodec, ICM_GETCODECSTATE,
                   (DWORD)&r4State, (DWORD)sizeof(R4_DEC_SEQ_DATA));

    /*  If r4State.fFillTransparentPixels = 0, it's disabled                */
    /*  otherwise it's enabled                                              */

Decode Scalability
To retrieve the current decode scalability mode, set the appropriate flag in the dwFlags field and send the ICM_GETCODECSTATE message. On successful return, the fScalability member of the R4_DEC_SEQ_DATA structure indicates the current mode.


    HIC             hCodec;             /* handle to an opened IVI codec    */
    R4_DEC_SEQ_DATA r4State;            /* initialized sequence structure   */

    r4State.dwFlags = DECSEQ_SCALABILITY | DECSEQ_VALID;

    ICSendMessage( hCodec, ICM_GETCODECSTATE,
                   (DWORD)&r4State, (DWORD)sizeof(R4_DEC_SEQ_DATA));

    /*  If r4State.fScalability = 0, decode scalability is disabled,        */
    /*  otherwise it's enabled                                              */

Alternate Line Zoom-by-Two
To retrieve the current zoom-by-two mode, set the appropriate flag in the dwFlags field and send the ICM_GETCODECSTATE message. On successful return, the fAltLine member of the R4_DEC_SEQ_DATA structure indicates the current mode.


    HIC             hCodec;             /* handle to an opened IVI codec    */
    R4_DEC_SEQ_DATA r4State;            /* initialized sequence structure   */

    r4State.dwFlags = DECSEQ_ALT_LINE | DECSEQ_VALID;

    ICSendMessage( hCodec, ICM_GETCODECSTATE,
                   (DWORD)&r4State, (DWORD)sizeof(R4_DEC_SEQ_DATA));

    /*  If r4State.fAltLine = 0, alt-line zoom-by-2 is disabled, otherwise  */
    /*  it's enabled                                                        */

Retrieving the Decode Frame Parameters
The following examples show how to use the ICM_GETCODECSTATE message to retrieve the current decode frame parameters. Examples are not provided for retrieving the address of the transparency bounding rectangle and the transparency bitmask, because these parameters were originally furnished by the application.

 

Retrieving the Transparent Pixel Fill Color
To retrieve the current transparent pixel fill color, set the appropriate flag in the dwFlags field and send the ICM_GETCODECSTATE message. On successful return, the dwFillColor member of the R4_DEC_FRAME_DATA structure contains the current pixel fill color.

 

    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    r4State.dwFlags = DECFRAME_FILL_COLOR | DECFRAME_VALID;
    ICSendMessage( hCodec,ICM_GETCODECSTATE,
                   (DWORD)&r4State, (DWORD)sizeof(R4_DEC_FRAME_DATA));
                        

Note: The value returned in the dwFillColor field is in the format of the current output color mode. If the current output mode is RGB24, the low order 3 bytes of dwFillColor contain the R, G and B values. If the current output mode is RGB8, the low byte of dwFillColor contains a palette index.

Retrieving the Decode Time Limit
To retrieve the current decode time limit, set the appropriate flag in the dwFlags field and send the ICM_GETCODECSTATE message. On successful return, the lTimeLimit member of the R4_DEC_FRAME_DATA structure contains the current value.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    r4State.dwFlags = DECFRAME_TIME_LIMIT | DECFRAME_VALID;

    ICSendMessage( hCodec, ICM_GETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

    /*  r4State.lTimeLimit now contains the current decode time limit       */


Retrieving the Position and Dimensions of the Decode Rectangle for Local Decode
To retrieve the current origin and dimensions of the decode rectangle, set the corresponding flag in the dwFlags field, supply the address of an R4_RECT structure in which to place the values, and send the ICM_GETCODECSTATE message. On successful return, the R4_RECT structure contains the current position and dimensions of the decode rectangle.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    R4_RECT r4DecodeRect;               /* the rectangle for retrieving the */
                                        /*   decode rect                    */

    r4State.dwFlags     = DECFRAME_DECODE_RECT | DECFRAME_VALID;
    r4State.rDecodeRect = &r4DecodeRect

    ICSendMessage( hCodec,ICM_GETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

    /*  r4DecodeRect now contains the current decode rectangle position     */
    /*  and dimensions.                                                     */


Retrieving the Position and Dimensions of the View Rectangle for Local Decode
To retrieve the current position and dimensions of the view rectangle, set the corresponding flag in the dwFlags field, supply the address of an R4_RECT structure in which to place the values, and send the ICM_GETCODECSTATE message. On successful return, the R4_RECT structure contains the current origin and dimensions of the view rectangle.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    R4_RECT r4ViewRect;                 /* the rectangle for retrieving the */
                                        /*   view rect                      */

    r4State.dwFlags   = DECFRAME_VIEW_RECT | DECFRAME_VALID;
    r4State.rViewRect = &r4ViewRect

    ICSendMessage( hCodec,ICM_GETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );

    /*  r4ViewRect now contains the current decode rectangle position       */
    /*  and dimensions.                                                     */


Retrieving the Brightness, Saturation, and Contrast Levels
To retrieve the current values for brightness, saturation, and contrast, set the corresponding flags in the dwFlags field and send the ICM_GETCODECSTATE message. On successful return, the lBrightness, lSaturation, and lContrast members of the R4_DEC_FRAME_DATA structure contain the current values.


    HIC               hCodec;           /* handle to an opened IVI codec    */
    R4_DEC_FRAME_DATA r4State;          /* initialized frame structure      */

    r4State.dwFlags = DECFRAME_BRIGHTNESS |
                      DECFRAME_SATURATION |
                      DECFRAME_CONTRAST   |
                      DECFRAME_VALID;

    ICSendMessage( hCodec, ICM_GETCODECSTATE,
                   (DWORD)&r4State, sizeof(R4_DEC_FRAME_DATA) );                      


References
  • Indeo Video Interactive Video for Windows Programming Interface Specification
    File names: vfw_head.htm and vfw_spec.htm.
  • Video for Windows Software Developer's Kit Programmer's Guide, available from Microsoft with a Level 2 subscription to the Microsoft Developer's Network.
  • A variety of other documents describing Indeo video interactive are available from Intel at this Web site.

For latest information, also see:

  • Microsoft Win32 Software Developer's Kit Help
  • Microsoft Visual C++ 4.0 Help


* Legal Stuff © 1997 Intel Corporation

Free Web Hosting