1 /* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2002,2003,2004,2005 Josh Coalson
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * - Neither the name of the Xiph.org Foundation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef FLAC__FILE_ENCODER_H
33 #define FLAC__FILE_ENCODER_H
36 #include "seekable_stream_encoder.h"
43 /** \file include/FLAC/file_encoder.h
46 * This module contains the functions which implement the file
49 * See the detailed documentation in the
50 * \link flac_file_encoder file encoder \endlink module.
53 /** \defgroup flac_file_encoder FLAC/file_encoder.h: file encoder interface
54 * \ingroup flac_encoder
57 * This module contains the functions which implement the file
60 * The basic usage of this encoder is as follows:
61 * - The program creates an instance of an encoder using
62 * FLAC__file_encoder_new().
63 * - The program overrides the default settings using
64 * FLAC__file_encoder_set_*() functions.
65 * - The program initializes the instance to validate the settings and
66 * prepare for encoding using FLAC__file_encoder_init().
67 * - The program calls FLAC__file_encoder_process() or
68 * FLAC__file_encoder_process_interleaved() to encode data, which
69 * subsequently writes data to the output file.
70 * - The program finishes the encoding with FLAC__file_encoder_finish(),
71 * which causes the encoder to encode any data still in its input pipe,
72 * rewind and write the STREAMINFO metadata to file, and finally reset
73 * the encoder to the uninitialized state.
74 * - The instance may be used again or deleted with
75 * FLAC__file_encoder_delete().
77 * The file encoder is a wrapper around the
78 * \link flac_seekable_stream_encoder seekable stream encoder \endlink which supplies all
79 * callbacks internally; the user need specify only the filename.
81 * Make sure to read the detailed description of the
82 * \link flac_seekable_stream_encoder seekable stream encoder module \endlink since the
83 * \link flac_stream_encoder stream encoder module \endlink since the
84 * file encoder inherits much of its behavior from them.
87 * The "set" functions may only be called when the encoder is in the
88 * state FLAC__FILE_ENCODER_UNINITIALIZED, i.e. after
89 * FLAC__file_encoder_new() or FLAC__file_encoder_finish(), but
90 * before FLAC__file_encoder_init(). If this is the case they will
91 * return \c true, otherwise \c false.
94 * FLAC__file_encoder_finish() resets all settings to the constructor
101 /** State values for a FLAC__FileEncoder
103 * The encoder's state can be obtained by calling FLAC__file_encoder_get_state().
107 FLAC__FILE_ENCODER_OK = 0,
108 /**< The encoder is in the normal OK state. */
110 FLAC__FILE_ENCODER_NO_FILENAME,
111 /**< FLAC__file_encoder_init() was called without first calling
112 * FLAC__file_encoder_set_filename().
115 FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR,
116 /**< An error occurred in the underlying seekable stream encoder;
117 * check FLAC__file_encoder_get_seekable_stream_encoder_state().
120 FLAC__FILE_ENCODER_FATAL_ERROR_WHILE_WRITING,
121 /**< A fatal error occurred while writing to the encoded file. */
123 FLAC__FILE_ENCODER_ERROR_OPENING_FILE,
124 /**< An error occurred opening the output file for writing. */
126 FLAC__FILE_ENCODER_MEMORY_ALLOCATION_ERROR,
127 /**< Memory allocation failed. */
129 FLAC__FILE_ENCODER_ALREADY_INITIALIZED,
130 /**< FLAC__file_encoder_init() was called when the encoder was
131 * already initialized, usually because
132 * FLAC__file_encoder_finish() was not called.
135 FLAC__FILE_ENCODER_UNINITIALIZED
136 /**< The encoder is in the uninitialized state. */
138 } FLAC__FileEncoderState;
140 /** Maps a FLAC__FileEncoderState to a C string.
142 * Using a FLAC__FileEncoderState as the index to this array
143 * will give the string equivalent. The contents should not be modified.
145 extern FLAC_API const char * const FLAC__FileEncoderStateString[];
148 /***********************************************************************
150 * class FLAC__FileEncoder
152 ***********************************************************************/
154 struct FLAC__FileEncoderProtected;
155 struct FLAC__FileEncoderPrivate;
156 /** The opaque structure definition for the file encoder type.
157 * See the \link flac_file_encoder file encoder module \endlink
158 * for a detailed description.
161 struct FLAC__FileEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
162 struct FLAC__FileEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
165 /** Signature for the progress callback.
166 * See FLAC__file_encoder_set_progress_callback() for more info.
168 * \param encoder The encoder instance calling the callback.
169 * \param bytes_written Bytes written so far.
170 * \param samples_written Samples written so far.
171 * \param frames_written Frames written so far.
172 * \param total_frames_estimate The estimate of the total number of
173 * frames to be written.
174 * \param client_data The callee's client data set through
175 * FLAC__file_encoder_set_client_data().
177 typedef void (*FLAC__FileEncoderProgressCallback)(const FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
180 /***********************************************************************
182 * Class constructor/destructor
184 ***********************************************************************/
186 /** Create a new file encoder instance. The instance is created with
187 * default settings; see the individual FLAC__file_encoder_set_*()
188 * functions for each setting's default.
190 * \retval FLAC__FileEncoder*
191 * \c NULL if there was an error allocating memory, else the new instance.
193 FLAC_API FLAC__FileEncoder *FLAC__file_encoder_new();
195 /** Free an encoder instance. Deletes the object pointed to by \a encoder.
197 * \param encoder A pointer to an existing encoder.
199 * \code encoder != NULL \endcode
201 FLAC_API void FLAC__file_encoder_delete(FLAC__FileEncoder *encoder);
203 /***********************************************************************
205 * Public class method prototypes
207 ***********************************************************************/
209 /** This is inherited from FLAC__SeekableStreamEncoder; see
210 * FLAC__seekable_stream_encoder_set_verify().
213 * \param encoder An encoder instance to set.
214 * \param value See above.
216 * \code encoder != NULL \endcode
218 * \c false if the encoder is already initialized, else \c true.
220 FLAC_API FLAC__bool FLAC__file_encoder_set_verify(FLAC__FileEncoder *encoder, FLAC__bool value);
222 /** This is inherited from FLAC__SeekableStreamEncoder; see
223 * FLAC__seekable_stream_encoder_set_streamable_subset().
226 * \param encoder An encoder instance to set.
227 * \param value See above.
229 * \code encoder != NULL \endcode
231 * \c false if the encoder is already initialized, else \c true.
233 FLAC_API FLAC__bool FLAC__file_encoder_set_streamable_subset(FLAC__FileEncoder *encoder, FLAC__bool value);
235 /** This is inherited from FLAC__SeekableStreamEncoder; see
236 * FLAC__seekable_stream_encoder_set_do_mid_side_stereo().
239 * \param encoder An encoder instance to set.
240 * \param value See above.
242 * \code encoder != NULL \endcode
244 * \c false if the encoder is already initialized, else \c true.
246 FLAC_API FLAC__bool FLAC__file_encoder_set_do_mid_side_stereo(FLAC__FileEncoder *encoder, FLAC__bool value);
248 /** This is inherited from FLAC__SeekableStreamEncoder; see
249 * FLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
252 * \param encoder An encoder instance to set.
253 * \param value See above.
255 * \code encoder != NULL \endcode
257 * \c false if the encoder is already initialized, else \c true.
259 FLAC_API FLAC__bool FLAC__file_encoder_set_loose_mid_side_stereo(FLAC__FileEncoder *encoder, FLAC__bool value);
261 /** This is inherited from FLAC__SeekableStreamEncoder; see
262 * FLAC__seekable_stream_encoder_set_channels().
265 * \param encoder An encoder instance to set.
266 * \param value See above.
268 * \code encoder != NULL \endcode
270 * \c false if the encoder is already initialized, else \c true.
272 FLAC_API FLAC__bool FLAC__file_encoder_set_channels(FLAC__FileEncoder *encoder, unsigned value);
274 /** This is inherited from FLAC__SeekableStreamEncoder; see
275 * FLAC__seekable_stream_encoder_set_bits_per_sample().
278 * Do not feed the encoder data that is wider than the value you
279 * set here or you will generate an invalid stream.
282 * \param encoder An encoder instance to set.
283 * \param value See above.
285 * \code encoder != NULL \endcode
287 * \c false if the encoder is already initialized, else \c true.
289 FLAC_API FLAC__bool FLAC__file_encoder_set_bits_per_sample(FLAC__FileEncoder *encoder, unsigned value);
291 /** This is inherited from FLAC__SeekableStreamEncoder; see
292 * FLAC__seekable_stream_encoder_set_sample_rate().
295 * \param encoder An encoder instance to set.
296 * \param value See above.
298 * \code encoder != NULL \endcode
300 * \c false if the encoder is already initialized, else \c true.
302 FLAC_API FLAC__bool FLAC__file_encoder_set_sample_rate(FLAC__FileEncoder *encoder, unsigned value);
304 /** This is inherited from FLAC__SeekableStreamEncoder; see
305 * FLAC__seekable_stream_encoder_set_blocksize().
308 * \param encoder An encoder instance to set.
309 * \param value See above.
311 * \code encoder != NULL \endcode
313 * \c false if the encoder is already initialized, else \c true.
315 FLAC_API FLAC__bool FLAC__file_encoder_set_blocksize(FLAC__FileEncoder *encoder, unsigned value);
317 /** This is inherited from FLAC__SeekableStreamEncoder; see
318 * FLAC__seekable_stream_encoder_set_apodization().
321 * \param encoder An encoder instance to set.
322 * \param specification See above.
324 * \code encoder != NULL \endcode
325 * \code specification != NULL \endcode
327 * \c false if the encoder is already initialized, else \c true.
329 /* @@@@add to unit tests*/
330 FLAC_API FLAC__bool FLAC__file_encoder_set_apodization(FLAC__FileEncoder *encoder, const char *specification);
332 /** This is inherited from FLAC__SeekableStreamEncoder; see
333 * FLAC__seekable_stream_encoder_set_max_lpc_order().
336 * \param encoder An encoder instance to set.
337 * \param value See above.
339 * \code encoder != NULL \endcode
341 * \c false if the encoder is already initialized, else \c true.
343 FLAC_API FLAC__bool FLAC__file_encoder_set_max_lpc_order(FLAC__FileEncoder *encoder, unsigned value);
345 /** This is inherited from FLAC__SeekableStreamEncoder; see
346 * FLAC__seekable_stream_encoder_set_qlp_coeff_precision().
349 * In the current implementation, qlp_coeff_precision + bits_per_sample must
353 * \param encoder An encoder instance to set.
354 * \param value See above.
356 * \code encoder != NULL \endcode
358 * \c false if the encoder is already initialized, else \c true.
360 FLAC_API FLAC__bool FLAC__file_encoder_set_qlp_coeff_precision(FLAC__FileEncoder *encoder, unsigned value);
362 /** This is inherited from FLAC__SeekableStreamEncoder; see
363 * FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
366 * \param encoder An encoder instance to set.
367 * \param value See above.
369 * \code encoder != NULL \endcode
371 * \c false if the encoder is already initialized, else \c true.
373 FLAC_API FLAC__bool FLAC__file_encoder_set_do_qlp_coeff_prec_search(FLAC__FileEncoder *encoder, FLAC__bool value);
375 /** This is inherited from FLAC__SeekableStreamEncoder; see
376 * FLAC__seekable_stream_encoder_set_do_escape_coding().
379 * \param encoder An encoder instance to set.
380 * \param value See above.
382 * \code encoder != NULL \endcode
384 * \c false if the encoder is already initialized, else \c true.
386 FLAC_API FLAC__bool FLAC__file_encoder_set_do_escape_coding(FLAC__FileEncoder *encoder, FLAC__bool value);
388 /** This is inherited from FLAC__SeekableStreamEncoder; see
389 * FLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
392 * \param encoder An encoder instance to set.
393 * \param value See above.
395 * \code encoder != NULL \endcode
397 * \c false if the encoder is already initialized, else \c true.
399 FLAC_API FLAC__bool FLAC__file_encoder_set_do_exhaustive_model_search(FLAC__FileEncoder *encoder, FLAC__bool value);
401 /** This is inherited from FLAC__SeekableStreamEncoder; see
402 * FLAC__seekable_stream_encoder_set_min_residual_partition_order().
405 * \param encoder An encoder instance to set.
406 * \param value See above.
408 * \code encoder != NULL \endcode
410 * \c false if the encoder is already initialized, else \c true.
412 FLAC_API FLAC__bool FLAC__file_encoder_set_min_residual_partition_order(FLAC__FileEncoder *encoder, unsigned value);
414 /** This is inherited from FLAC__SeekableStreamEncoder; see
415 * FLAC__seekable_stream_encoder_set_max_residual_partition_order().
418 * \param encoder An encoder instance to set.
419 * \param value See above.
421 * \code encoder != NULL \endcode
423 * \c false if the encoder is already initialized, else \c true.
425 FLAC_API FLAC__bool FLAC__file_encoder_set_max_residual_partition_order(FLAC__FileEncoder *encoder, unsigned value);
427 /** This is inherited from FLAC__SeekableStreamEncoder; see
428 * FLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
431 * \param encoder An encoder instance to set.
432 * \param value See above.
434 * \code encoder != NULL \endcode
436 * \c false if the encoder is already initialized, else \c true.
438 FLAC_API FLAC__bool FLAC__file_encoder_set_rice_parameter_search_dist(FLAC__FileEncoder *encoder, unsigned value);
440 /** This is inherited from FLAC__SeekableStreamEncoder; see
441 * FLAC__seekable_stream_encoder_set_total_samples_estimate().
444 * \param encoder An encoder instance to set.
445 * \param value See above.
447 * \code encoder != NULL \endcode
449 * \c false if the encoder is already initialized, else \c true.
451 FLAC_API FLAC__bool FLAC__file_encoder_set_total_samples_estimate(FLAC__FileEncoder *encoder, FLAC__uint64 value);
453 /** This is inherited from FLAC__SeekableStreamEncoder; see
454 * FLAC__seekable_stream_encoder_set_metadata().
456 * \default \c NULL, 0
457 * \param encoder An encoder instance to set.
458 * \param metadata See above.
459 * \param num_blocks See above.
461 * \code encoder != NULL \endcode
463 * \c false if the encoder is already initialized, else \c true.
465 FLAC_API FLAC__bool FLAC__file_encoder_set_metadata(FLAC__FileEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
467 /** Set the output file name encode to.
470 * The filename is mandatory and must be set before initialization.
473 * Unlike the FLAC__FileDecoder, the filename does not interpret "-" for
474 * \c stdout; writing to \c stdout is not relevant in the file encoder.
477 * \param encoder A encoder instance to set.
478 * \param value The output file name.
480 * \code encoder != NULL \endcode
481 * \code value != NULL \endcode
483 * \c false if the encoder is already initialized, or there was a memory
484 * allocation error, else \c true.
486 FLAC_API FLAC__bool FLAC__file_encoder_set_filename(FLAC__FileEncoder *encoder, const char *value);
488 /** Set the progress callback.
489 * The supplied function will be called when the encoder has finished
490 * writing a frame. The \c total_frames_estimate argument to the callback
491 * will be based on the value from
492 * FLAC__file_encoder_set_total_samples_estimate().
495 * Unlike most other callbacks, the progress callback is \b not mandatory
496 * and need not be set before initialization.
499 * \param encoder An encoder instance to set.
500 * \param value See above.
502 * \code encoder != NULL \endcode
503 * \code value != NULL \endcode
505 * \c false if the encoder is already initialized, else \c true.
507 FLAC_API FLAC__bool FLAC__file_encoder_set_progress_callback(FLAC__FileEncoder *encoder, FLAC__FileEncoderProgressCallback value);
509 /** Set the client data to be passed back to callbacks.
510 * This value will be supplied to callbacks in their \a client_data
514 * \param encoder An encoder instance to set.
515 * \param value See above.
517 * \code encoder != NULL \endcode
519 * \c false if the encoder is already initialized, else \c true.
521 FLAC_API FLAC__bool FLAC__file_encoder_set_client_data(FLAC__FileEncoder *encoder, void *value);
523 /** Get the current encoder state.
525 * \param encoder An encoder instance to query.
527 * \code encoder != NULL \endcode
528 * \retval FLAC__FileEncoderState
529 * The current encoder state.
531 FLAC_API FLAC__FileEncoderState FLAC__file_encoder_get_state(const FLAC__FileEncoder *encoder);
533 /** Get the state of the underlying seekable stream encoder.
534 * Useful when the file encoder state is
535 * \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR.
537 * \param encoder An encoder instance to query.
539 * \code encoder != NULL \endcode
540 * \retval FLAC__SeekableStreamEncoderState
541 * The seekable stream encoder state.
543 FLAC_API FLAC__SeekableStreamEncoderState FLAC__file_encoder_get_seekable_stream_encoder_state(const FLAC__FileEncoder *encoder);
545 /** Get the state of the underlying stream encoder.
546 * Useful when the file encoder state is
547 * \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR and the seekable stream
548 * encoder state is \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR.
550 * \param encoder An encoder instance to query.
552 * \code encoder != NULL \endcode
553 * \retval FLAC__StreamEncoderState
554 * The seekable stream encoder state.
556 FLAC_API FLAC__StreamEncoderState FLAC__file_encoder_get_stream_encoder_state(const FLAC__FileEncoder *encoder);
558 /** Get the state of the underlying stream encoder's verify decoder.
559 * Useful when the file encoder state is
560 * \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR and the seekable stream
561 * encoder state is \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and
562 * the stream encoder state is \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
564 * \param encoder An encoder instance to query.
566 * \code encoder != NULL \endcode
567 * \retval FLAC__StreamDecoderState
568 * The stream encoder state.
570 FLAC_API FLAC__StreamDecoderState FLAC__file_encoder_get_verify_decoder_state(const FLAC__FileEncoder *encoder);
572 /** Get the current encoder state as a C string.
573 * This version automatically resolves
574 * \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR by getting the
575 * seekable stream encoder's state.
577 * \param encoder A encoder instance to query.
579 * \code encoder != NULL \endcode
580 * \retval const char *
581 * The encoder state as a C string. Do not modify the contents.
583 FLAC_API const char *FLAC__file_encoder_get_resolved_state_string(const FLAC__FileEncoder *encoder);
585 /** Get relevant values about the nature of a verify decoder error.
586 * Inherited from FLAC__seekable_stream_encoder_get_verify_decoder_error_stats().
587 * Useful when the file encoder state is
588 * \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR and the seekable stream
590 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
591 * stream encoder state is
592 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
594 * \param encoder An encoder instance to query.
595 * \param absolute_sample The absolute sample number of the mismatch.
596 * \param frame_number The number of the frame in which the mismatch occurred.
597 * \param channel The channel in which the mismatch occurred.
598 * \param sample The number of the sample (relative to the frame) in
599 * which the mismatch occurred.
600 * \param expected The expected value for the sample in question.
601 * \param got The actual value returned by the decoder.
603 * \code encoder != NULL \endcode
605 FLAC_API void FLAC__file_encoder_get_verify_decoder_error_stats(const FLAC__FileEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
607 /** Get the "verify" flag.
608 * This is inherited from FLAC__SeekableStreamEncoder; see
609 * FLAC__seekable_stream_encoder_get_verify().
611 * \param encoder An encoder instance to query.
613 * \code encoder != NULL \endcode
615 * See FLAC__file_encoder_set_verify().
617 FLAC_API FLAC__bool FLAC__file_encoder_get_verify(const FLAC__FileEncoder *encoder);
619 /** Get the "streamable subset" flag.
620 * This is inherited from FLAC__SeekableStreamEncoder; see
621 * FLAC__seekable_stream_encoder_get_streamable_subset().
623 * \param encoder An encoder instance to query.
625 * \code encoder != NULL \endcode
627 * See FLAC__file_encoder_set_streamable_subset().
629 FLAC_API FLAC__bool FLAC__file_encoder_get_streamable_subset(const FLAC__FileEncoder *encoder);
631 /** Get the "mid/side stereo coding" flag.
632 * This is inherited from FLAC__SeekableStreamEncoder; see
633 * FLAC__seekable_stream_encoder_get_do_mid_side_stereo().
635 * \param encoder An encoder instance to query.
637 * \code encoder != NULL \endcode
639 * See FLAC__file_encoder_get_do_mid_side_stereo().
641 FLAC_API FLAC__bool FLAC__file_encoder_get_do_mid_side_stereo(const FLAC__FileEncoder *encoder);
643 /** Get the "adaptive mid/side switching" flag.
644 * This is inherited from FLAC__SeekableStreamEncoder; see
645 * FLAC__seekable_stream_encoder_get_loose_mid_side_stereo().
647 * \param encoder An encoder instance to query.
649 * \code encoder != NULL \endcode
651 * See FLAC__file_encoder_set_loose_mid_side_stereo().
653 FLAC_API FLAC__bool FLAC__file_encoder_get_loose_mid_side_stereo(const FLAC__FileEncoder *encoder);
655 /** Get the number of input channels being processed.
656 * This is inherited from FLAC__SeekableStreamEncoder; see
657 * FLAC__seekable_stream_encoder_get_channels().
659 * \param encoder An encoder instance to query.
661 * \code encoder != NULL \endcode
663 * See FLAC__file_encoder_set_channels().
665 FLAC_API unsigned FLAC__file_encoder_get_channels(const FLAC__FileEncoder *encoder);
667 /** Get the input sample resolution setting.
668 * This is inherited from FLAC__SeekableStreamEncoder; see
669 * FLAC__seekable_stream_encoder_get_bits_per_sample().
671 * \param encoder An encoder instance to query.
673 * \code encoder != NULL \endcode
675 * See FLAC__file_encoder_set_bits_per_sample().
677 FLAC_API unsigned FLAC__file_encoder_get_bits_per_sample(const FLAC__FileEncoder *encoder);
679 /** Get the input sample rate setting.
680 * This is inherited from FLAC__SeekableStreamEncoder; see
681 * FLAC__seekable_stream_encoder_get_sample_rate().
683 * \param encoder An encoder instance to query.
685 * \code encoder != NULL \endcode
687 * See FLAC__file_encoder_set_sample_rate().
689 FLAC_API unsigned FLAC__file_encoder_get_sample_rate(const FLAC__FileEncoder *encoder);
691 /** Get the blocksize setting.
692 * This is inherited from FLAC__SeekableStreamEncoder; see
693 * FLAC__seekable_stream_encoder_get_blocksize().
695 * \param encoder An encoder instance to query.
697 * \code encoder != NULL \endcode
699 * See FLAC__file_encoder_set_blocksize().
701 FLAC_API unsigned FLAC__file_encoder_get_blocksize(const FLAC__FileEncoder *encoder);
703 /** Get the maximum LPC order setting.
704 * This is inherited from FLAC__SeekableStreamEncoder; see
705 * FLAC__seekable_stream_encoder_get_max_lpc_order().
707 * \param encoder An encoder instance to query.
709 * \code encoder != NULL \endcode
711 * See FLAC__file_encoder_set_max_lpc_order().
713 FLAC_API unsigned FLAC__file_encoder_get_max_lpc_order(const FLAC__FileEncoder *encoder);
715 /** Get the quantized linear predictor coefficient precision setting.
716 * This is inherited from FLAC__SeekableStreamEncoder; see
717 * FLAC__seekable_stream_encoder_get_qlp_coeff_precision().
719 * \param encoder An encoder instance to query.
721 * \code encoder != NULL \endcode
723 * See FLAC__file_encoder_set_qlp_coeff_precision().
725 FLAC_API unsigned FLAC__file_encoder_get_qlp_coeff_precision(const FLAC__FileEncoder *encoder);
727 /** Get the qlp coefficient precision search flag.
728 * This is inherited from FLAC__SeekableStreamEncoder; see
729 * FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search().
731 * \param encoder An encoder instance to query.
733 * \code encoder != NULL \endcode
735 * See FLAC__file_encoder_set_do_qlp_coeff_prec_search().
737 FLAC_API FLAC__bool FLAC__file_encoder_get_do_qlp_coeff_prec_search(const FLAC__FileEncoder *encoder);
739 /** Get the "escape coding" flag.
740 * This is inherited from FLAC__SeekableStreamEncoder; see
741 * FLAC__seekable_stream_encoder_get_do_escape_coding().
743 * \param encoder An encoder instance to query.
745 * \code encoder != NULL \endcode
747 * See FLAC__file_encoder_set_do_escape_coding().
749 FLAC_API FLAC__bool FLAC__file_encoder_get_do_escape_coding(const FLAC__FileEncoder *encoder);
751 /** Get the exhaustive model search flag.
752 * This is inherited from FLAC__SeekableStreamEncoder; see
753 * FLAC__seekable_stream_encoder_get_do_exhaustive_model_search().
755 * \param encoder An encoder instance to query.
757 * \code encoder != NULL \endcode
759 * See FLAC__file_encoder_set_do_exhaustive_model_search().
761 FLAC_API FLAC__bool FLAC__file_encoder_get_do_exhaustive_model_search(const FLAC__FileEncoder *encoder);
763 /** Get the minimum residual partition order setting.
764 * This is inherited from FLAC__SeekableStreamEncoder; see
765 * FLAC__seekable_stream_encoder_get_min_residual_partition_order().
767 * \param encoder An encoder instance to query.
769 * \code encoder != NULL \endcode
771 * See FLAC__file_encoder_set_min_residual_partition_order().
773 FLAC_API unsigned FLAC__file_encoder_get_min_residual_partition_order(const FLAC__FileEncoder *encoder);
775 /** Get maximum residual partition order setting.
776 * This is inherited from FLAC__SeekableStreamEncoder; see
777 * FLAC__seekable_stream_encoder_get_max_residual_partition_order().
779 * \param encoder An encoder instance to query.
781 * \code encoder != NULL \endcode
783 * See FLAC__file_encoder_set_max_residual_partition_order().
785 FLAC_API unsigned FLAC__file_encoder_get_max_residual_partition_order(const FLAC__FileEncoder *encoder);
787 /** Get the Rice parameter search distance setting.
788 * This is inherited from FLAC__SeekableStreamEncoder; see
789 * FLAC__seekable_stream_encoder_get_rice_parameter_search_dist().
791 * \param encoder An encoder instance to query.
793 * \code encoder != NULL \endcode
795 * See FLAC__file_encoder_set_rice_parameter_search_dist().
797 FLAC_API unsigned FLAC__file_encoder_get_rice_parameter_search_dist(const FLAC__FileEncoder *encoder);
799 /** Get the previously set estimate of the total samples to be encoded.
800 * This is inherited from FLAC__SeekableStreamEncoder; see
801 * FLAC__seekable_stream_encoder_get_total_samples_estimate().
803 * \param encoder An encoder instance to query.
805 * \code encoder != NULL \endcode
806 * \retval FLAC__uint64
807 * See FLAC__file_encoder_set_total_samples_estimate().
809 FLAC_API FLAC__uint64 FLAC__file_encoder_get_total_samples_estimate(const FLAC__FileEncoder *encoder);
811 /** Initialize the encoder instance.
812 * Should be called after FLAC__file_encoder_new() and
813 * FLAC__file_encoder_set_*() but before FLAC__file_encoder_process()
814 * or FLAC__file_encoder_process_interleaved(). Will set and return
815 * the encoder state, which will be FLAC__FILE_ENCODER_OK if
816 * initialization succeeded.
818 * \param encoder An uninitialized encoder instance.
820 * \code encoder != NULL \endcode
821 * \retval FLAC__FileEncoderState
822 * \c FLAC__FILE_ENCODER_OK if initialization was successful; see
823 * FLAC__FileEncoderState for the meanings of other return values.
825 FLAC_API FLAC__FileEncoderState FLAC__file_encoder_init(FLAC__FileEncoder *encoder);
827 /** Finish the encoding process.
828 * Flushes the encoding buffer, releases resources, resets the encoder
829 * settings to their defaults, and returns the encoder state to
830 * FLAC__FILE_ENCODER_UNINITIALIZED.
832 * In the event of a prematurely-terminated encode, it is not strictly
833 * necessary to call this immediately before FLAC__file_encoder_delete()
834 * but it is good practice to match every FLAC__file_encoder_init()
835 * with a FLAC__file_encoder_finish().
837 * \param encoder An uninitialized encoder instance.
839 * \code encoder != NULL \endcode
841 FLAC_API void FLAC__file_encoder_finish(FLAC__FileEncoder *encoder);
843 /** Submit data for encoding.
844 * This is inherited from FLAC__SeekableStreamEncoder; see
845 * FLAC__seekable_stream_encoder_process().
847 * \param encoder An initialized encoder instance in the OK state.
848 * \param buffer An array of pointers to each channel's signal.
849 * \param samples The number of samples in one channel.
851 * \code encoder != NULL \endcode
852 * \code FLAC__file_encoder_get_state(encoder) == FLAC__FILE_ENCODER_OK \endcode
854 * \c true if successful, else \c false; in this case, check the
855 * encoder state with FLAC__file_encoder_get_state() to see what
858 FLAC_API FLAC__bool FLAC__file_encoder_process(FLAC__FileEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
860 /** Submit data for encoding.
861 * This is inherited from FLAC__SeekableStreamEncoder; see
862 * FLAC__seekable_stream_encoder_process_interleaved().
864 * \param encoder An initialized encoder instance in the OK state.
865 * \param buffer An array of channel-interleaved data (see above).
866 * \param samples The number of samples in one channel, the same as for
867 * FLAC__file_encoder_process(). For example, if
868 * encoding two channels, \c 1000 \a samples corresponds
869 * to a \a buffer of 2000 values.
871 * \code encoder != NULL \endcode
872 * \code FLAC__file_encoder_get_state(encoder) == FLAC__FILE_ENCODER_OK \endcode
874 * \c true if successful, else \c false; in this case, check the
875 * encoder state with FLAC__file_encoder_get_state() to see what
878 FLAC_API FLAC__bool FLAC__file_encoder_process_interleaved(FLAC__FileEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);