ADC Home > Reference Library > Technical Q&As > QuickTime > QuickTime Component Creation >

The similarity field in ImageCodecBandCompress and Key Frames


Q: Can the ImageCodecBandCompress routine of an Image Compressor ('imco') Component decide when a compressed frame will be a key frame or not? Or is the key frame rate fixed?

The only information I can find about this is in the description of the CodecCompressParams structure

A: The key frame rate is not automatically fixed, the codec can decide on whatever rate is appropriate. However, the explanation of what the codec developer needs to do can be confusing.

The key (no pun intended) is the similarity field of the CodecCompressParams structure. This is an OUT field which you need to fill in to indicate the similarity between adjacent frames.



 typedef struct {
   ImageSequence          sequenceID;
   ImageDescriptionHandle imageDescription;
   ...
   Fixed                  similarity; /* similarity between adjacent frames */
   ...
} CodecCompressParams;
                     

Listing 1. CodecCompressParams



The similarity field of the CodecCompressParams structure indicates the similarity between adjacent frames when performing temporal compression. Your component should return a fixed-point number in this field. This value indicates the relative similarity between the frame just compressed and the previous frame. Valid values range from 0 indicating a key frame to 255 indicating an identical frame.

This field is used only by the ImageCodecBandCompress function.

More accurately, you should use the following values:

0x00000000 - Indicates a Key Frame

0x00010000 - These values indicate frames that are not exactly identical to the previous frame

...

0x00nn0000

...

0x00FE0000

0x00FF0000 - Indicates that the frame can be discarded without damage

An Image Compressor should only set the similarity to 0x00FF0000 if the compressed frame may be discarded without damage. If bad video would result from discarding a frame, the Compressor should limit similarity to 0x00FE0000.

Under certain circumstances when setting similarity to a very low value, for example 0x00010000 (the lowest possible value when not a key frame), the next frame may have it's temporalQuality set to 0, indicating a key frame is needed. Codec developers should also be aware that in certain situations the Image Compression Manager will look at the similarity value returned by the compressor, and if this value is very low, will tell the compressor to re-compress the frame as a key frame. The Image Compression Manager will not do this if the codecFlagLiveGrab flag is set, or if an asynchronous completion proc is supplied.

IM QuickTime Components : The Compression Parameters Structure


[Jan 16 2002]


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.