From 1dba62f5b60aba6dd4782787617d15112eb4f230 Mon Sep 17 00:00:00 2001
From: Josh Coalson
The basic usage of libFLAC is as follows:
-
@@ -771,7 +773,7 @@ STREAM DECODER
- First we discuss the stream decoder. The instance type is FLAC__StreamDecoder. Typically the program will create a new instance by calling FLAC__stream_decoder_new(), then call FLAC__stream_decoder_init() with the addresses of the required callbacks. The program can also supply a client_data pointer to FLAC__stream_decoder_init() which will be included when calling the callbacks. + First we discuss the stream decoder. The instance type is FLAC__StreamDecoder. Typically the program will create a new instance by calling FLAC__stream_decoder_new(), then call FLAC__stream_decoder_set_*() functions to set the callbacks and client data, and call FLAC__stream_decoder_init(). The required callbacks are:
The file decoder is a wrapper around the stream decoder meant to simplfy the process of decoding from a file. The instance type is FLAC__FileDecoder. The flow and callbacks are similar to that of the stream decoder. However, a file path replaces the read callback argument during initialization. The program needs only to provide the path to the file and the file decoder handles the read callbacks. The remaining callbacks and process functions are analogous to their stream decoder counterparts.
-@@@MD5 checkingSince the file decoder manages the input automatically, it also can provide seeking. This is exposed through the FLAC__file_decoder_seek_absolute() method. At any point after the file decoder has been initialized, the program can call this function to seek to an exact sample within the file. Subsequently, the first time the write callback is called it will contain a (possibly partial) block starting at that sample.
+ The file decoder also provides MD5 signature checking. If this is turned on before initialization, FLAC__file_decoder_finish() will report when the decoded MD5 signature does not match the one stored in the STREAMINFO block. MD5 checking is automatically turned off if the is no signature in the STREAMINFO block or when a seek is attempted. +
+STREAM ENCODER
- The stream encoder functions similarly to the stream decoder, but has fewer callbacks and more options. The instance type is FLAC__StreamEncoder. Typically the program will create a new instance by calling FLAC__stream_encoder_new(), then initialize it by calling FLAC__stream_encoder_init(). + The stream encoder functions similarly to the stream decoder, but has fewer callbacks and more options. The instance type is FLAC__StreamEncoder. Typically the program will create a new instance by calling FLAC__stream_encoder_new(), then set the necessary parameters with FLAC__stream_encoder_set_*(), and initialize it by calling FLAC__stream_encoder_init().
Unlike the decoding process, FLAC encoding has many options that can affect the speed and compression ratio. When the program calls FLAC__stream_encoder_init() the encoder will validate the values, so you should make sure to check the returned state to see that it is FLAC__STREAM_ENCODER_OK. When setting these parameters you should have some basic knowledge of the format (see the user-level documentation or the formal description) but the required parameters are summarized here: @@ -833,7 +837,7 @@
- The program must also give FLAC__stream_encoder_init() addresses for the following callbacks: + The program provide addresses for the following callbacks:
- When the program is finished encoding data, it calls FLAC__stream_encoder_finish(), which causes the encoder to encode any data still in its input pipe, and call the metadata callback with the correct encoding statistics. Then the instance may be deleted with FLAC__stream_encoder_delete() or initialized again to encode another stream. + When the program is finished encoding data, it calls FLAC__stream_encoder_finish(), which causes the encoder to encode any data still in its input pipe, and call the metadata callback with the final encoding statistics. Then the instance may be deleted with FLAC__stream_encoder_delete() or initialized again to encode another stream.
MISCELLANEOUS -- 2.7.4