cannam@87
|
1 /* libFLAC - Free Lossless Audio Codec library
|
cannam@87
|
2 * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
cannam@87
|
3 *
|
cannam@87
|
4 * Redistribution and use in source and binary forms, with or without
|
cannam@87
|
5 * modification, are permitted provided that the following conditions
|
cannam@87
|
6 * are met:
|
cannam@87
|
7 *
|
cannam@87
|
8 * - Redistributions of source code must retain the above copyright
|
cannam@87
|
9 * notice, this list of conditions and the following disclaimer.
|
cannam@87
|
10 *
|
cannam@87
|
11 * - Redistributions in binary form must reproduce the above copyright
|
cannam@87
|
12 * notice, this list of conditions and the following disclaimer in the
|
cannam@87
|
13 * documentation and/or other materials provided with the distribution.
|
cannam@87
|
14 *
|
cannam@87
|
15 * - Neither the name of the Xiph.org Foundation nor the names of its
|
cannam@87
|
16 * contributors may be used to endorse or promote products derived from
|
cannam@87
|
17 * this software without specific prior written permission.
|
cannam@87
|
18 *
|
cannam@87
|
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
cannam@87
|
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
cannam@87
|
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
cannam@87
|
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
cannam@87
|
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
cannam@87
|
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
cannam@87
|
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
cannam@87
|
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
cannam@87
|
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
cannam@87
|
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
cannam@87
|
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
cannam@87
|
30 */
|
cannam@87
|
31
|
cannam@87
|
32 #ifndef FLAC__STREAM_ENCODER_H
|
cannam@87
|
33 #define FLAC__STREAM_ENCODER_H
|
cannam@87
|
34
|
cannam@87
|
35 #include <stdio.h> /* for FILE */
|
cannam@87
|
36 #include "export.h"
|
cannam@87
|
37 #include "format.h"
|
cannam@87
|
38 #include "stream_decoder.h"
|
cannam@87
|
39
|
cannam@87
|
40 #ifdef __cplusplus
|
cannam@87
|
41 extern "C" {
|
cannam@87
|
42 #endif
|
cannam@87
|
43
|
cannam@87
|
44
|
cannam@87
|
45 /** \file include/FLAC/stream_encoder.h
|
cannam@87
|
46 *
|
cannam@87
|
47 * \brief
|
cannam@87
|
48 * This module contains the functions which implement the stream
|
cannam@87
|
49 * encoder.
|
cannam@87
|
50 *
|
cannam@87
|
51 * See the detailed documentation in the
|
cannam@87
|
52 * \link flac_stream_encoder stream encoder \endlink module.
|
cannam@87
|
53 */
|
cannam@87
|
54
|
cannam@87
|
55 /** \defgroup flac_encoder FLAC/ \*_encoder.h: encoder interfaces
|
cannam@87
|
56 * \ingroup flac
|
cannam@87
|
57 *
|
cannam@87
|
58 * \brief
|
cannam@87
|
59 * This module describes the encoder layers provided by libFLAC.
|
cannam@87
|
60 *
|
cannam@87
|
61 * The stream encoder can be used to encode complete streams either to the
|
cannam@87
|
62 * client via callbacks, or directly to a file, depending on how it is
|
cannam@87
|
63 * initialized. When encoding via callbacks, the client provides a write
|
cannam@87
|
64 * callback which will be called whenever FLAC data is ready to be written.
|
cannam@87
|
65 * If the client also supplies a seek callback, the encoder will also
|
cannam@87
|
66 * automatically handle the writing back of metadata discovered while
|
cannam@87
|
67 * encoding, like stream info, seek points offsets, etc. When encoding to
|
cannam@87
|
68 * a file, the client needs only supply a filename or open \c FILE* and an
|
cannam@87
|
69 * optional progress callback for periodic notification of progress; the
|
cannam@87
|
70 * write and seek callbacks are supplied internally. For more info see the
|
cannam@87
|
71 * \link flac_stream_encoder stream encoder \endlink module.
|
cannam@87
|
72 */
|
cannam@87
|
73
|
cannam@87
|
74 /** \defgroup flac_stream_encoder FLAC/stream_encoder.h: stream encoder interface
|
cannam@87
|
75 * \ingroup flac_encoder
|
cannam@87
|
76 *
|
cannam@87
|
77 * \brief
|
cannam@87
|
78 * This module contains the functions which implement the stream
|
cannam@87
|
79 * encoder.
|
cannam@87
|
80 *
|
cannam@87
|
81 * The stream encoder can encode to native FLAC, and optionally Ogg FLAC
|
cannam@87
|
82 * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files.
|
cannam@87
|
83 *
|
cannam@87
|
84 * The basic usage of this encoder is as follows:
|
cannam@87
|
85 * - The program creates an instance of an encoder using
|
cannam@87
|
86 * FLAC__stream_encoder_new().
|
cannam@87
|
87 * - The program overrides the default settings using
|
cannam@87
|
88 * FLAC__stream_encoder_set_*() functions. At a minimum, the following
|
cannam@87
|
89 * functions should be called:
|
cannam@87
|
90 * - FLAC__stream_encoder_set_channels()
|
cannam@87
|
91 * - FLAC__stream_encoder_set_bits_per_sample()
|
cannam@87
|
92 * - FLAC__stream_encoder_set_sample_rate()
|
cannam@87
|
93 * - FLAC__stream_encoder_set_ogg_serial_number() (if encoding to Ogg FLAC)
|
cannam@87
|
94 * - FLAC__stream_encoder_set_total_samples_estimate() (if known)
|
cannam@87
|
95 * - If the application wants to control the compression level or set its own
|
cannam@87
|
96 * metadata, then the following should also be called:
|
cannam@87
|
97 * - FLAC__stream_encoder_set_compression_level()
|
cannam@87
|
98 * - FLAC__stream_encoder_set_verify()
|
cannam@87
|
99 * - FLAC__stream_encoder_set_metadata()
|
cannam@87
|
100 * - The rest of the set functions should only be called if the client needs
|
cannam@87
|
101 * exact control over how the audio is compressed; thorough understanding
|
cannam@87
|
102 * of the FLAC format is necessary to achieve good results.
|
cannam@87
|
103 * - The program initializes the instance to validate the settings and
|
cannam@87
|
104 * prepare for encoding using
|
cannam@87
|
105 * - FLAC__stream_encoder_init_stream() or FLAC__stream_encoder_init_FILE()
|
cannam@87
|
106 * or FLAC__stream_encoder_init_file() for native FLAC
|
cannam@87
|
107 * - FLAC__stream_encoder_init_ogg_stream() or FLAC__stream_encoder_init_ogg_FILE()
|
cannam@87
|
108 * or FLAC__stream_encoder_init_ogg_file() for Ogg FLAC
|
cannam@87
|
109 * - The program calls FLAC__stream_encoder_process() or
|
cannam@87
|
110 * FLAC__stream_encoder_process_interleaved() to encode data, which
|
cannam@87
|
111 * subsequently calls the callbacks when there is encoder data ready
|
cannam@87
|
112 * to be written.
|
cannam@87
|
113 * - The program finishes the encoding with FLAC__stream_encoder_finish(),
|
cannam@87
|
114 * which causes the encoder to encode any data still in its input pipe,
|
cannam@87
|
115 * update the metadata with the final encoding statistics if output
|
cannam@87
|
116 * seeking is possible, and finally reset the encoder to the
|
cannam@87
|
117 * uninitialized state.
|
cannam@87
|
118 * - The instance may be used again or deleted with
|
cannam@87
|
119 * FLAC__stream_encoder_delete().
|
cannam@87
|
120 *
|
cannam@87
|
121 * In more detail, the stream encoder functions similarly to the
|
cannam@87
|
122 * \link flac_stream_decoder stream decoder \endlink, but has fewer
|
cannam@87
|
123 * callbacks and more options. Typically the client will create a new
|
cannam@87
|
124 * instance by calling FLAC__stream_encoder_new(), then set the necessary
|
cannam@87
|
125 * parameters with FLAC__stream_encoder_set_*(), and initialize it by
|
cannam@87
|
126 * calling one of the FLAC__stream_encoder_init_*() functions.
|
cannam@87
|
127 *
|
cannam@87
|
128 * Unlike the decoders, the stream encoder has many options that can
|
cannam@87
|
129 * affect the speed and compression ratio. When setting these parameters
|
cannam@87
|
130 * you should have some basic knowledge of the format (see the
|
cannam@87
|
131 * <A HREF="../documentation.html#format">user-level documentation</A>
|
cannam@87
|
132 * or the <A HREF="../format.html">formal description</A>). The
|
cannam@87
|
133 * FLAC__stream_encoder_set_*() functions themselves do not validate the
|
cannam@87
|
134 * values as many are interdependent. The FLAC__stream_encoder_init_*()
|
cannam@87
|
135 * functions will do this, so make sure to pay attention to the state
|
cannam@87
|
136 * returned by FLAC__stream_encoder_init_*() to make sure that it is
|
cannam@87
|
137 * FLAC__STREAM_ENCODER_INIT_STATUS_OK. Any parameters that are not set
|
cannam@87
|
138 * before FLAC__stream_encoder_init_*() will take on the defaults from
|
cannam@87
|
139 * the constructor.
|
cannam@87
|
140 *
|
cannam@87
|
141 * There are three initialization functions for native FLAC, one for
|
cannam@87
|
142 * setting up the encoder to encode FLAC data to the client via
|
cannam@87
|
143 * callbacks, and two for encoding directly to a file.
|
cannam@87
|
144 *
|
cannam@87
|
145 * For encoding via callbacks, use FLAC__stream_encoder_init_stream().
|
cannam@87
|
146 * You must also supply a write callback which will be called anytime
|
cannam@87
|
147 * there is raw encoded data to write. If the client can seek the output
|
cannam@87
|
148 * it is best to also supply seek and tell callbacks, as this allows the
|
cannam@87
|
149 * encoder to go back after encoding is finished to write back
|
cannam@87
|
150 * information that was collected while encoding, like seek point offsets,
|
cannam@87
|
151 * frame sizes, etc.
|
cannam@87
|
152 *
|
cannam@87
|
153 * For encoding directly to a file, use FLAC__stream_encoder_init_FILE()
|
cannam@87
|
154 * or FLAC__stream_encoder_init_file(). Then you must only supply a
|
cannam@87
|
155 * filename or open \c FILE*; the encoder will handle all the callbacks
|
cannam@87
|
156 * internally. You may also supply a progress callback for periodic
|
cannam@87
|
157 * notification of the encoding progress.
|
cannam@87
|
158 *
|
cannam@87
|
159 * There are three similarly-named init functions for encoding to Ogg
|
cannam@87
|
160 * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the
|
cannam@87
|
161 * library has been built with Ogg support.
|
cannam@87
|
162 *
|
cannam@87
|
163 * The call to FLAC__stream_encoder_init_*() currently will also immediately
|
cannam@87
|
164 * call the write callback several times, once with the \c fLaC signature,
|
cannam@87
|
165 * and once for each encoded metadata block. Note that for Ogg FLAC
|
cannam@87
|
166 * encoding you will usually get at least twice the number of callbacks than
|
cannam@87
|
167 * with native FLAC, one for the Ogg page header and one for the page body.
|
cannam@87
|
168 *
|
cannam@87
|
169 * After initializing the instance, the client may feed audio data to the
|
cannam@87
|
170 * encoder in one of two ways:
|
cannam@87
|
171 *
|
cannam@87
|
172 * - Channel separate, through FLAC__stream_encoder_process() - The client
|
cannam@87
|
173 * will pass an array of pointers to buffers, one for each channel, to
|
cannam@87
|
174 * the encoder, each of the same length. The samples need not be
|
cannam@87
|
175 * block-aligned, but each channel should have the same number of samples.
|
cannam@87
|
176 * - Channel interleaved, through
|
cannam@87
|
177 * FLAC__stream_encoder_process_interleaved() - The client will pass a single
|
cannam@87
|
178 * pointer to data that is channel-interleaved (i.e. channel0_sample0,
|
cannam@87
|
179 * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...).
|
cannam@87
|
180 * Again, the samples need not be block-aligned but they must be
|
cannam@87
|
181 * sample-aligned, i.e. the first value should be channel0_sample0 and
|
cannam@87
|
182 * the last value channelN_sampleM.
|
cannam@87
|
183 *
|
cannam@87
|
184 * Note that for either process call, each sample in the buffers should be a
|
cannam@87
|
185 * signed integer, right-justified to the resolution set by
|
cannam@87
|
186 * FLAC__stream_encoder_set_bits_per_sample(). For example, if the resolution
|
cannam@87
|
187 * is 16 bits per sample, the samples should all be in the range [-32768,32767].
|
cannam@87
|
188 *
|
cannam@87
|
189 * When the client is finished encoding data, it calls
|
cannam@87
|
190 * FLAC__stream_encoder_finish(), which causes the encoder to encode any
|
cannam@87
|
191 * data still in its input pipe, and call the metadata callback with the
|
cannam@87
|
192 * final encoding statistics. Then the instance may be deleted with
|
cannam@87
|
193 * FLAC__stream_encoder_delete() or initialized again to encode another
|
cannam@87
|
194 * stream.
|
cannam@87
|
195 *
|
cannam@87
|
196 * For programs that write their own metadata, but that do not know the
|
cannam@87
|
197 * actual metadata until after encoding, it is advantageous to instruct
|
cannam@87
|
198 * the encoder to write a PADDING block of the correct size, so that
|
cannam@87
|
199 * instead of rewriting the whole stream after encoding, the program can
|
cannam@87
|
200 * just overwrite the PADDING block. If only the maximum size of the
|
cannam@87
|
201 * metadata is known, the program can write a slightly larger padding
|
cannam@87
|
202 * block, then split it after encoding.
|
cannam@87
|
203 *
|
cannam@87
|
204 * Make sure you understand how lengths are calculated. All FLAC metadata
|
cannam@87
|
205 * blocks have a 4 byte header which contains the type and length. This
|
cannam@87
|
206 * length does not include the 4 bytes of the header. See the format page
|
cannam@87
|
207 * for the specification of metadata blocks and their lengths.
|
cannam@87
|
208 *
|
cannam@87
|
209 * \note
|
cannam@87
|
210 * If you are writing the FLAC data to a file via callbacks, make sure it
|
cannam@87
|
211 * is open for update (e.g. mode "w+" for stdio streams). This is because
|
cannam@87
|
212 * after the first encoding pass, the encoder will try to seek back to the
|
cannam@87
|
213 * beginning of the stream, to the STREAMINFO block, to write some data
|
cannam@87
|
214 * there. (If using FLAC__stream_encoder_init*_file() or
|
cannam@87
|
215 * FLAC__stream_encoder_init*_FILE(), the file is managed internally.)
|
cannam@87
|
216 *
|
cannam@87
|
217 * \note
|
cannam@87
|
218 * The "set" functions may only be called when the encoder is in the
|
cannam@87
|
219 * state FLAC__STREAM_ENCODER_UNINITIALIZED, i.e. after
|
cannam@87
|
220 * FLAC__stream_encoder_new() or FLAC__stream_encoder_finish(), but
|
cannam@87
|
221 * before FLAC__stream_encoder_init_*(). If this is the case they will
|
cannam@87
|
222 * return \c true, otherwise \c false.
|
cannam@87
|
223 *
|
cannam@87
|
224 * \note
|
cannam@87
|
225 * FLAC__stream_encoder_finish() resets all settings to the constructor
|
cannam@87
|
226 * defaults.
|
cannam@87
|
227 *
|
cannam@87
|
228 * \{
|
cannam@87
|
229 */
|
cannam@87
|
230
|
cannam@87
|
231
|
cannam@87
|
232 /** State values for a FLAC__StreamEncoder.
|
cannam@87
|
233 *
|
cannam@87
|
234 * The encoder's state can be obtained by calling FLAC__stream_encoder_get_state().
|
cannam@87
|
235 *
|
cannam@87
|
236 * If the encoder gets into any other state besides \c FLAC__STREAM_ENCODER_OK
|
cannam@87
|
237 * or \c FLAC__STREAM_ENCODER_UNINITIALIZED, it becomes invalid for encoding and
|
cannam@87
|
238 * must be deleted with FLAC__stream_encoder_delete().
|
cannam@87
|
239 */
|
cannam@87
|
240 typedef enum {
|
cannam@87
|
241
|
cannam@87
|
242 FLAC__STREAM_ENCODER_OK = 0,
|
cannam@87
|
243 /**< The encoder is in the normal OK state and samples can be processed. */
|
cannam@87
|
244
|
cannam@87
|
245 FLAC__STREAM_ENCODER_UNINITIALIZED,
|
cannam@87
|
246 /**< The encoder is in the uninitialized state; one of the
|
cannam@87
|
247 * FLAC__stream_encoder_init_*() functions must be called before samples
|
cannam@87
|
248 * can be processed.
|
cannam@87
|
249 */
|
cannam@87
|
250
|
cannam@87
|
251 FLAC__STREAM_ENCODER_OGG_ERROR,
|
cannam@87
|
252 /**< An error occurred in the underlying Ogg layer. */
|
cannam@87
|
253
|
cannam@87
|
254 FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
|
cannam@87
|
255 /**< An error occurred in the underlying verify stream decoder;
|
cannam@87
|
256 * check FLAC__stream_encoder_get_verify_decoder_state().
|
cannam@87
|
257 */
|
cannam@87
|
258
|
cannam@87
|
259 FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA,
|
cannam@87
|
260 /**< The verify decoder detected a mismatch between the original
|
cannam@87
|
261 * audio signal and the decoded audio signal.
|
cannam@87
|
262 */
|
cannam@87
|
263
|
cannam@87
|
264 FLAC__STREAM_ENCODER_CLIENT_ERROR,
|
cannam@87
|
265 /**< One of the callbacks returned a fatal error. */
|
cannam@87
|
266
|
cannam@87
|
267 FLAC__STREAM_ENCODER_IO_ERROR,
|
cannam@87
|
268 /**< An I/O error occurred while opening/reading/writing a file.
|
cannam@87
|
269 * Check \c errno.
|
cannam@87
|
270 */
|
cannam@87
|
271
|
cannam@87
|
272 FLAC__STREAM_ENCODER_FRAMING_ERROR,
|
cannam@87
|
273 /**< An error occurred while writing the stream; usually, the
|
cannam@87
|
274 * write_callback returned an error.
|
cannam@87
|
275 */
|
cannam@87
|
276
|
cannam@87
|
277 FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR
|
cannam@87
|
278 /**< Memory allocation failed. */
|
cannam@87
|
279
|
cannam@87
|
280 } FLAC__StreamEncoderState;
|
cannam@87
|
281
|
cannam@87
|
282 /** Maps a FLAC__StreamEncoderState to a C string.
|
cannam@87
|
283 *
|
cannam@87
|
284 * Using a FLAC__StreamEncoderState as the index to this array
|
cannam@87
|
285 * will give the string equivalent. The contents should not be modified.
|
cannam@87
|
286 */
|
cannam@87
|
287 extern FLAC_API const char * const FLAC__StreamEncoderStateString[];
|
cannam@87
|
288
|
cannam@87
|
289
|
cannam@87
|
290 /** Possible return values for the FLAC__stream_encoder_init_*() functions.
|
cannam@87
|
291 */
|
cannam@87
|
292 typedef enum {
|
cannam@87
|
293
|
cannam@87
|
294 FLAC__STREAM_ENCODER_INIT_STATUS_OK = 0,
|
cannam@87
|
295 /**< Initialization was successful. */
|
cannam@87
|
296
|
cannam@87
|
297 FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR,
|
cannam@87
|
298 /**< General failure to set up encoder; call FLAC__stream_encoder_get_state() for cause. */
|
cannam@87
|
299
|
cannam@87
|
300 FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
|
cannam@87
|
301 /**< The library was not compiled with support for the given container
|
cannam@87
|
302 * format.
|
cannam@87
|
303 */
|
cannam@87
|
304
|
cannam@87
|
305 FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS,
|
cannam@87
|
306 /**< A required callback was not supplied. */
|
cannam@87
|
307
|
cannam@87
|
308 FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS,
|
cannam@87
|
309 /**< The encoder has an invalid setting for number of channels. */
|
cannam@87
|
310
|
cannam@87
|
311 FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE,
|
cannam@87
|
312 /**< The encoder has an invalid setting for bits-per-sample.
|
cannam@87
|
313 * FLAC supports 4-32 bps but the reference encoder currently supports
|
cannam@87
|
314 * only up to 24 bps.
|
cannam@87
|
315 */
|
cannam@87
|
316
|
cannam@87
|
317 FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE,
|
cannam@87
|
318 /**< The encoder has an invalid setting for the input sample rate. */
|
cannam@87
|
319
|
cannam@87
|
320 FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE,
|
cannam@87
|
321 /**< The encoder has an invalid setting for the block size. */
|
cannam@87
|
322
|
cannam@87
|
323 FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER,
|
cannam@87
|
324 /**< The encoder has an invalid setting for the maximum LPC order. */
|
cannam@87
|
325
|
cannam@87
|
326 FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION,
|
cannam@87
|
327 /**< The encoder has an invalid setting for the precision of the quantized linear predictor coefficients. */
|
cannam@87
|
328
|
cannam@87
|
329 FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER,
|
cannam@87
|
330 /**< The specified block size is less than the maximum LPC order. */
|
cannam@87
|
331
|
cannam@87
|
332 FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE,
|
cannam@87
|
333 /**< The encoder is bound to the <A HREF="../format.html#subset">Subset</A> but other settings violate it. */
|
cannam@87
|
334
|
cannam@87
|
335 FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA,
|
cannam@87
|
336 /**< The metadata input to the encoder is invalid, in one of the following ways:
|
cannam@87
|
337 * - FLAC__stream_encoder_set_metadata() was called with a null pointer but a block count > 0
|
cannam@87
|
338 * - One of the metadata blocks contains an undefined type
|
cannam@87
|
339 * - It contains an illegal CUESHEET as checked by FLAC__format_cuesheet_is_legal()
|
cannam@87
|
340 * - It contains an illegal SEEKTABLE as checked by FLAC__format_seektable_is_legal()
|
cannam@87
|
341 * - It contains more than one SEEKTABLE block or more than one VORBIS_COMMENT block
|
cannam@87
|
342 */
|
cannam@87
|
343
|
cannam@87
|
344 FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED
|
cannam@87
|
345 /**< FLAC__stream_encoder_init_*() was called when the encoder was
|
cannam@87
|
346 * already initialized, usually because
|
cannam@87
|
347 * FLAC__stream_encoder_finish() was not called.
|
cannam@87
|
348 */
|
cannam@87
|
349
|
cannam@87
|
350 } FLAC__StreamEncoderInitStatus;
|
cannam@87
|
351
|
cannam@87
|
352 /** Maps a FLAC__StreamEncoderInitStatus to a C string.
|
cannam@87
|
353 *
|
cannam@87
|
354 * Using a FLAC__StreamEncoderInitStatus as the index to this array
|
cannam@87
|
355 * will give the string equivalent. The contents should not be modified.
|
cannam@87
|
356 */
|
cannam@87
|
357 extern FLAC_API const char * const FLAC__StreamEncoderInitStatusString[];
|
cannam@87
|
358
|
cannam@87
|
359
|
cannam@87
|
360 /** Return values for the FLAC__StreamEncoder read callback.
|
cannam@87
|
361 */
|
cannam@87
|
362 typedef enum {
|
cannam@87
|
363
|
cannam@87
|
364 FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE,
|
cannam@87
|
365 /**< The read was OK and decoding can continue. */
|
cannam@87
|
366
|
cannam@87
|
367 FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM,
|
cannam@87
|
368 /**< The read was attempted at the end of the stream. */
|
cannam@87
|
369
|
cannam@87
|
370 FLAC__STREAM_ENCODER_READ_STATUS_ABORT,
|
cannam@87
|
371 /**< An unrecoverable error occurred. */
|
cannam@87
|
372
|
cannam@87
|
373 FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED
|
cannam@87
|
374 /**< Client does not support reading back from the output. */
|
cannam@87
|
375
|
cannam@87
|
376 } FLAC__StreamEncoderReadStatus;
|
cannam@87
|
377
|
cannam@87
|
378 /** Maps a FLAC__StreamEncoderReadStatus to a C string.
|
cannam@87
|
379 *
|
cannam@87
|
380 * Using a FLAC__StreamEncoderReadStatus as the index to this array
|
cannam@87
|
381 * will give the string equivalent. The contents should not be modified.
|
cannam@87
|
382 */
|
cannam@87
|
383 extern FLAC_API const char * const FLAC__StreamEncoderReadStatusString[];
|
cannam@87
|
384
|
cannam@87
|
385
|
cannam@87
|
386 /** Return values for the FLAC__StreamEncoder write callback.
|
cannam@87
|
387 */
|
cannam@87
|
388 typedef enum {
|
cannam@87
|
389
|
cannam@87
|
390 FLAC__STREAM_ENCODER_WRITE_STATUS_OK = 0,
|
cannam@87
|
391 /**< The write was OK and encoding can continue. */
|
cannam@87
|
392
|
cannam@87
|
393 FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR
|
cannam@87
|
394 /**< An unrecoverable error occurred. The encoder will return from the process call. */
|
cannam@87
|
395
|
cannam@87
|
396 } FLAC__StreamEncoderWriteStatus;
|
cannam@87
|
397
|
cannam@87
|
398 /** Maps a FLAC__StreamEncoderWriteStatus to a C string.
|
cannam@87
|
399 *
|
cannam@87
|
400 * Using a FLAC__StreamEncoderWriteStatus as the index to this array
|
cannam@87
|
401 * will give the string equivalent. The contents should not be modified.
|
cannam@87
|
402 */
|
cannam@87
|
403 extern FLAC_API const char * const FLAC__StreamEncoderWriteStatusString[];
|
cannam@87
|
404
|
cannam@87
|
405
|
cannam@87
|
406 /** Return values for the FLAC__StreamEncoder seek callback.
|
cannam@87
|
407 */
|
cannam@87
|
408 typedef enum {
|
cannam@87
|
409
|
cannam@87
|
410 FLAC__STREAM_ENCODER_SEEK_STATUS_OK,
|
cannam@87
|
411 /**< The seek was OK and encoding can continue. */
|
cannam@87
|
412
|
cannam@87
|
413 FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR,
|
cannam@87
|
414 /**< An unrecoverable error occurred. */
|
cannam@87
|
415
|
cannam@87
|
416 FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED
|
cannam@87
|
417 /**< Client does not support seeking. */
|
cannam@87
|
418
|
cannam@87
|
419 } FLAC__StreamEncoderSeekStatus;
|
cannam@87
|
420
|
cannam@87
|
421 /** Maps a FLAC__StreamEncoderSeekStatus to a C string.
|
cannam@87
|
422 *
|
cannam@87
|
423 * Using a FLAC__StreamEncoderSeekStatus as the index to this array
|
cannam@87
|
424 * will give the string equivalent. The contents should not be modified.
|
cannam@87
|
425 */
|
cannam@87
|
426 extern FLAC_API const char * const FLAC__StreamEncoderSeekStatusString[];
|
cannam@87
|
427
|
cannam@87
|
428
|
cannam@87
|
429 /** Return values for the FLAC__StreamEncoder tell callback.
|
cannam@87
|
430 */
|
cannam@87
|
431 typedef enum {
|
cannam@87
|
432
|
cannam@87
|
433 FLAC__STREAM_ENCODER_TELL_STATUS_OK,
|
cannam@87
|
434 /**< The tell was OK and encoding can continue. */
|
cannam@87
|
435
|
cannam@87
|
436 FLAC__STREAM_ENCODER_TELL_STATUS_ERROR,
|
cannam@87
|
437 /**< An unrecoverable error occurred. */
|
cannam@87
|
438
|
cannam@87
|
439 FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED
|
cannam@87
|
440 /**< Client does not support seeking. */
|
cannam@87
|
441
|
cannam@87
|
442 } FLAC__StreamEncoderTellStatus;
|
cannam@87
|
443
|
cannam@87
|
444 /** Maps a FLAC__StreamEncoderTellStatus to a C string.
|
cannam@87
|
445 *
|
cannam@87
|
446 * Using a FLAC__StreamEncoderTellStatus as the index to this array
|
cannam@87
|
447 * will give the string equivalent. The contents should not be modified.
|
cannam@87
|
448 */
|
cannam@87
|
449 extern FLAC_API const char * const FLAC__StreamEncoderTellStatusString[];
|
cannam@87
|
450
|
cannam@87
|
451
|
cannam@87
|
452 /***********************************************************************
|
cannam@87
|
453 *
|
cannam@87
|
454 * class FLAC__StreamEncoder
|
cannam@87
|
455 *
|
cannam@87
|
456 ***********************************************************************/
|
cannam@87
|
457
|
cannam@87
|
458 struct FLAC__StreamEncoderProtected;
|
cannam@87
|
459 struct FLAC__StreamEncoderPrivate;
|
cannam@87
|
460 /** The opaque structure definition for the stream encoder type.
|
cannam@87
|
461 * See the \link flac_stream_encoder stream encoder module \endlink
|
cannam@87
|
462 * for a detailed description.
|
cannam@87
|
463 */
|
cannam@87
|
464 typedef struct {
|
cannam@87
|
465 struct FLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
|
cannam@87
|
466 struct FLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
|
cannam@87
|
467 } FLAC__StreamEncoder;
|
cannam@87
|
468
|
cannam@87
|
469 /** Signature for the read callback.
|
cannam@87
|
470 *
|
cannam@87
|
471 * A function pointer matching this signature must be passed to
|
cannam@87
|
472 * FLAC__stream_encoder_init_ogg_stream() if seeking is supported.
|
cannam@87
|
473 * The supplied function will be called when the encoder needs to read back
|
cannam@87
|
474 * encoded data. This happens during the metadata callback, when the encoder
|
cannam@87
|
475 * has to read, modify, and rewrite the metadata (e.g. seekpoints) gathered
|
cannam@87
|
476 * while encoding. The address of the buffer to be filled is supplied, along
|
cannam@87
|
477 * with the number of bytes the buffer can hold. The callback may choose to
|
cannam@87
|
478 * supply less data and modify the byte count but must be careful not to
|
cannam@87
|
479 * overflow the buffer. The callback then returns a status code chosen from
|
cannam@87
|
480 * FLAC__StreamEncoderReadStatus.
|
cannam@87
|
481 *
|
cannam@87
|
482 * Here is an example of a read callback for stdio streams:
|
cannam@87
|
483 * \code
|
cannam@87
|
484 * FLAC__StreamEncoderReadStatus read_cb(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
|
cannam@87
|
485 * {
|
cannam@87
|
486 * FILE *file = ((MyClientData*)client_data)->file;
|
cannam@87
|
487 * if(*bytes > 0) {
|
cannam@87
|
488 * *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file);
|
cannam@87
|
489 * if(ferror(file))
|
cannam@87
|
490 * return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
|
cannam@87
|
491 * else if(*bytes == 0)
|
cannam@87
|
492 * return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM;
|
cannam@87
|
493 * else
|
cannam@87
|
494 * return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE;
|
cannam@87
|
495 * }
|
cannam@87
|
496 * else
|
cannam@87
|
497 * return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
|
cannam@87
|
498 * }
|
cannam@87
|
499 * \endcode
|
cannam@87
|
500 *
|
cannam@87
|
501 * \note In general, FLAC__StreamEncoder functions which change the
|
cannam@87
|
502 * state should not be called on the \a encoder while in the callback.
|
cannam@87
|
503 *
|
cannam@87
|
504 * \param encoder The encoder instance calling the callback.
|
cannam@87
|
505 * \param buffer A pointer to a location for the callee to store
|
cannam@87
|
506 * data to be encoded.
|
cannam@87
|
507 * \param bytes A pointer to the size of the buffer. On entry
|
cannam@87
|
508 * to the callback, it contains the maximum number
|
cannam@87
|
509 * of bytes that may be stored in \a buffer. The
|
cannam@87
|
510 * callee must set it to the actual number of bytes
|
cannam@87
|
511 * stored (0 in case of error or end-of-stream) before
|
cannam@87
|
512 * returning.
|
cannam@87
|
513 * \param client_data The callee's client data set through
|
cannam@87
|
514 * FLAC__stream_encoder_set_client_data().
|
cannam@87
|
515 * \retval FLAC__StreamEncoderReadStatus
|
cannam@87
|
516 * The callee's return status.
|
cannam@87
|
517 */
|
cannam@87
|
518 typedef FLAC__StreamEncoderReadStatus (*FLAC__StreamEncoderReadCallback)(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
|
cannam@87
|
519
|
cannam@87
|
520 /** Signature for the write callback.
|
cannam@87
|
521 *
|
cannam@87
|
522 * A function pointer matching this signature must be passed to
|
cannam@87
|
523 * FLAC__stream_encoder_init*_stream(). The supplied function will be called
|
cannam@87
|
524 * by the encoder anytime there is raw encoded data ready to write. It may
|
cannam@87
|
525 * include metadata mixed with encoded audio frames and the data is not
|
cannam@87
|
526 * guaranteed to be aligned on frame or metadata block boundaries.
|
cannam@87
|
527 *
|
cannam@87
|
528 * The only duty of the callback is to write out the \a bytes worth of data
|
cannam@87
|
529 * in \a buffer to the current position in the output stream. The arguments
|
cannam@87
|
530 * \a samples and \a current_frame are purely informational. If \a samples
|
cannam@87
|
531 * is greater than \c 0, then \a current_frame will hold the current frame
|
cannam@87
|
532 * number that is being written; otherwise it indicates that the write
|
cannam@87
|
533 * callback is being called to write metadata.
|
cannam@87
|
534 *
|
cannam@87
|
535 * \note
|
cannam@87
|
536 * Unlike when writing to native FLAC, when writing to Ogg FLAC the
|
cannam@87
|
537 * write callback will be called twice when writing each audio
|
cannam@87
|
538 * frame; once for the page header, and once for the page body.
|
cannam@87
|
539 * When writing the page header, the \a samples argument to the
|
cannam@87
|
540 * write callback will be \c 0.
|
cannam@87
|
541 *
|
cannam@87
|
542 * \note In general, FLAC__StreamEncoder functions which change the
|
cannam@87
|
543 * state should not be called on the \a encoder while in the callback.
|
cannam@87
|
544 *
|
cannam@87
|
545 * \param encoder The encoder instance calling the callback.
|
cannam@87
|
546 * \param buffer An array of encoded data of length \a bytes.
|
cannam@87
|
547 * \param bytes The byte length of \a buffer.
|
cannam@87
|
548 * \param samples The number of samples encoded by \a buffer.
|
cannam@87
|
549 * \c 0 has a special meaning; see above.
|
cannam@87
|
550 * \param current_frame The number of the current frame being encoded.
|
cannam@87
|
551 * \param client_data The callee's client data set through
|
cannam@87
|
552 * FLAC__stream_encoder_init_*().
|
cannam@87
|
553 * \retval FLAC__StreamEncoderWriteStatus
|
cannam@87
|
554 * The callee's return status.
|
cannam@87
|
555 */
|
cannam@87
|
556 typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
|
cannam@87
|
557
|
cannam@87
|
558 /** Signature for the seek callback.
|
cannam@87
|
559 *
|
cannam@87
|
560 * A function pointer matching this signature may be passed to
|
cannam@87
|
561 * FLAC__stream_encoder_init*_stream(). The supplied function will be called
|
cannam@87
|
562 * when the encoder needs to seek the output stream. The encoder will pass
|
cannam@87
|
563 * the absolute byte offset to seek to, 0 meaning the beginning of the stream.
|
cannam@87
|
564 *
|
cannam@87
|
565 * Here is an example of a seek callback for stdio streams:
|
cannam@87
|
566 * \code
|
cannam@87
|
567 * FLAC__StreamEncoderSeekStatus seek_cb(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data)
|
cannam@87
|
568 * {
|
cannam@87
|
569 * FILE *file = ((MyClientData*)client_data)->file;
|
cannam@87
|
570 * if(file == stdin)
|
cannam@87
|
571 * return FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
|
cannam@87
|
572 * else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0)
|
cannam@87
|
573 * return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
|
cannam@87
|
574 * else
|
cannam@87
|
575 * return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
|
cannam@87
|
576 * }
|
cannam@87
|
577 * \endcode
|
cannam@87
|
578 *
|
cannam@87
|
579 * \note In general, FLAC__StreamEncoder functions which change the
|
cannam@87
|
580 * state should not be called on the \a encoder while in the callback.
|
cannam@87
|
581 *
|
cannam@87
|
582 * \param encoder The encoder instance calling the callback.
|
cannam@87
|
583 * \param absolute_byte_offset The offset from the beginning of the stream
|
cannam@87
|
584 * to seek to.
|
cannam@87
|
585 * \param client_data The callee's client data set through
|
cannam@87
|
586 * FLAC__stream_encoder_init_*().
|
cannam@87
|
587 * \retval FLAC__StreamEncoderSeekStatus
|
cannam@87
|
588 * The callee's return status.
|
cannam@87
|
589 */
|
cannam@87
|
590 typedef FLAC__StreamEncoderSeekStatus (*FLAC__StreamEncoderSeekCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
cannam@87
|
591
|
cannam@87
|
592 /** Signature for the tell callback.
|
cannam@87
|
593 *
|
cannam@87
|
594 * A function pointer matching this signature may be passed to
|
cannam@87
|
595 * FLAC__stream_encoder_init*_stream(). The supplied function will be called
|
cannam@87
|
596 * when the encoder needs to know the current position of the output stream.
|
cannam@87
|
597 *
|
cannam@87
|
598 * \warning
|
cannam@87
|
599 * The callback must return the true current byte offset of the output to
|
cannam@87
|
600 * which the encoder is writing. If you are buffering the output, make
|
cannam@87
|
601 * sure and take this into account. If you are writing directly to a
|
cannam@87
|
602 * FILE* from your write callback, ftell() is sufficient. If you are
|
cannam@87
|
603 * writing directly to a file descriptor from your write callback, you
|
cannam@87
|
604 * can use lseek(fd, SEEK_CUR, 0). The encoder may later seek back to
|
cannam@87
|
605 * these points to rewrite metadata after encoding.
|
cannam@87
|
606 *
|
cannam@87
|
607 * Here is an example of a tell callback for stdio streams:
|
cannam@87
|
608 * \code
|
cannam@87
|
609 * FLAC__StreamEncoderTellStatus tell_cb(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
|
cannam@87
|
610 * {
|
cannam@87
|
611 * FILE *file = ((MyClientData*)client_data)->file;
|
cannam@87
|
612 * off_t pos;
|
cannam@87
|
613 * if(file == stdin)
|
cannam@87
|
614 * return FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED;
|
cannam@87
|
615 * else if((pos = ftello(file)) < 0)
|
cannam@87
|
616 * return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR;
|
cannam@87
|
617 * else {
|
cannam@87
|
618 * *absolute_byte_offset = (FLAC__uint64)pos;
|
cannam@87
|
619 * return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
|
cannam@87
|
620 * }
|
cannam@87
|
621 * }
|
cannam@87
|
622 * \endcode
|
cannam@87
|
623 *
|
cannam@87
|
624 * \note In general, FLAC__StreamEncoder functions which change the
|
cannam@87
|
625 * state should not be called on the \a encoder while in the callback.
|
cannam@87
|
626 *
|
cannam@87
|
627 * \param encoder The encoder instance calling the callback.
|
cannam@87
|
628 * \param absolute_byte_offset The address at which to store the current
|
cannam@87
|
629 * position of the output.
|
cannam@87
|
630 * \param client_data The callee's client data set through
|
cannam@87
|
631 * FLAC__stream_encoder_init_*().
|
cannam@87
|
632 * \retval FLAC__StreamEncoderTellStatus
|
cannam@87
|
633 * The callee's return status.
|
cannam@87
|
634 */
|
cannam@87
|
635 typedef FLAC__StreamEncoderTellStatus (*FLAC__StreamEncoderTellCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
cannam@87
|
636
|
cannam@87
|
637 /** Signature for the metadata callback.
|
cannam@87
|
638 *
|
cannam@87
|
639 * A function pointer matching this signature may be passed to
|
cannam@87
|
640 * FLAC__stream_encoder_init*_stream(). The supplied function will be called
|
cannam@87
|
641 * once at the end of encoding with the populated STREAMINFO structure. This
|
cannam@87
|
642 * is so the client can seek back to the beginning of the file and write the
|
cannam@87
|
643 * STREAMINFO block with the correct statistics after encoding (like
|
cannam@87
|
644 * minimum/maximum frame size and total samples).
|
cannam@87
|
645 *
|
cannam@87
|
646 * \note In general, FLAC__StreamEncoder functions which change the
|
cannam@87
|
647 * state should not be called on the \a encoder while in the callback.
|
cannam@87
|
648 *
|
cannam@87
|
649 * \param encoder The encoder instance calling the callback.
|
cannam@87
|
650 * \param metadata The final populated STREAMINFO block.
|
cannam@87
|
651 * \param client_data The callee's client data set through
|
cannam@87
|
652 * FLAC__stream_encoder_init_*().
|
cannam@87
|
653 */
|
cannam@87
|
654 typedef void (*FLAC__StreamEncoderMetadataCallback)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data);
|
cannam@87
|
655
|
cannam@87
|
656 /** Signature for the progress callback.
|
cannam@87
|
657 *
|
cannam@87
|
658 * A function pointer matching this signature may be passed to
|
cannam@87
|
659 * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE().
|
cannam@87
|
660 * The supplied function will be called when the encoder has finished
|
cannam@87
|
661 * writing a frame. The \c total_frames_estimate argument to the
|
cannam@87
|
662 * callback will be based on the value from
|
cannam@87
|
663 * FLAC__stream_encoder_set_total_samples_estimate().
|
cannam@87
|
664 *
|
cannam@87
|
665 * \note In general, FLAC__StreamEncoder functions which change the
|
cannam@87
|
666 * state should not be called on the \a encoder while in the callback.
|
cannam@87
|
667 *
|
cannam@87
|
668 * \param encoder The encoder instance calling the callback.
|
cannam@87
|
669 * \param bytes_written Bytes written so far.
|
cannam@87
|
670 * \param samples_written Samples written so far.
|
cannam@87
|
671 * \param frames_written Frames written so far.
|
cannam@87
|
672 * \param total_frames_estimate The estimate of the total number of
|
cannam@87
|
673 * frames to be written.
|
cannam@87
|
674 * \param client_data The callee's client data set through
|
cannam@87
|
675 * FLAC__stream_encoder_init_*().
|
cannam@87
|
676 */
|
cannam@87
|
677 typedef void (*FLAC__StreamEncoderProgressCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
|
cannam@87
|
678
|
cannam@87
|
679
|
cannam@87
|
680 /***********************************************************************
|
cannam@87
|
681 *
|
cannam@87
|
682 * Class constructor/destructor
|
cannam@87
|
683 *
|
cannam@87
|
684 ***********************************************************************/
|
cannam@87
|
685
|
cannam@87
|
686 /** Create a new stream encoder instance. The instance is created with
|
cannam@87
|
687 * default settings; see the individual FLAC__stream_encoder_set_*()
|
cannam@87
|
688 * functions for each setting's default.
|
cannam@87
|
689 *
|
cannam@87
|
690 * \retval FLAC__StreamEncoder*
|
cannam@87
|
691 * \c NULL if there was an error allocating memory, else the new instance.
|
cannam@87
|
692 */
|
cannam@87
|
693 FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void);
|
cannam@87
|
694
|
cannam@87
|
695 /** Free an encoder instance. Deletes the object pointed to by \a encoder.
|
cannam@87
|
696 *
|
cannam@87
|
697 * \param encoder A pointer to an existing encoder.
|
cannam@87
|
698 * \assert
|
cannam@87
|
699 * \code encoder != NULL \endcode
|
cannam@87
|
700 */
|
cannam@87
|
701 FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder);
|
cannam@87
|
702
|
cannam@87
|
703
|
cannam@87
|
704 /***********************************************************************
|
cannam@87
|
705 *
|
cannam@87
|
706 * Public class method prototypes
|
cannam@87
|
707 *
|
cannam@87
|
708 ***********************************************************************/
|
cannam@87
|
709
|
cannam@87
|
710 /** Set the serial number for the FLAC stream to use in the Ogg container.
|
cannam@87
|
711 *
|
cannam@87
|
712 * \note
|
cannam@87
|
713 * This does not need to be set for native FLAC encoding.
|
cannam@87
|
714 *
|
cannam@87
|
715 * \note
|
cannam@87
|
716 * It is recommended to set a serial number explicitly as the default of '0'
|
cannam@87
|
717 * may collide with other streams.
|
cannam@87
|
718 *
|
cannam@87
|
719 * \default \c 0
|
cannam@87
|
720 * \param encoder An encoder instance to set.
|
cannam@87
|
721 * \param serial_number See above.
|
cannam@87
|
722 * \assert
|
cannam@87
|
723 * \code encoder != NULL \endcode
|
cannam@87
|
724 * \retval FLAC__bool
|
cannam@87
|
725 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
726 */
|
cannam@87
|
727 FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncoder *encoder, long serial_number);
|
cannam@87
|
728
|
cannam@87
|
729 /** Set the "verify" flag. If \c true, the encoder will verify it's own
|
cannam@87
|
730 * encoded output by feeding it through an internal decoder and comparing
|
cannam@87
|
731 * the original signal against the decoded signal. If a mismatch occurs,
|
cannam@87
|
732 * the process call will return \c false. Note that this will slow the
|
cannam@87
|
733 * encoding process by the extra time required for decoding and comparison.
|
cannam@87
|
734 *
|
cannam@87
|
735 * \default \c false
|
cannam@87
|
736 * \param encoder An encoder instance to set.
|
cannam@87
|
737 * \param value Flag value (see above).
|
cannam@87
|
738 * \assert
|
cannam@87
|
739 * \code encoder != NULL \endcode
|
cannam@87
|
740 * \retval FLAC__bool
|
cannam@87
|
741 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
742 */
|
cannam@87
|
743 FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
cannam@87
|
744
|
cannam@87
|
745 /** Set the <A HREF="../format.html#subset">Subset</A> flag. If \c true,
|
cannam@87
|
746 * the encoder will comply with the Subset and will check the
|
cannam@87
|
747 * settings during FLAC__stream_encoder_init_*() to see if all settings
|
cannam@87
|
748 * comply. If \c false, the settings may take advantage of the full
|
cannam@87
|
749 * range that the format allows.
|
cannam@87
|
750 *
|
cannam@87
|
751 * Make sure you know what it entails before setting this to \c false.
|
cannam@87
|
752 *
|
cannam@87
|
753 * \default \c true
|
cannam@87
|
754 * \param encoder An encoder instance to set.
|
cannam@87
|
755 * \param value Flag value (see above).
|
cannam@87
|
756 * \assert
|
cannam@87
|
757 * \code encoder != NULL \endcode
|
cannam@87
|
758 * \retval FLAC__bool
|
cannam@87
|
759 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
760 */
|
cannam@87
|
761 FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
cannam@87
|
762
|
cannam@87
|
763 /** Set the number of channels to be encoded.
|
cannam@87
|
764 *
|
cannam@87
|
765 * \default \c 2
|
cannam@87
|
766 * \param encoder An encoder instance to set.
|
cannam@87
|
767 * \param value See above.
|
cannam@87
|
768 * \assert
|
cannam@87
|
769 * \code encoder != NULL \endcode
|
cannam@87
|
770 * \retval FLAC__bool
|
cannam@87
|
771 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
772 */
|
cannam@87
|
773 FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
774
|
cannam@87
|
775 /** Set the sample resolution of the input to be encoded.
|
cannam@87
|
776 *
|
cannam@87
|
777 * \warning
|
cannam@87
|
778 * Do not feed the encoder data that is wider than the value you
|
cannam@87
|
779 * set here or you will generate an invalid stream.
|
cannam@87
|
780 *
|
cannam@87
|
781 * \default \c 16
|
cannam@87
|
782 * \param encoder An encoder instance to set.
|
cannam@87
|
783 * \param value See above.
|
cannam@87
|
784 * \assert
|
cannam@87
|
785 * \code encoder != NULL \endcode
|
cannam@87
|
786 * \retval FLAC__bool
|
cannam@87
|
787 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
788 */
|
cannam@87
|
789 FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
790
|
cannam@87
|
791 /** Set the sample rate (in Hz) of the input to be encoded.
|
cannam@87
|
792 *
|
cannam@87
|
793 * \default \c 44100
|
cannam@87
|
794 * \param encoder An encoder instance to set.
|
cannam@87
|
795 * \param value See above.
|
cannam@87
|
796 * \assert
|
cannam@87
|
797 * \code encoder != NULL \endcode
|
cannam@87
|
798 * \retval FLAC__bool
|
cannam@87
|
799 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
800 */
|
cannam@87
|
801 FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
802
|
cannam@87
|
803 /** Set the compression level
|
cannam@87
|
804 *
|
cannam@87
|
805 * The compression level is roughly proportional to the amount of effort
|
cannam@87
|
806 * the encoder expends to compress the file. A higher level usually
|
cannam@87
|
807 * means more computation but higher compression. The default level is
|
cannam@87
|
808 * suitable for most applications.
|
cannam@87
|
809 *
|
cannam@87
|
810 * Currently the levels range from \c 0 (fastest, least compression) to
|
cannam@87
|
811 * \c 8 (slowest, most compression). A value larger than \c 8 will be
|
cannam@87
|
812 * treated as \c 8.
|
cannam@87
|
813 *
|
cannam@87
|
814 * This function automatically calls the following other \c _set_
|
cannam@87
|
815 * functions with appropriate values, so the client does not need to
|
cannam@87
|
816 * unless it specifically wants to override them:
|
cannam@87
|
817 * - FLAC__stream_encoder_set_do_mid_side_stereo()
|
cannam@87
|
818 * - FLAC__stream_encoder_set_loose_mid_side_stereo()
|
cannam@87
|
819 * - FLAC__stream_encoder_set_apodization()
|
cannam@87
|
820 * - FLAC__stream_encoder_set_max_lpc_order()
|
cannam@87
|
821 * - FLAC__stream_encoder_set_qlp_coeff_precision()
|
cannam@87
|
822 * - FLAC__stream_encoder_set_do_qlp_coeff_prec_search()
|
cannam@87
|
823 * - FLAC__stream_encoder_set_do_escape_coding()
|
cannam@87
|
824 * - FLAC__stream_encoder_set_do_exhaustive_model_search()
|
cannam@87
|
825 * - FLAC__stream_encoder_set_min_residual_partition_order()
|
cannam@87
|
826 * - FLAC__stream_encoder_set_max_residual_partition_order()
|
cannam@87
|
827 * - FLAC__stream_encoder_set_rice_parameter_search_dist()
|
cannam@87
|
828 *
|
cannam@87
|
829 * The actual values set for each level are:
|
cannam@87
|
830 * <table>
|
cannam@87
|
831 * <tr>
|
cannam@87
|
832 * <td><b>level</b><td>
|
cannam@87
|
833 * <td>do mid-side stereo<td>
|
cannam@87
|
834 * <td>loose mid-side stereo<td>
|
cannam@87
|
835 * <td>apodization<td>
|
cannam@87
|
836 * <td>max lpc order<td>
|
cannam@87
|
837 * <td>qlp coeff precision<td>
|
cannam@87
|
838 * <td>qlp coeff prec search<td>
|
cannam@87
|
839 * <td>escape coding<td>
|
cannam@87
|
840 * <td>exhaustive model search<td>
|
cannam@87
|
841 * <td>min residual partition order<td>
|
cannam@87
|
842 * <td>max residual partition order<td>
|
cannam@87
|
843 * <td>rice parameter search dist<td>
|
cannam@87
|
844 * </tr>
|
cannam@87
|
845 * <tr> <td><b>0</b><td> <td>false<td> <td>false<td> <td>tukey(0.5)<td> <td>0<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>3<td> <td>0<td> </tr>
|
cannam@87
|
846 * <tr> <td><b>1</b><td> <td>true<td> <td>true<td> <td>tukey(0.5)<td> <td>0<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>3<td> <td>0<td> </tr>
|
cannam@87
|
847 * <tr> <td><b>2</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>0<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>3<td> <td>0<td> </tr>
|
cannam@87
|
848 * <tr> <td><b>3</b><td> <td>false<td> <td>false<td> <td>tukey(0.5)<td> <td>6<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>4<td> <td>0<td> </tr>
|
cannam@87
|
849 * <tr> <td><b>4</b><td> <td>true<td> <td>true<td> <td>tukey(0.5)<td> <td>8<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>4<td> <td>0<td> </tr>
|
cannam@87
|
850 * <tr> <td><b>5</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>8<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>5<td> <td>0<td> </tr>
|
cannam@87
|
851 * <tr> <td><b>6</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>8<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>6<td> <td>0<td> </tr>
|
cannam@87
|
852 * <tr> <td><b>7</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>8<td> <td>0<td> <td>false<td> <td>false<td> <td>true<td> <td>0<td> <td>6<td> <td>0<td> </tr>
|
cannam@87
|
853 * <tr> <td><b>8</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>12<td> <td>0<td> <td>false<td> <td>false<td> <td>true<td> <td>0<td> <td>6<td> <td>0<td> </tr>
|
cannam@87
|
854 * </table>
|
cannam@87
|
855 *
|
cannam@87
|
856 * \default \c 5
|
cannam@87
|
857 * \param encoder An encoder instance to set.
|
cannam@87
|
858 * \param value See above.
|
cannam@87
|
859 * \assert
|
cannam@87
|
860 * \code encoder != NULL \endcode
|
cannam@87
|
861 * \retval FLAC__bool
|
cannam@87
|
862 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
863 */
|
cannam@87
|
864 FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
865
|
cannam@87
|
866 /** Set the blocksize to use while encoding.
|
cannam@87
|
867 *
|
cannam@87
|
868 * The number of samples to use per frame. Use \c 0 to let the encoder
|
cannam@87
|
869 * estimate a blocksize; this is usually best.
|
cannam@87
|
870 *
|
cannam@87
|
871 * \default \c 0
|
cannam@87
|
872 * \param encoder An encoder instance to set.
|
cannam@87
|
873 * \param value See above.
|
cannam@87
|
874 * \assert
|
cannam@87
|
875 * \code encoder != NULL \endcode
|
cannam@87
|
876 * \retval FLAC__bool
|
cannam@87
|
877 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
878 */
|
cannam@87
|
879 FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
880
|
cannam@87
|
881 /** Set to \c true to enable mid-side encoding on stereo input. The
|
cannam@87
|
882 * number of channels must be 2 for this to have any effect. Set to
|
cannam@87
|
883 * \c false to use only independent channel coding.
|
cannam@87
|
884 *
|
cannam@87
|
885 * \default \c false
|
cannam@87
|
886 * \param encoder An encoder instance to set.
|
cannam@87
|
887 * \param value Flag value (see above).
|
cannam@87
|
888 * \assert
|
cannam@87
|
889 * \code encoder != NULL \endcode
|
cannam@87
|
890 * \retval FLAC__bool
|
cannam@87
|
891 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
892 */
|
cannam@87
|
893 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
cannam@87
|
894
|
cannam@87
|
895 /** Set to \c true to enable adaptive switching between mid-side and
|
cannam@87
|
896 * left-right encoding on stereo input. Set to \c false to use
|
cannam@87
|
897 * exhaustive searching. Setting this to \c true requires
|
cannam@87
|
898 * FLAC__stream_encoder_set_do_mid_side_stereo() to also be set to
|
cannam@87
|
899 * \c true in order to have any effect.
|
cannam@87
|
900 *
|
cannam@87
|
901 * \default \c false
|
cannam@87
|
902 * \param encoder An encoder instance to set.
|
cannam@87
|
903 * \param value Flag value (see above).
|
cannam@87
|
904 * \assert
|
cannam@87
|
905 * \code encoder != NULL \endcode
|
cannam@87
|
906 * \retval FLAC__bool
|
cannam@87
|
907 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
908 */
|
cannam@87
|
909 FLAC_API FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
cannam@87
|
910
|
cannam@87
|
911 /** Sets the apodization function(s) the encoder will use when windowing
|
cannam@87
|
912 * audio data for LPC analysis.
|
cannam@87
|
913 *
|
cannam@87
|
914 * The \a specification is a plain ASCII string which specifies exactly
|
cannam@87
|
915 * which functions to use. There may be more than one (up to 32),
|
cannam@87
|
916 * separated by \c ';' characters. Some functions take one or more
|
cannam@87
|
917 * comma-separated arguments in parentheses.
|
cannam@87
|
918 *
|
cannam@87
|
919 * The available functions are \c bartlett, \c bartlett_hann,
|
cannam@87
|
920 * \c blackman, \c blackman_harris_4term_92db, \c connes, \c flattop,
|
cannam@87
|
921 * \c gauss(STDDEV), \c hamming, \c hann, \c kaiser_bessel, \c nuttall,
|
cannam@87
|
922 * \c rectangle, \c triangle, \c tukey(P), \c welch.
|
cannam@87
|
923 *
|
cannam@87
|
924 * For \c gauss(STDDEV), STDDEV specifies the standard deviation
|
cannam@87
|
925 * (0<STDDEV<=0.5).
|
cannam@87
|
926 *
|
cannam@87
|
927 * For \c tukey(P), P specifies the fraction of the window that is
|
cannam@87
|
928 * tapered (0<=P<=1). P=0 corresponds to \c rectangle and P=1
|
cannam@87
|
929 * corresponds to \c hann.
|
cannam@87
|
930 *
|
cannam@87
|
931 * Example specifications are \c "blackman" or
|
cannam@87
|
932 * \c "hann;triangle;tukey(0.5);tukey(0.25);tukey(0.125)"
|
cannam@87
|
933 *
|
cannam@87
|
934 * Any function that is specified erroneously is silently dropped. Up
|
cannam@87
|
935 * to 32 functions are kept, the rest are dropped. If the specification
|
cannam@87
|
936 * is empty the encoder defaults to \c "tukey(0.5)".
|
cannam@87
|
937 *
|
cannam@87
|
938 * When more than one function is specified, then for every subframe the
|
cannam@87
|
939 * encoder will try each of them separately and choose the window that
|
cannam@87
|
940 * results in the smallest compressed subframe.
|
cannam@87
|
941 *
|
cannam@87
|
942 * Note that each function specified causes the encoder to occupy a
|
cannam@87
|
943 * floating point array in which to store the window.
|
cannam@87
|
944 *
|
cannam@87
|
945 * \default \c "tukey(0.5)"
|
cannam@87
|
946 * \param encoder An encoder instance to set.
|
cannam@87
|
947 * \param specification See above.
|
cannam@87
|
948 * \assert
|
cannam@87
|
949 * \code encoder != NULL \endcode
|
cannam@87
|
950 * \code specification != NULL \endcode
|
cannam@87
|
951 * \retval FLAC__bool
|
cannam@87
|
952 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
953 */
|
cannam@87
|
954 FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *encoder, const char *specification);
|
cannam@87
|
955
|
cannam@87
|
956 /** Set the maximum LPC order, or \c 0 to use only the fixed predictors.
|
cannam@87
|
957 *
|
cannam@87
|
958 * \default \c 0
|
cannam@87
|
959 * \param encoder An encoder instance to set.
|
cannam@87
|
960 * \param value See above.
|
cannam@87
|
961 * \assert
|
cannam@87
|
962 * \code encoder != NULL \endcode
|
cannam@87
|
963 * \retval FLAC__bool
|
cannam@87
|
964 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
965 */
|
cannam@87
|
966 FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
967
|
cannam@87
|
968 /** Set the precision, in bits, of the quantized linear predictor
|
cannam@87
|
969 * coefficients, or \c 0 to let the encoder select it based on the
|
cannam@87
|
970 * blocksize.
|
cannam@87
|
971 *
|
cannam@87
|
972 * \note
|
cannam@87
|
973 * In the current implementation, qlp_coeff_precision + bits_per_sample must
|
cannam@87
|
974 * be less than 32.
|
cannam@87
|
975 *
|
cannam@87
|
976 * \default \c 0
|
cannam@87
|
977 * \param encoder An encoder instance to set.
|
cannam@87
|
978 * \param value See above.
|
cannam@87
|
979 * \assert
|
cannam@87
|
980 * \code encoder != NULL \endcode
|
cannam@87
|
981 * \retval FLAC__bool
|
cannam@87
|
982 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
983 */
|
cannam@87
|
984 FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
985
|
cannam@87
|
986 /** Set to \c false to use only the specified quantized linear predictor
|
cannam@87
|
987 * coefficient precision, or \c true to search neighboring precision
|
cannam@87
|
988 * values and use the best one.
|
cannam@87
|
989 *
|
cannam@87
|
990 * \default \c false
|
cannam@87
|
991 * \param encoder An encoder instance to set.
|
cannam@87
|
992 * \param value See above.
|
cannam@87
|
993 * \assert
|
cannam@87
|
994 * \code encoder != NULL \endcode
|
cannam@87
|
995 * \retval FLAC__bool
|
cannam@87
|
996 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
997 */
|
cannam@87
|
998 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
cannam@87
|
999
|
cannam@87
|
1000 /** Deprecated. Setting this value has no effect.
|
cannam@87
|
1001 *
|
cannam@87
|
1002 * \default \c false
|
cannam@87
|
1003 * \param encoder An encoder instance to set.
|
cannam@87
|
1004 * \param value See above.
|
cannam@87
|
1005 * \assert
|
cannam@87
|
1006 * \code encoder != NULL \endcode
|
cannam@87
|
1007 * \retval FLAC__bool
|
cannam@87
|
1008 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
1009 */
|
cannam@87
|
1010 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_escape_coding(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
cannam@87
|
1011
|
cannam@87
|
1012 /** Set to \c false to let the encoder estimate the best model order
|
cannam@87
|
1013 * based on the residual signal energy, or \c true to force the
|
cannam@87
|
1014 * encoder to evaluate all order models and select the best.
|
cannam@87
|
1015 *
|
cannam@87
|
1016 * \default \c false
|
cannam@87
|
1017 * \param encoder An encoder instance to set.
|
cannam@87
|
1018 * \param value See above.
|
cannam@87
|
1019 * \assert
|
cannam@87
|
1020 * \code encoder != NULL \endcode
|
cannam@87
|
1021 * \retval FLAC__bool
|
cannam@87
|
1022 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
1023 */
|
cannam@87
|
1024 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
cannam@87
|
1025
|
cannam@87
|
1026 /** Set the minimum partition order to search when coding the residual.
|
cannam@87
|
1027 * This is used in tandem with
|
cannam@87
|
1028 * FLAC__stream_encoder_set_max_residual_partition_order().
|
cannam@87
|
1029 *
|
cannam@87
|
1030 * The partition order determines the context size in the residual.
|
cannam@87
|
1031 * The context size will be approximately <tt>blocksize / (2 ^ order)</tt>.
|
cannam@87
|
1032 *
|
cannam@87
|
1033 * Set both min and max values to \c 0 to force a single context,
|
cannam@87
|
1034 * whose Rice parameter is based on the residual signal variance.
|
cannam@87
|
1035 * Otherwise, set a min and max order, and the encoder will search
|
cannam@87
|
1036 * all orders, using the mean of each context for its Rice parameter,
|
cannam@87
|
1037 * and use the best.
|
cannam@87
|
1038 *
|
cannam@87
|
1039 * \default \c 0
|
cannam@87
|
1040 * \param encoder An encoder instance to set.
|
cannam@87
|
1041 * \param value See above.
|
cannam@87
|
1042 * \assert
|
cannam@87
|
1043 * \code encoder != NULL \endcode
|
cannam@87
|
1044 * \retval FLAC__bool
|
cannam@87
|
1045 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
1046 */
|
cannam@87
|
1047 FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
1048
|
cannam@87
|
1049 /** Set the maximum partition order to search when coding the residual.
|
cannam@87
|
1050 * This is used in tandem with
|
cannam@87
|
1051 * FLAC__stream_encoder_set_min_residual_partition_order().
|
cannam@87
|
1052 *
|
cannam@87
|
1053 * The partition order determines the context size in the residual.
|
cannam@87
|
1054 * The context size will be approximately <tt>blocksize / (2 ^ order)</tt>.
|
cannam@87
|
1055 *
|
cannam@87
|
1056 * Set both min and max values to \c 0 to force a single context,
|
cannam@87
|
1057 * whose Rice parameter is based on the residual signal variance.
|
cannam@87
|
1058 * Otherwise, set a min and max order, and the encoder will search
|
cannam@87
|
1059 * all orders, using the mean of each context for its Rice parameter,
|
cannam@87
|
1060 * and use the best.
|
cannam@87
|
1061 *
|
cannam@87
|
1062 * \default \c 0
|
cannam@87
|
1063 * \param encoder An encoder instance to set.
|
cannam@87
|
1064 * \param value See above.
|
cannam@87
|
1065 * \assert
|
cannam@87
|
1066 * \code encoder != NULL \endcode
|
cannam@87
|
1067 * \retval FLAC__bool
|
cannam@87
|
1068 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
1069 */
|
cannam@87
|
1070 FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
1071
|
cannam@87
|
1072 /** Deprecated. Setting this value has no effect.
|
cannam@87
|
1073 *
|
cannam@87
|
1074 * \default \c 0
|
cannam@87
|
1075 * \param encoder An encoder instance to set.
|
cannam@87
|
1076 * \param value See above.
|
cannam@87
|
1077 * \assert
|
cannam@87
|
1078 * \code encoder != NULL \endcode
|
cannam@87
|
1079 * \retval FLAC__bool
|
cannam@87
|
1080 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
1081 */
|
cannam@87
|
1082 FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value);
|
cannam@87
|
1083
|
cannam@87
|
1084 /** Set an estimate of the total samples that will be encoded.
|
cannam@87
|
1085 * This is merely an estimate and may be set to \c 0 if unknown.
|
cannam@87
|
1086 * This value will be written to the STREAMINFO block before encoding,
|
cannam@87
|
1087 * and can remove the need for the caller to rewrite the value later
|
cannam@87
|
1088 * if the value is known before encoding.
|
cannam@87
|
1089 *
|
cannam@87
|
1090 * \default \c 0
|
cannam@87
|
1091 * \param encoder An encoder instance to set.
|
cannam@87
|
1092 * \param value See above.
|
cannam@87
|
1093 * \assert
|
cannam@87
|
1094 * \code encoder != NULL \endcode
|
cannam@87
|
1095 * \retval FLAC__bool
|
cannam@87
|
1096 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
1097 */
|
cannam@87
|
1098 FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value);
|
cannam@87
|
1099
|
cannam@87
|
1100 /** Set the metadata blocks to be emitted to the stream before encoding.
|
cannam@87
|
1101 * A value of \c NULL, \c 0 implies no metadata; otherwise, supply an
|
cannam@87
|
1102 * array of pointers to metadata blocks. The array is non-const since
|
cannam@87
|
1103 * the encoder may need to change the \a is_last flag inside them, and
|
cannam@87
|
1104 * in some cases update seek point offsets. Otherwise, the encoder will
|
cannam@87
|
1105 * not modify or free the blocks. It is up to the caller to free the
|
cannam@87
|
1106 * metadata blocks after encoding finishes.
|
cannam@87
|
1107 *
|
cannam@87
|
1108 * \note
|
cannam@87
|
1109 * The encoder stores only copies of the pointers in the \a metadata array;
|
cannam@87
|
1110 * the metadata blocks themselves must survive at least until after
|
cannam@87
|
1111 * FLAC__stream_encoder_finish() returns. Do not free the blocks until then.
|
cannam@87
|
1112 *
|
cannam@87
|
1113 * \note
|
cannam@87
|
1114 * The STREAMINFO block is always written and no STREAMINFO block may
|
cannam@87
|
1115 * occur in the supplied array.
|
cannam@87
|
1116 *
|
cannam@87
|
1117 * \note
|
cannam@87
|
1118 * By default the encoder does not create a SEEKTABLE. If one is supplied
|
cannam@87
|
1119 * in the \a metadata array, but the client has specified that it does not
|
cannam@87
|
1120 * support seeking, then the SEEKTABLE will be written verbatim. However
|
cannam@87
|
1121 * by itself this is not very useful as the client will not know the stream
|
cannam@87
|
1122 * offsets for the seekpoints ahead of time. In order to get a proper
|
cannam@87
|
1123 * seektable the client must support seeking. See next note.
|
cannam@87
|
1124 *
|
cannam@87
|
1125 * \note
|
cannam@87
|
1126 * SEEKTABLE blocks are handled specially. Since you will not know
|
cannam@87
|
1127 * the values for the seek point stream offsets, you should pass in
|
cannam@87
|
1128 * a SEEKTABLE 'template', that is, a SEEKTABLE object with the
|
cannam@87
|
1129 * required sample numbers (or placeholder points), with \c 0 for the
|
cannam@87
|
1130 * \a frame_samples and \a stream_offset fields for each point. If the
|
cannam@87
|
1131 * client has specified that it supports seeking by providing a seek
|
cannam@87
|
1132 * callback to FLAC__stream_encoder_init_stream() or both seek AND read
|
cannam@87
|
1133 * callback to FLAC__stream_encoder_init_ogg_stream() (or by using
|
cannam@87
|
1134 * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE()),
|
cannam@87
|
1135 * then while it is encoding the encoder will fill the stream offsets in
|
cannam@87
|
1136 * for you and when encoding is finished, it will seek back and write the
|
cannam@87
|
1137 * real values into the SEEKTABLE block in the stream. There are helper
|
cannam@87
|
1138 * routines for manipulating seektable template blocks; see metadata.h:
|
cannam@87
|
1139 * FLAC__metadata_object_seektable_template_*(). If the client does
|
cannam@87
|
1140 * not support seeking, the SEEKTABLE will have inaccurate offsets which
|
cannam@87
|
1141 * will slow down or remove the ability to seek in the FLAC stream.
|
cannam@87
|
1142 *
|
cannam@87
|
1143 * \note
|
cannam@87
|
1144 * The encoder instance \b will modify the first \c SEEKTABLE block
|
cannam@87
|
1145 * as it transforms the template to a valid seektable while encoding,
|
cannam@87
|
1146 * but it is still up to the caller to free all metadata blocks after
|
cannam@87
|
1147 * encoding.
|
cannam@87
|
1148 *
|
cannam@87
|
1149 * \note
|
cannam@87
|
1150 * A VORBIS_COMMENT block may be supplied. The vendor string in it
|
cannam@87
|
1151 * will be ignored. libFLAC will use it's own vendor string. libFLAC
|
cannam@87
|
1152 * will not modify the passed-in VORBIS_COMMENT's vendor string, it
|
cannam@87
|
1153 * will simply write it's own into the stream. If no VORBIS_COMMENT
|
cannam@87
|
1154 * block is present in the \a metadata array, libFLAC will write an
|
cannam@87
|
1155 * empty one, containing only the vendor string.
|
cannam@87
|
1156 *
|
cannam@87
|
1157 * \note The Ogg FLAC mapping requires that the VORBIS_COMMENT block be
|
cannam@87
|
1158 * the second metadata block of the stream. The encoder already supplies
|
cannam@87
|
1159 * the STREAMINFO block automatically. If \a metadata does not contain a
|
cannam@87
|
1160 * VORBIS_COMMENT block, the encoder will supply that too. Otherwise, if
|
cannam@87
|
1161 * \a metadata does contain a VORBIS_COMMENT block and it is not the
|
cannam@87
|
1162 * first, the init function will reorder \a metadata by moving the
|
cannam@87
|
1163 * VORBIS_COMMENT block to the front; the relative ordering of the other
|
cannam@87
|
1164 * blocks will remain as they were.
|
cannam@87
|
1165 *
|
cannam@87
|
1166 * \note The Ogg FLAC mapping limits the number of metadata blocks per
|
cannam@87
|
1167 * stream to \c 65535. If \a num_blocks exceeds this the function will
|
cannam@87
|
1168 * return \c false.
|
cannam@87
|
1169 *
|
cannam@87
|
1170 * \default \c NULL, 0
|
cannam@87
|
1171 * \param encoder An encoder instance to set.
|
cannam@87
|
1172 * \param metadata See above.
|
cannam@87
|
1173 * \param num_blocks See above.
|
cannam@87
|
1174 * \assert
|
cannam@87
|
1175 * \code encoder != NULL \endcode
|
cannam@87
|
1176 * \retval FLAC__bool
|
cannam@87
|
1177 * \c false if the encoder is already initialized, else \c true.
|
cannam@87
|
1178 * \c false if the encoder is already initialized, or if
|
cannam@87
|
1179 * \a num_blocks > 65535 if encoding to Ogg FLAC, else \c true.
|
cannam@87
|
1180 */
|
cannam@87
|
1181 FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
|
cannam@87
|
1182
|
cannam@87
|
1183 /** Get the current encoder state.
|
cannam@87
|
1184 *
|
cannam@87
|
1185 * \param encoder An encoder instance to query.
|
cannam@87
|
1186 * \assert
|
cannam@87
|
1187 * \code encoder != NULL \endcode
|
cannam@87
|
1188 * \retval FLAC__StreamEncoderState
|
cannam@87
|
1189 * The current encoder state.
|
cannam@87
|
1190 */
|
cannam@87
|
1191 FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1192
|
cannam@87
|
1193 /** Get the state of the verify stream decoder.
|
cannam@87
|
1194 * Useful when the stream encoder state is
|
cannam@87
|
1195 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
|
cannam@87
|
1196 *
|
cannam@87
|
1197 * \param encoder An encoder instance to query.
|
cannam@87
|
1198 * \assert
|
cannam@87
|
1199 * \code encoder != NULL \endcode
|
cannam@87
|
1200 * \retval FLAC__StreamDecoderState
|
cannam@87
|
1201 * The verify stream decoder state.
|
cannam@87
|
1202 */
|
cannam@87
|
1203 FLAC_API FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1204
|
cannam@87
|
1205 /** Get the current encoder state as a C string.
|
cannam@87
|
1206 * This version automatically resolves
|
cannam@87
|
1207 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR by getting the
|
cannam@87
|
1208 * verify decoder's state.
|
cannam@87
|
1209 *
|
cannam@87
|
1210 * \param encoder A encoder instance to query.
|
cannam@87
|
1211 * \assert
|
cannam@87
|
1212 * \code encoder != NULL \endcode
|
cannam@87
|
1213 * \retval const char *
|
cannam@87
|
1214 * The encoder state as a C string. Do not modify the contents.
|
cannam@87
|
1215 */
|
cannam@87
|
1216 FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1217
|
cannam@87
|
1218 /** Get relevant values about the nature of a verify decoder error.
|
cannam@87
|
1219 * Useful when the stream encoder state is
|
cannam@87
|
1220 * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR. The arguments should
|
cannam@87
|
1221 * be addresses in which the stats will be returned, or NULL if value
|
cannam@87
|
1222 * is not desired.
|
cannam@87
|
1223 *
|
cannam@87
|
1224 * \param encoder An encoder instance to query.
|
cannam@87
|
1225 * \param absolute_sample The absolute sample number of the mismatch.
|
cannam@87
|
1226 * \param frame_number The number of the frame in which the mismatch occurred.
|
cannam@87
|
1227 * \param channel The channel in which the mismatch occurred.
|
cannam@87
|
1228 * \param sample The number of the sample (relative to the frame) in
|
cannam@87
|
1229 * which the mismatch occurred.
|
cannam@87
|
1230 * \param expected The expected value for the sample in question.
|
cannam@87
|
1231 * \param got The actual value returned by the decoder.
|
cannam@87
|
1232 * \assert
|
cannam@87
|
1233 * \code encoder != NULL \endcode
|
cannam@87
|
1234 */
|
cannam@87
|
1235 FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
|
cannam@87
|
1236
|
cannam@87
|
1237 /** Get the "verify" flag.
|
cannam@87
|
1238 *
|
cannam@87
|
1239 * \param encoder An encoder instance to query.
|
cannam@87
|
1240 * \assert
|
cannam@87
|
1241 * \code encoder != NULL \endcode
|
cannam@87
|
1242 * \retval FLAC__bool
|
cannam@87
|
1243 * See FLAC__stream_encoder_set_verify().
|
cannam@87
|
1244 */
|
cannam@87
|
1245 FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1246
|
cannam@87
|
1247 /** Get the <A HREF="../format.html#subset>Subset</A> flag.
|
cannam@87
|
1248 *
|
cannam@87
|
1249 * \param encoder An encoder instance to query.
|
cannam@87
|
1250 * \assert
|
cannam@87
|
1251 * \code encoder != NULL \endcode
|
cannam@87
|
1252 * \retval FLAC__bool
|
cannam@87
|
1253 * See FLAC__stream_encoder_set_streamable_subset().
|
cannam@87
|
1254 */
|
cannam@87
|
1255 FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1256
|
cannam@87
|
1257 /** Get the number of input channels being processed.
|
cannam@87
|
1258 *
|
cannam@87
|
1259 * \param encoder An encoder instance to query.
|
cannam@87
|
1260 * \assert
|
cannam@87
|
1261 * \code encoder != NULL \endcode
|
cannam@87
|
1262 * \retval unsigned
|
cannam@87
|
1263 * See FLAC__stream_encoder_set_channels().
|
cannam@87
|
1264 */
|
cannam@87
|
1265 FLAC_API unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1266
|
cannam@87
|
1267 /** Get the input sample resolution setting.
|
cannam@87
|
1268 *
|
cannam@87
|
1269 * \param encoder An encoder instance to query.
|
cannam@87
|
1270 * \assert
|
cannam@87
|
1271 * \code encoder != NULL \endcode
|
cannam@87
|
1272 * \retval unsigned
|
cannam@87
|
1273 * See FLAC__stream_encoder_set_bits_per_sample().
|
cannam@87
|
1274 */
|
cannam@87
|
1275 FLAC_API unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1276
|
cannam@87
|
1277 /** Get the input sample rate setting.
|
cannam@87
|
1278 *
|
cannam@87
|
1279 * \param encoder An encoder instance to query.
|
cannam@87
|
1280 * \assert
|
cannam@87
|
1281 * \code encoder != NULL \endcode
|
cannam@87
|
1282 * \retval unsigned
|
cannam@87
|
1283 * See FLAC__stream_encoder_set_sample_rate().
|
cannam@87
|
1284 */
|
cannam@87
|
1285 FLAC_API unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1286
|
cannam@87
|
1287 /** Get the blocksize setting.
|
cannam@87
|
1288 *
|
cannam@87
|
1289 * \param encoder An encoder instance to query.
|
cannam@87
|
1290 * \assert
|
cannam@87
|
1291 * \code encoder != NULL \endcode
|
cannam@87
|
1292 * \retval unsigned
|
cannam@87
|
1293 * See FLAC__stream_encoder_set_blocksize().
|
cannam@87
|
1294 */
|
cannam@87
|
1295 FLAC_API unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1296
|
cannam@87
|
1297 /** Get the "mid/side stereo coding" flag.
|
cannam@87
|
1298 *
|
cannam@87
|
1299 * \param encoder An encoder instance to query.
|
cannam@87
|
1300 * \assert
|
cannam@87
|
1301 * \code encoder != NULL \endcode
|
cannam@87
|
1302 * \retval FLAC__bool
|
cannam@87
|
1303 * See FLAC__stream_encoder_get_do_mid_side_stereo().
|
cannam@87
|
1304 */
|
cannam@87
|
1305 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1306
|
cannam@87
|
1307 /** Get the "adaptive mid/side switching" flag.
|
cannam@87
|
1308 *
|
cannam@87
|
1309 * \param encoder An encoder instance to query.
|
cannam@87
|
1310 * \assert
|
cannam@87
|
1311 * \code encoder != NULL \endcode
|
cannam@87
|
1312 * \retval FLAC__bool
|
cannam@87
|
1313 * See FLAC__stream_encoder_set_loose_mid_side_stereo().
|
cannam@87
|
1314 */
|
cannam@87
|
1315 FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1316
|
cannam@87
|
1317 /** Get the maximum LPC order setting.
|
cannam@87
|
1318 *
|
cannam@87
|
1319 * \param encoder An encoder instance to query.
|
cannam@87
|
1320 * \assert
|
cannam@87
|
1321 * \code encoder != NULL \endcode
|
cannam@87
|
1322 * \retval unsigned
|
cannam@87
|
1323 * See FLAC__stream_encoder_set_max_lpc_order().
|
cannam@87
|
1324 */
|
cannam@87
|
1325 FLAC_API unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1326
|
cannam@87
|
1327 /** Get the quantized linear predictor coefficient precision setting.
|
cannam@87
|
1328 *
|
cannam@87
|
1329 * \param encoder An encoder instance to query.
|
cannam@87
|
1330 * \assert
|
cannam@87
|
1331 * \code encoder != NULL \endcode
|
cannam@87
|
1332 * \retval unsigned
|
cannam@87
|
1333 * See FLAC__stream_encoder_set_qlp_coeff_precision().
|
cannam@87
|
1334 */
|
cannam@87
|
1335 FLAC_API unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1336
|
cannam@87
|
1337 /** Get the qlp coefficient precision search flag.
|
cannam@87
|
1338 *
|
cannam@87
|
1339 * \param encoder An encoder instance to query.
|
cannam@87
|
1340 * \assert
|
cannam@87
|
1341 * \code encoder != NULL \endcode
|
cannam@87
|
1342 * \retval FLAC__bool
|
cannam@87
|
1343 * See FLAC__stream_encoder_set_do_qlp_coeff_prec_search().
|
cannam@87
|
1344 */
|
cannam@87
|
1345 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1346
|
cannam@87
|
1347 /** Get the "escape coding" flag.
|
cannam@87
|
1348 *
|
cannam@87
|
1349 * \param encoder An encoder instance to query.
|
cannam@87
|
1350 * \assert
|
cannam@87
|
1351 * \code encoder != NULL \endcode
|
cannam@87
|
1352 * \retval FLAC__bool
|
cannam@87
|
1353 * See FLAC__stream_encoder_set_do_escape_coding().
|
cannam@87
|
1354 */
|
cannam@87
|
1355 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1356
|
cannam@87
|
1357 /** Get the exhaustive model search flag.
|
cannam@87
|
1358 *
|
cannam@87
|
1359 * \param encoder An encoder instance to query.
|
cannam@87
|
1360 * \assert
|
cannam@87
|
1361 * \code encoder != NULL \endcode
|
cannam@87
|
1362 * \retval FLAC__bool
|
cannam@87
|
1363 * See FLAC__stream_encoder_set_do_exhaustive_model_search().
|
cannam@87
|
1364 */
|
cannam@87
|
1365 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1366
|
cannam@87
|
1367 /** Get the minimum residual partition order setting.
|
cannam@87
|
1368 *
|
cannam@87
|
1369 * \param encoder An encoder instance to query.
|
cannam@87
|
1370 * \assert
|
cannam@87
|
1371 * \code encoder != NULL \endcode
|
cannam@87
|
1372 * \retval unsigned
|
cannam@87
|
1373 * See FLAC__stream_encoder_set_min_residual_partition_order().
|
cannam@87
|
1374 */
|
cannam@87
|
1375 FLAC_API unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1376
|
cannam@87
|
1377 /** Get maximum residual partition order setting.
|
cannam@87
|
1378 *
|
cannam@87
|
1379 * \param encoder An encoder instance to query.
|
cannam@87
|
1380 * \assert
|
cannam@87
|
1381 * \code encoder != NULL \endcode
|
cannam@87
|
1382 * \retval unsigned
|
cannam@87
|
1383 * See FLAC__stream_encoder_set_max_residual_partition_order().
|
cannam@87
|
1384 */
|
cannam@87
|
1385 FLAC_API unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1386
|
cannam@87
|
1387 /** Get the Rice parameter search distance setting.
|
cannam@87
|
1388 *
|
cannam@87
|
1389 * \param encoder An encoder instance to query.
|
cannam@87
|
1390 * \assert
|
cannam@87
|
1391 * \code encoder != NULL \endcode
|
cannam@87
|
1392 * \retval unsigned
|
cannam@87
|
1393 * See FLAC__stream_encoder_set_rice_parameter_search_dist().
|
cannam@87
|
1394 */
|
cannam@87
|
1395 FLAC_API unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1396
|
cannam@87
|
1397 /** Get the previously set estimate of the total samples to be encoded.
|
cannam@87
|
1398 * The encoder merely mimics back the value given to
|
cannam@87
|
1399 * FLAC__stream_encoder_set_total_samples_estimate() since it has no
|
cannam@87
|
1400 * other way of knowing how many samples the client will encode.
|
cannam@87
|
1401 *
|
cannam@87
|
1402 * \param encoder An encoder instance to set.
|
cannam@87
|
1403 * \assert
|
cannam@87
|
1404 * \code encoder != NULL \endcode
|
cannam@87
|
1405 * \retval FLAC__uint64
|
cannam@87
|
1406 * See FLAC__stream_encoder_get_total_samples_estimate().
|
cannam@87
|
1407 */
|
cannam@87
|
1408 FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC__StreamEncoder *encoder);
|
cannam@87
|
1409
|
cannam@87
|
1410 /** Initialize the encoder instance to encode native FLAC streams.
|
cannam@87
|
1411 *
|
cannam@87
|
1412 * This flavor of initialization sets up the encoder to encode to a
|
cannam@87
|
1413 * native FLAC stream. I/O is performed via callbacks to the client.
|
cannam@87
|
1414 * For encoding to a plain file via filename or open \c FILE*,
|
cannam@87
|
1415 * FLAC__stream_encoder_init_file() and FLAC__stream_encoder_init_FILE()
|
cannam@87
|
1416 * provide a simpler interface.
|
cannam@87
|
1417 *
|
cannam@87
|
1418 * This function should be called after FLAC__stream_encoder_new() and
|
cannam@87
|
1419 * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
|
cannam@87
|
1420 * or FLAC__stream_encoder_process_interleaved().
|
cannam@87
|
1421 * initialization succeeded.
|
cannam@87
|
1422 *
|
cannam@87
|
1423 * The call to FLAC__stream_encoder_init_stream() currently will also
|
cannam@87
|
1424 * immediately call the write callback several times, once with the \c fLaC
|
cannam@87
|
1425 * signature, and once for each encoded metadata block.
|
cannam@87
|
1426 *
|
cannam@87
|
1427 * \param encoder An uninitialized encoder instance.
|
cannam@87
|
1428 * \param write_callback See FLAC__StreamEncoderWriteCallback. This
|
cannam@87
|
1429 * pointer must not be \c NULL.
|
cannam@87
|
1430 * \param seek_callback See FLAC__StreamEncoderSeekCallback. This
|
cannam@87
|
1431 * pointer may be \c NULL if seeking is not
|
cannam@87
|
1432 * supported. The encoder uses seeking to go back
|
cannam@87
|
1433 * and write some some stream statistics to the
|
cannam@87
|
1434 * STREAMINFO block; this is recommended but not
|
cannam@87
|
1435 * necessary to create a valid FLAC stream. If
|
cannam@87
|
1436 * \a seek_callback is not \c NULL then a
|
cannam@87
|
1437 * \a tell_callback must also be supplied.
|
cannam@87
|
1438 * Alternatively, a dummy seek callback that just
|
cannam@87
|
1439 * returns \c FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED
|
cannam@87
|
1440 * may also be supplied, all though this is slightly
|
cannam@87
|
1441 * less efficient for the encoder.
|
cannam@87
|
1442 * \param tell_callback See FLAC__StreamEncoderTellCallback. This
|
cannam@87
|
1443 * pointer may be \c NULL if seeking is not
|
cannam@87
|
1444 * supported. If \a seek_callback is \c NULL then
|
cannam@87
|
1445 * this argument will be ignored. If
|
cannam@87
|
1446 * \a seek_callback is not \c NULL then a
|
cannam@87
|
1447 * \a tell_callback must also be supplied.
|
cannam@87
|
1448 * Alternatively, a dummy tell callback that just
|
cannam@87
|
1449 * returns \c FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED
|
cannam@87
|
1450 * may also be supplied, all though this is slightly
|
cannam@87
|
1451 * less efficient for the encoder.
|
cannam@87
|
1452 * \param metadata_callback See FLAC__StreamEncoderMetadataCallback. This
|
cannam@87
|
1453 * pointer may be \c NULL if the callback is not
|
cannam@87
|
1454 * desired. If the client provides a seek callback,
|
cannam@87
|
1455 * this function is not necessary as the encoder
|
cannam@87
|
1456 * will automatically seek back and update the
|
cannam@87
|
1457 * STREAMINFO block. It may also be \c NULL if the
|
cannam@87
|
1458 * client does not support seeking, since it will
|
cannam@87
|
1459 * have no way of going back to update the
|
cannam@87
|
1460 * STREAMINFO. However the client can still supply
|
cannam@87
|
1461 * a callback if it would like to know the details
|
cannam@87
|
1462 * from the STREAMINFO.
|
cannam@87
|
1463 * \param client_data This value will be supplied to callbacks in their
|
cannam@87
|
1464 * \a client_data argument.
|
cannam@87
|
1465 * \assert
|
cannam@87
|
1466 * \code encoder != NULL \endcode
|
cannam@87
|
1467 * \retval FLAC__StreamEncoderInitStatus
|
cannam@87
|
1468 * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
|
cannam@87
|
1469 * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
|
cannam@87
|
1470 */
|
cannam@87
|
1471 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data);
|
cannam@87
|
1472
|
cannam@87
|
1473 /** Initialize the encoder instance to encode Ogg FLAC streams.
|
cannam@87
|
1474 *
|
cannam@87
|
1475 * This flavor of initialization sets up the encoder to encode to a FLAC
|
cannam@87
|
1476 * stream in an Ogg container. I/O is performed via callbacks to the
|
cannam@87
|
1477 * client. For encoding to a plain file via filename or open \c FILE*,
|
cannam@87
|
1478 * FLAC__stream_encoder_init_ogg_file() and FLAC__stream_encoder_init_ogg_FILE()
|
cannam@87
|
1479 * provide a simpler interface.
|
cannam@87
|
1480 *
|
cannam@87
|
1481 * This function should be called after FLAC__stream_encoder_new() and
|
cannam@87
|
1482 * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
|
cannam@87
|
1483 * or FLAC__stream_encoder_process_interleaved().
|
cannam@87
|
1484 * initialization succeeded.
|
cannam@87
|
1485 *
|
cannam@87
|
1486 * The call to FLAC__stream_encoder_init_ogg_stream() currently will also
|
cannam@87
|
1487 * immediately call the write callback several times to write the metadata
|
cannam@87
|
1488 * packets.
|
cannam@87
|
1489 *
|
cannam@87
|
1490 * \param encoder An uninitialized encoder instance.
|
cannam@87
|
1491 * \param read_callback See FLAC__StreamEncoderReadCallback. This
|
cannam@87
|
1492 * pointer must not be \c NULL if \a seek_callback
|
cannam@87
|
1493 * is non-NULL since they are both needed to be
|
cannam@87
|
1494 * able to write data back to the Ogg FLAC stream
|
cannam@87
|
1495 * in the post-encode phase.
|
cannam@87
|
1496 * \param write_callback See FLAC__StreamEncoderWriteCallback. This
|
cannam@87
|
1497 * pointer must not be \c NULL.
|
cannam@87
|
1498 * \param seek_callback See FLAC__StreamEncoderSeekCallback. This
|
cannam@87
|
1499 * pointer may be \c NULL if seeking is not
|
cannam@87
|
1500 * supported. The encoder uses seeking to go back
|
cannam@87
|
1501 * and write some some stream statistics to the
|
cannam@87
|
1502 * STREAMINFO block; this is recommended but not
|
cannam@87
|
1503 * necessary to create a valid FLAC stream. If
|
cannam@87
|
1504 * \a seek_callback is not \c NULL then a
|
cannam@87
|
1505 * \a tell_callback must also be supplied.
|
cannam@87
|
1506 * Alternatively, a dummy seek callback that just
|
cannam@87
|
1507 * returns \c FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED
|
cannam@87
|
1508 * may also be supplied, all though this is slightly
|
cannam@87
|
1509 * less efficient for the encoder.
|
cannam@87
|
1510 * \param tell_callback See FLAC__StreamEncoderTellCallback. This
|
cannam@87
|
1511 * pointer may be \c NULL if seeking is not
|
cannam@87
|
1512 * supported. If \a seek_callback is \c NULL then
|
cannam@87
|
1513 * this argument will be ignored. If
|
cannam@87
|
1514 * \a seek_callback is not \c NULL then a
|
cannam@87
|
1515 * \a tell_callback must also be supplied.
|
cannam@87
|
1516 * Alternatively, a dummy tell callback that just
|
cannam@87
|
1517 * returns \c FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED
|
cannam@87
|
1518 * may also be supplied, all though this is slightly
|
cannam@87
|
1519 * less efficient for the encoder.
|
cannam@87
|
1520 * \param metadata_callback See FLAC__StreamEncoderMetadataCallback. This
|
cannam@87
|
1521 * pointer may be \c NULL if the callback is not
|
cannam@87
|
1522 * desired. If the client provides a seek callback,
|
cannam@87
|
1523 * this function is not necessary as the encoder
|
cannam@87
|
1524 * will automatically seek back and update the
|
cannam@87
|
1525 * STREAMINFO block. It may also be \c NULL if the
|
cannam@87
|
1526 * client does not support seeking, since it will
|
cannam@87
|
1527 * have no way of going back to update the
|
cannam@87
|
1528 * STREAMINFO. However the client can still supply
|
cannam@87
|
1529 * a callback if it would like to know the details
|
cannam@87
|
1530 * from the STREAMINFO.
|
cannam@87
|
1531 * \param client_data This value will be supplied to callbacks in their
|
cannam@87
|
1532 * \a client_data argument.
|
cannam@87
|
1533 * \assert
|
cannam@87
|
1534 * \code encoder != NULL \endcode
|
cannam@87
|
1535 * \retval FLAC__StreamEncoderInitStatus
|
cannam@87
|
1536 * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
|
cannam@87
|
1537 * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
|
cannam@87
|
1538 */
|
cannam@87
|
1539 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderReadCallback read_callback, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data);
|
cannam@87
|
1540
|
cannam@87
|
1541 /** Initialize the encoder instance to encode native FLAC files.
|
cannam@87
|
1542 *
|
cannam@87
|
1543 * This flavor of initialization sets up the encoder to encode to a
|
cannam@87
|
1544 * plain native FLAC file. For non-stdio streams, you must use
|
cannam@87
|
1545 * FLAC__stream_encoder_init_stream() and provide callbacks for the I/O.
|
cannam@87
|
1546 *
|
cannam@87
|
1547 * This function should be called after FLAC__stream_encoder_new() and
|
cannam@87
|
1548 * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
|
cannam@87
|
1549 * or FLAC__stream_encoder_process_interleaved().
|
cannam@87
|
1550 * initialization succeeded.
|
cannam@87
|
1551 *
|
cannam@87
|
1552 * \param encoder An uninitialized encoder instance.
|
cannam@87
|
1553 * \param file An open file. The file should have been opened
|
cannam@87
|
1554 * with mode \c "w+b" and rewound. The file
|
cannam@87
|
1555 * becomes owned by the encoder and should not be
|
cannam@87
|
1556 * manipulated by the client while encoding.
|
cannam@87
|
1557 * Unless \a file is \c stdout, it will be closed
|
cannam@87
|
1558 * when FLAC__stream_encoder_finish() is called.
|
cannam@87
|
1559 * Note however that a proper SEEKTABLE cannot be
|
cannam@87
|
1560 * created when encoding to \c stdout since it is
|
cannam@87
|
1561 * not seekable.
|
cannam@87
|
1562 * \param progress_callback See FLAC__StreamEncoderProgressCallback. This
|
cannam@87
|
1563 * pointer may be \c NULL if the callback is not
|
cannam@87
|
1564 * desired.
|
cannam@87
|
1565 * \param client_data This value will be supplied to callbacks in their
|
cannam@87
|
1566 * \a client_data argument.
|
cannam@87
|
1567 * \assert
|
cannam@87
|
1568 * \code encoder != NULL \endcode
|
cannam@87
|
1569 * \code file != NULL \endcode
|
cannam@87
|
1570 * \retval FLAC__StreamEncoderInitStatus
|
cannam@87
|
1571 * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
|
cannam@87
|
1572 * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
|
cannam@87
|
1573 */
|
cannam@87
|
1574 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
|
cannam@87
|
1575
|
cannam@87
|
1576 /** Initialize the encoder instance to encode Ogg FLAC files.
|
cannam@87
|
1577 *
|
cannam@87
|
1578 * This flavor of initialization sets up the encoder to encode to a
|
cannam@87
|
1579 * plain Ogg FLAC file. For non-stdio streams, you must use
|
cannam@87
|
1580 * FLAC__stream_encoder_init_ogg_stream() and provide callbacks for the I/O.
|
cannam@87
|
1581 *
|
cannam@87
|
1582 * This function should be called after FLAC__stream_encoder_new() and
|
cannam@87
|
1583 * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
|
cannam@87
|
1584 * or FLAC__stream_encoder_process_interleaved().
|
cannam@87
|
1585 * initialization succeeded.
|
cannam@87
|
1586 *
|
cannam@87
|
1587 * \param encoder An uninitialized encoder instance.
|
cannam@87
|
1588 * \param file An open file. The file should have been opened
|
cannam@87
|
1589 * with mode \c "w+b" and rewound. The file
|
cannam@87
|
1590 * becomes owned by the encoder and should not be
|
cannam@87
|
1591 * manipulated by the client while encoding.
|
cannam@87
|
1592 * Unless \a file is \c stdout, it will be closed
|
cannam@87
|
1593 * when FLAC__stream_encoder_finish() is called.
|
cannam@87
|
1594 * Note however that a proper SEEKTABLE cannot be
|
cannam@87
|
1595 * created when encoding to \c stdout since it is
|
cannam@87
|
1596 * not seekable.
|
cannam@87
|
1597 * \param progress_callback See FLAC__StreamEncoderProgressCallback. This
|
cannam@87
|
1598 * pointer may be \c NULL if the callback is not
|
cannam@87
|
1599 * desired.
|
cannam@87
|
1600 * \param client_data This value will be supplied to callbacks in their
|
cannam@87
|
1601 * \a client_data argument.
|
cannam@87
|
1602 * \assert
|
cannam@87
|
1603 * \code encoder != NULL \endcode
|
cannam@87
|
1604 * \code file != NULL \endcode
|
cannam@87
|
1605 * \retval FLAC__StreamEncoderInitStatus
|
cannam@87
|
1606 * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
|
cannam@87
|
1607 * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
|
cannam@87
|
1608 */
|
cannam@87
|
1609 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
|
cannam@87
|
1610
|
cannam@87
|
1611 /** Initialize the encoder instance to encode native FLAC files.
|
cannam@87
|
1612 *
|
cannam@87
|
1613 * This flavor of initialization sets up the encoder to encode to a plain
|
cannam@87
|
1614 * FLAC file. If POSIX fopen() semantics are not sufficient (for example,
|
cannam@87
|
1615 * with Unicode filenames on Windows), you must use
|
cannam@87
|
1616 * FLAC__stream_encoder_init_FILE(), or FLAC__stream_encoder_init_stream()
|
cannam@87
|
1617 * and provide callbacks for the I/O.
|
cannam@87
|
1618 *
|
cannam@87
|
1619 * This function should be called after FLAC__stream_encoder_new() and
|
cannam@87
|
1620 * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
|
cannam@87
|
1621 * or FLAC__stream_encoder_process_interleaved().
|
cannam@87
|
1622 * initialization succeeded.
|
cannam@87
|
1623 *
|
cannam@87
|
1624 * \param encoder An uninitialized encoder instance.
|
cannam@87
|
1625 * \param filename The name of the file to encode to. The file will
|
cannam@87
|
1626 * be opened with fopen(). Use \c NULL to encode to
|
cannam@87
|
1627 * \c stdout. Note however that a proper SEEKTABLE
|
cannam@87
|
1628 * cannot be created when encoding to \c stdout since
|
cannam@87
|
1629 * it is not seekable.
|
cannam@87
|
1630 * \param progress_callback See FLAC__StreamEncoderProgressCallback. This
|
cannam@87
|
1631 * pointer may be \c NULL if the callback is not
|
cannam@87
|
1632 * desired.
|
cannam@87
|
1633 * \param client_data This value will be supplied to callbacks in their
|
cannam@87
|
1634 * \a client_data argument.
|
cannam@87
|
1635 * \assert
|
cannam@87
|
1636 * \code encoder != NULL \endcode
|
cannam@87
|
1637 * \retval FLAC__StreamEncoderInitStatus
|
cannam@87
|
1638 * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
|
cannam@87
|
1639 * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
|
cannam@87
|
1640 */
|
cannam@87
|
1641 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
|
cannam@87
|
1642
|
cannam@87
|
1643 /** Initialize the encoder instance to encode Ogg FLAC files.
|
cannam@87
|
1644 *
|
cannam@87
|
1645 * This flavor of initialization sets up the encoder to encode to a plain
|
cannam@87
|
1646 * Ogg FLAC file. If POSIX fopen() semantics are not sufficient (for example,
|
cannam@87
|
1647 * with Unicode filenames on Windows), you must use
|
cannam@87
|
1648 * FLAC__stream_encoder_init_ogg_FILE(), or FLAC__stream_encoder_init_ogg_stream()
|
cannam@87
|
1649 * and provide callbacks for the I/O.
|
cannam@87
|
1650 *
|
cannam@87
|
1651 * This function should be called after FLAC__stream_encoder_new() and
|
cannam@87
|
1652 * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
|
cannam@87
|
1653 * or FLAC__stream_encoder_process_interleaved().
|
cannam@87
|
1654 * initialization succeeded.
|
cannam@87
|
1655 *
|
cannam@87
|
1656 * \param encoder An uninitialized encoder instance.
|
cannam@87
|
1657 * \param filename The name of the file to encode to. The file will
|
cannam@87
|
1658 * be opened with fopen(). Use \c NULL to encode to
|
cannam@87
|
1659 * \c stdout. Note however that a proper SEEKTABLE
|
cannam@87
|
1660 * cannot be created when encoding to \c stdout since
|
cannam@87
|
1661 * it is not seekable.
|
cannam@87
|
1662 * \param progress_callback See FLAC__StreamEncoderProgressCallback. This
|
cannam@87
|
1663 * pointer may be \c NULL if the callback is not
|
cannam@87
|
1664 * desired.
|
cannam@87
|
1665 * \param client_data This value will be supplied to callbacks in their
|
cannam@87
|
1666 * \a client_data argument.
|
cannam@87
|
1667 * \assert
|
cannam@87
|
1668 * \code encoder != NULL \endcode
|
cannam@87
|
1669 * \retval FLAC__StreamEncoderInitStatus
|
cannam@87
|
1670 * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
|
cannam@87
|
1671 * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
|
cannam@87
|
1672 */
|
cannam@87
|
1673 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
|
cannam@87
|
1674
|
cannam@87
|
1675 /** Finish the encoding process.
|
cannam@87
|
1676 * Flushes the encoding buffer, releases resources, resets the encoder
|
cannam@87
|
1677 * settings to their defaults, and returns the encoder state to
|
cannam@87
|
1678 * FLAC__STREAM_ENCODER_UNINITIALIZED. Note that this can generate
|
cannam@87
|
1679 * one or more write callbacks before returning, and will generate
|
cannam@87
|
1680 * a metadata callback.
|
cannam@87
|
1681 *
|
cannam@87
|
1682 * Note that in the course of processing the last frame, errors can
|
cannam@87
|
1683 * occur, so the caller should be sure to check the return value to
|
cannam@87
|
1684 * ensure the file was encoded properly.
|
cannam@87
|
1685 *
|
cannam@87
|
1686 * In the event of a prematurely-terminated encode, it is not strictly
|
cannam@87
|
1687 * necessary to call this immediately before FLAC__stream_encoder_delete()
|
cannam@87
|
1688 * but it is good practice to match every FLAC__stream_encoder_init_*()
|
cannam@87
|
1689 * with a FLAC__stream_encoder_finish().
|
cannam@87
|
1690 *
|
cannam@87
|
1691 * \param encoder An uninitialized encoder instance.
|
cannam@87
|
1692 * \assert
|
cannam@87
|
1693 * \code encoder != NULL \endcode
|
cannam@87
|
1694 * \retval FLAC__bool
|
cannam@87
|
1695 * \c false if an error occurred processing the last frame; or if verify
|
cannam@87
|
1696 * mode is set (see FLAC__stream_encoder_set_verify()), there was a
|
cannam@87
|
1697 * verify mismatch; else \c true. If \c false, caller should check the
|
cannam@87
|
1698 * state with FLAC__stream_encoder_get_state() for more information
|
cannam@87
|
1699 * about the error.
|
cannam@87
|
1700 */
|
cannam@87
|
1701 FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder);
|
cannam@87
|
1702
|
cannam@87
|
1703 /** Submit data for encoding.
|
cannam@87
|
1704 * This version allows you to supply the input data via an array of
|
cannam@87
|
1705 * pointers, each pointer pointing to an array of \a samples samples
|
cannam@87
|
1706 * representing one channel. The samples need not be block-aligned,
|
cannam@87
|
1707 * but each channel should have the same number of samples. Each sample
|
cannam@87
|
1708 * should be a signed integer, right-justified to the resolution set by
|
cannam@87
|
1709 * FLAC__stream_encoder_set_bits_per_sample(). For example, if the
|
cannam@87
|
1710 * resolution is 16 bits per sample, the samples should all be in the
|
cannam@87
|
1711 * range [-32768,32767].
|
cannam@87
|
1712 *
|
cannam@87
|
1713 * For applications where channel order is important, channels must
|
cannam@87
|
1714 * follow the order as described in the
|
cannam@87
|
1715 * <A HREF="../format.html#frame_header">frame header</A>.
|
cannam@87
|
1716 *
|
cannam@87
|
1717 * \param encoder An initialized encoder instance in the OK state.
|
cannam@87
|
1718 * \param buffer An array of pointers to each channel's signal.
|
cannam@87
|
1719 * \param samples The number of samples in one channel.
|
cannam@87
|
1720 * \assert
|
cannam@87
|
1721 * \code encoder != NULL \endcode
|
cannam@87
|
1722 * \code FLAC__stream_encoder_get_state(encoder) == FLAC__STREAM_ENCODER_OK \endcode
|
cannam@87
|
1723 * \retval FLAC__bool
|
cannam@87
|
1724 * \c true if successful, else \c false; in this case, check the
|
cannam@87
|
1725 * encoder state with FLAC__stream_encoder_get_state() to see what
|
cannam@87
|
1726 * went wrong.
|
cannam@87
|
1727 */
|
cannam@87
|
1728 FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
|
cannam@87
|
1729
|
cannam@87
|
1730 /** Submit data for encoding.
|
cannam@87
|
1731 * This version allows you to supply the input data where the channels
|
cannam@87
|
1732 * are interleaved into a single array (i.e. channel0_sample0,
|
cannam@87
|
1733 * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...).
|
cannam@87
|
1734 * The samples need not be block-aligned but they must be
|
cannam@87
|
1735 * sample-aligned, i.e. the first value should be channel0_sample0
|
cannam@87
|
1736 * and the last value channelN_sampleM. Each sample should be a signed
|
cannam@87
|
1737 * integer, right-justified to the resolution set by
|
cannam@87
|
1738 * FLAC__stream_encoder_set_bits_per_sample(). For example, if the
|
cannam@87
|
1739 * resolution is 16 bits per sample, the samples should all be in the
|
cannam@87
|
1740 * range [-32768,32767].
|
cannam@87
|
1741 *
|
cannam@87
|
1742 * For applications where channel order is important, channels must
|
cannam@87
|
1743 * follow the order as described in the
|
cannam@87
|
1744 * <A HREF="../format.html#frame_header">frame header</A>.
|
cannam@87
|
1745 *
|
cannam@87
|
1746 * \param encoder An initialized encoder instance in the OK state.
|
cannam@87
|
1747 * \param buffer An array of channel-interleaved data (see above).
|
cannam@87
|
1748 * \param samples The number of samples in one channel, the same as for
|
cannam@87
|
1749 * FLAC__stream_encoder_process(). For example, if
|
cannam@87
|
1750 * encoding two channels, \c 1000 \a samples corresponds
|
cannam@87
|
1751 * to a \a buffer of 2000 values.
|
cannam@87
|
1752 * \assert
|
cannam@87
|
1753 * \code encoder != NULL \endcode
|
cannam@87
|
1754 * \code FLAC__stream_encoder_get_state(encoder) == FLAC__STREAM_ENCODER_OK \endcode
|
cannam@87
|
1755 * \retval FLAC__bool
|
cannam@87
|
1756 * \c true if successful, else \c false; in this case, check the
|
cannam@87
|
1757 * encoder state with FLAC__stream_encoder_get_state() to see what
|
cannam@87
|
1758 * went wrong.
|
cannam@87
|
1759 */
|
cannam@87
|
1760 FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);
|
cannam@87
|
1761
|
cannam@87
|
1762 /* \} */
|
cannam@87
|
1763
|
cannam@87
|
1764 #ifdef __cplusplus
|
cannam@87
|
1765 }
|
cannam@87
|
1766 #endif
|
cannam@87
|
1767
|
cannam@87
|
1768 #endif
|