2001-02-08 00:38:41 +00:00
|
|
|
/* libFLAC - Free Lossless Audio Codec library
|
2002-01-26 17:36:39 +00:00
|
|
|
* Copyright (C) 2000,2001,2002 Josh Coalson
|
2000-12-10 04:09:52 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
#ifndef FLAC__STREAM_ENCODER_H
|
|
|
|
#define FLAC__STREAM_ENCODER_H
|
2000-12-10 04:09:52 +00:00
|
|
|
|
|
|
|
#include "format.h"
|
|
|
|
|
2002-05-06 17:39:29 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-07-24 06:15:56 +00:00
|
|
|
/** \file include/FLAC/stream_encoder.h
|
|
|
|
*
|
|
|
|
* \brief
|
|
|
|
* This module contains the functions which implement the stream
|
|
|
|
* encoder.
|
|
|
|
*
|
|
|
|
* See the detailed documentation in the
|
|
|
|
* \link flac_stream_encoder stream encoder \endlink module.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \defgroup flac_stream_encoder FLAC/stream_encoder.h: stream encoder interface
|
|
|
|
* \ingroup flac
|
|
|
|
*
|
|
|
|
* \brief
|
|
|
|
* This module contains the functions which implement the stream
|
|
|
|
* encoder.
|
|
|
|
*
|
|
|
|
* The basic usage of a libFLAC encoder is as follows:
|
|
|
|
* - The program creates an instance of an encoder using
|
|
|
|
* FLAC__stream_encoder_new().
|
|
|
|
* - The program overrides the default settings and sets callbacks for
|
|
|
|
* reading, writing, error reporting, and metadata reporting using
|
|
|
|
* FLAC__stream_encoder_set_*() functions.
|
|
|
|
* - The program initializes the instance to validate the settings and
|
|
|
|
* prepare for encoding using FLAC__stream_encoder_init().
|
|
|
|
* - The program calls FLAC__stream_encoder_process() or
|
|
|
|
* FLAC__stream_encoder_process_interleaved() to encode data, which
|
|
|
|
* subsequently calls the callbacks.
|
|
|
|
* - The program finishes the instance with FLAC__stream_encoder_finish(),
|
|
|
|
* which flushes the input and output and resets the encoder to the
|
|
|
|
* unitialized state.
|
|
|
|
* - The instance may be used again or deleted with
|
|
|
|
* FLAC__stream_encoder_delete().
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* The "set" functions may only be called when the encoder is in the
|
|
|
|
* state FLAC__STREAM_ENCODER_UNINITIALIZED, i.e. after
|
|
|
|
* FLAC__stream_encoder_new() or FLAC__stream_encoder_finish(), but
|
|
|
|
* before FLAC__stream_encoder_init(). If this is the case they will
|
|
|
|
* return true, otherwise false.
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* The "set" functions do not validate the values as many are
|
|
|
|
* interdependent. The FLAC__stream_encoder_init() function will do
|
|
|
|
* this, so make sure to pay attention to the state returned by
|
|
|
|
* FLAC__stream_encoder_init() to make sure that it is
|
|
|
|
* FLAC__STREAM_ENCODER_OK.
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* Unlike the decoders, the stream encoder has many options that can
|
|
|
|
* affect the speed and compression ratio. When setting these parameters
|
|
|
|
* you should have some basic knowledge of the format (see the
|
|
|
|
* <A HREF="../documentation.html#format">user-level documentation</A>
|
|
|
|
* or the <A HREF="../format.html">formal description</A>).
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* Any parameters that are not set before FLAC__stream_encoder_init()
|
|
|
|
* will take on the defaults from the constructor.
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* FLAC__stream_encoder_finish() resets all settings to the constructor
|
|
|
|
* defaults, including the callbacks.
|
|
|
|
*
|
|
|
|
* \{
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/** State values for a FLAC__StreamEncoder
|
|
|
|
*
|
|
|
|
* The encoder's state can be obtained by calling FLAC__stream_encoder_get_state().
|
|
|
|
*/
|
2000-12-10 04:09:52 +00:00
|
|
|
typedef enum {
|
2002-07-24 06:15:56 +00:00
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_OK = 0,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder is in the normal OK state. */
|
|
|
|
|
2001-06-16 07:32:25 +00:00
|
|
|
FLAC__STREAM_ENCODER_INVALID_CALLBACK,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder was initialized before setting all the required callbacks. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_INVALID_NUMBER_OF_CHANNELS,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder has an invalid setting for number of channels. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_INVALID_BITS_PER_SAMPLE,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder has an invalid setting for bits-per-sample.
|
|
|
|
* FLAC supports 4-32 bps but the reference encoder currently supports
|
|
|
|
* only up to 24 bps.
|
|
|
|
*/
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_INVALID_SAMPLE_RATE,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder has an invalid setting for the input sample rate. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_INVALID_BLOCK_SIZE,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder has an invalid setting for the block size. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_INVALID_QLP_COEFF_PRECISION,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder has an invalid setting for the precision of the quantized linear predictor coefficients. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_MID_SIDE_CHANNELS_MISMATCH,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< Mid/side coding was specified but the number of channels is not equal to 2. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_MID_SIDE_SAMPLE_SIZE_MISMATCH,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< Deprecated. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_ILLEGAL_MID_SIDE_FORCE,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< Loose mid/side coding was specified but mid/side coding was not. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The specified block size is less than the maximum LPC order. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_NOT_STREAMABLE,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder is bound to the "streamable subset" but other settings violate it. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_FRAMING_ERROR,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< An error occurred while writing the stream; usually, the write_callback returned an error. */
|
|
|
|
|
2002-06-01 05:39:38 +00:00
|
|
|
FLAC__STREAM_ENCODER_INVALID_METADATA,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The metadata input to the encoder is invalid. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< An error occurred while writing the stream; usually, the write_callback returned an error. */
|
|
|
|
|
|
|
|
FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_WRITING,
|
|
|
|
/**< The write_callback returned an error. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< Memory allocation failed. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_ALREADY_INITIALIZED,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< FLAC__stream_encoder_init() was called when the encoder was
|
|
|
|
* already initialized, usually because
|
|
|
|
* FLAC__stream_encoder_finish() was not called.
|
|
|
|
*/
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_UNINITIALIZED
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The encoder is in the uninitialized state. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
} FLAC__StreamEncoderState;
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Maps a FLAC__StreamEncoderState to a C string.
|
|
|
|
*
|
|
|
|
* Using a FLAC__StreamEncoderState as the index to this array
|
|
|
|
* will give the string equivalent. The contents should not be modified.
|
|
|
|
*/
|
2002-06-07 05:27:37 +00:00
|
|
|
extern const char * const FLAC__StreamEncoderStateString[];
|
2000-12-10 04:09:52 +00:00
|
|
|
|
2002-07-24 06:15:56 +00:00
|
|
|
/** Return values for the FLAC__StreamEncoder write callback.
|
|
|
|
*/
|
2000-12-10 04:09:52 +00:00
|
|
|
typedef enum {
|
2002-07-24 06:15:56 +00:00
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_WRITE_OK = 0,
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< The write was OK and encoding can continue. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
FLAC__STREAM_ENCODER_WRITE_FATAL_ERROR
|
2002-07-24 06:15:56 +00:00
|
|
|
/**< An unrecoverable error occurred. The encoder will return from the process call. */
|
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
} FLAC__StreamEncoderWriteStatus;
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Maps a FLAC__StreamEncoderWriteStatus to a C string.
|
|
|
|
*
|
|
|
|
* Using a FLAC__StreamEncoderWriteStatus as the index to this array
|
|
|
|
* will give the string equivalent. The contents should not be modified.
|
|
|
|
*/
|
2002-06-07 05:27:37 +00:00
|
|
|
extern const char * const FLAC__StreamEncoderWriteStatusString[];
|
2000-12-10 04:09:52 +00:00
|
|
|
|
2002-07-24 06:15:56 +00:00
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* class FLAC__StreamEncoder
|
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
struct FLAC__StreamEncoderProtected;
|
|
|
|
struct FLAC__StreamEncoderPrivate;
|
2002-07-24 06:15:56 +00:00
|
|
|
/** The opaque structure definition for the stream encoder type.
|
|
|
|
*/
|
2000-12-10 04:09:52 +00:00
|
|
|
typedef struct {
|
2001-08-16 20:07:29 +00:00
|
|
|
struct FLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
|
|
|
|
struct FLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
|
2001-06-13 17:59:57 +00:00
|
|
|
} FLAC__StreamEncoder;
|
|
|
|
|
2002-07-24 06:15:56 +00:00
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* Class constructor/destructor
|
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
2002-07-24 06:15:56 +00:00
|
|
|
/** Create a new stream encoder instance. The instance is created with
|
|
|
|
* default settings; see the individual FLAC__stream_encoder_set_*()
|
|
|
|
* functions for each setting's default.
|
|
|
|
*
|
|
|
|
* \retval FLAC__StreamEncoder*
|
|
|
|
* \c NULL if there was an error allocating memory, else the new instance.
|
|
|
|
*/
|
|
|
|
FLAC__StreamEncoder *FLAC__stream_encoder_new();
|
|
|
|
|
|
|
|
/** Free an encoder instance. Deletes the object pointed to by \a encoder.
|
|
|
|
*
|
|
|
|
* \param encoder A pointer to an existing encoder.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
*/
|
|
|
|
void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* Public class method prototypes
|
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
2001-06-16 07:32:25 +00:00
|
|
|
/*
|
2002-06-01 05:39:38 +00:00
|
|
|
* FLAC__bool do_qlp_coeff_prec_search (DEFAULT: false ) false => use qlp_coeff_precision, true => search around qlp_coeff_precision, take best
|
|
|
|
* FLAC__bool do_escape_coding (DEFAULT: false ) true => search for escape codes in the entropy coding stage for slightly better compression
|
|
|
|
* FLAC__bool do_exhaustive_model_search (DEFAULT: false ) false => use estimated bits per residual for scoring, true => generate all, take shortest
|
|
|
|
* unsigned min_residual_partition_order (DEFAULT: 0 ) 0 => estimate Rice parameter based on residual variance; >0 => partition residual, use parameter
|
|
|
|
* unsigned max_residual_partition_order (DEFAULT: 0 ) for each based on mean; min_ and max_ specify the min and max Rice partition order
|
|
|
|
* unsigned rice_parameter_search_dist (DEFAULT: 0 ) 0 => try only calc'd parameter k; else try all [k-dist..k+dist] parameters, use best
|
|
|
|
* FLAC__uint64 total_samples_estimate (DEFAULT: 0 ) may be 0 if unknown. acts as a placeholder in the STREAMINFO until the actual total is calculated
|
2002-06-08 04:53:42 +00:00
|
|
|
* FLAC__StreamMetadata **metadata (DEFAULT: NULL,0) optional metadata blocks to prepend. STREAMINFO is not allowed since it is done internally.
|
2002-06-01 05:39:38 +00:00
|
|
|
* + unsigned num_blocks
|
|
|
|
* void* client_data (DEFAULT: NULL ) passed back through the callbacks
|
2001-06-16 07:32:25 +00:00
|
|
|
*/
|
2001-06-13 17:59:57 +00:00
|
|
|
|
2002-07-24 06:15:56 +00:00
|
|
|
/** Set the "streamable subset" flag. If \c true, the encoder will comply
|
|
|
|
* with the subset (see the format specification) and will check the
|
|
|
|
* settings during FLAC__stream_encoder_init() to see if all settings
|
|
|
|
* comply. If \c false, the settings may take advantage of the full
|
|
|
|
* range that the format allows.
|
2001-06-13 17:59:57 +00:00
|
|
|
*
|
2002-07-24 06:15:56 +00:00
|
|
|
* Make sure you know what it entails before setting this to \c false.
|
2001-06-13 17:59:57 +00:00
|
|
|
*
|
2002-07-24 06:15:56 +00:00
|
|
|
* \default \c true
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value Flag value (see above).
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
|
|
|
FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
2001-06-13 17:59:57 +00:00
|
|
|
|
2002-07-24 06:15:56 +00:00
|
|
|
/** Set to \c true to enable mid-side encoding on stereo input. The
|
|
|
|
* number of channels must be 2. Set to \c false to use only
|
|
|
|
* independent channel coding.
|
2001-06-16 07:32:25 +00:00
|
|
|
*
|
2002-07-24 06:15:56 +00:00
|
|
|
* \default \c false
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value Flag value (see above).
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
2001-06-16 07:32:25 +00:00
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set to \c true to enable adaptive switching between mid-side and
|
|
|
|
* left-right encoding on stereo input. The number of channels must
|
|
|
|
* be 2. Set to \c false to use exhaustive searching. In either
|
|
|
|
* case, the mid/side stereo setting must be \c true.
|
|
|
|
*
|
|
|
|
* \default \c false
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value Flag value (see above).
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c 2
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the sample resolution of the input to be encoded.
|
|
|
|
*
|
|
|
|
* \warning
|
|
|
|
* Do not feed the encoder data that is wider than the value you
|
|
|
|
* set here or you will generate an invalid stream.
|
|
|
|
*
|
|
|
|
* \default \c 16
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the sample rate (in Hz) of the input to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c 44100
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the blocksize to use while encoding.
|
|
|
|
*
|
|
|
|
* \default \c 1152
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the maximum LPC order, or \c 0 to use only the fixed predictors.
|
|
|
|
*
|
|
|
|
* \default \c 0
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the precision, in bits, of the quantized linear predictor
|
|
|
|
* coefficients, or \c 0 to let the encoder select it based on the
|
|
|
|
* blocksize.
|
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* In the current implementation, qlp_coeff_precision + bits_per_sample must
|
|
|
|
* be less than 32.
|
|
|
|
*
|
|
|
|
* \default \c 0
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c false
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c false
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_do_escape_coding(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c false
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c 0
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c 0
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c 0
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c 0
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c NULL, 0
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-06-08 04:53:42 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c NULL; the callback is mandatory and must be set before initialization
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \code value != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_write_callback(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteStatus (*value)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data));
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c NULL; the callback is mandatory and must be set before initialization
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \code value != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-06-08 04:53:42 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_metadata_callback(FLAC__StreamEncoder *encoder, void (*value)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data));
|
2002-07-24 06:15:56 +00:00
|
|
|
|
|
|
|
/** Set the number of channels to be encoded.
|
|
|
|
*
|
|
|
|
* \default \c NULL
|
|
|
|
* \param encoder An encoder instance to set.
|
|
|
|
* \param value See above.
|
|
|
|
* \assert
|
|
|
|
* \code encoder != NULL \endcode
|
|
|
|
* \retval FLAC__bool
|
|
|
|
* \c false if the encoder is already initialized, else \c true.
|
|
|
|
*/
|
2002-05-29 05:51:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_set_client_data(FLAC__StreamEncoder *encoder, void *value);
|
2001-06-16 07:32:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Various "get" methods
|
|
|
|
*/
|
|
|
|
FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder);
|
2001-06-23 03:03:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder);
|
|
|
|
FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder);
|
|
|
|
FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder);
|
|
|
|
FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder);
|
2001-07-12 21:32:13 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder);
|
2001-06-23 03:03:24 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder);
|
|
|
|
unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder);
|
2001-06-16 07:32:25 +00:00
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
/*
|
|
|
|
* Initialize the instance; should be called after construction and
|
2001-06-16 07:32:25 +00:00
|
|
|
* 'set' calls but before any of the 'process' calls. Will set and
|
|
|
|
* return the encoder state, which will be FLAC__STREAM_ENCODER_OK
|
|
|
|
* if initialization succeeded.
|
2001-06-13 17:59:57 +00:00
|
|
|
*/
|
2001-06-16 07:32:25 +00:00
|
|
|
FLAC__StreamEncoderState FLAC__stream_encoder_init(FLAC__StreamEncoder *encoder);
|
2000-12-10 04:09:52 +00:00
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
/*
|
2001-06-16 07:32:25 +00:00
|
|
|
* Flush the encoding buffer, release resources, and return the encoder
|
|
|
|
* state to FLAC__STREAM_ENCODER_UNINITIALIZED. Note that this can
|
|
|
|
* generate one or more write_callback()s before returning.
|
2001-06-13 17:59:57 +00:00
|
|
|
*/
|
2001-06-16 07:32:25 +00:00
|
|
|
void FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder);
|
2000-12-10 04:09:52 +00:00
|
|
|
|
2001-06-13 17:59:57 +00:00
|
|
|
/*
|
2001-06-16 07:32:25 +00:00
|
|
|
* Methods for encoding the data
|
2001-06-13 17:59:57 +00:00
|
|
|
*/
|
2002-06-07 05:27:37 +00:00
|
|
|
FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
|
|
|
|
FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);
|
2000-12-10 04:09:52 +00:00
|
|
|
|
2002-07-24 06:15:56 +00:00
|
|
|
/* \} */
|
|
|
|
|
2002-05-06 17:39:29 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-12-10 04:09:52 +00:00
|
|
|
#endif
|