< Previous PageNext Page > Hide TOC

Using Data Codec Components

This chapter discusses how to use data codec components to compress or decompress data. A list of functions provided by data codec components is also included.

Data codecs enable you to compress and decompress data that is not automatically handled by QuickTime media operations. For example, QuickTime automatically uses image and sound codecs to compress and decompress video and sound tracks, but does not automatically compress or decompress sprites.

Data codecs are useful for compressing and decompressing sprites, 3D models, or other data types whose media handlers do not inherently support compression.

Data codecs also enable you to compress or decompress arbitrary blocks of data from other sources. The data does not necessarily need to come from, or go to, a QuickTime movie.

Data codecs are divided into compressor and decompressor components. All data compressors have a component type of DataCompressorComponentType and all data decompressors have a component type of DataDecompressorComponentType. The compression algorithm is indicated by the component subtype.

Once you have selected a data codec component, you can compress or decompress from one buffer to another. With care, this can be done at interrupt time.

In this section:

Component Types
Functions


Component Types

Data compressor and decompressor components have component types of DataCompressorComponentType and DataDecompressorComponentType. Each component has a unique component subtype, indicating the type of compression algorithm it supports.

Select an appropriate data codec component for your data using the Component Manager functions, such as the OpenADefaultComponent or FindNextComponent functions.

Prior to compressing or decompressing data, you need to create a buffer containing the source data and allocate a buffer to receive the destination data. You can use the DataCodecGetCompressBufferSize function to determine the size of destination buffer you need to allocate before doing a compression or decompression.

The DataCodecCompress function enables you to compress data using a specified compressor component. Similarly, the DataCodecDecompress function enables you decompress data using a specified decompressor component.

If a compressor or decompressor component implements the DataCodecBeginInterruptSafe and DataCodecEndInterruptSafe functions, your application or other software can perform compression or decompression operations during interrupt time. You do this as follows:

1. Before performing the compression or decompression operation, call the DataCodecBeginInterruptSafe function. In the call, pass the maximum size of a data block to be compressed or decompressed in the maxSrcSize parameter.

2. If the call fails, do not perform compression or decompression operations during interrupt time. Otherwise, you may proceed.

3. When the compression or decompression operation is complete, call DataCodecEndInterruptSafe to release resources used to make the operation safe at interrupt time.

Functions

The following functions are provided by data codec components:



< Previous PageNext Page > Hide TOC


© 2005, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-01-10)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.