15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

444<br />

Lossy Data Compression<br />

Video basically saves successive still images, so lossy compression can save<br />

space by looking <strong>for</strong> identical backgrounds between video frames. Rather than<br />

store the same background multiple times, lossy compression stores the background<br />

only once and uses that identical image multiple times. Because the<br />

same background may appear in several video frames, this technique can<br />

shrink the size of a video considerably.<br />

Another way to compress data is to alter the bit depth. Bit depth defines how<br />

many bits are used to store data, such as 96-bit or 160-bit. The more bits<br />

used, the greater the quality but the larger the file size. The fewer bits used,<br />

the less storage space required and the less data saved, reducing the file<br />

size. That’s why a 96-bit MP3 file is smaller than the same file saved as a 160-<br />

bit MP3 file. The 96-bit file can’t store as much data as the 160-bit file, which<br />

means lower audio quality than the 160-bit file.<br />

When compressing a file, lossy compression may use constant bit rate (CBR)<br />

or variable bit rate (VBR) compression. CBR reduces the bit rate uni<strong>for</strong>mly<br />

throughout the entire file and makes compression faster. Un<strong>for</strong>tunately, this<br />

also means that silent portions of an audio file get compressed at the same<br />

rate as noisier parts of the audio file, resulting in less-than-optimum<br />

compression.<br />

VBR alters the bit rate, depending on the complexity of the data. This improves<br />

quality but at the cost of a slower compression time. For even higher quality,<br />

some compression algorithms offer two-pass VBR, which means the program<br />

analyzes the file twice to get the maximum quality and the smallest file size<br />

possible, but at the expense of much slower compression speed.<br />

All types of compression are always a trade-off. With lossless compression,<br />

the trade-off is between size and speed. The smaller you want to compress<br />

the file, the longer it takes. With lossy compression, the trade-off is mostly<br />

between size and quality. The smaller the file size, the lower the overall quality.<br />

Both lossless and lossy compression algorithms are necessary, depending<br />

on which type better suits your needs.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!