annotate DEPENDENCIES/mingw32/include/FLAC/stream_encoder.h @ 133:4acb5d8d80b6 tip

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