TweetFollow Us on Twitter

March 95 - SOMEWHERE IN QUICKTIME

SOMEWHERE IN QUICKTIME

Choosing the Right Codec

JOHN WANG

[IMAGE Wang.GIF]

As described in Chapter 3 of Inside Macintosh: QuickTime , the Image Compression Manager performs compression and decompression by invoking image compressor and decompressor components. These components, calledcodecs , present a standard interface to the Image Compression Manager using the Component Manager. But each codec is unique because each implements a different compression and decompression algorithm. Codecs can vary greatly in the three major characteristics that are used to judge image compression algorithms: compression ratio, compression speed, and image quality. QuickTime 2.0 ships with eight codecs that can be selected for use by your QuickTime application under various conditions. In addition, users or third-party products can install custom codecs into the system by simply placing them in the Extensions folder.

With all the choices for image compression and decompression, the only way to choose the best codec for a particular purpose is to have some understanding of all the codecs available on your system. Inside Macintosh provides general descriptions of the standard QuickTime codecs, but detailed information is important in making an intelligent codec selection. The way to find this detailed information is to communicate programmatically with the codec and request its capabilities through the codec call CDGetCodecInfo. As described inInside Macintosh: QuickTime Components, this call returns a compressor information structure.

For example, information about what pixel depths a compressor supports for storing image data is important to choosing the right codec. If your application creates and compresses a picture, the decision of whether to create the picture in 8-bit, 16-bit, or 32-bit color can be based partially on what pixel depths the compressor supports. If the compressed data can store only 16 bits of color information, it would be inefficient to create a picture with 32 bits of color.

Accompanying this column on this issue's CD is the sample application GetCodecInfoApp, which (by calling CDGetCodecInfo) allows you to easily obtain detailed information about codecs installed in your system. I'll discuss GetCodecInfoApp and point out some characteristics that should be considered in choosing a codec.

USING CODECS
There are actually two separate parts to a codec: one for the compression and one for the decompression. Not all codecs provide both; nevertheless, all compressor and decompressor combinations are referred to as codecs. One example of a decompression-only codec is the codec that comes with the QuickTake 100 digital camera from Apple. The hardware in the QuickTake 100 camera performs the compression and downloads compressed data to the Macintosh. The Macintosh only needs to perform decompression.

A compressor is a component of type compressor-ComponentType ('imco') and a decompressor is a component of type decompressorComponentType ('imdc'). Detailed information on writing a codec is provided in Chapter 4 ofInside Macintosh: QuickTime Components . But to select the appropriate codec to use, you don't need to do any programming; you can simply use GetCodecInfoApp, without any need to understand how it was written. This application creates a text file containing a report of all the codec components installed in your system. For example, the output for the Cinepak codec looks like this:

Compressor Name: Cinepak
------------------------------------
- version = 1
- revisionLevel = 1
- vendor = appl
- compressionAccuracy = 128
- compressionLevel = 128
- minimum height = 1
- minimum width = 1
- compress pipeline latency = 0
- compression capabilities:
	directly compresses 32-bit pixel maps
	supports temporal compression
	can recompress images without accumulating errors
	can rate constrain to caller defined limit
- compression format:
	can store images in 24-bit color
	can store images in 8-bit grayscale
	can store custom color table
	compressed data requires non-key frames to be
		decompressed in same order as compressed
- estimated compression speed:
640x480 32-bit RGB = 11485 milliseconds

Decompressor Name: Cinepak
------------------------------------
- version = 1
- revisionLevel = 1
- vendor = appl
- decompressionAccuracy = 128
- minimum height = 1
- minimum width = 1
- decompress pipeline latency = 0
- decompression capabilities:
	directly decompresses into 32-bit pixel maps
	supports temporal compression
	can recompress images without accumulating errors
	can rate constrain to caller defined limit
- decompression format:
	can decompress images from 24-bit color
		compressed format
	can decompress images from 8-bit grayscale
		compressed format
	can store custom color table
	compressed data requires non-key frames to be
		decompressed in same order as compressed
- estimated decompression speed:
640x480 32-bit RGB = 56 milliseconds

GetCodecInfoApp gets information about codecs by calling the codec's CDGetCodecInfo function, which all codecs must support; if you're writing a codec, it's important to report your capabilities with this function. To measure the codec's speed, the application actually passes it an image to compress or decompress, and reports the result.

The Image Compression Manager function GetCodecInfo can also be used to obtain information about codecs, but only for compressor codecs; you won't be able to get information about decompression-only codecs with GetCodecInfo. *

An example of a characteristic you can determine with GetCodecInfoApp is what pixel depths the decompressor can decompress directly into. This is important because it affects the speed of the image decompression. If the codec can't decompress directly into the destination pixel map, the Image Compression Manager will have to decompress into an offscreen buffer and move the image data into the destination after converting the pixel depth. This results in additional memory and processor bandwidth requirements. If you know exactly what pixel depths a decompressor supports, you can set up the destination for the best performance.

Most codecs support only a limited number of pixel depths for the compressed data storage format. For example, the Video Compressor will store image data only in 16-bit color. If you compress a 32- bit color image, you'll lose information, since the compressed format will store the equivalent of 16 bits of data. The pixel depth for the compressed data storage format also determines which of the different compression settings are available -- for example, the pixel depth pop-up menu for Compression Settings displayed by the standard image-compression dialog component (used, for example, by Picture Compressor, an application that's part of the QuickTime Starter Kit) will only allow you to choose Color for the Video Compressor. The Animation Compressor is one of the few compressors that will store compressed data in nearly all pixel depth formats: Black and White, 4 Grays, 4 Colors, 16 Grays, 16 Colors, and so on.

When compressing movies, you'll often want to select a codec that supports temporal compression; not all codecs do. Temporal compression is the use of frame differencing to compress consecutive image frames by skipping data that doesn't change from frame to frame. Temporal compression is useful only for sequences of images stored as QuickTime movies. Knowing which codecs support temporal compression will allow you to choose the best codec for compressing sequences.

If you're compressing pictures with scientific data, it may be extremely important that there be no image quality loss. In this case, you'll want to look for a codec that supportslossless compression. For example, the Photo Compressor (JPEG codec) is a lossy codec because even at the highest quality setting, there may still be some loss of image quality. On the other hand, the Animation Compressor is lossless at higher quality settings and will preserve every pixel value.

There are many additional features a codec may support that are important to know. For example, certain codecs will support data spooling so that only portions of the compressed data need to be read into memory at any one time. This can be a requirement when working with very large compressed images that will be displayed in systems with limited memory. Another example is support for stretching to double size during decompression. This is extremely useful, since the performance is much greater if the scaling is performed during decompression rather than as a separate step after decompression.

SOME RECOMMENDATIONS
For most video clips, the Cinepak Compressor is the recommended codec. As you can see from GetCodecInfoApp's report, this codec is very slow in compression. However, its decompression speed and compression level are excellent, making it the best choice for most video data for CD-ROM playback.

An alternative to Cinepak is the Video Compressor. Since its compression speed is fairly quick, it's better for an application that requires fast compression.

If your source material is animation graphics in a movie, there are several compressors that may do the job. The Animation Compressor and Graphics Compressor may be equally suitable. In this case, you may need to experiment to determine which is the best codec to use. Finally, if you're compressing photo images, the Photo Compressor is the best codec to use. It has only moderate compression and decompression speed, but the compression ratio and quality are excellent and the compression ratio scales accordingly with image quality. If you want better image quality at the expense of larger compressed data size, you can easily achieve this with the Photo Compressor.

PRESSING ON
If you're writing a codec, you can see from this column that it's very important to properly report the codec's capabilities; GetCodecInfoApp may be useful for you to verify that your codec is doing this properly. For the rest of you, I hope this column has provided some insight on how to choose the right codec for producing the best movies and compressed images.


JOHN WANG (AppleLink WANG.JY) used to be a proud member of the PIGs (Printing, Imaging, and Graphics group) in Apple's Developer Technical Support group. But he decided that there are other challenges in life and programming. So now John spends his entire day waiting for MPW to compile code that he's writing in his software engineering role in the Image Capture group. Just in case you fail to notice, we're sure he'd like us to point out that he makes a gratuitous plug for his group's product, the QuickTake 100 digital camera, in this column. *

Thanks to Peter Hoddie, Don Johnson, Kent Sandvik, and Nick Thompson for reviewing this column. *

 
AAPL
$111.25
Apple Inc.
+1.55
MSFT
$48.78
Microsoft Corpora
-0.09
GOOG
$547.31
Google Inc.
-2.98

MacTech Search:
Community Search:

Software Updates via MacUpdate

Labels & Addresses 1.6.9 - Powerful...
Labels & Addresses is a home and office tool for printing all sorts of labels, envelopes, inventory labels, and price tags. Merge-printing capability makes the program a great tool for holiday... Read more
Microsoft Office 2011 14.4.6 - Popular p...
Microsoft Office 2011 helps you create professional documents and presentations. And since Office for Mac 2011 is compatible with Office for Windows, you can work on documents with virtually anyone... Read more
Google Chrome 38.0.2125.122 - Modern and...
Google Chrome is a Web browser by Google, created to be a modern platform for Web pages and applications. It utilizes very fast loading of Web pages and has a V8 engine, which is a custom built... Read more
Tidy Up 4.0 - Find duplicate files and t...
Tidy Up is a complete duplicate finder and disk-tidiness utility. With Tidy Up you can search for duplicate files and packages by the owner application, content, type, creator, extension, time... Read more
Adobe Flash Player 15.0.0.223 - Plug-in...
Adobe Flash Player is a cross-platform, browser-based application runtime that provides uncompromised viewing of expressive applications, content, and videos across browsers and operating systems.... Read more
Firefox 33.1 - Fast, safe Web browser. (...
Firefox for Mac offers a fast, safe Web browsing experience. Browse quickly, securely, and effortlessly. With its industry-leading features, Firefox is the choice of Web development professionals... Read more
TextSoap 7.4.3 - Flexible text editing u...
TextSoap is for people who work with text. TextSoap effortlessly cleans up text from endlessly different formats. Wash away unwanted characters, spaces, tabs. Fix paragraphs with hard returns at the... Read more
Pixa 1.1.5 - Quickly and easily organize...
Pixa is an image-organizing application. The new app functions well, is easy to use, and helps people organize their images quickly and easily on their computers. For those who prefer not to use the... Read more
Yummy FTP 1.10.1 - FTP/SFTP/FTPS client...
Yummy FTP is an FTP + SFTP + FTPS file transfer client which focuses on speed, reliability and productivity. Whether you need to transfer a few files or a few thousand, schedule automatic backups, or... Read more
X Lossless Decoder 20141109 - Encode, tr...
X Lossless Decoder (XLD) is a tool for OS X that is able to decode/convert/play various 'lossless' audio files. The supported audio files can be split into some tracks with cue sheet when decoding... Read more

Latest Forum Discussions

See All

Airline Director (Games)
Airline Director 1.2 Device: iOS Universal Category: Games Price: $2.99, Version: 1.2 (iTunes) Description: Airline Director is an airline management game. Your goal is to build your airline into a global player in the airline... | Read more »
Random Heroes 3 (Games)
Random Heroes 3 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: Alien scum are invading earth one last time! A group of unlikely heroes are set out to save the world once and for all! From... | Read more »
FRAMED (Games)
FRAMED 1.0.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.0 (iTunes) Description: FRAMED. A Multi-Award Winning Narrative-Puzzle Game.Change the Order, Change the Outcome. ** Winner of Over 25 Awards &... | Read more »
XCOM®: Enemy Within (Games)
XCOM®: Enemy Within 1.0.0 Device: iOS Universal Category: Games Price: $12.99, Version: 1.0.0 (iTunes) Description: ***NOTE: Compatible with iPad 3, iPad mini 2, iPhone 5 and up. WILL NOT be able to run on earlier generations,... | Read more »
Candy Crush Soda Saga Review
Candy Crush Soda Saga Review By Jennifer Allen on November 12th, 2014 Our Rating: :: NEW TRICKSUniversal App - Designed for iPhone and iPad Candy Crush Soda Saga is the latest of King’s match-3 games, and it’s just as fun as the... | Read more »
Zombie Catchers Review
Zombie Catchers Review By Nadia Oxford on November 12th, 2014 Our Rating: :: TASTE THE ZOMBIE RAINBOWUniversal App - Designed for iPhone and iPad Zombie Catchers is tons of fun to play, though free-to-play timers put a bit of a... | Read more »
The New Forgotten Shores Expansion is No...
The New Forgotten Shores Expansion is Now Available for Monument Valley Posted by Jessica Fisher on November 12th, 2014 [ permalink ] | Read more »
Super Secret Service Review
Super Secret Service Review By Jordan Minor on November 12th, 2014 Our Rating: :: GET DOWN MR. PRESIDENT!Universal App - Designed for iPhone and iPad Super Secret Service is a great candidate, but a one term president.   | Read more »
The Latest Plants vs. Zombies 2 Update I...
The Latest Plants vs. | Read more »
World of Warriors Review
World of Warriors Review By Jennifer Allen on November 12th, 2014 Our Rating: :: PRETTY BUT PRICEYUniversal App - Designed for iPhone and iPad World of Warriors looks gorgeous and has a ‘gotta catch em all’ vibe to it, but its in-... | Read more »

Price Scanner via MacPrices.net

Bracket MacBook Pro Retina Cable Dock
No electronics. No moving parts. Just high-grade aluminium. Because simple works – meet Bracket, a minimalistic designed accessory that keeps your MacBook Pro Retina cables fixed and organised. The... Read more
Word for iOS; Restoration Of Classic Microsof...
Back when started out using the Mac in 1992, the previously owned Mac Plus I bought came loaded up with a copies of Microsoft Word for Mac versions 3 and 4. I immediately fell in love with these... Read more
Sale! New 1.4GHz Mac mini for $449, save $50,...
 B&H Photo has lowered their price on the new 1.4GHz Mac mini to $449.99 including free shipping plus NY tax only. Their price is $50 off MSRP, and it’s the lowest price available for this new... Read more
MeezyCube Cord Fray Protector For The MacBook...
MacBooks are a costly investment, and protective covers exist for almost every part of a MacBook system from the keyboard to the screen and outer shell. All except for the charge brick, which is left... Read more
Save up to $400 with Apple refurbished 2014 1...
The Apple Store is now offering Apple Certified Refurbished 2014 15″ Retina MacBook Pros for up to $400 off the cost of new models. An Apple one-year warranty is included with each model, and... Read more
13-inch 1.4GHz/256GB MacBook Air on sale for...
Amazon has the 13″ 1.4GHz/256GB MacBook Air on sale for $1099.99 including free shipping. Their price is $100 off MSRP, and it’s the lowest price available for this model from any reseller (except... Read more
Satechi Launches Multi-Functional Edge Wirele...
Your humble servant isn’t much of a gamer, but I’m a big fan of gaming mice, which typically feature higher tracking precision and rugged construction along with comfortable ergonomics than “regular... Read more
LINK Power Drive Combines Flash Drive and Pow...
Imation Corp. has announced the Imation LINK Power Drive — a new device that brings flash storage and battery-charging capabilities together in a single unit for the iPhone and other iOS devices. “... Read more
Sale! $200 off the 15″ 2.2GHz Retina MacBook...
 B&H Photo has the 2014 15″ 2.2GHz Retina MacBook Pro on sale for $1799.99 for a limited time. Shipping is free, and B&H charges NY sales tax only. B&H will also include free copies of... Read more
Roundup of Apple refurbished iPads
Apple dropped prices recently on Apple Certified Refurbished iPad Airs and iPad mini 2s, with models available starting at $249. Apple’s one-year warranty is included with each model, and shipping is... Read more

Jobs Board

Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Position Opening at *Apple* - Apple (United...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** The Apple Store is a retail environment like no other - uniquely focused on delivering amazing customer experiences. As an Expert, you introduce people Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.