annotate src/flac-1.2.1/include/FLAC/stream_encoder.h @ 169:223a55898ab9 tip default

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