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
23 #include "stream_encoder.h"
30 /** \file include/FLAC/seekable_stream_encoder.h
33 * This module contains the functions which implement the seekable stream
36 * See the detailed documentation in the
37 * \link flac_seekable_stream_encoder seekable stream encoder \endlink module.
40 /** \defgroup flac_seekable_stream_encoder FLAC/seekable_stream_encoder.h: seekable stream encoder interface
41 * \ingroup flac_encoder
44 * This module contains the functions which implement the seekable stream
47 * The basic usage of this encoder is as follows:
48 * - The program creates an instance of an encoder using
49 * FLAC__seekable_stream_encoder_new().
50 * - The program overrides the default settings and sets callbacks using
51 * FLAC__seekable_stream_encoder_set_*() functions.
52 * - The program initializes the instance to validate the settings and
53 * prepare for encoding using FLAC__seekable_stream_encoder_init().
54 * - The program calls FLAC__seekable_stream_encoder_process() or
55 * FLAC__seekable_stream_encoder_process_interleaved() to encode data, which
56 * subsequently calls the callbacks when there is encoder data ready
58 * - The program finishes the encoding with FLAC__seekable_stream_encoder_finish(),
59 * which causes the encoder to encode any data still in its input pipe,
60 * rewrite the metadata with the final encoding statistics, and finally
61 * reset the encoder to the uninitialized state.
62 * - The instance may be used again or deleted with
63 * FLAC__seekable_stream_encoder_delete().
65 * The seekable stream encoder is a wrapper around the
66 * \link flac_stream_encoder stream encoder \endlink with callbacks for
67 * seeking the output. This allows the encoder to go back and rewrite
68 * some of the metadata after encoding if necessary, and provides the
69 * metadata callback of the stream encoder internally. However, you
70 * must provide a seek callback (see
71 * FLAC__seekable_stream_encoder_set_seek_callback()).
73 * Make sure to read the detailed description of the
74 * \link flac_stream_encoder stream encoder module \endlink since the
75 * seekable stream encoder inherits much of its behavior.
78 * If you are writing the FLAC data to a file, make sure it is open
79 * for update (e.g. mode "w+" for stdio streams). This is because after
80 * the first encoding pass, the encoder will try to seek back to the
81 * beginning of the stream, to the STREAMINFO block, to write some data
85 * The "set" functions may only be called when the encoder is in the
86 * state FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED, i.e. after
87 * FLAC__seekable_stream_encoder_new() or FLAC__seekable_stream_encoder_finish(), but
88 * before FLAC__seekable_stream_encoder_init(). If this is the case they will
89 * return \c true, otherwise \c false.
92 * FLAC__seekable_stream_encoder_finish() resets all settings to the constructor
93 * defaults, including the callbacks.
99 /** State values for a FLAC__SeekableStreamEncoder
101 * The encoder's state can be obtained by calling FLAC__seekable_stream_encoder_get_state().
105 FLAC__SEEKABLE_STREAM_ENCODER_OK = 0,
106 /**< The encoder is in the normal OK state. */
108 FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR,
109 /**< An error occurred in the underlying stream encoder;
110 * check FLAC__seekable_stream_encoder_get_stream_encoder_state().
113 FLAC__SEEKABLE_STREAM_ENCODER_MEMORY_ALLOCATION_ERROR,
114 /**< Memory allocation failed. */
116 FLAC__SEEKABLE_STREAM_ENCODER_WRITE_ERROR,
117 /**< The write callback returned an error. */
119 FLAC__SEEKABLE_STREAM_ENCODER_READ_ERROR,
120 /**< The read callback returned an error. */
122 FLAC__SEEKABLE_STREAM_ENCODER_SEEK_ERROR,
123 /**< The seek callback returned an error. */
125 FLAC__SEEKABLE_STREAM_ENCODER_ALREADY_INITIALIZED,
126 /**< FLAC__seekable_stream_encoder_init() was called when the encoder was
127 * already initialized, usually because
128 * FLAC__seekable_stream_encoder_finish() was not called.
131 FLAC__SEEKABLE_STREAM_ENCODER_INVALID_CALLBACK,
132 /**< FLAC__seekable_stream_encoder_init() was called without all
133 * callbacks being set.
136 FLAC__SEEKABLE_STREAM_ENCODER_INVALID_SEEKTABLE,
137 /**< An invalid seek table was passed is the metadata to
138 * FLAC__seekable_stream_encoder_set_metadata().
141 FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED
142 /**< The encoder is in the uninitialized state. */
144 } FLAC__SeekableStreamEncoderState;
146 /** Maps a FLAC__SeekableStreamEncoderState to a C string.
148 * Using a FLAC__SeekableStreamEncoderState as the index to this array
149 * will give the string equivalent. The contents should not be modified.
151 extern const char * const FLAC__SeekableStreamEncoderStateString[];
154 /** Return values for the FLAC__SeekableStreamEncoder seek callback.
158 FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK,
159 /**< The seek was OK and encoding can continue. */
161 FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR
162 /**< An unrecoverable error occurred. The encoder will return from the process call. */
164 } FLAC__SeekableStreamEncoderSeekStatus;
166 /** Maps a FLAC__SeekableStreamEncoderSeekStatus to a C string.
168 * Using a FLAC__SeekableStreamEncoderSeekStatus as the index to this array
169 * will give the string equivalent. The contents should not be modified.
171 extern const char * const FLAC__SeekableStreamEncoderSeekStatusString[];
174 /***********************************************************************
176 * class FLAC__SeekableStreamEncoder
178 ***********************************************************************/
180 struct FLAC__SeekableStreamEncoderProtected;
181 struct FLAC__SeekableStreamEncoderPrivate;
182 /** The opaque structure definition for the seekable stream encoder type.
183 * See the \link flac_seekable_stream_encoder seekable stream encoder module \endlink
184 * for a detailed description.
187 struct FLAC__SeekableStreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
188 struct FLAC__SeekableStreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
189 } FLAC__SeekableStreamEncoder;
191 /** Signature for the seek callback.
192 * See FLAC__seekable_stream_encoder_set_seek_callback() for more info.
194 * \param encoder The encoder instance calling the callback.
195 * \param absolute_byte_offset The offset from the beginning of the stream
197 * \param client_data The callee's client data set through
198 * FLAC__seekable_stream_encoder_set_client_data().
199 * \retval FLAC__SeekableStreamEncoderSeekStatus
200 * The callee's return status.
202 typedef FLAC__SeekableStreamEncoderSeekStatus (*FLAC__SeekableStreamEncoderSeekCallback)(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
204 /** Signature for the write callback.
205 * See FLAC__seekable_stream_encoder_set_write_callback()
206 * and FLAC__StreamEncoderWriteCallback for more info.
208 * \param encoder The encoder instance calling the callback.
209 * \param buffer An array of encoded data of length \a bytes.
210 * \param bytes The byte length of \a buffer.
211 * \param samples The number of samples encoded by \a buffer.
212 * \c 0 has a special meaning; see
213 * FLAC__stream_encoder_set_write_callback().
214 * \param current_frame The number of current frame being encoded.
215 * \param client_data The callee's client data set through
216 * FLAC__seekable_stream_encoder_set_client_data().
217 * \retval FLAC__StreamEncoderWriteStatus
218 * The callee's return status.
220 typedef FLAC__StreamEncoderWriteStatus (*FLAC__SeekableStreamEncoderWriteCallback)(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
223 /***********************************************************************
225 * Class constructor/destructor
227 ***********************************************************************/
229 /** Create a new seekable stream encoder instance. The instance is created with
230 * default settings; see the individual FLAC__seekable_stream_encoder_set_*()
231 * functions for each setting's default.
233 * \retval FLAC__SeekableStreamEncoder*
234 * \c NULL if there was an error allocating memory, else the new instance.
236 FLAC__SeekableStreamEncoder *FLAC__seekable_stream_encoder_new();
238 /** Free an encoder instance. Deletes the object pointed to by \a encoder.
240 * \param encoder A pointer to an existing encoder.
242 * \code encoder != NULL \endcode
244 void FLAC__seekable_stream_encoder_delete(FLAC__SeekableStreamEncoder *encoder);
246 /***********************************************************************
248 * Public class method prototypes
250 ***********************************************************************/
252 /** This is inherited from FLAC__StreamEncoder; see
253 * FLAC__stream_encoder_set_verify().
256 * \param encoder An encoder instance to set.
257 * \param value See above.
259 * \code encoder != NULL \endcode
261 * \c false if the encoder is already initialized, else \c true.
263 FLAC__bool FLAC__seekable_stream_encoder_set_verify(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
265 /** This is inherited from FLAC__StreamEncoder; see
266 * FLAC__stream_encoder_set_streamable_subset().
269 * \param encoder An encoder instance to set.
270 * \param value See above.
272 * \code encoder != NULL \endcode
274 * \c false if the encoder is already initialized, else \c true.
276 FLAC__bool FLAC__seekable_stream_encoder_set_streamable_subset(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
278 /** This is inherited from FLAC__StreamEncoder; see
279 * FLAC__stream_encoder_set_do_mid_side_stereo().
282 * \param encoder An encoder instance to set.
283 * \param value See above.
285 * \code encoder != NULL \endcode
287 * \c false if the encoder is already initialized, else \c true.
289 FLAC__bool FLAC__seekable_stream_encoder_set_do_mid_side_stereo(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
291 /** This is inherited from FLAC__StreamEncoder; see
292 * FLAC__stream_encoder_set_loose_mid_side_stereo().
295 * \param encoder An encoder instance to set.
296 * \param value See above.
298 * \code encoder != NULL \endcode
300 * \c false if the encoder is already initialized, else \c true.
302 FLAC__bool FLAC__seekable_stream_encoder_set_loose_mid_side_stereo(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
304 /** This is inherited from FLAC__StreamEncoder; see
305 * FLAC__stream_encoder_set_channels().
308 * \param encoder An encoder instance to set.
309 * \param value See above.
311 * \code encoder != NULL \endcode
313 * \c false if the encoder is already initialized, else \c true.
315 FLAC__bool FLAC__seekable_stream_encoder_set_channels(FLAC__SeekableStreamEncoder *encoder, unsigned value);
317 /** This is inherited from FLAC__StreamEncoder; see
318 * FLAC__stream_encoder_set_bits_per_sample().
321 * Do not feed the encoder data that is wider than the value you
322 * set here or you will generate an invalid stream.
325 * \param encoder An encoder instance to set.
326 * \param value See above.
328 * \code encoder != NULL \endcode
330 * \c false if the encoder is already initialized, else \c true.
332 FLAC__bool FLAC__seekable_stream_encoder_set_bits_per_sample(FLAC__SeekableStreamEncoder *encoder, unsigned value);
334 /** This is inherited from FLAC__StreamEncoder; see
335 * FLAC__stream_encoder_set_sample_rate().
338 * \param encoder An encoder instance to set.
339 * \param value See above.
341 * \code encoder != NULL \endcode
343 * \c false if the encoder is already initialized, else \c true.
345 FLAC__bool FLAC__seekable_stream_encoder_set_sample_rate(FLAC__SeekableStreamEncoder *encoder, unsigned value);
347 /** This is inherited from FLAC__StreamEncoder; see
348 * FLAC__stream_encoder_set_blocksize().
351 * \param encoder An encoder instance to set.
352 * \param value See above.
354 * \code encoder != NULL \endcode
356 * \c false if the encoder is already initialized, else \c true.
358 FLAC__bool FLAC__seekable_stream_encoder_set_blocksize(FLAC__SeekableStreamEncoder *encoder, unsigned value);
360 /** This is inherited from FLAC__StreamEncoder; see
361 * FLAC__stream_encoder_set_max_lpc_order().
364 * \param encoder An encoder instance to set.
365 * \param value See above.
367 * \code encoder != NULL \endcode
369 * \c false if the encoder is already initialized, else \c true.
371 FLAC__bool FLAC__seekable_stream_encoder_set_max_lpc_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
373 /** This is inherited from FLAC__StreamEncoder; see
374 * FLAC__stream_encoder_set_qlp_coeff_precision().
377 * In the current implementation, qlp_coeff_precision + bits_per_sample must
381 * \param encoder An encoder instance to set.
382 * \param value See above.
384 * \code encoder != NULL \endcode
386 * \c false if the encoder is already initialized, else \c true.
388 FLAC__bool FLAC__seekable_stream_encoder_set_qlp_coeff_precision(FLAC__SeekableStreamEncoder *encoder, unsigned value);
390 /** This is inherited from FLAC__StreamEncoder; see
391 * FLAC__stream_encoder_set_do_qlp_coeff_prec_search().
394 * \param encoder An encoder instance to set.
395 * \param value See above.
397 * \code encoder != NULL \endcode
399 * \c false if the encoder is already initialized, else \c true.
401 FLAC__bool FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
403 /** This is inherited from FLAC__StreamEncoder; see
404 * FLAC__stream_encoder_set_do_escape_coding().
407 * \param encoder An encoder instance to set.
408 * \param value See above.
410 * \code encoder != NULL \endcode
412 * \c false if the encoder is already initialized, else \c true.
414 FLAC__bool FLAC__seekable_stream_encoder_set_do_escape_coding(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
416 /** This is inherited from FLAC__StreamEncoder; see
417 * FLAC__stream_encoder_set_do_exhaustive_model_search().
420 * \param encoder An encoder instance to set.
421 * \param value See above.
423 * \code encoder != NULL \endcode
425 * \c false if the encoder is already initialized, else \c true.
427 FLAC__bool FLAC__seekable_stream_encoder_set_do_exhaustive_model_search(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
429 /** This is inherited from FLAC__StreamEncoder; see
430 * FLAC__stream_encoder_set_min_residual_partition_order().
433 * \param encoder An encoder instance to set.
434 * \param value See above.
436 * \code encoder != NULL \endcode
438 * \c false if the encoder is already initialized, else \c true.
440 FLAC__bool FLAC__seekable_stream_encoder_set_min_residual_partition_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
442 /** This is inherited from FLAC__StreamEncoder; see
443 * FLAC__stream_encoder_set_max_residual_partition_order().
446 * \param encoder An encoder instance to set.
447 * \param value See above.
449 * \code encoder != NULL \endcode
451 * \c false if the encoder is already initialized, else \c true.
453 FLAC__bool FLAC__seekable_stream_encoder_set_max_residual_partition_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
455 /** This is inherited from FLAC__StreamEncoder; see
456 * FLAC__stream_encoder_set_rice_parameter_search_dist().
459 * \param encoder An encoder instance to set.
460 * \param value See above.
462 * \code encoder != NULL \endcode
464 * \c false if the encoder is already initialized, else \c true.
466 FLAC__bool FLAC__seekable_stream_encoder_set_rice_parameter_search_dist(FLAC__SeekableStreamEncoder *encoder, unsigned value);
468 /** This is inherited from FLAC__StreamEncoder; see
469 * FLAC__stream_encoder_set_total_samples_estimate().
472 * \param encoder An encoder instance to set.
473 * \param value See above.
475 * \code encoder != NULL \endcode
477 * \c false if the encoder is already initialized, else \c true.
479 FLAC__bool FLAC__seekable_stream_encoder_set_total_samples_estimate(FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 value);
481 /** This is inherited from FLAC__StreamEncoder; see
482 * FLAC__stream_encoder_set_metadata().
485 * SEEKTABLE blocks are handled specially. Since you will not know
486 * the values for the seek point stream offsets, you should pass in
487 * a SEEKTABLE 'template', that is, a SEEKTABLE object with the
488 * required sample numbers (or placeholder points), with \c 0 for the
489 * \a frame_samples and \a stream_offset fields for each point. While
490 * encoding, the encoder will fill them in for you and when encoding
491 * is finished, it will seek back and write the real values into the
492 * SEEKTABLE block in the stream. There are helper routines for
493 * manipulating seektable template blocks; see metadata.h:
494 * FLAC__metadata_object_seektable_template_*().
497 * The encoder instance \b will modify the first \c SEEKTABLE block
498 * as it transforms the template to a valid seektable while encoding,
499 * but it is still up to the caller to free all metadata blocks after
502 * \default \c NULL, 0
503 * \param encoder An encoder instance to set.
504 * \param metadata See above.
505 * \param num_blocks See above.
507 * \code encoder != NULL \endcode
509 * \c false if the encoder is already initialized, else \c true.
511 FLAC__bool FLAC__seekable_stream_encoder_set_metadata(FLAC__SeekableStreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
513 /** Set the seek callback.
514 * The supplied function will be called when the encoder needs to seek
515 * the output stream. The encoder will pass the absolute byte offset
516 * to seek to, 0 meaning the beginning of the stream.
519 * The callback is mandatory and must be set before initialization.
522 * \param encoder An encoder instance to set.
523 * \param value See above.
525 * \code encoder != NULL \endcode
526 * \code value != NULL \endcode
528 * \c false if the encoder is already initialized, else \c true.
530 FLAC__bool FLAC__seekable_stream_encoder_set_seek_callback(FLAC__SeekableStreamEncoder *encoder, FLAC__SeekableStreamEncoderSeekCallback value);
532 /** Set the write callback.
533 * This is inherited from FLAC__StreamEncoder; see
534 * FLAC__stream_encoder_set_write_callback().
537 * The callback is mandatory and must be set before initialization.
540 * \param encoder An encoder instance to set.
541 * \param value See above.
543 * \code encoder != NULL \endcode
544 * \code value != NULL \endcode
546 * \c false if the encoder is already initialized, else \c true.
548 FLAC__bool FLAC__seekable_stream_encoder_set_write_callback(FLAC__SeekableStreamEncoder *encoder, FLAC__SeekableStreamEncoderWriteCallback value);
550 /** Set the client data to be passed back to callbacks.
551 * This value will be supplied to callbacks in their \a client_data
555 * \param encoder An encoder instance to set.
556 * \param value See above.
558 * \code encoder != NULL \endcode
560 * \c false if the encoder is already initialized, else \c true.
562 FLAC__bool FLAC__seekable_stream_encoder_set_client_data(FLAC__SeekableStreamEncoder *encoder, void *value);
564 /** Get the current encoder state.
566 * \param encoder An encoder instance to query.
568 * \code encoder != NULL \endcode
569 * \retval FLAC__SeekableStreamEncoderState
570 * The current encoder state.
572 FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_get_state(const FLAC__SeekableStreamEncoder *encoder);
574 /** Get the state of the underlying stream encoder.
575 * Useful when the seekable stream encoder state is
576 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR.
578 * \param encoder An encoder instance to query.
580 * \code encoder != NULL \endcode
581 * \retval FLAC__StreamEncoderState
582 * The stream encoder state.
584 FLAC__StreamEncoderState FLAC__seekable_stream_encoder_get_stream_encoder_state(const FLAC__SeekableStreamEncoder *encoder);
586 /** Get the state of the underlying stream encoder's verify decoder.
587 * Useful when the seekable stream encoder state is
588 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
589 * stream encoder state is \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
591 * \param encoder An encoder instance to query.
593 * \code encoder != NULL \endcode
594 * \retval FLAC__StreamDecoderState
595 * The stream encoder state.
597 FLAC__StreamDecoderState FLAC__seekable_stream_encoder_get_verify_decoder_state(const FLAC__SeekableStreamEncoder *encoder);
599 /** Get relevant values about the nature of a verify decoder error.
600 * Inherited from FLAC__stream_encoder_get_verify_decoder_error_stats().
601 * Useful when the seekable stream encoder state is
602 * \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
603 * stream encoder state is
604 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
606 * \param encoder An encoder instance to query.
607 * \param absolute_sample The absolute sample number of the mismatch.
608 * \param frame_number The number of the frame in which the mismatch occurred.
609 * \param channel The channel in which the mismatch occurred.
610 * \param sample The number of the sample (relative to the frame) in
611 * which the mismatch occurred.
612 * \param expected The expected value for the sample in question.
613 * \param got The actual value returned by the decoder.
615 * \code encoder != NULL \endcode
617 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);
619 /** Get the "verify" flag.
620 * This is inherited from FLAC__StreamEncoder; see
621 * FLAC__stream_encoder_get_verify().
623 * \param encoder An encoder instance to query.
625 * \code encoder != NULL \endcode
627 * See FLAC__seekable_stream_encoder_set_verify().
629 FLAC__bool FLAC__seekable_stream_encoder_get_verify(const FLAC__SeekableStreamEncoder *encoder);
631 /** Get the "streamable subset" flag.
632 * This is inherited from FLAC__StreamEncoder; see
633 * FLAC__stream_encoder_get_streamable_subset().
635 * \param encoder An encoder instance to query.
637 * \code encoder != NULL \endcode
639 * See FLAC__seekable_stream_encoder_set_streamable_subset().
641 FLAC__bool FLAC__seekable_stream_encoder_get_streamable_subset(const FLAC__SeekableStreamEncoder *encoder);
643 /** Get the "mid/side stereo coding" flag.
644 * This is inherited from FLAC__StreamEncoder; see
645 * FLAC__stream_encoder_get_do_mid_side_stereo().
647 * \param encoder An encoder instance to query.
649 * \code encoder != NULL \endcode
651 * See FLAC__seekable_stream_encoder_get_do_mid_side_stereo().
653 FLAC__bool FLAC__seekable_stream_encoder_get_do_mid_side_stereo(const FLAC__SeekableStreamEncoder *encoder);
655 /** Get the "adaptive mid/side switching" flag.
656 * This is inherited from FLAC__StreamEncoder; see
657 * FLAC__stream_encoder_get_loose_mid_side_stereo().
659 * \param encoder An encoder instance to query.
661 * \code encoder != NULL \endcode
663 * See FLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
665 FLAC__bool FLAC__seekable_stream_encoder_get_loose_mid_side_stereo(const FLAC__SeekableStreamEncoder *encoder);
667 /** Get the number of input channels being processed.
668 * This is inherited from FLAC__StreamEncoder; see
669 * FLAC__stream_encoder_get_channels().
671 * \param encoder An encoder instance to query.
673 * \code encoder != NULL \endcode
675 * See FLAC__seekable_stream_encoder_set_channels().
677 unsigned FLAC__seekable_stream_encoder_get_channels(const FLAC__SeekableStreamEncoder *encoder);
679 /** Get the input sample resolution setting.
680 * This is inherited from FLAC__StreamEncoder; see
681 * FLAC__stream_encoder_get_bits_per_sample().
683 * \param encoder An encoder instance to query.
685 * \code encoder != NULL \endcode
687 * See FLAC__seekable_stream_encoder_set_bits_per_sample().
689 unsigned FLAC__seekable_stream_encoder_get_bits_per_sample(const FLAC__SeekableStreamEncoder *encoder);
691 /** Get the input sample rate setting.
692 * This is inherited from FLAC__StreamEncoder; see
693 * FLAC__stream_encoder_get_sample_rate().
695 * \param encoder An encoder instance to query.
697 * \code encoder != NULL \endcode
699 * See FLAC__seekable_stream_encoder_set_sample_rate().
701 unsigned FLAC__seekable_stream_encoder_get_sample_rate(const FLAC__SeekableStreamEncoder *encoder);
703 /** Get the blocksize setting.
704 * This is inherited from FLAC__StreamEncoder; see
705 * FLAC__stream_encoder_get_blocksize().
707 * \param encoder An encoder instance to query.
709 * \code encoder != NULL \endcode
711 * See FLAC__seekable_stream_encoder_set_blocksize().
713 unsigned FLAC__seekable_stream_encoder_get_blocksize(const FLAC__SeekableStreamEncoder *encoder);
715 /** Get the maximum LPC order setting.
716 * This is inherited from FLAC__StreamEncoder; see
717 * FLAC__stream_encoder_get_max_lpc_order().
719 * \param encoder An encoder instance to query.
721 * \code encoder != NULL \endcode
723 * See FLAC__seekable_stream_encoder_set_max_lpc_order().
725 unsigned FLAC__seekable_stream_encoder_get_max_lpc_order(const FLAC__SeekableStreamEncoder *encoder);
727 /** Get the quantized linear predictor coefficient precision setting.
728 * This is inherited from FLAC__StreamEncoder; see
729 * FLAC__stream_encoder_get_qlp_coeff_precision().
731 * \param encoder An encoder instance to query.
733 * \code encoder != NULL \endcode
735 * See FLAC__seekable_stream_encoder_set_qlp_coeff_precision().
737 unsigned FLAC__seekable_stream_encoder_get_qlp_coeff_precision(const FLAC__SeekableStreamEncoder *encoder);
739 /** Get the qlp coefficient precision search flag.
740 * This is inherited from FLAC__StreamEncoder; see
741 * FLAC__stream_encoder_get_do_qlp_coeff_prec_search().
743 * \param encoder An encoder instance to query.
745 * \code encoder != NULL \endcode
747 * See FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
749 FLAC__bool FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__SeekableStreamEncoder *encoder);
751 /** Get the "escape coding" flag.
752 * This is inherited from FLAC__StreamEncoder; see
753 * FLAC__stream_encoder_get_do_escape_coding().
755 * \param encoder An encoder instance to query.
757 * \code encoder != NULL \endcode
759 * See FLAC__seekable_stream_encoder_set_do_escape_coding().
761 FLAC__bool FLAC__seekable_stream_encoder_get_do_escape_coding(const FLAC__SeekableStreamEncoder *encoder);
763 /** Get the exhaustive model search flag.
764 * This is inherited from FLAC__StreamEncoder; see
765 * FLAC__stream_encoder_get_do_exhaustive_model_search().
767 * \param encoder An encoder instance to query.
769 * \code encoder != NULL \endcode
771 * See FLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
773 FLAC__bool FLAC__seekable_stream_encoder_get_do_exhaustive_model_search(const FLAC__SeekableStreamEncoder *encoder);
775 /** Get the minimum residual partition order setting.
776 * This is inherited from FLAC__StreamEncoder; see
777 * FLAC__stream_encoder_get_min_residual_partition_order().
779 * \param encoder An encoder instance to query.
781 * \code encoder != NULL \endcode
783 * See FLAC__seekable_stream_encoder_set_min_residual_partition_order().
785 unsigned FLAC__seekable_stream_encoder_get_min_residual_partition_order(const FLAC__SeekableStreamEncoder *encoder);
787 /** Get maximum residual partition order setting.
788 * This is inherited from FLAC__StreamEncoder; see
789 * FLAC__stream_encoder_get_max_residual_partition_order().
791 * \param encoder An encoder instance to query.
793 * \code encoder != NULL \endcode
795 * See FLAC__seekable_stream_encoder_set_max_residual_partition_order().
797 unsigned FLAC__seekable_stream_encoder_get_max_residual_partition_order(const FLAC__SeekableStreamEncoder *encoder);
799 /** Get the Rice parameter search distance setting.
800 * This is inherited from FLAC__StreamEncoder; see
801 * FLAC__stream_encoder_get_rice_parameter_search_dist().
803 * \param encoder An encoder instance to query.
805 * \code encoder != NULL \endcode
807 * See FLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
809 unsigned FLAC__seekable_stream_encoder_get_rice_parameter_search_dist(const FLAC__SeekableStreamEncoder *encoder);
811 /** Get the previously set estimate of the total samples to be encoded.
812 * This is inherited from FLAC__StreamEncoder; see
813 * FLAC__stream_encoder_get_total_samples_estimate().
815 * \param encoder An encoder instance to query.
817 * \code encoder != NULL \endcode
818 * \retval FLAC__uint64
819 * See FLAC__seekable_stream_encoder_set_total_samples_estimate().
821 FLAC__uint64 FLAC__seekable_stream_encoder_get_total_samples_estimate(const FLAC__SeekableStreamEncoder *encoder);
823 /** Initialize the encoder instance.
824 * Should be called after FLAC__seekable_stream_encoder_new() and
825 * FLAC__seekable_stream_encoder_set_*() but before FLAC__seekable_stream_encoder_process()
826 * or FLAC__seekable_stream_encoder_process_interleaved(). Will set and return
827 * the encoder state, which will be FLAC__SEEKABLE_STREAM_ENCODER_OK if
828 * initialization succeeded.
830 * The call to FLAC__seekable_stream_encoder_init() currently will also immediately
831 * call the write callback with the \c fLaC signature and all the encoded
834 * \param encoder An uninitialized encoder instance.
836 * \code encoder != NULL \endcode
837 * \retval FLAC__SeekableStreamEncoderState
838 * \c FLAC__SEEKABLE_STREAM_ENCODER_OK if initialization was successful; see
839 * FLAC__SeekableStreamEncoderState for the meanings of other return values.
841 FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_init(FLAC__SeekableStreamEncoder *encoder);
843 /** Finish the encoding process.
844 * Flushes the encoding buffer, releases resources, resets the encoder
845 * settings to their defaults, and returns the encoder state to
846 * FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED.
848 * In the event of a prematurely-terminated encode, it is not strictly
849 * necessary to call this immediately before FLAC__seekable_stream_encoder_delete()
850 * but it is good practice to match every FLAC__seekable_stream_encoder_init()
851 * with a FLAC__seekable_stream_encoder_finish().
853 * \param encoder An uninitialized encoder instance.
855 * \code encoder != NULL \endcode
857 void FLAC__seekable_stream_encoder_finish(FLAC__SeekableStreamEncoder *encoder);
859 /** Submit data for encoding.
860 * This is inherited from FLAC__StreamEncoder; see
861 * FLAC__stream_encoder_process().
863 * \param encoder An initialized encoder instance in the OK state.
864 * \param buffer An array of pointers to each channel's signal.
865 * \param samples The number of samples in one channel.
867 * \code encoder != NULL \endcode
868 * \code FLAC__seekable_stream_encoder_get_state(encoder) == FLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
870 * \c true if successful, else \c false; in this case, check the
871 * encoder state with FLAC__seekable_stream_encoder_get_state() to see what
874 FLAC__bool FLAC__seekable_stream_encoder_process(FLAC__SeekableStreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
876 /** Submit data for encoding.
877 * This is inherited from FLAC__StreamEncoder; see
878 * FLAC__stream_encoder_process_interleaved().
880 * \param encoder An initialized encoder instance in the OK state.
881 * \param buffer An array of channel-interleaved data (see above).
882 * \param samples The number of samples in one channel, the same as for
883 * FLAC__seekable_stream_encoder_process(). For example, if
884 * encoding two channels, \c 1000 \a samples corresponds
885 * to a \a buffer of 2000 values.
887 * \code encoder != NULL \endcode
888 * \code FLAC__seekable_stream_encoder_get_state(encoder) == FLAC__SEEKABLE_STREAM_ENCODER_OK \endcode
890 * \c true if successful, else \c false; in this case, check the
891 * encoder state with FLAC__seekable_stream_encoder_get_state() to see what
894 FLAC__bool FLAC__seekable_stream_encoder_process_interleaved(FLAC__SeekableStreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);