On Tuesday, March 26, 2002, at 12:23 AM, Dirk Nehring wrote:
I'm writing a program to correct bad MP3 files (by dropping bad frames, dropping IDv2 tags on demand, etc.) by using libmad. One point is that I want to add an CRC-16 checksum to the header. Can I use the libmad low level interface for this (i.e. set protection bit, and call mad_frame_decode(), get crc-checksum from header->crc_target)?
You probably can't add a checksum easily if there isn't one already because it involves adding a 16-bit field to the audio data region, and you may not have enough room for it in every frame.
If you can overcome that problem, your strategy might work. If you mark the protection bit in the frame header, make sure you call mad_frame_decode() with the CRC field present or it will compute the wrong CRC.
The computed CRC is in header->crc_check.
-- Rob Leslie rob@mars.org