annotate osx/include/FLAC/stream_encoder.h @ 32:0b732c03ec57

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