Sunday, April 29, 2007

when does a 32 bit overflow?

A very interesting self experienced, sw engineering related case, I like to share with you….

What I had was a super long avi file, from a trip I took many years ago. It is on my hard drive, and I was trying to back up onto DVD discs, and free some space on my pc. The file was 44.5 GB in size. Not a 20 hour mpeg*, but a 5 hour avi, since any mpeg encoding would be a lossy process. And I like to keep the original quality. Anyways. All I thought I had to do was to cut 44.5 gig into 10 to fit into 10 DVD discs, at 4.45 a piece on a 4.7 gig disc. No brainer. Just time to burn. Finally all done. Smart of me to have checked before deleting the source files on my hard drive. All 10 discs are corrupted.

I don’t think anyone will be interested in my debugging path. So cut it short, after rebooting the machine, downloading and trying other burner programs, comparing the size of the successful discs, and more, I pulled out the calculator. So when does a 32 bit overflow? 4.295 gig. Maybe I should have known it by heart, but shame on me.

So here is what it tells me. The burner driver must be using a 32 bit unsigned to keep the size of each file on disc, which is why it corrupts my 4.45 gig file, but not my 4.276 gig file (how lucky was I with this one… a less than 20 MB margin made it a good burn without me realizing it). But it must be using a 64 bit to keep track of the total size of all files on disc, which is why it did not have problem with my other disc, with 5 files on it, totaling to 4.64 GB, but each one is smaller than 2^16.

After all, all I had to do was to cut up the file into 20 pieces, instead of a single 4.45 gig file on a 4.7 disc, have 2 files at 2.225 gig each on a disc.

The moral of the story? A 32 bit might not be large enough for DVD discs. With technology going forward, blu-ray or then bigger media coming along… Does it remind you the y2k problem?

0 Comments:

Post a Comment

<< Home