Optical Disc Technology  » Buffer Underrun and Overrun Scenarios

Buffer Underrun and Overrun Scenarios

----------------------------------------------------------

Permission is granted for the below article to forward,

reprint, distribute, use for ezine, newsletter, website,

offer as free bonus or part of a product for sale as long

as no changes are made and the byline, copyright, and the

resource box below is included.

----------------------------------------------------------

Buffer Underrun and Overrun Scenarios

By Stephen Bucaro

Buffer underrun and buffer overrun are occurrences that

can result in some very frustrating errors. This is not a

"how-to" article about fixing buffer underrun and buffer

overrun errors, but a basic description of what a buffer

is, why we need buffers, and what causes buffer underrun

and buffer overrun.

Buffer Underrun

The most common occurrence of buffer underrun is CD

recorders. Let's imagine an example of a CD recording

session. The computer has an ATA hard drive capable of

transferring data at a rate of 8 MBps (Mega Bytes per

second). The CD recorder has a recording rate of 8 MBps.

Everything should work fine, right?

Note: The data transfer rates mentioned in this article do

not apply to any specific device. They're just for purposes

of discussion.

The 8 MBps specification for the hard drive is for "burst"

mode. In other words, it can transfer data at a rate of

8 MBps for only a few seconds. Then the transfer rate drops

much lower, and if the hard drive hasn't been maintained,

for example it has not been defragmented recently, the

transfer rate can drop even lower.

Whereas a hard drive can skip from cluster to cluster

while reading and writing, a CD recorder must burn the data

track in a continuous stream without stopping. The design

of a CD recorder requires a "sustained" transfer rate.

When two devices that operate at different transfer rates

must communicate, we can make them work together by placing

a buffer between them. A buffer is a block of memory, like

a bucket for bytes. When you start the CD recording session,

the hard drive begins filling the buffer. When the buffer

is almost full, the CD recorder begins drawing bytes out of

the buffer.

and buffer overrun....

If everything goes smoothly, the hard drive will be able

to keep enough bytes in the buffer so that the speedy CD

recorder won't empty the buffer. If the buffer runs dry,

the CD recorder has no data to burn into the CD, so it

stops. Buffer underrun error.

We can reduce the chances of buffer underrun by configuring

a larger buffer. Then the hard drive will be able to put

more bytes in the bucket before the CD recorder starts

drawing them out. However, sometimes you can't increase the

size of the buffer because the computer doesn't have a

large amount of RAM installed. When the computer needs more

RAM, it uses "virtual" RAM. That is, it allocates part of

the hard disk and pretends like that's RAM. Now, even though

you've increased the size of the buffer, you have caused

the hard drive to work even slower.

Buffer Underrun and Overrun Scenarios

Buffer Overrun

The most common occurrence of buffer overrun is video

recorders. Let's imagine an example of a video camera

connected to a computer. The video camera records at a data

rate of 168 MBps. The computer monitor is capable of

displaying data at a rate of only 60 MBps. We have a big

problem, right?

Thanks to MPEG compression, we might not have as big a

problem as first appears. With MPEG compression, the video

camera does not have to send the entire image for every

frame. It sends only the data for the part of the image

that changed, and it compresses that part.

If the image doesn't change much, and the part that changed

compresses well, the video camera might need to transfer at

a rate of only a few MBps. But if the entire image changes

every frame and the image does not compress well, the video

camera might transfer data at a higher rate than the

computer monitor is capable of displaying.

Again, we have two devices that operate at different

transfer rates that must communicate. We can make them work

together by placing a buffer between them. When you start

recording video, the video recorder starts filing the

buffer. The computer display immediately begins pulling

data out of the buffer to compose display frames.

If everything goes smoothly, the computer display will be

pulling data out of the buffer fast enough so that the

buffer never completely fills. If the buffer fills up, the

video camera can't put any more data in, so it stops.

Buffer overrun error.

We can reduce the chances of buffer overrun by defining a

larger buffer. Then the video camera will be able to put

more bytes in the bucket before it fills up. Hopefully,

the video camera will run into a few frames where the

entire image doesn't change, reducing its data transfer

rate enough so the computer display can catch up.

Underrun, Overrun Protection

Today, CD recorder buffer underrun is much less common.

Computers come with much more RAM than they did before,

and CD recorders have learned to monitor the buffer and

reduce the recording speed if the buffer starts to run low.

Video camera buffer overrun is also less common. Video uses

a program called a "codec" (for encode/decode). A smart

codec can monitor the buffer and reconfigure itself when

the buffer gets too full. It might for example automatically

reduce the color depth of the video, or drop frames, until

the computer display catches up.

Underrun and overrun Protection doesn't completely solve

the problem. If underrun protection activates, a CD

recording session will take much longer. If overrun

protection activates, the video quality will be reduced.

The only way to solve underrun and overrun problems, after

increasing the size of the buffer, is to match the data

transfer rates of the devices that need to communicate.

You can upgrade to a faster hard drive, or install to a

high performance video card.

Now, if you need to troubleshoot a buffer underrun or

buffer overrun errors, at least you know what a buffer is,

why we need buffers, and what causes buffer underrun and

buffer overrun errors.

----------------------------------------------------------

Resource Box:

Copyright(C)2004 Bucaro TecHelp. To learn how to maintain

your computer and use it more effectively to design a Web

site and make money on the Web visit bucarotechelp.com

To subscribe to Bucaro TecHelp Newsletter Send a blank

email to subscribe@bucarotechelp.com

----------------------------------------------------------

About the Author

None