annotate src/flac-1.2.1/include/FLAC/stream_encoder.h @ 23:619f715526df sv_v2.1

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