annotate win64-mingw/include/FLAC/stream_encoder.h @ 122:62723f530572

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