1 /* libOggFLAC - Free Lossless Audio Codec + Ogg library
2 * Copyright (C) 2002,2003,2004 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 OggFLAC__FILE_ENCODER_H
33 #define OggFLAC__FILE_ENCODER_H
36 #include "seekable_stream_encoder.h"
43 /** \file include/OggFLAC/file_encoder.h
46 * This module contains the functions which implement the file
49 * See the detailed documentation in the
50 * \link oggflac_file_encoder file encoder \endlink module.
53 /** \defgroup oggflac_file_encoder OggFLAC/file_encoder.h: file encoder interface
54 * \ingroup oggflac_encoder
57 * This module contains the functions which implement the file
58 * encoder. Unlink the Ogg stream and seekable stream encoders, which
59 * derive from their FLAC counterparts, the Ogg file encoder is derived
60 * from the Ogg seekable stream encoder.
62 * The interface here is nearly identical to FLAC's file
63 * encoder, including the callbacks, with the addition of
64 * OggFLAC__file_encoder_set_serial_number(). See the
65 * \link flac_file_encoder FLAC file encoder module \endlink
66 * for full documentation.
72 /** State values for a OggFLAC__FileEncoder
74 * The encoder's state can be obtained by calling OggFLAC__file_encoder_get_state().
78 OggFLAC__FILE_ENCODER_OK = 0,
79 /**< The encoder is in the normal OK state. */
81 OggFLAC__FILE_ENCODER_NO_FILENAME,
82 /**< OggFLAC__file_encoder_init() was called without first calling
83 * OggFLAC__file_encoder_set_filename().
86 OggFLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR,
87 /**< An error occurred in the underlying seekable stream encoder;
88 * check OggFLAC__file_encoder_get_seekable_stream_encoder_state().
91 OggFLAC__FILE_ENCODER_FATAL_ERROR_WHILE_WRITING,
92 /**< A fatal error occurred while writing to the encoded file. */
94 OggFLAC__FILE_ENCODER_ERROR_OPENING_FILE,
95 /**< An error occurred opening the output file for writing. */
97 OggFLAC__FILE_ENCODER_MEMORY_ALLOCATION_ERROR,
98 /**< Memory allocation failed. */
100 OggFLAC__FILE_ENCODER_ALREADY_INITIALIZED,
101 /**< OggFLAC__file_encoder_init() was called when the encoder was
102 * already initialized, usually because
103 * OggFLAC__file_encoder_finish() was not called.
106 OggFLAC__FILE_ENCODER_UNINITIALIZED
107 /**< The encoder is in the uninitialized state. */
109 } OggFLAC__FileEncoderState;
111 /** Maps a FLAC__FileEncoderState to a C string.
113 * Using a FLAC__FileEncoderState as the index to this array
114 * will give the string equivalent. The contents should not be modified.
116 extern OggFLAC_API const char * const OggFLAC__FileEncoderStateString[];
119 /***********************************************************************
121 * class FLAC__FileEncoder
123 ***********************************************************************/
125 struct OggFLAC__FileEncoderProtected;
126 struct OggFLAC__FileEncoderPrivate;
127 /** The opaque structure definition for the file encoder type.
128 * See the \link oggflac_file_encoder file encoder module \endlink
129 * for a detailed description.
132 struct OggFLAC__FileEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
133 struct OggFLAC__FileEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
134 } OggFLAC__FileEncoder;
136 /** Signature for the progress callback.
137 * See OggFLAC__file_encoder_set_progress_callback()
138 * and FLAC__FileEncoderProgressCallback for more info.
140 * \param encoder The encoder instance calling the callback.
141 * \param bytes_written Bytes written so far.
142 * \param samples_written Samples written so far.
143 * \param frames_written Frames written so far.
144 * \param total_frames_estimate The estimate of the total number of
145 * frames to be written.
146 * \param client_data The callee's client data set through
147 * OggFLAC__file_encoder_set_client_data().
149 typedef void (*OggFLAC__FileEncoderProgressCallback)(const OggFLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
152 /***********************************************************************
154 * Class constructor/destructor
156 ***********************************************************************/
158 /** Create a new file encoder instance. The instance is created with
159 * default settings; see the individual OggFLAC__file_encoder_set_*()
160 * functions for each setting's default.
162 * \retval OggFLAC__FileEncoder*
163 * \c NULL if there was an error allocating memory, else the new instance.
165 OggFLAC_API OggFLAC__FileEncoder *OggFLAC__file_encoder_new();
167 /** Free an encoder instance. Deletes the object pointed to by \a encoder.
169 * \param encoder A pointer to an existing encoder.
171 * \code encoder != NULL \endcode
173 OggFLAC_API void OggFLAC__file_encoder_delete(OggFLAC__FileEncoder *encoder);
175 /***********************************************************************
177 * Public class method prototypes
179 ***********************************************************************/
181 /** Set the serial number for the FLAC stream.
184 * \param encoder An encoder instance to set.
185 * \param serial_number See above.
187 * \code encoder != NULL \endcode
189 * \c false if the encoder is already initialized, else \c true.
191 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_serial_number(OggFLAC__FileEncoder *encoder, long serial_number);
193 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
194 * OggFLAC__seekable_stream_encoder_set_verify().
197 * \param encoder An encoder instance to set.
198 * \param value See above.
200 * \code encoder != NULL \endcode
202 * \c false if the encoder is already initialized, else \c true.
204 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_verify(OggFLAC__FileEncoder *encoder, FLAC__bool value);
206 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
207 * OggFLAC__seekable_stream_encoder_set_streamable_subset().
210 * \param encoder An encoder instance to set.
211 * \param value See above.
213 * \code encoder != NULL \endcode
215 * \c false if the encoder is already initialized, else \c true.
217 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_streamable_subset(OggFLAC__FileEncoder *encoder, FLAC__bool value);
219 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
220 * OggFLAC__seekable_stream_encoder_set_do_mid_side_stereo().
223 * \param encoder An encoder instance to set.
224 * \param value See above.
226 * \code encoder != NULL \endcode
228 * \c false if the encoder is already initialized, else \c true.
230 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_do_mid_side_stereo(OggFLAC__FileEncoder *encoder, FLAC__bool value);
232 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
233 * OggFLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
236 * \param encoder An encoder instance to set.
237 * \param value See above.
239 * \code encoder != NULL \endcode
241 * \c false if the encoder is already initialized, else \c true.
243 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_loose_mid_side_stereo(OggFLAC__FileEncoder *encoder, FLAC__bool value);
245 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
246 * OggFLAC__seekable_stream_encoder_set_channels().
249 * \param encoder An encoder instance to set.
250 * \param value See above.
252 * \code encoder != NULL \endcode
254 * \c false if the encoder is already initialized, else \c true.
256 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_channels(OggFLAC__FileEncoder *encoder, unsigned value);
258 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
259 * OggFLAC__seekable_stream_encoder_set_bits_per_sample().
262 * Do not feed the encoder data that is wider than the value you
263 * set here or you will generate an invalid stream.
266 * \param encoder An encoder instance to set.
267 * \param value See above.
269 * \code encoder != NULL \endcode
271 * \c false if the encoder is already initialized, else \c true.
273 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_bits_per_sample(OggFLAC__FileEncoder *encoder, unsigned value);
275 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
276 * OggFLAC__seekable_stream_encoder_set_sample_rate().
279 * \param encoder An encoder instance to set.
280 * \param value See above.
282 * \code encoder != NULL \endcode
284 * \c false if the encoder is already initialized, else \c true.
286 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_sample_rate(OggFLAC__FileEncoder *encoder, unsigned value);
288 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
289 * OggFLAC__seekable_stream_encoder_set_blocksize().
292 * \param encoder An encoder instance to set.
293 * \param value See above.
295 * \code encoder != NULL \endcode
297 * \c false if the encoder is already initialized, else \c true.
299 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_blocksize(OggFLAC__FileEncoder *encoder, unsigned value);
301 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
302 * OggFLAC__seekable_stream_encoder_set_max_lpc_order().
305 * \param encoder An encoder instance to set.
306 * \param value See above.
308 * \code encoder != NULL \endcode
310 * \c false if the encoder is already initialized, else \c true.
312 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_max_lpc_order(OggFLAC__FileEncoder *encoder, unsigned value);
314 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
315 * OggFLAC__seekable_stream_encoder_set_qlp_coeff_precision().
318 * In the current implementation, qlp_coeff_precision + bits_per_sample must
322 * \param encoder An encoder instance to set.
323 * \param value See above.
325 * \code encoder != NULL \endcode
327 * \c false if the encoder is already initialized, else \c true.
329 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_qlp_coeff_precision(OggFLAC__FileEncoder *encoder, unsigned value);
331 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
332 * OggFLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
335 * \param encoder An encoder instance to set.
336 * \param value See above.
338 * \code encoder != NULL \endcode
340 * \c false if the encoder is already initialized, else \c true.
342 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_do_qlp_coeff_prec_search(OggFLAC__FileEncoder *encoder, FLAC__bool value);
344 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
345 * OggFLAC__seekable_stream_encoder_set_do_escape_coding().
348 * \param encoder An encoder instance to set.
349 * \param value See above.
351 * \code encoder != NULL \endcode
353 * \c false if the encoder is already initialized, else \c true.
355 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_do_escape_coding(OggFLAC__FileEncoder *encoder, FLAC__bool value);
357 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
358 * OggFLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
361 * \param encoder An encoder instance to set.
362 * \param value See above.
364 * \code encoder != NULL \endcode
366 * \c false if the encoder is already initialized, else \c true.
368 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_do_exhaustive_model_search(OggFLAC__FileEncoder *encoder, FLAC__bool value);
370 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
371 * OggFLAC__seekable_stream_encoder_set_min_residual_partition_order().
374 * \param encoder An encoder instance to set.
375 * \param value See above.
377 * \code encoder != NULL \endcode
379 * \c false if the encoder is already initialized, else \c true.
381 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_min_residual_partition_order(OggFLAC__FileEncoder *encoder, unsigned value);
383 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
384 * OggFLAC__seekable_stream_encoder_set_max_residual_partition_order().
387 * \param encoder An encoder instance to set.
388 * \param value See above.
390 * \code encoder != NULL \endcode
392 * \c false if the encoder is already initialized, else \c true.
394 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_max_residual_partition_order(OggFLAC__FileEncoder *encoder, unsigned value);
396 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
397 * OggFLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
400 * \param encoder An encoder instance to set.
401 * \param value See above.
403 * \code encoder != NULL \endcode
405 * \c false if the encoder is already initialized, else \c true.
407 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_rice_parameter_search_dist(OggFLAC__FileEncoder *encoder, unsigned value);
409 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
410 * OggFLAC__seekable_stream_encoder_set_total_samples_estimate().
413 * \param encoder An encoder instance to set.
414 * \param value See above.
416 * \code encoder != NULL \endcode
418 * \c false if the encoder is already initialized, else \c true.
420 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_total_samples_estimate(OggFLAC__FileEncoder *encoder, FLAC__uint64 value);
422 /** This is inherited from OggFLAC__SeekableStreamEncoder; see
423 * OggFLAC__seekable_stream_encoder_set_metadata().
425 * \default \c NULL, 0
426 * \param encoder An encoder instance to set.
427 * \param metadata See above.
428 * \param num_blocks See above.
430 * \code encoder != NULL \endcode
432 * \c false if the encoder is already initialized, else \c true.
434 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_metadata(OggFLAC__FileEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
436 /** Set the output file name encode to.
439 * The filename is mandatory and must be set before initialization.
442 * Unlike the OggFLAC__FileDecoder, the filename does not interpret "-" for
443 * \c stdout; writing to \c stdout is not relevant in the file encoder.
446 * \param encoder A encoder instance to set.
447 * \param value The output file name.
449 * \code encoder != NULL \endcode
450 * \code value != NULL \endcode
452 * \c false if the encoder is already initialized, or there was a memory
453 * allocation error, else \c true.
455 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_filename(OggFLAC__FileEncoder *encoder, const char *value);
457 /** Set the progress callback.
458 * The supplied function will be called when the encoder has finished
459 * writing a frame. The \c total_frames_estimate argument to the callback
460 * will be based on the value from
461 * OggFLAC__file_encoder_set_total_samples_estimate().
464 * Unlike most other callbacks, the progress callback is \b not mandatory
465 * and need not be set before initialization.
468 * \param encoder An encoder instance to set.
469 * \param value See above.
471 * \code encoder != NULL \endcode
472 * \code value != NULL \endcode
474 * \c false if the encoder is already initialized, else \c true.
476 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_progress_callback(OggFLAC__FileEncoder *encoder, OggFLAC__FileEncoderProgressCallback value);
478 /** Set the client data to be passed back to callbacks.
479 * This value will be supplied to callbacks in their \a client_data
483 * \param encoder An encoder instance to set.
484 * \param value See above.
486 * \code encoder != NULL \endcode
488 * \c false if the encoder is already initialized, else \c true.
490 OggFLAC_API FLAC__bool OggFLAC__file_encoder_set_client_data(OggFLAC__FileEncoder *encoder, void *value);
492 /** Get the current encoder state.
494 * \param encoder An encoder instance to query.
496 * \code encoder != NULL \endcode
497 * \retval FLAC__FileEncoderState
498 * The current encoder state.
500 OggFLAC_API OggFLAC__FileEncoderState OggFLAC__file_encoder_get_state(const OggFLAC__FileEncoder *encoder);
502 /** Get the state of the underlying seekable stream encoder.
503 * Useful when the file encoder state is
504 * \c OggFLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR.
506 * \param encoder An encoder instance to query.
508 * \code encoder != NULL \endcode
509 * \retval OggFLAC__SeekableStreamEncoderState
510 * The seekable stream encoder state.
512 OggFLAC_API OggFLAC__SeekableStreamEncoderState OggFLAC__file_encoder_get_seekable_stream_encoder_state(const OggFLAC__FileEncoder *encoder);
514 /** Get the state of the underlying FLAC stream encoder.
515 * Useful when the file encoder state is
516 * \c OggFLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR
517 * and the seekable stream encoder state is
518 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR.
520 * \param encoder An encoder instance to query.
522 * \code encoder != NULL \endcode
523 * \retval FLAC__StreamEncoderState
524 * The seekable stream encoder state.
526 OggFLAC_API FLAC__StreamEncoderState OggFLAC__file_encoder_get_FLAC_stream_encoder_state(const OggFLAC__FileEncoder *encoder);
528 /** Get the state of the underlying stream encoder's verify decoder.
529 * Useful when the file encoder state is
530 * \c OggFLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR
531 * and the seekable stream encoder state is
532 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_STREAM_ENCODER_ERROR
533 * and the FLAC stream encoder state is
534 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
536 * \param encoder An encoder instance to query.
538 * \code encoder != NULL \endcode
539 * \retval FLAC__StreamDecoderState
540 * The stream encoder state.
542 OggFLAC_API FLAC__StreamDecoderState OggFLAC__file_encoder_get_verify_decoder_state(const OggFLAC__FileEncoder *encoder);
544 /** Get the current encoder state as a C string.
545 * This version automatically resolves
546 * \c OggFLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR by getting the
547 * seekable stream encoder's state.
549 * \param encoder A encoder instance to query.
551 * \code encoder != NULL \endcode
552 * \retval const char *
553 * The encoder state as a C string. Do not modify the contents.
555 OggFLAC_API const char *OggFLAC__file_encoder_get_resolved_state_string(const OggFLAC__FileEncoder *encoder);
557 /** Get relevant values about the nature of a verify decoder error.
558 * Inherited from OggFLAC__seekable_stream_encoder_get_verify_decoder_error_stats().
559 * Useful when the file encoder state is
560 * \c OggFLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR
561 * and the seekable stream encoder state is
562 * \c OggFLAC__SEEKABLE_STREAM_ENCODER_FLAC_SEEKABLE_STREAM_ENCODER_ERROR
563 * and the FLAC seekable stream encoder state is
564 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR
565 * and the FLAC stream encoder state is
566 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
568 * \param encoder An encoder instance to query.
569 * \param absolute_sample The absolute sample number of the mismatch.
570 * \param frame_number The number of the frame in which the mismatch occurred.
571 * \param channel The channel in which the mismatch occurred.
572 * \param sample The number of the sample (relative to the frame) in
573 * which the mismatch occurred.
574 * \param expected The expected value for the sample in question.
575 * \param got The actual value returned by the decoder.
577 * \code encoder != NULL \endcode
579 OggFLAC_API void OggFLAC__file_encoder_get_verify_decoder_error_stats(const OggFLAC__FileEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
581 /** Get the "verify" flag.
582 * This is inherited from OggFLAC__SeekableStreamEncoder; see
583 * OggFLAC__seekable_stream_encoder_get_verify().
585 * \param encoder An encoder instance to query.
587 * \code encoder != NULL \endcode
589 * See OggFLAC__file_encoder_set_verify().
591 OggFLAC_API FLAC__bool OggFLAC__file_encoder_get_verify(const OggFLAC__FileEncoder *encoder);
593 /** Get the "streamable subset" flag.
594 * This is inherited from OggFLAC__SeekableStreamEncoder; see
595 * OggFLAC__seekable_stream_encoder_get_streamable_subset().
597 * \param encoder An encoder instance to query.
599 * \code encoder != NULL \endcode
601 * See OggFLAC__file_encoder_set_streamable_subset().
603 OggFLAC_API FLAC__bool OggFLAC__file_encoder_get_streamable_subset(const OggFLAC__FileEncoder *encoder);
605 /** Get the "mid/side stereo coding" flag.
606 * This is inherited from OggFLAC__SeekableStreamEncoder; see
607 * OggFLAC__seekable_stream_encoder_get_do_mid_side_stereo().
609 * \param encoder An encoder instance to query.
611 * \code encoder != NULL \endcode
613 * See OggFLAC__file_encoder_get_do_mid_side_stereo().
615 OggFLAC_API FLAC__bool OggFLAC__file_encoder_get_do_mid_side_stereo(const OggFLAC__FileEncoder *encoder);
617 /** Get the "adaptive mid/side switching" flag.
618 * This is inherited from OggFLAC__SeekableStreamEncoder; see
619 * OggFLAC__seekable_stream_encoder_get_loose_mid_side_stereo().
621 * \param encoder An encoder instance to query.
623 * \code encoder != NULL \endcode
625 * See OggFLAC__file_encoder_set_loose_mid_side_stereo().
627 OggFLAC_API FLAC__bool OggFLAC__file_encoder_get_loose_mid_side_stereo(const OggFLAC__FileEncoder *encoder);
629 /** Get the number of input channels being processed.
630 * This is inherited from OggFLAC__SeekableStreamEncoder; see
631 * OggFLAC__seekable_stream_encoder_get_channels().
633 * \param encoder An encoder instance to query.
635 * \code encoder != NULL \endcode
637 * See FLAC__file_encoder_set_channels().
639 OggFLAC_API unsigned OggFLAC__file_encoder_get_channels(const OggFLAC__FileEncoder *encoder);
641 /** Get the input sample resolution setting.
642 * This is inherited from OggFLAC__SeekableStreamEncoder; see
643 * OggFLAC__seekable_stream_encoder_get_bits_per_sample().
645 * \param encoder An encoder instance to query.
647 * \code encoder != NULL \endcode
649 * See OggFLAC__file_encoder_set_bits_per_sample().
651 OggFLAC_API unsigned OggFLAC__file_encoder_get_bits_per_sample(const OggFLAC__FileEncoder *encoder);
653 /** Get the input sample rate setting.
654 * This is inherited from OggFLAC__SeekableStreamEncoder; see
655 * OggFLAC__seekable_stream_encoder_get_sample_rate().
657 * \param encoder An encoder instance to query.
659 * \code encoder != NULL \endcode
661 * See OggFLAC__file_encoder_set_sample_rate().
663 OggFLAC_API unsigned OggFLAC__file_encoder_get_sample_rate(const OggFLAC__FileEncoder *encoder);
665 /** Get the blocksize setting.
666 * This is inherited from OggFLAC__SeekableStreamEncoder; see
667 * OggFLAC__seekable_stream_encoder_get_blocksize().
669 * \param encoder An encoder instance to query.
671 * \code encoder != NULL \endcode
673 * See OggFLAC__file_encoder_set_blocksize().
675 OggFLAC_API unsigned OggFLAC__file_encoder_get_blocksize(const OggFLAC__FileEncoder *encoder);
677 /** Get the maximum LPC order setting.
678 * This is inherited from OggFLAC__SeekableStreamEncoder; see
679 * OggFLAC__seekable_stream_encoder_get_max_lpc_order().
681 * \param encoder An encoder instance to query.
683 * \code encoder != NULL \endcode
685 * See OggFLAC__file_encoder_set_max_lpc_order().
687 OggFLAC_API unsigned OggFLAC__file_encoder_get_max_lpc_order(const OggFLAC__FileEncoder *encoder);
689 /** Get the quantized linear predictor coefficient precision setting.
690 * This is inherited from OggFLAC__SeekableStreamEncoder; see
691 * OggFLAC__seekable_stream_encoder_get_qlp_coeff_precision().
693 * \param encoder An encoder instance to query.
695 * \code encoder != NULL \endcode
697 * See OggFLAC__file_encoder_set_qlp_coeff_precision().
699 OggFLAC_API unsigned OggFLAC__file_encoder_get_qlp_coeff_precision(const OggFLAC__FileEncoder *encoder);
701 /** Get the qlp coefficient precision search flag.
702 * This is inherited from OggFLAC__SeekableStreamEncoder; see
703 * OggFLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search().
705 * \param encoder An encoder instance to query.
707 * \code encoder != NULL \endcode
709 * See OggFLAC__file_encoder_set_do_qlp_coeff_prec_search().
711 OggFLAC_API FLAC__bool OggFLAC__file_encoder_get_do_qlp_coeff_prec_search(const OggFLAC__FileEncoder *encoder);
713 /** Get the "escape coding" flag.
714 * This is inherited from OggFLAC__SeekableStreamEncoder; see
715 * OggFLAC__seekable_stream_encoder_get_do_escape_coding().
717 * \param encoder An encoder instance to query.
719 * \code encoder != NULL \endcode
721 * See OggFLAC__file_encoder_set_do_escape_coding().
723 OggFLAC_API FLAC__bool OggFLAC__file_encoder_get_do_escape_coding(const OggFLAC__FileEncoder *encoder);
725 /** Get the exhaustive model search flag.
726 * This is inherited from OggFLAC__SeekableStreamEncoder; see
727 * OggFLAC__seekable_stream_encoder_get_do_exhaustive_model_search().
729 * \param encoder An encoder instance to query.
731 * \code encoder != NULL \endcode
733 * See OggFLAC__file_encoder_set_do_exhaustive_model_search().
735 OggFLAC_API FLAC__bool OggFLAC__file_encoder_get_do_exhaustive_model_search(const OggFLAC__FileEncoder *encoder);
737 /** Get the minimum residual partition order setting.
738 * This is inherited from OggFLAC__SeekableStreamEncoder; see
739 * OggFLAC__seekable_stream_encoder_get_min_residual_partition_order().
741 * \param encoder An encoder instance to query.
743 * \code encoder != NULL \endcode
745 * See OggFLAC__file_encoder_set_min_residual_partition_order().
747 OggFLAC_API unsigned OggFLAC__file_encoder_get_min_residual_partition_order(const OggFLAC__FileEncoder *encoder);
749 /** Get maximum residual partition order setting.
750 * This is inherited from OggFLAC__SeekableStreamEncoder; see
751 * OggFLAC__seekable_stream_encoder_get_max_residual_partition_order().
753 * \param encoder An encoder instance to query.
755 * \code encoder != NULL \endcode
757 * See OggFLAC__file_encoder_set_max_residual_partition_order().
759 OggFLAC_API unsigned OggFLAC__file_encoder_get_max_residual_partition_order(const OggFLAC__FileEncoder *encoder);
761 /** Get the Rice parameter search distance setting.
762 * This is inherited from OggFLAC__SeekableStreamEncoder; see
763 * OggFLAC__seekable_stream_encoder_get_rice_parameter_search_dist().
765 * \param encoder An encoder instance to query.
767 * \code encoder != NULL \endcode
769 * See OggFLAC__file_encoder_set_rice_parameter_search_dist().
771 OggFLAC_API unsigned OggFLAC__file_encoder_get_rice_parameter_search_dist(const OggFLAC__FileEncoder *encoder);
773 /** Get the previously set estimate of the total samples to be encoded.
774 * This is inherited from OggFLAC__SeekableStreamEncoder; see
775 * OggFLAC__seekable_stream_encoder_get_total_samples_estimate().
777 * \param encoder An encoder instance to query.
779 * \code encoder != NULL \endcode
780 * \retval FLAC__uint64
781 * See OggFLAC__file_encoder_set_total_samples_estimate().
783 OggFLAC_API FLAC__uint64 OggFLAC__file_encoder_get_total_samples_estimate(const OggFLAC__FileEncoder *encoder);
785 /** Initialize the encoder instance.
786 * Should be called after OggFLAC__file_encoder_new() and
787 * OggFLAC__file_encoder_set_*() but before OggFLAC__file_encoder_process()
788 * or OggFLAC__file_encoder_process_interleaved(). Will set and return
789 * the encoder state, which will be OggFLAC__FILE_ENCODER_OK if
790 * initialization succeeded.
792 * \param encoder An uninitialized encoder instance.
794 * \code encoder != NULL \endcode
795 * \retval OggFLAC__FileEncoderState
796 * \c OggFLAC__FILE_ENCODER_OK if initialization was successful; see
797 * OggFLAC__FileEncoderState for the meanings of other return values.
799 OggFLAC_API OggFLAC__FileEncoderState OggFLAC__file_encoder_init(OggFLAC__FileEncoder *encoder);
801 /** Finish the encoding process.
802 * Flushes the encoding buffer, releases resources, resets the encoder
803 * settings to their defaults, and returns the encoder state to
804 * OggFLAC__FILE_ENCODER_UNINITIALIZED.
806 * In the event of a prematurely-terminated encode, it is not strictly
807 * necessary to call this immediately before OggFLAC__file_encoder_delete()
808 * but it is good practice to match every OggFLAC__file_encoder_init()
809 * with a OggFLAC__file_encoder_finish().
811 * \param encoder An uninitialized encoder instance.
813 * \code encoder != NULL \endcode
815 OggFLAC_API void OggFLAC__file_encoder_finish(OggFLAC__FileEncoder *encoder);
817 /** Submit data for encoding.
818 * This is inherited from OggFLAC__SeekableStreamEncoder; see
819 * OggFLAC__seekable_stream_encoder_process().
821 * \param encoder An initialized encoder instance in the OK state.
822 * \param buffer An array of pointers to each channel's signal.
823 * \param samples The number of samples in one channel.
825 * \code encoder != NULL \endcode
826 * \code OggFLAC__file_encoder_get_state(encoder) == OggFLAC__FILE_ENCODER_OK \endcode
828 * \c true if successful, else \c false; in this case, check the
829 * encoder state with OggFLAC__file_encoder_get_state() to see what
832 OggFLAC_API FLAC__bool OggFLAC__file_encoder_process(OggFLAC__FileEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
834 /** Submit data for encoding.
835 * This is inherited from OggFLAC__SeekableStreamEncoder; see
836 * OggFLAC__seekable_stream_encoder_process_interleaved().
838 * \param encoder An initialized encoder instance in the OK state.
839 * \param buffer An array of channel-interleaved data (see above).
840 * \param samples The number of samples in one channel, the same as for
841 * OggFLAC__file_encoder_process(). For example, if
842 * encoding two channels, \c 1000 \a samples corresponds
843 * to a \a buffer of 2000 values.
845 * \code encoder != NULL \endcode
846 * \code OggFLAC__file_encoder_get_state(encoder) == OggFLAC__FILE_ENCODER_OK \endcode
848 * \c true if successful, else \c false; in this case, check the
849 * encoder state with OggFLAC__file_encoder_get_state() to see what
852 OggFLAC_API FLAC__bool OggFLAC__file_encoder_process_interleaved(OggFLAC__FileEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);