annotate win32-mingw/include/FLAC/stream_encoder.h @ 169:223a55898ab9 tip default

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