annotate win64-mingw/include/FLAC/stream_encoder.h @ 42:2cd0e3b3e1fd

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