add support for specifying which apodization functions to use to window data before...
[platform/upstream/flac.git] / include / FLAC / file_encoder.h
1 /* libFLAC - Free Lossless Audio Codec library
2  * Copyright (C) 2002,2003,2004,2005  Josh Coalson
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * - Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * - Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * - Neither the name of the Xiph.org Foundation nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifndef FLAC__FILE_ENCODER_H
33 #define FLAC__FILE_ENCODER_H
34
35 #include "export.h"
36 #include "seekable_stream_encoder.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42
43 /** \file include/FLAC/file_encoder.h
44  *
45  *  \brief
46  *  This module contains the functions which implement the file
47  *  encoder.
48  *
49  *  See the detailed documentation in the
50  *  \link flac_file_encoder file encoder \endlink module.
51  */
52
53 /** \defgroup flac_file_encoder FLAC/file_encoder.h: file encoder interface
54  *  \ingroup flac_encoder
55  *
56  *  \brief
57  *  This module contains the functions which implement the file
58  *  encoder.
59  *
60  * The basic usage of this encoder is as follows:
61  * - The program creates an instance of an encoder using
62  *   FLAC__file_encoder_new().
63  * - The program overrides the default settings using
64  *   FLAC__file_encoder_set_*() functions.
65  * - The program initializes the instance to validate the settings and
66  *   prepare for encoding using FLAC__file_encoder_init().
67  * - The program calls FLAC__file_encoder_process() or
68  *   FLAC__file_encoder_process_interleaved() to encode data, which
69  *   subsequently writes data to the output file.
70  * - The program finishes the encoding with FLAC__file_encoder_finish(),
71  *   which causes the encoder to encode any data still in its input pipe,
72  *   rewind and write the STREAMINFO metadata to file, and finally reset
73  *   the encoder to the uninitialized state.
74  * - The instance may be used again or deleted with
75  *   FLAC__file_encoder_delete().
76  *
77  * The file encoder is a wrapper around the
78  * \link flac_seekable_stream_encoder seekable stream encoder \endlink which supplies all
79  * callbacks internally; the user need specify only the filename.
80  *
81  * Make sure to read the detailed description of the
82  * \link flac_seekable_stream_encoder seekable stream encoder module \endlink since the
83  * \link flac_stream_encoder stream encoder module \endlink since the
84  * file encoder inherits much of its behavior from them.
85  *
86  * \note
87  * The "set" functions may only be called when the encoder is in the
88  * state FLAC__FILE_ENCODER_UNINITIALIZED, i.e. after
89  * FLAC__file_encoder_new() or FLAC__file_encoder_finish(), but
90  * before FLAC__file_encoder_init().  If this is the case they will
91  * return \c true, otherwise \c false.
92  *
93  * \note
94  * FLAC__file_encoder_finish() resets all settings to the constructor
95  * defaults.
96  *
97  * \{
98  */
99
100
101 /** State values for a FLAC__FileEncoder
102  *
103  *  The encoder's state can be obtained by calling FLAC__file_encoder_get_state().
104  */
105 typedef enum {
106
107         FLAC__FILE_ENCODER_OK = 0,
108         /**< The encoder is in the normal OK state. */
109
110         FLAC__FILE_ENCODER_NO_FILENAME,
111         /**< FLAC__file_encoder_init() was called without first calling
112          * FLAC__file_encoder_set_filename().
113          */
114
115         FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR,
116         /**< An error occurred in the underlying seekable stream encoder;
117          * check FLAC__file_encoder_get_seekable_stream_encoder_state().
118          */
119
120         FLAC__FILE_ENCODER_FATAL_ERROR_WHILE_WRITING,
121         /**< A fatal error occurred while writing to the encoded file. */
122
123         FLAC__FILE_ENCODER_ERROR_OPENING_FILE,
124         /**< An error occurred opening the output file for writing. */
125
126         FLAC__FILE_ENCODER_MEMORY_ALLOCATION_ERROR,
127         /**< Memory allocation failed. */
128
129         FLAC__FILE_ENCODER_ALREADY_INITIALIZED,
130         /**< FLAC__file_encoder_init() was called when the encoder was
131          * already initialized, usually because
132          * FLAC__file_encoder_finish() was not called.
133          */
134
135         FLAC__FILE_ENCODER_UNINITIALIZED
136         /**< The encoder is in the uninitialized state. */
137
138 } FLAC__FileEncoderState;
139
140 /** Maps a FLAC__FileEncoderState to a C string.
141  *
142  *  Using a FLAC__FileEncoderState as the index to this array
143  *  will give the string equivalent.  The contents should not be modified.
144  */
145 extern FLAC_API const char * const FLAC__FileEncoderStateString[];
146
147
148 /***********************************************************************
149  *
150  * class FLAC__FileEncoder
151  *
152  ***********************************************************************/
153
154 struct FLAC__FileEncoderProtected;
155 struct FLAC__FileEncoderPrivate;
156 /** The opaque structure definition for the file encoder type.
157  *  See the \link flac_file_encoder file encoder module \endlink
158  *  for a detailed description.
159  */
160 typedef struct {
161         struct FLAC__FileEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
162         struct FLAC__FileEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
163 } FLAC__FileEncoder;
164
165 /** Signature for the progress callback.
166  *  See FLAC__file_encoder_set_progress_callback() for more info.
167  *
168  * \param  encoder          The encoder instance calling the callback.
169  * \param  bytes_written    Bytes written so far.
170  * \param  samples_written  Samples written so far.
171  * \param  frames_written   Frames written so far.
172  * \param  total_frames_estimate  The estimate of the total number of
173  *                                frames to be written.
174  * \param  client_data      The callee's client data set through
175  *                          FLAC__file_encoder_set_client_data().
176  */
177 typedef void (*FLAC__FileEncoderProgressCallback)(const FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
178
179
180 /***********************************************************************
181  *
182  * Class constructor/destructor
183  *
184  ***********************************************************************/
185
186 /** Create a new file encoder instance.  The instance is created with
187  *  default settings; see the individual FLAC__file_encoder_set_*()
188  *  functions for each setting's default.
189  *
190  * \retval FLAC__FileEncoder*
191  *    \c NULL if there was an error allocating memory, else the new instance.
192  */
193 FLAC_API FLAC__FileEncoder *FLAC__file_encoder_new();
194
195 /** Free an encoder instance.  Deletes the object pointed to by \a encoder.
196  *
197  * \param encoder  A pointer to an existing encoder.
198  * \assert
199  *    \code encoder != NULL \endcode
200  */
201 FLAC_API void FLAC__file_encoder_delete(FLAC__FileEncoder *encoder);
202
203 /***********************************************************************
204  *
205  * Public class method prototypes
206  *
207  ***********************************************************************/
208
209 /** This is inherited from FLAC__SeekableStreamEncoder; see
210  *  FLAC__seekable_stream_encoder_set_verify().
211  *
212  * \default \c true
213  * \param  encoder  An encoder instance to set.
214  * \param  value    See above.
215  * \assert
216  *    \code encoder != NULL \endcode
217  * \retval FLAC__bool
218  *    \c false if the encoder is already initialized, else \c true.
219  */
220 FLAC_API FLAC__bool FLAC__file_encoder_set_verify(FLAC__FileEncoder *encoder, FLAC__bool value);
221
222 /** This is inherited from FLAC__SeekableStreamEncoder; see
223  *  FLAC__seekable_stream_encoder_set_streamable_subset().
224  *
225  * \default \c true
226  * \param  encoder  An encoder instance to set.
227  * \param  value    See above.
228  * \assert
229  *    \code encoder != NULL \endcode
230  * \retval FLAC__bool
231  *    \c false if the encoder is already initialized, else \c true.
232  */
233 FLAC_API FLAC__bool FLAC__file_encoder_set_streamable_subset(FLAC__FileEncoder *encoder, FLAC__bool value);
234
235 /** This is inherited from FLAC__SeekableStreamEncoder; see
236  *  FLAC__seekable_stream_encoder_set_do_mid_side_stereo().
237  *
238  * \default \c false
239  * \param  encoder  An encoder instance to set.
240  * \param  value    See above.
241  * \assert
242  *    \code encoder != NULL \endcode
243  * \retval FLAC__bool
244  *    \c false if the encoder is already initialized, else \c true.
245  */
246 FLAC_API FLAC__bool FLAC__file_encoder_set_do_mid_side_stereo(FLAC__FileEncoder *encoder, FLAC__bool value);
247
248 /** This is inherited from FLAC__SeekableStreamEncoder; see
249  *  FLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
250  *
251  * \default \c false
252  * \param  encoder  An encoder instance to set.
253  * \param  value    See above.
254  * \assert
255  *    \code encoder != NULL \endcode
256  * \retval FLAC__bool
257  *    \c false if the encoder is already initialized, else \c true.
258  */
259 FLAC_API FLAC__bool FLAC__file_encoder_set_loose_mid_side_stereo(FLAC__FileEncoder *encoder, FLAC__bool value);
260
261 /** This is inherited from FLAC__SeekableStreamEncoder; see
262  *  FLAC__seekable_stream_encoder_set_channels().
263  *
264  * \default \c 2
265  * \param  encoder  An encoder instance to set.
266  * \param  value    See above.
267  * \assert
268  *    \code encoder != NULL \endcode
269  * \retval FLAC__bool
270  *    \c false if the encoder is already initialized, else \c true.
271  */
272 FLAC_API FLAC__bool FLAC__file_encoder_set_channels(FLAC__FileEncoder *encoder, unsigned value);
273
274 /** This is inherited from FLAC__SeekableStreamEncoder; see
275  *  FLAC__seekable_stream_encoder_set_bits_per_sample().
276  *
277  * \warning
278  * Do not feed the encoder data that is wider than the value you
279  * set here or you will generate an invalid stream.
280  *
281  * \default \c 16
282  * \param  encoder  An encoder instance to set.
283  * \param  value    See above.
284  * \assert
285  *    \code encoder != NULL \endcode
286  * \retval FLAC__bool
287  *    \c false if the encoder is already initialized, else \c true.
288  */
289 FLAC_API FLAC__bool FLAC__file_encoder_set_bits_per_sample(FLAC__FileEncoder *encoder, unsigned value);
290
291 /** This is inherited from FLAC__SeekableStreamEncoder; see
292  *  FLAC__seekable_stream_encoder_set_sample_rate().
293  *
294  * \default \c 44100
295  * \param  encoder  An encoder instance to set.
296  * \param  value    See above.
297  * \assert
298  *    \code encoder != NULL \endcode
299  * \retval FLAC__bool
300  *    \c false if the encoder is already initialized, else \c true.
301  */
302 FLAC_API FLAC__bool FLAC__file_encoder_set_sample_rate(FLAC__FileEncoder *encoder, unsigned value);
303
304 /** This is inherited from FLAC__SeekableStreamEncoder; see
305  *  FLAC__seekable_stream_encoder_set_blocksize().
306  *
307  * \default \c 1152
308  * \param  encoder  An encoder instance to set.
309  * \param  value    See above.
310  * \assert
311  *    \code encoder != NULL \endcode
312  * \retval FLAC__bool
313  *    \c false if the encoder is already initialized, else \c true.
314  */
315 FLAC_API FLAC__bool FLAC__file_encoder_set_blocksize(FLAC__FileEncoder *encoder, unsigned value);
316
317 /** This is inherited from FLAC__SeekableStreamEncoder; see
318  *  FLAC__seekable_stream_encoder_set_apodization().
319  *
320  * \default \c 0
321  * \param  encoder        An encoder instance to set.
322  * \param  specification  See above.
323  * \assert
324  *    \code encoder != NULL \endcode
325  *    \code specification != NULL \endcode
326  * \retval FLAC__bool
327  *    \c false if the encoder is already initialized, else \c true.
328  */
329 /* @@@@add to unit tests*/
330 FLAC_API FLAC__bool FLAC__file_encoder_set_apodization(FLAC__FileEncoder *encoder, const char *specification);
331
332 /** This is inherited from FLAC__SeekableStreamEncoder; see
333  *  FLAC__seekable_stream_encoder_set_max_lpc_order().
334  *
335  * \default \c 0
336  * \param  encoder  An encoder instance to set.
337  * \param  value    See above.
338  * \assert
339  *    \code encoder != NULL \endcode
340  * \retval FLAC__bool
341  *    \c false if the encoder is already initialized, else \c true.
342  */
343 FLAC_API FLAC__bool FLAC__file_encoder_set_max_lpc_order(FLAC__FileEncoder *encoder, unsigned value);
344
345 /** This is inherited from FLAC__SeekableStreamEncoder; see
346  *  FLAC__seekable_stream_encoder_set_qlp_coeff_precision().
347  *
348  * \note
349  * In the current implementation, qlp_coeff_precision + bits_per_sample must
350  * be less than 32.
351  *
352  * \default \c 0
353  * \param  encoder  An encoder instance to set.
354  * \param  value    See above.
355  * \assert
356  *    \code encoder != NULL \endcode
357  * \retval FLAC__bool
358  *    \c false if the encoder is already initialized, else \c true.
359  */
360 FLAC_API FLAC__bool FLAC__file_encoder_set_qlp_coeff_precision(FLAC__FileEncoder *encoder, unsigned value);
361
362 /** This is inherited from FLAC__SeekableStreamEncoder; see
363  *  FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
364  *
365  * \default \c false
366  * \param  encoder  An encoder instance to set.
367  * \param  value    See above.
368  * \assert
369  *    \code encoder != NULL \endcode
370  * \retval FLAC__bool
371  *    \c false if the encoder is already initialized, else \c true.
372  */
373 FLAC_API FLAC__bool FLAC__file_encoder_set_do_qlp_coeff_prec_search(FLAC__FileEncoder *encoder, FLAC__bool value);
374
375 /** This is inherited from FLAC__SeekableStreamEncoder; see
376  *  FLAC__seekable_stream_encoder_set_do_escape_coding().
377  *
378  * \default \c false
379  * \param  encoder  An encoder instance to set.
380  * \param  value    See above.
381  * \assert
382  *    \code encoder != NULL \endcode
383  * \retval FLAC__bool
384  *    \c false if the encoder is already initialized, else \c true.
385  */
386 FLAC_API FLAC__bool FLAC__file_encoder_set_do_escape_coding(FLAC__FileEncoder *encoder, FLAC__bool value);
387
388 /** This is inherited from FLAC__SeekableStreamEncoder; see
389  *  FLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
390  *
391  * \default \c false
392  * \param  encoder  An encoder instance to set.
393  * \param  value    See above.
394  * \assert
395  *    \code encoder != NULL \endcode
396  * \retval FLAC__bool
397  *    \c false if the encoder is already initialized, else \c true.
398  */
399 FLAC_API FLAC__bool FLAC__file_encoder_set_do_exhaustive_model_search(FLAC__FileEncoder *encoder, FLAC__bool value);
400
401 /** This is inherited from FLAC__SeekableStreamEncoder; see
402  *  FLAC__seekable_stream_encoder_set_min_residual_partition_order().
403  *
404  * \default \c 0
405  * \param  encoder  An encoder instance to set.
406  * \param  value    See above.
407  * \assert
408  *    \code encoder != NULL \endcode
409  * \retval FLAC__bool
410  *    \c false if the encoder is already initialized, else \c true.
411  */
412 FLAC_API FLAC__bool FLAC__file_encoder_set_min_residual_partition_order(FLAC__FileEncoder *encoder, unsigned value);
413
414 /** This is inherited from FLAC__SeekableStreamEncoder; see
415  *  FLAC__seekable_stream_encoder_set_max_residual_partition_order().
416  *
417  * \default \c 0
418  * \param  encoder  An encoder instance to set.
419  * \param  value    See above.
420  * \assert
421  *    \code encoder != NULL \endcode
422  * \retval FLAC__bool
423  *    \c false if the encoder is already initialized, else \c true.
424  */
425 FLAC_API FLAC__bool FLAC__file_encoder_set_max_residual_partition_order(FLAC__FileEncoder *encoder, unsigned value);
426
427 /** This is inherited from FLAC__SeekableStreamEncoder; see
428  *  FLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
429  *
430  * \default \c 0
431  * \param  encoder  An encoder instance to set.
432  * \param  value    See above.
433  * \assert
434  *    \code encoder != NULL \endcode
435  * \retval FLAC__bool
436  *    \c false if the encoder is already initialized, else \c true.
437  */
438 FLAC_API FLAC__bool FLAC__file_encoder_set_rice_parameter_search_dist(FLAC__FileEncoder *encoder, unsigned value);
439
440 /** This is inherited from FLAC__SeekableStreamEncoder; see
441  *  FLAC__seekable_stream_encoder_set_total_samples_estimate().
442  *
443  * \default \c 0
444  * \param  encoder  An encoder instance to set.
445  * \param  value    See above.
446  * \assert
447  *    \code encoder != NULL \endcode
448  * \retval FLAC__bool
449  *    \c false if the encoder is already initialized, else \c true.
450  */
451 FLAC_API FLAC__bool FLAC__file_encoder_set_total_samples_estimate(FLAC__FileEncoder *encoder, FLAC__uint64 value);
452
453 /** This is inherited from FLAC__SeekableStreamEncoder; see
454  *  FLAC__seekable_stream_encoder_set_metadata().
455  *
456  * \default \c NULL, 0
457  * \param  encoder     An encoder instance to set.
458  * \param  metadata    See above.
459  * \param  num_blocks  See above.
460  * \assert
461  *    \code encoder != NULL \endcode
462  * \retval FLAC__bool
463  *    \c false if the encoder is already initialized, else \c true.
464  */
465 FLAC_API FLAC__bool FLAC__file_encoder_set_metadata(FLAC__FileEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
466
467 /** Set the output file name encode to.
468  *
469  * \note
470  * The filename is mandatory and must be set before initialization.
471  *
472  * \note
473  * Unlike the FLAC__FileDecoder, the filename does not interpret "-" for
474  * \c stdout; writing to \c stdout is not relevant in the file encoder.
475  *
476  * \default \c NULL
477  * \param  encoder  A encoder instance to set.
478  * \param  value    The output file name.
479  * \assert
480  *    \code encoder != NULL \endcode
481  *    \code value != NULL \endcode
482  * \retval FLAC__bool
483  *    \c false if the encoder is already initialized, or there was a memory
484  *    allocation error, else \c true.
485  */
486 FLAC_API FLAC__bool FLAC__file_encoder_set_filename(FLAC__FileEncoder *encoder, const char *value);
487
488 /** Set the progress callback.
489  *  The supplied function will be called when the encoder has finished
490  *  writing a frame.  The \c total_frames_estimate argument to the callback
491  *  will be based on the value from
492  *  FLAC__file_encoder_set_total_samples_estimate().
493  *
494  * \note
495  * Unlike most other callbacks, the progress callback is \b not mandatory
496  * and need not be set before initialization.
497  *
498  * \default \c NULL
499  * \param  encoder  An encoder instance to set.
500  * \param  value    See above.
501  * \assert
502  *    \code encoder != NULL \endcode
503  *    \code value != NULL \endcode
504  * \retval FLAC__bool
505  *    \c false if the encoder is already initialized, else \c true.
506  */
507 FLAC_API FLAC__bool FLAC__file_encoder_set_progress_callback(FLAC__FileEncoder *encoder, FLAC__FileEncoderProgressCallback value);
508
509 /** Set the client data to be passed back to callbacks.
510  *  This value will be supplied to callbacks in their \a client_data
511  *  argument.
512  *
513  * \default \c NULL
514  * \param  encoder  An encoder instance to set.
515  * \param  value    See above.
516  * \assert
517  *    \code encoder != NULL \endcode
518  * \retval FLAC__bool
519  *    \c false if the encoder is already initialized, else \c true.
520  */
521 FLAC_API FLAC__bool FLAC__file_encoder_set_client_data(FLAC__FileEncoder *encoder, void *value);
522
523 /** Get the current encoder state.
524  *
525  * \param  encoder  An encoder instance to query.
526  * \assert
527  *    \code encoder != NULL \endcode
528  * \retval FLAC__FileEncoderState
529  *    The current encoder state.
530  */
531 FLAC_API FLAC__FileEncoderState FLAC__file_encoder_get_state(const FLAC__FileEncoder *encoder);
532
533 /** Get the state of the underlying seekable stream encoder.
534  *  Useful when the file encoder state is
535  *  \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR.
536  *
537  * \param  encoder  An encoder instance to query.
538  * \assert
539  *    \code encoder != NULL \endcode
540  * \retval FLAC__SeekableStreamEncoderState
541  *    The seekable stream encoder state.
542  */
543 FLAC_API FLAC__SeekableStreamEncoderState FLAC__file_encoder_get_seekable_stream_encoder_state(const FLAC__FileEncoder *encoder);
544
545 /** Get the state of the underlying stream encoder.
546  *  Useful when the file encoder state is
547  *  \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR and the seekable stream
548  *  encoder state is \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR.
549  *
550  * \param  encoder  An encoder instance to query.
551  * \assert
552  *    \code encoder != NULL \endcode
553  * \retval FLAC__StreamEncoderState
554  *    The seekable stream encoder state.
555  */
556 FLAC_API FLAC__StreamEncoderState FLAC__file_encoder_get_stream_encoder_state(const FLAC__FileEncoder *encoder);
557
558 /** Get the state of the underlying stream encoder's verify decoder.
559  *  Useful when the file encoder state is
560  *  \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR and the seekable stream
561  *  encoder state is \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and
562  *  the stream encoder state is \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
563  *
564  * \param  encoder  An encoder instance to query.
565  * \assert
566  *    \code encoder != NULL \endcode
567  * \retval FLAC__StreamDecoderState
568  *    The stream encoder state.
569  */
570 FLAC_API FLAC__StreamDecoderState FLAC__file_encoder_get_verify_decoder_state(const FLAC__FileEncoder *encoder);
571
572 /** Get the current encoder state as a C string.
573  *  This version automatically resolves
574  *  \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR by getting the
575  *  seekable stream encoder's state.
576  *
577  * \param  encoder  A encoder instance to query.
578  * \assert
579  *    \code encoder != NULL \endcode
580  * \retval const char *
581  *    The encoder state as a C string.  Do not modify the contents.
582  */
583 FLAC_API const char *FLAC__file_encoder_get_resolved_state_string(const FLAC__FileEncoder *encoder);
584
585 /** Get relevant values about the nature of a verify decoder error.
586  *  Inherited from FLAC__seekable_stream_encoder_get_verify_decoder_error_stats().
587  *  Useful when the file encoder state is
588  *  \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR and the seekable stream
589  *  encoder state is
590  *  \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
591  *  stream encoder state is
592  *  \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
593  *
594  * \param  encoder  An encoder instance to query.
595  * \param  absolute_sample  The absolute sample number of the mismatch.
596  * \param  frame_number  The number of the frame in which the mismatch occurred.
597  * \param  channel       The channel in which the mismatch occurred.
598  * \param  sample        The number of the sample (relative to the frame) in
599  *                       which the mismatch occurred.
600  * \param  expected      The expected value for the sample in question.
601  * \param  got           The actual value returned by the decoder.
602  * \assert
603  *    \code encoder != NULL \endcode
604  */
605 FLAC_API void FLAC__file_encoder_get_verify_decoder_error_stats(const FLAC__FileEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
606
607 /** Get the "verify" flag.
608  *  This is inherited from FLAC__SeekableStreamEncoder; see
609  *  FLAC__seekable_stream_encoder_get_verify().
610  *
611  * \param  encoder  An encoder instance to query.
612  * \assert
613  *    \code encoder != NULL \endcode
614  * \retval FLAC__bool
615  *    See FLAC__file_encoder_set_verify().
616  */
617 FLAC_API FLAC__bool FLAC__file_encoder_get_verify(const FLAC__FileEncoder *encoder);
618
619 /** Get the "streamable subset" flag.
620  *  This is inherited from FLAC__SeekableStreamEncoder; see
621  *  FLAC__seekable_stream_encoder_get_streamable_subset().
622  *
623  * \param  encoder  An encoder instance to query.
624  * \assert
625  *    \code encoder != NULL \endcode
626  * \retval FLAC__bool
627  *    See FLAC__file_encoder_set_streamable_subset().
628  */
629 FLAC_API FLAC__bool FLAC__file_encoder_get_streamable_subset(const FLAC__FileEncoder *encoder);
630
631 /** Get the "mid/side stereo coding" flag.
632  *  This is inherited from FLAC__SeekableStreamEncoder; see
633  *  FLAC__seekable_stream_encoder_get_do_mid_side_stereo().
634  *
635  * \param  encoder  An encoder instance to query.
636  * \assert
637  *    \code encoder != NULL \endcode
638  * \retval FLAC__bool
639  *    See FLAC__file_encoder_get_do_mid_side_stereo().
640  */
641 FLAC_API FLAC__bool FLAC__file_encoder_get_do_mid_side_stereo(const FLAC__FileEncoder *encoder);
642
643 /** Get the "adaptive mid/side switching" flag.
644  *  This is inherited from FLAC__SeekableStreamEncoder; see
645  *  FLAC__seekable_stream_encoder_get_loose_mid_side_stereo().
646  *
647  * \param  encoder  An encoder instance to query.
648  * \assert
649  *    \code encoder != NULL \endcode
650  * \retval FLAC__bool
651  *    See FLAC__file_encoder_set_loose_mid_side_stereo().
652  */
653 FLAC_API FLAC__bool FLAC__file_encoder_get_loose_mid_side_stereo(const FLAC__FileEncoder *encoder);
654
655 /** Get the number of input channels being processed.
656  *  This is inherited from FLAC__SeekableStreamEncoder; see
657  *  FLAC__seekable_stream_encoder_get_channels().
658  *
659  * \param  encoder  An encoder instance to query.
660  * \assert
661  *    \code encoder != NULL \endcode
662  * \retval unsigned
663  *    See FLAC__file_encoder_set_channels().
664  */
665 FLAC_API unsigned FLAC__file_encoder_get_channels(const FLAC__FileEncoder *encoder);
666
667 /** Get the input sample resolution setting.
668  *  This is inherited from FLAC__SeekableStreamEncoder; see
669  *  FLAC__seekable_stream_encoder_get_bits_per_sample().
670  *
671  * \param  encoder  An encoder instance to query.
672  * \assert
673  *    \code encoder != NULL \endcode
674  * \retval unsigned
675  *    See FLAC__file_encoder_set_bits_per_sample().
676  */
677 FLAC_API unsigned FLAC__file_encoder_get_bits_per_sample(const FLAC__FileEncoder *encoder);
678
679 /** Get the input sample rate setting.
680  *  This is inherited from FLAC__SeekableStreamEncoder; see
681  *  FLAC__seekable_stream_encoder_get_sample_rate().
682  *
683  * \param  encoder  An encoder instance to query.
684  * \assert
685  *    \code encoder != NULL \endcode
686  * \retval unsigned
687  *    See FLAC__file_encoder_set_sample_rate().
688  */
689 FLAC_API unsigned FLAC__file_encoder_get_sample_rate(const FLAC__FileEncoder *encoder);
690
691 /** Get the blocksize setting.
692  *  This is inherited from FLAC__SeekableStreamEncoder; see
693  *  FLAC__seekable_stream_encoder_get_blocksize().
694  *
695  * \param  encoder  An encoder instance to query.
696  * \assert
697  *    \code encoder != NULL \endcode
698  * \retval unsigned
699  *    See FLAC__file_encoder_set_blocksize().
700  */
701 FLAC_API unsigned FLAC__file_encoder_get_blocksize(const FLAC__FileEncoder *encoder);
702
703 /** Get the maximum LPC order setting.
704  *  This is inherited from FLAC__SeekableStreamEncoder; see
705  *  FLAC__seekable_stream_encoder_get_max_lpc_order().
706  *
707  * \param  encoder  An encoder instance to query.
708  * \assert
709  *    \code encoder != NULL \endcode
710  * \retval unsigned
711  *    See FLAC__file_encoder_set_max_lpc_order().
712  */
713 FLAC_API unsigned FLAC__file_encoder_get_max_lpc_order(const FLAC__FileEncoder *encoder);
714
715 /** Get the quantized linear predictor coefficient precision setting.
716  *  This is inherited from FLAC__SeekableStreamEncoder; see
717  *  FLAC__seekable_stream_encoder_get_qlp_coeff_precision().
718  *
719  * \param  encoder  An encoder instance to query.
720  * \assert
721  *    \code encoder != NULL \endcode
722  * \retval unsigned
723  *    See FLAC__file_encoder_set_qlp_coeff_precision().
724  */
725 FLAC_API unsigned FLAC__file_encoder_get_qlp_coeff_precision(const FLAC__FileEncoder *encoder);
726
727 /** Get the qlp coefficient precision search flag.
728  *  This is inherited from FLAC__SeekableStreamEncoder; see
729  *  FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search().
730  *
731  * \param  encoder  An encoder instance to query.
732  * \assert
733  *    \code encoder != NULL \endcode
734  * \retval FLAC__bool
735  *    See FLAC__file_encoder_set_do_qlp_coeff_prec_search().
736  */
737 FLAC_API FLAC__bool FLAC__file_encoder_get_do_qlp_coeff_prec_search(const FLAC__FileEncoder *encoder);
738
739 /** Get the "escape coding" flag.
740  *  This is inherited from FLAC__SeekableStreamEncoder; see
741  *  FLAC__seekable_stream_encoder_get_do_escape_coding().
742  *
743  * \param  encoder  An encoder instance to query.
744  * \assert
745  *    \code encoder != NULL \endcode
746  * \retval FLAC__bool
747  *    See FLAC__file_encoder_set_do_escape_coding().
748  */
749 FLAC_API FLAC__bool FLAC__file_encoder_get_do_escape_coding(const FLAC__FileEncoder *encoder);
750
751 /** Get the exhaustive model search flag.
752  *  This is inherited from FLAC__SeekableStreamEncoder; see
753  *  FLAC__seekable_stream_encoder_get_do_exhaustive_model_search().
754  *
755  * \param  encoder  An encoder instance to query.
756  * \assert
757  *    \code encoder != NULL \endcode
758  * \retval FLAC__bool
759  *    See FLAC__file_encoder_set_do_exhaustive_model_search().
760  */
761 FLAC_API FLAC__bool FLAC__file_encoder_get_do_exhaustive_model_search(const FLAC__FileEncoder *encoder);
762
763 /** Get the minimum residual partition order setting.
764  *  This is inherited from FLAC__SeekableStreamEncoder; see
765  *  FLAC__seekable_stream_encoder_get_min_residual_partition_order().
766  *
767  * \param  encoder  An encoder instance to query.
768  * \assert
769  *    \code encoder != NULL \endcode
770  * \retval unsigned
771  *    See FLAC__file_encoder_set_min_residual_partition_order().
772  */
773 FLAC_API unsigned FLAC__file_encoder_get_min_residual_partition_order(const FLAC__FileEncoder *encoder);
774
775 /** Get maximum residual partition order setting.
776  *  This is inherited from FLAC__SeekableStreamEncoder; see
777  *  FLAC__seekable_stream_encoder_get_max_residual_partition_order().
778  *
779  * \param  encoder  An encoder instance to query.
780  * \assert
781  *    \code encoder != NULL \endcode
782  * \retval unsigned
783  *    See FLAC__file_encoder_set_max_residual_partition_order().
784  */
785 FLAC_API unsigned FLAC__file_encoder_get_max_residual_partition_order(const FLAC__FileEncoder *encoder);
786
787 /** Get the Rice parameter search distance setting.
788  *  This is inherited from FLAC__SeekableStreamEncoder; see
789  *  FLAC__seekable_stream_encoder_get_rice_parameter_search_dist().
790  *
791  * \param  encoder  An encoder instance to query.
792  * \assert
793  *    \code encoder != NULL \endcode
794  * \retval unsigned
795  *    See FLAC__file_encoder_set_rice_parameter_search_dist().
796  */
797 FLAC_API unsigned FLAC__file_encoder_get_rice_parameter_search_dist(const FLAC__FileEncoder *encoder);
798
799 /** Get the previously set estimate of the total samples to be encoded.
800  *  This is inherited from FLAC__SeekableStreamEncoder; see
801  *  FLAC__seekable_stream_encoder_get_total_samples_estimate().
802  *
803  * \param  encoder  An encoder instance to query.
804  * \assert
805  *    \code encoder != NULL \endcode
806  * \retval FLAC__uint64
807  *    See FLAC__file_encoder_set_total_samples_estimate().
808  */
809 FLAC_API FLAC__uint64 FLAC__file_encoder_get_total_samples_estimate(const FLAC__FileEncoder *encoder);
810
811 /** Initialize the encoder instance.
812  *  Should be called after FLAC__file_encoder_new() and
813  *  FLAC__file_encoder_set_*() but before FLAC__file_encoder_process()
814  *  or FLAC__file_encoder_process_interleaved().  Will set and return
815  *  the encoder state, which will be FLAC__FILE_ENCODER_OK if
816  *  initialization succeeded.
817  *
818  * \param  encoder  An uninitialized encoder instance.
819  * \assert
820  *    \code encoder != NULL \endcode
821  * \retval FLAC__FileEncoderState
822  *    \c FLAC__FILE_ENCODER_OK if initialization was successful; see
823  *    FLAC__FileEncoderState for the meanings of other return values.
824  */
825 FLAC_API FLAC__FileEncoderState FLAC__file_encoder_init(FLAC__FileEncoder *encoder);
826
827 /** Finish the encoding process.
828  *  Flushes the encoding buffer, releases resources, resets the encoder
829  *  settings to their defaults, and returns the encoder state to
830  *  FLAC__FILE_ENCODER_UNINITIALIZED.
831  *
832  *  In the event of a prematurely-terminated encode, it is not strictly
833  *  necessary to call this immediately before FLAC__file_encoder_delete()
834  *  but it is good practice to match every FLAC__file_encoder_init()
835  *  with a FLAC__file_encoder_finish().
836  *
837  * \param  encoder  An uninitialized encoder instance.
838  * \assert
839  *    \code encoder != NULL \endcode
840  */
841 FLAC_API void FLAC__file_encoder_finish(FLAC__FileEncoder *encoder);
842
843 /** Submit data for encoding.
844  *  This is inherited from FLAC__SeekableStreamEncoder; see
845  *  FLAC__seekable_stream_encoder_process().
846  *
847  * \param  encoder  An initialized encoder instance in the OK state.
848  * \param  buffer   An array of pointers to each channel's signal.
849  * \param  samples  The number of samples in one channel.
850  * \assert
851  *    \code encoder != NULL \endcode
852  *    \code FLAC__file_encoder_get_state(encoder) == FLAC__FILE_ENCODER_OK \endcode
853  * \retval FLAC__bool
854  *    \c true if successful, else \c false; in this case, check the
855  *    encoder state with FLAC__file_encoder_get_state() to see what
856  *    went wrong.
857  */
858 FLAC_API FLAC__bool FLAC__file_encoder_process(FLAC__FileEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
859
860 /** Submit data for encoding.
861  *  This is inherited from FLAC__SeekableStreamEncoder; see
862  *  FLAC__seekable_stream_encoder_process_interleaved().
863  *
864  * \param  encoder  An initialized encoder instance in the OK state.
865  * \param  buffer   An array of channel-interleaved data (see above).
866  * \param  samples  The number of samples in one channel, the same as for
867  *                  FLAC__file_encoder_process().  For example, if
868  *                  encoding two channels, \c 1000 \a samples corresponds
869  *                  to a \a buffer of 2000 values.
870  * \assert
871  *    \code encoder != NULL \endcode
872  *    \code FLAC__file_encoder_get_state(encoder) == FLAC__FILE_ENCODER_OK \endcode
873  * \retval FLAC__bool
874  *    \c true if successful, else \c false; in this case, check the
875  *    encoder state with FLAC__file_encoder_get_state() to see what
876  *    went wrong.
877  */
878 FLAC_API FLAC__bool FLAC__file_encoder_process_interleaved(FLAC__FileEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);
879
880 /* \} */
881
882 #ifdef __cplusplus
883 }
884 #endif
885
886 #endif