1 /* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2002 Josh Coalson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef FLAC__SEEKABLE_STREAM_ENCODER_H
21 #define FLAC__SEEKABLE_STREAM_ENCODER_H
24 #include "stream_encoder.h"
31 /** \file include/FLAC/seekable_stream_encoder.h
34 * This module contains the functions which implement the seekable stream
37 * See the detailed documentation in the
38 * \link flac_seekable_stream_encoder seekable stream encoder \endlink module.
41 /** \defgroup flac_seekable_stream_encoder FLAC/seekable_stream_encoder.h: seekable stream encoder interface
42 * \ingroup flac_encoder
45 * This module contains the functions which implement the seekable stream
48 * The basic usage of this encoder is as follows:
49 * - The program creates an instance of an encoder using
50 * FLAC__seekable_stream_encoder_new().
51 * - The program overrides the default settings and sets callbacks using
52 * FLAC__seekable_stream_encoder_set_*() functions.
53 * - The program initializes the instance to validate the settings and
54 * prepare for encoding using FLAC__seekable_stream_encoder_init().
55 * - The program calls FLAC__seekable_stream_encoder_process() or
56 * FLAC__seekable_stream_encoder_process_interleaved() to encode data, which
57 * subsequently calls the callbacks when there is encoder data ready
59 * - The program finishes the encoding with FLAC__seekable_stream_encoder_finish(),
60 * which causes the encoder to encode any data still in its input pipe,
61 * rewrite the metadata with the final encoding statistics, and finally
62 * reset the encoder to the uninitialized state.
63 * - The instance may be used again or deleted with
64 * FLAC__seekable_stream_encoder_delete().
66 * The seekable stream encoder is a wrapper around the
67 * \link flac_stream_encoder stream encoder \endlink with callbacks for
68 * seeking the output. This allows the encoder to go back and rewrite
69 * some of the metadata after encoding if necessary, and provides the
70 * metadata callback of the stream encoder internally. However, you
71 * must provide a seek callback (see
72 * FLAC__seekable_stream_encoder_set_seek_callback()).
74 * Make sure to read the detailed description of the
75 * \link flac_stream_encoder stream encoder module \endlink since the
76 * seekable stream encoder inherits much of its behavior.
79 * If you are writing the FLAC data to a file, make sure it is open
80 * for update (e.g. mode "w+" for stdio streams). This is because after
81 * the first encoding pass, the encoder will try to seek back to the
82 * beginning of the stream, to the STREAMINFO block, to write some data
86 * The "set" functions may only be called when the encoder is in the
87 * state FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED, i.e. after
88 * FLAC__seekable_stream_encoder_new() or FLAC__seekable_stream_encoder_finish(), but
89 * before FLAC__seekable_stream_encoder_init(). If this is the case they will
90 * return \c true, otherwise \c false.
93 * FLAC__seekable_stream_encoder_finish() resets all settings to the constructor
94 * defaults, including the callbacks.
100 /** State values for a FLAC__SeekableStreamEncoder
102 * The encoder's state can be obtained by calling FLAC__seekable_stream_encoder_get_state().
106 FLAC__SEEKABLE_STREAM_ENCODER_OK = 0,
107 /**< The encoder is in the normal OK state. */
109 FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR,
110 /**< An error occurred in the underlying stream encoder;
111 * check FLAC__seekable_stream_encoder_get_stream_encoder_state().
114 FLAC__SEEKABLE_STREAM_ENCODER_MEMORY_ALLOCATION_ERROR,
115 /**< Memory allocation failed. */
117 FLAC__SEEKABLE_STREAM_ENCODER_WRITE_ERROR,
118 /**< The write callback returned an error. */
120 FLAC__SEEKABLE_STREAM_ENCODER_READ_ERROR,
121 /**< The read callback returned an error. */
123 FLAC__SEEKABLE_STREAM_ENCODER_SEEK_ERROR,
124 /**< The seek callback returned an error. */
126 FLAC__SEEKABLE_STREAM_ENCODER_ALREADY_INITIALIZED,
127 /**< FLAC__seekable_stream_encoder_init() was called when the encoder was
128 * already initialized, usually because
129 * FLAC__seekable_stream_encoder_finish() was not called.
132 FLAC__SEEKABLE_STREAM_ENCODER_INVALID_CALLBACK,
133 /**< FLAC__seekable_stream_encoder_init() was called without all
134 * callbacks being set.
137 FLAC__SEEKABLE_STREAM_ENCODER_INVALID_SEEKTABLE,
138 /**< An invalid seek table was passed is the metadata to
139 * FLAC__seekable_stream_encoder_set_metadata().
142 FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED
143 /**< The encoder is in the uninitialized state. */
145 } FLAC__SeekableStreamEncoderState;
147 /** Maps a FLAC__SeekableStreamEncoderState to a C string.
149 * Using a FLAC__SeekableStreamEncoderState as the index to this array
150 * will give the string equivalent. The contents should not be modified.
152 extern FLAC_API const char * const FLAC__SeekableStreamEncoderStateString[];
155 /** Return values for the FLAC__SeekableStreamEncoder seek callback.
159 FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK,
160 /**< The seek was OK and encoding can continue. */
162 FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR
163 /**< An unrecoverable error occurred. The encoder will return from the process call. */
165 } FLAC__SeekableStreamEncoderSeekStatus;
167 /** Maps a FLAC__SeekableStreamEncoderSeekStatus to a C string.
169 * Using a FLAC__SeekableStreamEncoderSeekStatus as the index to this array
170 * will give the string equivalent. The contents should not be modified.
172 extern FLAC_API const char * const FLAC__SeekableStreamEncoderSeekStatusString[];
175 /***********************************************************************
177 * class FLAC__SeekableStreamEncoder
179 ***********************************************************************/
181 struct FLAC__SeekableStreamEncoderProtected;
182 struct FLAC__SeekableStreamEncoderPrivate;
183 /** The opaque structure definition for the seekable stream encoder type.
184 * See the \link flac_seekable_stream_encoder seekable stream encoder module \endlink
185 * for a detailed description.
188 struct FLAC__SeekableStreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
189 struct FLAC__SeekableStreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
190 } FLAC__SeekableStreamEncoder;
192 /** Signature for the seek callback.
193 * See FLAC__seekable_stream_encoder_set_seek_callback() for more info.
195 * \param encoder The encoder instance calling the callback.
196 * \param absolute_byte_offset The offset from the beginning of the stream
198 * \param client_data The callee's client data set through
199 * FLAC__seekable_stream_encoder_set_client_data().
200 * \retval FLAC__SeekableStreamEncoderSeekStatus
201 * The callee's return status.
203 typedef FLAC__SeekableStreamEncoderSeekStatus (*FLAC__SeekableStreamEncoderSeekCallback)(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
205 /** Signature for the write callback.
206 * See FLAC__seekable_stream_encoder_set_write_callback()
207 * and FLAC__StreamEncoderWriteCallback for more info.
209 * \param encoder The encoder instance calling the callback.
210 * \param buffer An array of encoded data of length \a bytes.
211 * \param bytes The byte length of \a buffer.
212 * \param samples The number of samples encoded by \a buffer.
213 * \c 0 has a special meaning; see
214 * FLAC__stream_encoder_set_write_callback().
215 * \param current_frame The number of current frame being encoded.
216 * \param client_data The callee's client data set through
217 * FLAC__seekable_stream_encoder_set_client_data().
218 * \retval FLAC__StreamEncoderWriteStatus
219 * The callee's return status.
221 typedef FLAC__StreamEncoderWriteStatus (*FLAC__SeekableStreamEncoderWriteCallback)(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
224 /***********************************************************************
226 * Class constructor/destructor
228 ***********************************************************************/
230 /** Create a new seekable stream encoder instance. The instance is created with
231 * default settings; see the individual FLAC__seekable_stream_encoder_set_*()
232 * functions for each setting's default.
234 * \retval FLAC__SeekableStreamEncoder*
235 * \c NULL if there was an error allocating memory, else the new instance.
237 FLAC_API FLAC__SeekableStreamEncoder *FLAC__seekable_stream_encoder_new();
239 /** Free an encoder instance. Deletes the object pointed to by \a encoder.
241 * \param encoder A pointer to an existing encoder.
243 * \code encoder != NULL \endcode
245 FLAC_API void FLAC__seekable_stream_encoder_delete(FLAC__SeekableStreamEncoder *encoder);
247 /***********************************************************************
249 * Public class method prototypes
251 ***********************************************************************/
253 /** This is inherited from FLAC__StreamEncoder; see
254 * FLAC__stream_encoder_set_verify().
257 * \param encoder An encoder instance to set.
258 * \param value See above.
260 * \code encoder != NULL \endcode
262 * \c false if the encoder is already initialized, else \c true.
264 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_verify(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
266 /** This is inherited from FLAC__StreamEncoder; see
267 * FLAC__stream_encoder_set_streamable_subset().
270 * \param encoder An encoder instance to set.
271 * \param value See above.
273 * \code encoder != NULL \endcode
275 * \c false if the encoder is already initialized, else \c true.
277 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_streamable_subset(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
279 /** This is inherited from FLAC__StreamEncoder; see
280 * FLAC__stream_encoder_set_do_mid_side_stereo().
283 * \param encoder An encoder instance to set.
284 * \param value See above.
286 * \code encoder != NULL \endcode
288 * \c false if the encoder is already initialized, else \c true.
290 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_do_mid_side_stereo(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
292 /** This is inherited from FLAC__StreamEncoder; see
293 * FLAC__stream_encoder_set_loose_mid_side_stereo().
296 * \param encoder An encoder instance to set.
297 * \param value See above.
299 * \code encoder != NULL \endcode
301 * \c false if the encoder is already initialized, else \c true.
303 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_loose_mid_side_stereo(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
305 /** This is inherited from FLAC__StreamEncoder; see
306 * FLAC__stream_encoder_set_channels().
309 * \param encoder An encoder instance to set.
310 * \param value See above.
312 * \code encoder != NULL \endcode
314 * \c false if the encoder is already initialized, else \c true.
316 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_channels(FLAC__SeekableStreamEncoder *encoder, unsigned value);
318 /** This is inherited from FLAC__StreamEncoder; see
319 * FLAC__stream_encoder_set_bits_per_sample().
322 * Do not feed the encoder data that is wider than the value you
323 * set here or you will generate an invalid stream.
326 * \param encoder An encoder instance to set.
327 * \param value See above.
329 * \code encoder != NULL \endcode
331 * \c false if the encoder is already initialized, else \c true.
333 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_bits_per_sample(FLAC__SeekableStreamEncoder *encoder, unsigned value);
335 /** This is inherited from FLAC__StreamEncoder; see
336 * FLAC__stream_encoder_set_sample_rate().
339 * \param encoder An encoder instance to set.
340 * \param value See above.
342 * \code encoder != NULL \endcode
344 * \c false if the encoder is already initialized, else \c true.
346 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_sample_rate(FLAC__SeekableStreamEncoder *encoder, unsigned value);
348 /** This is inherited from FLAC__StreamEncoder; see
349 * FLAC__stream_encoder_set_blocksize().
352 * \param encoder An encoder instance to set.
353 * \param value See above.
355 * \code encoder != NULL \endcode
357 * \c false if the encoder is already initialized, else \c true.
359 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_blocksize(FLAC__SeekableStreamEncoder *encoder, unsigned value);
361 /** This is inherited from FLAC__StreamEncoder; see
362 * FLAC__stream_encoder_set_max_lpc_order().
365 * \param encoder An encoder instance to set.
366 * \param value See above.
368 * \code encoder != NULL \endcode
370 * \c false if the encoder is already initialized, else \c true.
372 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_max_lpc_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
374 /** This is inherited from FLAC__StreamEncoder; see
375 * FLAC__stream_encoder_set_qlp_coeff_precision().
378 * In the current implementation, qlp_coeff_precision + bits_per_sample must
382 * \param encoder An encoder instance to set.
383 * \param value See above.
385 * \code encoder != NULL \endcode
387 * \c false if the encoder is already initialized, else \c true.
389 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_qlp_coeff_precision(FLAC__SeekableStreamEncoder *encoder, unsigned value);
391 /** This is inherited from FLAC__StreamEncoder; see
392 * FLAC__stream_encoder_set_do_qlp_coeff_prec_search().
395 * \param encoder An encoder instance to set.
396 * \param value See above.
398 * \code encoder != NULL \endcode
400 * \c false if the encoder is already initialized, else \c true.
402 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
404 /** This is inherited from FLAC__StreamEncoder; see
405 * FLAC__stream_encoder_set_do_escape_coding().
408 * \param encoder An encoder instance to set.
409 * \param value See above.
411 * \code encoder != NULL \endcode
413 * \c false if the encoder is already initialized, else \c true.
415 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_do_escape_coding(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
417 /** This is inherited from FLAC__StreamEncoder; see
418 * FLAC__stream_encoder_set_do_exhaustive_model_search().
421 * \param encoder An encoder instance to set.
422 * \param value See above.
424 * \code encoder != NULL \endcode
426 * \c false if the encoder is already initialized, else \c true.
428 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_do_exhaustive_model_search(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
430 /** This is inherited from FLAC__StreamEncoder; see
431 * FLAC__stream_encoder_set_min_residual_partition_order().
434 * \param encoder An encoder instance to set.
435 * \param value See above.
437 * \code encoder != NULL \endcode
439 * \c false if the encoder is already initialized, else \c true.
441 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_min_residual_partition_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
443 /** This is inherited from FLAC__StreamEncoder; see
444 * FLAC__stream_encoder_set_max_residual_partition_order().
447 * \param encoder An encoder instance to set.
448 * \param value See above.
450 * \code encoder != NULL \endcode
452 * \c false if the encoder is already initialized, else \c true.
454 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_max_residual_partition_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
456 /** This is inherited from FLAC__StreamEncoder; see
457 * FLAC__stream_encoder_set_rice_parameter_search_dist().
460 * \param encoder An encoder instance to set.
461 * \param value See above.
463 * \code encoder != NULL \endcode
465 * \c false if the encoder is already initialized, else \c true.
467 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_rice_parameter_search_dist(FLAC__SeekableStreamEncoder *encoder, unsigned value);
469 /** This is inherited from FLAC__StreamEncoder; see
470 * FLAC__stream_encoder_set_total_samples_estimate().
473 * \param encoder An encoder instance to set.
474 * \param value See above.
476 * \code encoder != NULL \endcode
478 * \c false if the encoder is already initialized, else \c true.
480 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_total_samples_estimate(FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 value);
482 /** This is inherited from FLAC__StreamEncoder; see
483 * FLAC__stream_encoder_set_metadata().
486 * SEEKTABLE blocks are handled specially. Since you will not know
487 * the values for the seek point stream offsets, you should pass in
488 * a SEEKTABLE 'template', that is, a SEEKTABLE object with the
489 * required sample numbers (or placeholder points), with \c 0 for the
490 * \a frame_samples and \a stream_offset fields for each point. While
491 * encoding, the encoder will fill them in for you and when encoding
492 * is finished, it will seek back and write the real values into the
493 * SEEKTABLE block in the stream. There are helper routines for
494 * manipulating seektable template blocks; see metadata.h:
495 * FLAC__metadata_object_seektable_template_*().
498 * The encoder instance \b will modify the first \c SEEKTABLE block
499 * as it transforms the template to a valid seektable while encoding,
500 * but it is still up to the caller to free all metadata blocks after
503 * \default \c NULL, 0
504 * \param encoder An encoder instance to set.
505 * \param metadata See above.
506 * \param num_blocks See above.
508 * \code encoder != NULL \endcode
510 * \c false if the encoder is already initialized, else \c true.
512 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_metadata(FLAC__SeekableStreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
514 /** Set the seek callback.
515 * The supplied function will be called when the encoder needs to seek
516 * the output stream. The encoder will pass the absolute byte offset
517 * to seek to, 0 meaning the beginning of the stream.
520 * The callback is mandatory and must be set before initialization.
523 * \param encoder An encoder instance to set.
524 * \param value See above.
526 * \code encoder != NULL \endcode
527 * \code value != NULL \endcode
529 * \c false if the encoder is already initialized, else \c true.
531 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_seek_callback(FLAC__SeekableStreamEncoder *encoder, FLAC__SeekableStreamEncoderSeekCallback value);
533 /** Set the write callback.
534 * This is inherited from FLAC__StreamEncoder; see
535 * FLAC__stream_encoder_set_write_callback().
538 * The callback is mandatory and must be set before initialization.
541 * \param encoder An encoder instance to set.
542 * \param value See above.
544 * \code encoder != NULL \endcode
545 * \code value != NULL \endcode
547 * \c false if the encoder is already initialized, else \c true.
549 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_write_callback(FLAC__SeekableStreamEncoder *encoder, FLAC__SeekableStreamEncoderWriteCallback value);
551 /** Set the client data to be passed back to callbacks.
552 * This value will be supplied to callbacks in their \a client_data
556 * \param encoder An encoder instance to set.
557 * \param value See above.
559 * \code encoder != NULL \endcode
561 * \c false if the encoder is already initialized, else \c true.
563 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_client_data(FLAC__SeekableStreamEncoder *encoder, void *value);
565 /** Get the current encoder state.
567 * \param encoder An encoder instance to query.
569 * \code encoder != NULL \endcode
570 * \retval FLAC__SeekableStreamEncoderState
571 * The current encoder state.
573 FLAC_API FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_get_state(const FLAC__SeekableStreamEncoder *encoder);
575 /** Get the state of the underlying stream encoder.
576 * Useful when the seekable stream encoder state is
577 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR.
579 * \param encoder An encoder instance to query.
581 * \code encoder != NULL \endcode
582 * \retval FLAC__StreamEncoderState
583 * The stream encoder state.
585 FLAC_API FLAC__StreamEncoderState FLAC__seekable_stream_encoder_get_stream_encoder_state(const FLAC__SeekableStreamEncoder *encoder);
587 /** Get the state of the underlying stream encoder's verify decoder.
588 * Useful when the seekable stream encoder state is
589 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
590 * stream encoder state is \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
592 * \param encoder An encoder instance to query.
594 * \code encoder != NULL \endcode
595 * \retval FLAC__StreamDecoderState
596 * The stream encoder state.
598 FLAC_API FLAC__StreamDecoderState FLAC__seekable_stream_encoder_get_verify_decoder_state(const FLAC__SeekableStreamEncoder *encoder);
600 /** Get relevant values about the nature of a verify decoder error.
601 * Inherited from FLAC__stream_encoder_get_verify_decoder_error_stats().
602 * Useful when the seekable stream encoder state is
603 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
604 * stream encoder state is
605 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
607 * \param encoder An encoder instance to query.
608 * \param absolute_sample The absolute sample number of the mismatch.
609 * \param frame_number The number of the frame in which the mismatch occurred.
610 * \param channel The channel in which the mismatch occurred.
611 * \param sample The number of the sample (relative to the frame) in
612 * which the mismatch occurred.
613 * \param expected The expected value for the sample in question.
614 * \param got The actual value returned by the decoder.
616 * \code encoder != NULL \endcode
618 FLAC_API void FLAC__seekable_stream_encoder_get_verify_decoder_error_stats(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
620 /** Get the "verify" flag.
621 * This is inherited from FLAC__StreamEncoder; see
622 * FLAC__stream_encoder_get_verify().
624 * \param encoder An encoder instance to query.
626 * \code encoder != NULL \endcode
628 * See FLAC__seekable_stream_encoder_set_verify().
630 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_verify(const FLAC__SeekableStreamEncoder *encoder);
632 /** Get the "streamable subset" flag.
633 * This is inherited from FLAC__StreamEncoder; see
634 * FLAC__stream_encoder_get_streamable_subset().
636 * \param encoder An encoder instance to query.
638 * \code encoder != NULL \endcode
640 * See FLAC__seekable_stream_encoder_set_streamable_subset().
642 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_streamable_subset(const FLAC__SeekableStreamEncoder *encoder);
644 /** Get the "mid/side stereo coding" flag.
645 * This is inherited from FLAC__StreamEncoder; see
646 * FLAC__stream_encoder_get_do_mid_side_stereo().
648 * \param encoder An encoder instance to query.
650 * \code encoder != NULL \endcode
652 * See FLAC__seekable_stream_encoder_get_do_mid_side_stereo().
654 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_mid_side_stereo(const FLAC__SeekableStreamEncoder *encoder);
656 /** Get the "adaptive mid/side switching" flag.
657 * This is inherited from FLAC__StreamEncoder; see
658 * FLAC__stream_encoder_get_loose_mid_side_stereo().
660 * \param encoder An encoder instance to query.
662 * \code encoder != NULL \endcode
664 * See FLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
666 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_loose_mid_side_stereo(const FLAC__SeekableStreamEncoder *encoder);
668 /** Get the number of input channels being processed.
669 * This is inherited from FLAC__StreamEncoder; see
670 * FLAC__stream_encoder_get_channels().
672 * \param encoder An encoder instance to query.
674 * \code encoder != NULL \endcode
676 * See FLAC__seekable_stream_encoder_set_channels().
678 FLAC_API unsigned FLAC__seekable_stream_encoder_get_channels(const FLAC__SeekableStreamEncoder *encoder);
680 /** Get the input sample resolution setting.
681 * This is inherited from FLAC__StreamEncoder; see
682 * FLAC__stream_encoder_get_bits_per_sample().
684 * \param encoder An encoder instance to query.
686 * \code encoder != NULL \endcode
688 * See FLAC__seekable_stream_encoder_set_bits_per_sample().
690 FLAC_API unsigned FLAC__seekable_stream_encoder_get_bits_per_sample(const FLAC__SeekableStreamEncoder *encoder);
692 /** Get the input sample rate setting.
693 * This is inherited from FLAC__StreamEncoder; see
694 * FLAC__stream_encoder_get_sample_rate().
696 * \param encoder An encoder instance to query.
698 * \code encoder != NULL \endcode
700 * See FLAC__seekable_stream_encoder_set_sample_rate().
702 FLAC_API unsigned FLAC__seekable_stream_encoder_get_sample_rate(const FLAC__SeekableStreamEncoder *encoder);
704 /** Get the blocksize setting.
705 * This is inherited from FLAC__StreamEncoder; see
706 * FLAC__stream_encoder_get_blocksize().
708 * \param encoder An encoder instance to query.
710 * \code encoder != NULL \endcode
712 * See FLAC__seekable_stream_encoder_set_blocksize().
714 FLAC_API unsigned FLAC__seekable_stream_encoder_get_blocksize(const FLAC__SeekableStreamEncoder *encoder);
716 /** Get the maximum LPC order setting.
717 * This is inherited from FLAC__StreamEncoder; see
718 * FLAC__stream_encoder_get_max_lpc_order().
720 * \param encoder An encoder instance to query.
722 * \code encoder != NULL \endcode
724 * See FLAC__seekable_stream_encoder_set_max_lpc_order().
726 FLAC_API unsigned FLAC__seekable_stream_encoder_get_max_lpc_order(const FLAC__SeekableStreamEncoder *encoder);
728 /** Get the quantized linear predictor coefficient precision setting.
729 * This is inherited from FLAC__StreamEncoder; see
730 * FLAC__stream_encoder_get_qlp_coeff_precision().
732 * \param encoder An encoder instance to query.
734 * \code encoder != NULL \endcode
736 * See FLAC__seekable_stream_encoder_set_qlp_coeff_precision().
738 FLAC_API unsigned FLAC__seekable_stream_encoder_get_qlp_coeff_precision(const FLAC__SeekableStreamEncoder *encoder);
740 /** Get the qlp coefficient precision search flag.
741 * This is inherited from FLAC__StreamEncoder; see
742 * FLAC__stream_encoder_get_do_qlp_coeff_prec_search().
744 * \param encoder An encoder instance to query.
746 * \code encoder != NULL \endcode
748 * See FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
750 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__SeekableStreamEncoder *encoder);
752 /** Get the "escape coding" flag.
753 * This is inherited from FLAC__StreamEncoder; see
754 * FLAC__stream_encoder_get_do_escape_coding().
756 * \param encoder An encoder instance to query.
758 * \code encoder != NULL \endcode
760 * See FLAC__seekable_stream_encoder_set_do_escape_coding().
762 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_escape_coding(const FLAC__SeekableStreamEncoder *encoder);
764 /** Get the exhaustive model search flag.
765 * This is inherited from FLAC__StreamEncoder; see
766 * FLAC__stream_encoder_get_do_exhaustive_model_search().
768 * \param encoder An encoder instance to query.
770 * \code encoder != NULL \endcode
772 * See FLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
774 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_exhaustive_model_search(const FLAC__SeekableStreamEncoder *encoder);
776 /** Get the minimum residual partition order setting.
777 * This is inherited from FLAC__StreamEncoder; see
778 * FLAC__stream_encoder_get_min_residual_partition_order().
780 * \param encoder An encoder instance to query.
782 * \code encoder != NULL \endcode
784 * See FLAC__seekable_stream_encoder_set_min_residual_partition_order().
786 FLAC_API unsigned FLAC__seekable_stream_encoder_get_min_residual_partition_order(const FLAC__SeekableStreamEncoder *encoder);
788 /** Get maximum residual partition order setting.
789 * This is inherited from FLAC__StreamEncoder; see
790 * FLAC__stream_encoder_get_max_residual_partition_order().
792 * \param encoder An encoder instance to query.
794 * \code encoder != NULL \endcode
796 * See FLAC__seekable_stream_encoder_set_max_residual_partition_order().
798 FLAC_API unsigned FLAC__seekable_stream_encoder_get_max_residual_partition_order(const FLAC__SeekableStreamEncoder *encoder);
800 /** Get the Rice parameter search distance setting.
801 * This is inherited from FLAC__StreamEncoder; see
802 * FLAC__stream_encoder_get_rice_parameter_search_dist().
804 * \param encoder An encoder instance to query.
806 * \code encoder != NULL \endcode
808 * See FLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
810 FLAC_API unsigned FLAC__seekable_stream_encoder_get_rice_parameter_search_dist(const FLAC__SeekableStreamEncoder *encoder);
812 /** Get the previously set estimate of the total samples to be encoded.
813 * This is inherited from FLAC__StreamEncoder; see
814 * FLAC__stream_encoder_get_total_samples_estimate().
816 * \param encoder An encoder instance to query.
818 * \code encoder != NULL \endcode
819 * \retval FLAC__uint64
820 * See FLAC__seekable_stream_encoder_set_total_samples_estimate().
822 FLAC_API FLAC__uint64 FLAC__seekable_stream_encoder_get_total_samples_estimate(const FLAC__SeekableStreamEncoder *encoder);
824 /** Initialize the encoder instance.
825 * Should be called after FLAC__seekable_stream_encoder_new() and
826 * FLAC__seekable_stream_encoder_set_*() but before FLAC__seekable_stream_encoder_process()
827 * or FLAC__seekable_stream_encoder_process_interleaved(). Will set and return
828 * the encoder state, which will be FLAC__SEEKABLE_STREAM_ENCODER_OK if
829 * initialization succeeded.
831 * The call to FLAC__seekable_stream_encoder_init() currently will also immediately
832 * call the write callback with the \c fLaC signature and all the encoded
835 * \param encoder An uninitialized encoder instance.
837 * \code encoder != NULL \endcode
838 * \retval FLAC__SeekableStreamEncoderState
839 * \c FLAC__SEEKABLE_STREAM_ENCODER_OK if initialization was successful; see
840 * FLAC__SeekableStreamEncoderState for the meanings of other return values.
842 FLAC_API FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_init(FLAC__SeekableStreamEncoder *encoder);
844 /** Finish the encoding process.
845 * Flushes the encoding buffer, releases resources, resets the encoder
846 * settings to their defaults, and returns the encoder state to
847 * FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED.
849 * In the event of a prematurely-terminated encode, it is not strictly
850 * necessary to call this immediately before FLAC__seekable_stream_encoder_delete()
851 * but it is good practice to match every FLAC__seekable_stream_encoder_init()
852 * with a FLAC__seekable_stream_encoder_finish().
854 * \param encoder An uninitialized encoder instance.
856 * \code encoder != NULL \endcode
858 FLAC_API void FLAC__seekable_stream_encoder_finish(FLAC__SeekableStreamEncoder *encoder);
860 /** Submit data for encoding.
861 * This is inherited from FLAC__StreamEncoder; see
862 * FLAC__stream_encoder_process().
864 * \param encoder An initialized encoder instance in the OK state.
865 * \param buffer An array of pointers to each channel's signal.
866 * \param samples The number of samples in one channel.
868 * \code encoder != NULL \endcode
869 * \code FLAC__seekable_stream_encoder_get_state(encoder) == FLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
871 * \c true if successful, else \c false; in this case, check the
872 * encoder state with FLAC__seekable_stream_encoder_get_state() to see what
875 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_process(FLAC__SeekableStreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
877 /** Submit data for encoding.
878 * This is inherited from FLAC__StreamEncoder; see
879 * FLAC__stream_encoder_process_interleaved().
881 * \param encoder An initialized encoder instance in the OK state.
882 * \param buffer An array of channel-interleaved data (see above).
883 * \param samples The number of samples in one channel, the same as for
884 * FLAC__seekable_stream_encoder_process(). For example, if
885 * encoding two channels, \c 1000 \a samples corresponds
886 * to a \a buffer of 2000 values.
888 * \code encoder != NULL \endcode
889 * \code FLAC__seekable_stream_encoder_get_state(encoder) == FLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
891 * \c true if successful, else \c false; in this case, check the
892 * encoder state with FLAC__seekable_stream_encoder_get_state() to see what
895 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_process_interleaved(FLAC__SeekableStreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);