Introduction
The video compression manager (VCM) provides access to the
interface used by installable compressors to handle real-time
data. Typically applications use installable compressors to
perform compressing and decompressing video data. The simplest
solution for decompressing is using a DrawDib API, which is wraps
all necessary functionality and provide a simple way for
visualization of compressed images. The same approach has been
used in MCIWnd for displaying an AVI files. All in all, looks
like there is no reason to deal with low-level VCM API in most
cases excepting:
- Processing a real-time video data from capture card with h/w codec
- Compressing/decompressing AVI file and writing results to the disk
- Compressing and decompressing single video image.
No comments about (1) and (2): this is the most usual way for
utilizing VCM service.CVidc
class presented
below is intended for compressing and decompressing single video
image, although it can be easy modified for any other purpose. I
had a special reason for developing this class: in fact video
codecs has an extremely high rate of decompression, no one from
existing image compressors can compare with video codecs. At the
same time, all of them are quite slow for compression. Thereby
when you need to store many compressed images and provide the
fastest reading, using the video codec seems to be the best
solution.
Class implementation.
CVidc class includes several methods from the list VCM
services for compressing and decompressing single video image.
Class does not support drawing (ICDrawXXX
) and
sequence compressing (ICSeqCompressFrameXXX
).
Class usage.
- Create
CVidc
class object - Call
OpenCompressor()
method to initialize
compressing, or suitable kind ofOpenDecompressor()
for decompressing. - Setup your callback function using
SetProgressCallback()
method if you need a progress notification. - Call
Compress()
orDecompress()
.
If you need to decompress single image from sequence
you can probably useDecompressEx()
, which
accepts special flags( see SDK for more info). - Close codec using
Close()
method.
Class also provides a few services for querying format,
enumerating installed codecs, obtaining information from codec
and so on. See Vidc.h for more info.
Remark about capturing compressed video data.
I can predict some questions about using of CVidc
for capturing together with
AviCap
wrapper presented earlier.
I did not test this combination. You can try to use DecompressEx()
method with proper conversion of VHDR_KEYFRAME
(dwFlags
in VIDEOHDR
) into ICDECOMPRESS_NOTKEYFRAME
(dwFlags
argument for DecompressEx(
)).