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 the current encoder state as a C string.
601 * This version automatically resolves
602 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR by getting the
603 * stream encoder's state.
605 * \param encoder A encoder instance to query.
607 * \code encoder != NULL \endcode
608 * \retval const char *
609 * The encoder state as a C string. Do not modify the contents.
611 FLAC_API const char *FLAC__seekable_stream_encoder_get_resolved_state_string(const FLAC__SeekableStreamEncoder *encoder);
613 /** Get relevant values about the nature of a verify decoder error.
614 * Inherited from FLAC__stream_encoder_get_verify_decoder_error_stats().
615 * Useful when the seekable stream encoder state is
616 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
617 * stream encoder state is
618 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
620 * \param encoder An encoder instance to query.
621 * \param absolute_sample The absolute sample number of the mismatch.
622 * \param frame_number The number of the frame in which the mismatch occurred.
623 * \param channel The channel in which the mismatch occurred.
624 * \param sample The number of the sample (relative to the frame) in
625 * which the mismatch occurred.
626 * \param expected The expected value for the sample in question.
627 * \param got The actual value returned by the decoder.
629 * \code encoder != NULL \endcode
631 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);
633 /** Get the "verify" flag.
634 * This is inherited from FLAC__StreamEncoder; see
635 * FLAC__stream_encoder_get_verify().
637 * \param encoder An encoder instance to query.
639 * \code encoder != NULL \endcode
641 * See FLAC__seekable_stream_encoder_set_verify().
643 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_verify(const FLAC__SeekableStreamEncoder *encoder);
645 /** Get the "streamable subset" flag.
646 * This is inherited from FLAC__StreamEncoder; see
647 * FLAC__stream_encoder_get_streamable_subset().
649 * \param encoder An encoder instance to query.
651 * \code encoder != NULL \endcode
653 * See FLAC__seekable_stream_encoder_set_streamable_subset().
655 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_streamable_subset(const FLAC__SeekableStreamEncoder *encoder);
657 /** Get the "mid/side stereo coding" flag.
658 * This is inherited from FLAC__StreamEncoder; see
659 * FLAC__stream_encoder_get_do_mid_side_stereo().
661 * \param encoder An encoder instance to query.
663 * \code encoder != NULL \endcode
665 * See FLAC__seekable_stream_encoder_get_do_mid_side_stereo().
667 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_mid_side_stereo(const FLAC__SeekableStreamEncoder *encoder);
669 /** Get the "adaptive mid/side switching" flag.
670 * This is inherited from FLAC__StreamEncoder; see
671 * FLAC__stream_encoder_get_loose_mid_side_stereo().
673 * \param encoder An encoder instance to query.
675 * \code encoder != NULL \endcode
677 * See FLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
679 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_loose_mid_side_stereo(const FLAC__SeekableStreamEncoder *encoder);
681 /** Get the number of input channels being processed.
682 * This is inherited from FLAC__StreamEncoder; see
683 * FLAC__stream_encoder_get_channels().
685 * \param encoder An encoder instance to query.
687 * \code encoder != NULL \endcode
689 * See FLAC__seekable_stream_encoder_set_channels().
691 FLAC_API unsigned FLAC__seekable_stream_encoder_get_channels(const FLAC__SeekableStreamEncoder *encoder);
693 /** Get the input sample resolution setting.
694 * This is inherited from FLAC__StreamEncoder; see
695 * FLAC__stream_encoder_get_bits_per_sample().
697 * \param encoder An encoder instance to query.
699 * \code encoder != NULL \endcode
701 * See FLAC__seekable_stream_encoder_set_bits_per_sample().
703 FLAC_API unsigned FLAC__seekable_stream_encoder_get_bits_per_sample(const FLAC__SeekableStreamEncoder *encoder);
705 /** Get the input sample rate setting.
706 * This is inherited from FLAC__StreamEncoder; see
707 * FLAC__stream_encoder_get_sample_rate().
709 * \param encoder An encoder instance to query.
711 * \code encoder != NULL \endcode
713 * See FLAC__seekable_stream_encoder_set_sample_rate().
715 FLAC_API unsigned FLAC__seekable_stream_encoder_get_sample_rate(const FLAC__SeekableStreamEncoder *encoder);
717 /** Get the blocksize setting.
718 * This is inherited from FLAC__StreamEncoder; see
719 * FLAC__stream_encoder_get_blocksize().
721 * \param encoder An encoder instance to query.
723 * \code encoder != NULL \endcode
725 * See FLAC__seekable_stream_encoder_set_blocksize().
727 FLAC_API unsigned FLAC__seekable_stream_encoder_get_blocksize(const FLAC__SeekableStreamEncoder *encoder);
729 /** Get the maximum LPC order setting.
730 * This is inherited from FLAC__StreamEncoder; see
731 * FLAC__stream_encoder_get_max_lpc_order().
733 * \param encoder An encoder instance to query.
735 * \code encoder != NULL \endcode
737 * See FLAC__seekable_stream_encoder_set_max_lpc_order().
739 FLAC_API unsigned FLAC__seekable_stream_encoder_get_max_lpc_order(const FLAC__SeekableStreamEncoder *encoder);
741 /** Get the quantized linear predictor coefficient precision setting.
742 * This is inherited from FLAC__StreamEncoder; see
743 * FLAC__stream_encoder_get_qlp_coeff_precision().
745 * \param encoder An encoder instance to query.
747 * \code encoder != NULL \endcode
749 * See FLAC__seekable_stream_encoder_set_qlp_coeff_precision().
751 FLAC_API unsigned FLAC__seekable_stream_encoder_get_qlp_coeff_precision(const FLAC__SeekableStreamEncoder *encoder);
753 /** Get the qlp coefficient precision search flag.
754 * This is inherited from FLAC__StreamEncoder; see
755 * FLAC__stream_encoder_get_do_qlp_coeff_prec_search().
757 * \param encoder An encoder instance to query.
759 * \code encoder != NULL \endcode
761 * See FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
763 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__SeekableStreamEncoder *encoder);
765 /** Get the "escape coding" flag.
766 * This is inherited from FLAC__StreamEncoder; see
767 * FLAC__stream_encoder_get_do_escape_coding().
769 * \param encoder An encoder instance to query.
771 * \code encoder != NULL \endcode
773 * See FLAC__seekable_stream_encoder_set_do_escape_coding().
775 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_escape_coding(const FLAC__SeekableStreamEncoder *encoder);
777 /** Get the exhaustive model search flag.
778 * This is inherited from FLAC__StreamEncoder; see
779 * FLAC__stream_encoder_get_do_exhaustive_model_search().
781 * \param encoder An encoder instance to query.
783 * \code encoder != NULL \endcode
785 * See FLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
787 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_exhaustive_model_search(const FLAC__SeekableStreamEncoder *encoder);
789 /** Get the minimum residual partition order setting.
790 * This is inherited from FLAC__StreamEncoder; see
791 * FLAC__stream_encoder_get_min_residual_partition_order().
793 * \param encoder An encoder instance to query.
795 * \code encoder != NULL \endcode
797 * See FLAC__seekable_stream_encoder_set_min_residual_partition_order().
799 FLAC_API unsigned FLAC__seekable_stream_encoder_get_min_residual_partition_order(const FLAC__SeekableStreamEncoder *encoder);
801 /** Get maximum residual partition order setting.
802 * This is inherited from FLAC__StreamEncoder; see
803 * FLAC__stream_encoder_get_max_residual_partition_order().
805 * \param encoder An encoder instance to query.
807 * \code encoder != NULL \endcode
809 * See FLAC__seekable_stream_encoder_set_max_residual_partition_order().
811 FLAC_API unsigned FLAC__seekable_stream_encoder_get_max_residual_partition_order(const FLAC__SeekableStreamEncoder *encoder);
813 /** Get the Rice parameter search distance setting.
814 * This is inherited from FLAC__StreamEncoder; see
815 * FLAC__stream_encoder_get_rice_parameter_search_dist().
817 * \param encoder An encoder instance to query.
819 * \code encoder != NULL \endcode
821 * See FLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
823 FLAC_API unsigned FLAC__seekable_stream_encoder_get_rice_parameter_search_dist(const FLAC__SeekableStreamEncoder *encoder);
825 /** Get the previously set estimate of the total samples to be encoded.
826 * This is inherited from FLAC__StreamEncoder; see
827 * FLAC__stream_encoder_get_total_samples_estimate().
829 * \param encoder An encoder instance to query.
831 * \code encoder != NULL \endcode
832 * \retval FLAC__uint64
833 * See FLAC__seekable_stream_encoder_set_total_samples_estimate().
835 FLAC_API FLAC__uint64 FLAC__seekable_stream_encoder_get_total_samples_estimate(const FLAC__SeekableStreamEncoder *encoder);
837 /** Initialize the encoder instance.
838 * Should be called after FLAC__seekable_stream_encoder_new() and
839 * FLAC__seekable_stream_encoder_set_*() but before FLAC__seekable_stream_encoder_process()
840 * or FLAC__seekable_stream_encoder_process_interleaved(). Will set and return
841 * the encoder state, which will be FLAC__SEEKABLE_STREAM_ENCODER_OK if
842 * initialization succeeded.
844 * The call to FLAC__seekable_stream_encoder_init() currently will also immediately
845 * call the write callback with the \c fLaC signature and all the encoded
848 * \param encoder An uninitialized encoder instance.
850 * \code encoder != NULL \endcode
851 * \retval FLAC__SeekableStreamEncoderState
852 * \c FLAC__SEEKABLE_STREAM_ENCODER_OK if initialization was successful; see
853 * FLAC__SeekableStreamEncoderState for the meanings of other return values.
855 FLAC_API FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_init(FLAC__SeekableStreamEncoder *encoder);
857 /** Finish the encoding process.
858 * Flushes the encoding buffer, releases resources, resets the encoder
859 * settings to their defaults, and returns the encoder state to
860 * FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED.
862 * In the event of a prematurely-terminated encode, it is not strictly
863 * necessary to call this immediately before FLAC__seekable_stream_encoder_delete()
864 * but it is good practice to match every FLAC__seekable_stream_encoder_init()
865 * with a FLAC__seekable_stream_encoder_finish().
867 * \param encoder An uninitialized encoder instance.
869 * \code encoder != NULL \endcode
871 FLAC_API void FLAC__seekable_stream_encoder_finish(FLAC__SeekableStreamEncoder *encoder);
873 /** Submit data for encoding.
874 * This is inherited from FLAC__StreamEncoder; see
875 * FLAC__stream_encoder_process().
877 * \param encoder An initialized encoder instance in the OK state.
878 * \param buffer An array of pointers to each channel's signal.
879 * \param samples The number of samples in one channel.
881 * \code encoder != NULL \endcode
882 * \code FLAC__seekable_stream_encoder_get_state(encoder) == FLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
884 * \c true if successful, else \c false; in this case, check the
885 * encoder state with FLAC__seekable_stream_encoder_get_state() to see what
888 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_process(FLAC__SeekableStreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
890 /** Submit data for encoding.
891 * This is inherited from FLAC__StreamEncoder; see
892 * FLAC__stream_encoder_process_interleaved().
894 * \param encoder An initialized encoder instance in the OK state.
895 * \param buffer An array of channel-interleaved data (see above).
896 * \param samples The number of samples in one channel, the same as for
897 * FLAC__seekable_stream_encoder_process(). For example, if
898 * encoding two channels, \c 1000 \a samples corresponds
899 * to a \a buffer of 2000 values.
901 * \code encoder != NULL \endcode
902 * \code FLAC__seekable_stream_encoder_get_state(encoder) == FLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
904 * \c true if successful, else \c false; in this case, check the
905 * encoder state with FLAC__seekable_stream_encoder_get_state() to see what
908 FLAC_API FLAC__bool FLAC__seekable_stream_encoder_process_interleaved(FLAC__SeekableStreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);