4

I know from [Sources], that FLAC computes CRC and MD5.

What I am afraid that flac --test only does CRC test - as stated in man flac : same as -d except no decoded file is written .

How to check flac file correctness, using MD5 of raw PCM placed in STREAMINFO in given .flac file ?

If flac --test makes job, are there any reliable (like in flac documentation) references that shows it?

Sources:

http://en.wikipedia.org/wiki/Free_Lossless_Audio_Codec we can find:

FLAC uses CRC checksums for identifying corrupted frames when used in a streaming protocol, and also has a complete MD5 hash of the raw PCM audio stored in its STREAMINFO metadata header.

http://flac.sourceforge.net/comparison.html

By default when processing files, flac computes the MD5 sum while encoding and decoding.

To see md5sums in STEAMINFO we can use:

$ metaflac --show-md5sum *.flac
4

The most reliable source is the source code itself, and it does suggest that MD5 stored in STREAMINFO is checked by default.

0

http://wiki.etree.org/index.php?page=FlacFingerprint shows this info:

Instead, when you decompress or use flac's Test feature, FLAC automatically verifies each file against an internal checksum stored in the file.

Note that a flac fingerprint isn't a checksum of the encoded flac data - it's a checksum of the decoded music data. So to test the file, flac decodes the data in the file and verifies that the checksum of the music data matches the (internally stored) flac fingerprint.

This has a few interesting implications:

When flac decodes, it checks the file (and each part of the file) against the internal checksum data. If a flac file decodes without error, it's a good file - as long as you are using an application that reports decoding errors!

This seems to imply that both the CRC and MD5 are checked since the CRCs are only for frames. I did a little test and got 2:FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH, which is expected. Looking at the code, the following implies that it is always checked:

/*
 * undocumented debugging options for the test suite
 */
{ "no-md5-sum"                , share__no_argument, 0, 0 },

And by default it is set:

FLAC__stream_decoder_set_md5_checking(decoder_session->decoder, true);

Set the "MD5 signature checking" flag. If true, the decoder will compute the MD5 signature of the unencoded audio data while decoding and compare it to the signature from the STREAMINFO block, if it exists, during FLAC__stream_decoder_finish().

It's as the answer from sendmoreinfo indicates:

The most reliable source is the source code itself, and it does suggest that MD5 stored in STREAMINFO is checked by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.