seekable_stream_encoder.h
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:39k
源码类别:

Windows CE

开发平台:

C/C++

  1. /* libFLAC - Free Lossless Audio Codec library
  2.  * Copyright (C) 2002,2003,2004,2005  Josh Coalson
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  *
  8.  * - Redistributions of source code must retain the above copyright
  9.  * notice, this list of conditions and the following disclaimer.
  10.  *
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  * notice, this list of conditions and the following disclaimer in the
  13.  * documentation and/or other materials provided with the distribution.
  14.  *
  15.  * - Neither the name of the Xiph.org Foundation nor the names of its
  16.  * contributors may be used to endorse or promote products derived from
  17.  * this software without specific prior written permission.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20.  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22.  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
  23.  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25.  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26.  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  27.  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28.  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30.  */
  31. #ifndef FLAC__SEEKABLE_STREAM_ENCODER_H
  32. #define FLAC__SEEKABLE_STREAM_ENCODER_H
  33. #include "export.h"
  34. #include "stream_encoder.h"
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /** file include/FLAC/seekable_stream_encoder.h
  39.  *
  40.  *  brief
  41.  *  This module contains the functions which implement the seekable stream
  42.  *  encoder.
  43.  *
  44.  *  See the detailed documentation in the
  45.  *  link flac_seekable_stream_encoder seekable stream encoder endlink module.
  46.  */
  47. /** defgroup flac_seekable_stream_encoder FLAC/seekable_stream_encoder.h: seekable stream encoder interface
  48.  *  ingroup flac_encoder
  49.  *
  50.  *  brief
  51.  *  This module contains the functions which implement the seekable stream
  52.  *  encoder.
  53.  *
  54.  * The basic usage of this encoder is as follows:
  55.  * - The program creates an instance of an encoder using
  56.  *   FLAC__seekable_stream_encoder_new().
  57.  * - The program overrides the default settings and sets callbacks using
  58.  *   FLAC__seekable_stream_encoder_set_*() functions.
  59.  * - The program initializes the instance to validate the settings and
  60.  *   prepare for encoding using FLAC__seekable_stream_encoder_init().
  61.  * - The program calls FLAC__seekable_stream_encoder_process() or
  62.  *   FLAC__seekable_stream_encoder_process_interleaved() to encode data, which
  63.  *   subsequently calls the callbacks when there is encoder data ready
  64.  *   to be written.
  65.  * - The program finishes the encoding with FLAC__seekable_stream_encoder_finish(),
  66.  *   which causes the encoder to encode any data still in its input pipe,
  67.  *   rewrite the metadata with the final encoding statistics, and finally
  68.  *   reset the encoder to the uninitialized state.
  69.  * - The instance may be used again or deleted with
  70.  *   FLAC__seekable_stream_encoder_delete().
  71.  *
  72.  * The seekable stream encoder is a wrapper around the
  73.  * link flac_stream_encoder stream encoder endlink with callbacks for
  74.  * seeking the output and reporting the output stream position.  This
  75.  * allows the encoder to go back and rewrite some of the metadata after
  76.  * encoding if necessary, and provides the metadata callback of the stream
  77.  * encoder internally.  However, you must provide seek and tell callbacks
  78.  * (see FLAC__seekable_stream_encoder_set_seek_callback() and
  79.  * FLAC__seekable_stream_encoder_set_tell_callback()).
  80.  *
  81.  * Make sure to read the detailed description of the
  82.  * link flac_stream_encoder stream encoder module endlink since the
  83.  * seekable stream encoder inherits much of its behavior.
  84.  *
  85.  * note
  86.  * If you are writing the FLAC data to a file, make sure it is open
  87.  * for update (e.g. mode "w+" for stdio streams).  This is because after
  88.  * the first encoding pass, the encoder will try to seek back to the
  89.  * beginning of the stream, to the STREAMINFO block, to write some data
  90.  * there.
  91.  *
  92.  * note
  93.  * The "set" functions may only be called when the encoder is in the
  94.  * state FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED, i.e. after
  95.  * FLAC__seekable_stream_encoder_new() or FLAC__seekable_stream_encoder_finish(), but
  96.  * before FLAC__seekable_stream_encoder_init().  If this is the case they will
  97.  * return c true, otherwise c false.
  98.  *
  99.  * note
  100.  * FLAC__seekable_stream_encoder_finish() resets all settings to the constructor
  101.  * defaults, including the callbacks.
  102.  *
  103.  * {
  104.  */
  105. /** State values for a FLAC__SeekableStreamEncoder
  106.  *
  107.  *  The encoder's state can be obtained by calling FLAC__seekable_stream_encoder_get_state().
  108.  */
  109. typedef enum {
  110. FLAC__SEEKABLE_STREAM_ENCODER_OK = 0,
  111. /**< The encoder is in the normal OK state. */
  112. FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR,
  113. /**< An error occurred in the underlying stream encoder;
  114.  * check FLAC__seekable_stream_encoder_get_stream_encoder_state().
  115.  */
  116. FLAC__SEEKABLE_STREAM_ENCODER_MEMORY_ALLOCATION_ERROR,
  117. /**< Memory allocation failed. */
  118. FLAC__SEEKABLE_STREAM_ENCODER_WRITE_ERROR,
  119. /**< The write callback returned an error. */
  120. FLAC__SEEKABLE_STREAM_ENCODER_READ_ERROR,
  121. /**< The read callback returned an error. */
  122. FLAC__SEEKABLE_STREAM_ENCODER_SEEK_ERROR,
  123. /**< The seek callback returned an error. */
  124. FLAC__SEEKABLE_STREAM_ENCODER_TELL_ERROR,
  125. /**< The tell callback returned an error. */
  126. FLAC__SEEKABLE_STREAM_ENCODER_ALREADY_INITIALIZED,
  127. /**< FLAC__seekable_stream_encoder_init() was called when the encoder was
  128.  * already initialized, usually because
  129.  * FLAC__seekable_stream_encoder_finish() was not called.
  130.  */
  131. FLAC__SEEKABLE_STREAM_ENCODER_INVALID_CALLBACK,
  132. /**< FLAC__seekable_stream_encoder_init() was called without all
  133.  * callbacks being set.
  134.  */
  135. FLAC__SEEKABLE_STREAM_ENCODER_INVALID_SEEKTABLE,
  136. /**< An invalid seek table was passed is the metadata to
  137.  * FLAC__seekable_stream_encoder_set_metadata().
  138.  */
  139. FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED
  140. /**< The encoder is in the uninitialized state. */
  141. } FLAC__SeekableStreamEncoderState;
  142. /** Maps a FLAC__SeekableStreamEncoderState to a C string.
  143.  *
  144.  *  Using a FLAC__SeekableStreamEncoderState as the index to this array
  145.  *  will give the string equivalent.  The contents should not be modified.
  146.  */
  147. extern FLAC_API const char * const FLAC__SeekableStreamEncoderStateString[];
  148. /** Return values for the FLAC__SeekableStreamEncoder seek callback.
  149.  */
  150. typedef enum {
  151. FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK,
  152. /**< The seek was OK and encoding can continue. */
  153. FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_ERROR
  154. /**< An unrecoverable error occurred.  The encoder will return from the process call. */
  155. } FLAC__SeekableStreamEncoderSeekStatus;
  156. /** Maps a FLAC__SeekableStreamEncoderSeekStatus to a C string.
  157.  *
  158.  *  Using a FLAC__SeekableStreamEncoderSeekStatus as the index to this array
  159.  *  will give the string equivalent.  The contents should not be modified.
  160.  */
  161. extern FLAC_API const char * const FLAC__SeekableStreamEncoderSeekStatusString[];
  162. /** Return values for the FLAC__SeekableStreamEncoder tell callback.
  163.  */
  164. typedef enum {
  165. FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_OK,
  166. /**< The tell was OK and encoding can continue. */
  167. FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_ERROR
  168. /**< An unrecoverable error occurred.  The encoder will return from the process call. */
  169. } FLAC__SeekableStreamEncoderTellStatus;
  170. /** Maps a FLAC__SeekableStreamEncoderTellStatus to a C string.
  171.  *
  172.  *  Using a FLAC__SeekableStreamEncoderTellStatus as the index to this array
  173.  *  will give the string equivalent.  The contents should not be modified.
  174.  */
  175. extern FLAC_API const char * const FLAC__SeekableStreamEncoderTellStatusString[];
  176. /***********************************************************************
  177.  *
  178.  * class FLAC__SeekableStreamEncoder
  179.  *
  180.  ***********************************************************************/
  181. struct FLAC__SeekableStreamEncoderProtected;
  182. struct FLAC__SeekableStreamEncoderPrivate;
  183. /** The opaque structure definition for the seekable stream encoder type.
  184.  *  See the link flac_seekable_stream_encoder seekable stream encoder module endlink
  185.  *  for a detailed description.
  186.  */
  187. typedef struct {
  188. struct FLAC__SeekableStreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
  189. struct FLAC__SeekableStreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
  190. } FLAC__SeekableStreamEncoder;
  191. /** Signature for the seek callback.
  192.  *  See FLAC__seekable_stream_encoder_set_seek_callback() for more info.
  193.  *
  194.  * param  encoder  The encoder instance calling the callback.
  195.  * param  absolute_byte_offset  The offset from the beginning of the stream
  196.  *                               to seek to.
  197.  * param  client_data  The callee's client data set through
  198.  *                      FLAC__seekable_stream_encoder_set_client_data().
  199.  * retval FLAC__SeekableStreamEncoderSeekStatus
  200.  *    The callee's return status.
  201.  */
  202. typedef FLAC__SeekableStreamEncoderSeekStatus (*FLAC__SeekableStreamEncoderSeekCallback)(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
  203. /** Signature for the tell callback.
  204.  *  See FLAC__seekable_stream_encoder_set_tell_callback() for more info.
  205.  *
  206.  * warning
  207.  * The callback must return the true current byte offset of the output to
  208.  * which the encoder is writing.  If you are buffering the output, make
  209.  * sure and take this into account.  If you are writing directly to a
  210.  * FILE* from your write callback, ftell() is sufficient.  If you are
  211.  * writing directly to a file descriptor from your write callback, you
  212.  * can use lseek(fd, SEEK_CUR, 0).  The encoder may later seek back to
  213.  * these points to rewrite metadata after encoding.
  214.  *
  215.  * param  encoder  The encoder instance calling the callback.
  216.  * param  absolute_byte_offset  The address at which to store the current
  217.  *                               position of the output.
  218.  * param  client_data  The callee's client data set through
  219.  *                      FLAC__seekable_stream_encoder_set_client_data().
  220.  * retval FLAC__SeekableStreamEncoderTellStatus
  221.  *    The callee's return status.
  222.  */
  223. typedef FLAC__SeekableStreamEncoderTellStatus (*FLAC__SeekableStreamEncoderTellCallback)(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
  224. /** Signature for the write callback.
  225.  *  See FLAC__seekable_stream_encoder_set_write_callback()
  226.  *  and FLAC__StreamEncoderWriteCallback for more info.
  227.  *
  228.  * param  encoder  The encoder instance calling the callback.
  229.  * param  buffer   An array of encoded data of length a bytes.
  230.  * param  bytes    The byte length of a buffer.
  231.  * param  samples  The number of samples encoded by a buffer.
  232.  *                  c 0 has a special meaning; see
  233.  *                  FLAC__stream_encoder_set_write_callback().
  234.  * param  current_frame  The number of current frame being encoded.
  235.  * param  client_data  The callee's client data set through
  236.  *                      FLAC__seekable_stream_encoder_set_client_data().
  237.  * retval FLAC__StreamEncoderWriteStatus
  238.  *    The callee's return status.
  239.  */
  240. typedef FLAC__StreamEncoderWriteStatus (*FLAC__SeekableStreamEncoderWriteCallback)(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
  241. /***********************************************************************
  242.  *
  243.  * Class constructor/destructor
  244.  *
  245.  ***********************************************************************/
  246. /** Create a new seekable stream encoder instance.  The instance is created with
  247.  *  default settings; see the individual FLAC__seekable_stream_encoder_set_*()
  248.  *  functions for each setting's default.
  249.  *
  250.  * retval FLAC__SeekableStreamEncoder*
  251.  *    c NULL if there was an error allocating memory, else the new instance.
  252.  */
  253. FLAC_API FLAC__SeekableStreamEncoder *FLAC__seekable_stream_encoder_new();
  254. /** Free an encoder instance.  Deletes the object pointed to by a encoder.
  255.  *
  256.  * param encoder  A pointer to an existing encoder.
  257.  * assert
  258.  *    code encoder != NULL endcode
  259.  */
  260. FLAC_API void FLAC__seekable_stream_encoder_delete(FLAC__SeekableStreamEncoder *encoder);
  261. /***********************************************************************
  262.  *
  263.  * Public class method prototypes
  264.  *
  265.  ***********************************************************************/
  266. /** This is inherited from FLAC__StreamEncoder; see
  267.  *  FLAC__stream_encoder_set_verify().
  268.  *
  269.  * default c true
  270.  * param  encoder  An encoder instance to set.
  271.  * param  value    See above.
  272.  * assert
  273.  *    code encoder != NULL endcode
  274.  * retval FLAC__bool
  275.  *    c false if the encoder is already initialized, else c true.
  276.  */
  277. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_verify(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
  278. /** This is inherited from FLAC__StreamEncoder; see
  279.  *  FLAC__stream_encoder_set_streamable_subset().
  280.  *
  281.  * default c true
  282.  * param  encoder  An encoder instance to set.
  283.  * param  value    See above.
  284.  * assert
  285.  *    code encoder != NULL endcode
  286.  * retval FLAC__bool
  287.  *    c false if the encoder is already initialized, else c true.
  288.  */
  289. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_streamable_subset(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
  290. /** This is inherited from FLAC__StreamEncoder; see
  291.  *  FLAC__stream_encoder_set_do_mid_side_stereo().
  292.  *
  293.  * default c false
  294.  * param  encoder  An encoder instance to set.
  295.  * param  value    See above.
  296.  * assert
  297.  *    code encoder != NULL endcode
  298.  * retval FLAC__bool
  299.  *    c false if the encoder is already initialized, else c true.
  300.  */
  301. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_do_mid_side_stereo(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
  302. /** This is inherited from FLAC__StreamEncoder; see
  303.  *  FLAC__stream_encoder_set_loose_mid_side_stereo().
  304.  *
  305.  * default c false
  306.  * param  encoder  An encoder instance to set.
  307.  * param  value    See above.
  308.  * assert
  309.  *    code encoder != NULL endcode
  310.  * retval FLAC__bool
  311.  *    c false if the encoder is already initialized, else c true.
  312.  */
  313. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_loose_mid_side_stereo(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
  314. /** This is inherited from FLAC__StreamEncoder; see
  315.  *  FLAC__stream_encoder_set_channels().
  316.  *
  317.  * default c 2
  318.  * param  encoder  An encoder instance to set.
  319.  * param  value    See above.
  320.  * assert
  321.  *    code encoder != NULL endcode
  322.  * retval FLAC__bool
  323.  *    c false if the encoder is already initialized, else c true.
  324.  */
  325. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_channels(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  326. /** This is inherited from FLAC__StreamEncoder; see
  327.  *  FLAC__stream_encoder_set_bits_per_sample().
  328.  *
  329.  * warning
  330.  * Do not feed the encoder data that is wider than the value you
  331.  * set here or you will generate an invalid stream.
  332.  *
  333.  * default c 16
  334.  * param  encoder  An encoder instance to set.
  335.  * param  value    See above.
  336.  * assert
  337.  *    code encoder != NULL endcode
  338.  * retval FLAC__bool
  339.  *    c false if the encoder is already initialized, else c true.
  340.  */
  341. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_bits_per_sample(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  342. /** This is inherited from FLAC__StreamEncoder; see
  343.  *  FLAC__stream_encoder_set_sample_rate().
  344.  *
  345.  * default c 44100
  346.  * param  encoder  An encoder instance to set.
  347.  * param  value    See above.
  348.  * assert
  349.  *    code encoder != NULL endcode
  350.  * retval FLAC__bool
  351.  *    c false if the encoder is already initialized, else c true.
  352.  */
  353. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_sample_rate(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  354. /** This is inherited from FLAC__StreamEncoder; see
  355.  *  FLAC__stream_encoder_set_blocksize().
  356.  *
  357.  * default c 1152
  358.  * param  encoder  An encoder instance to set.
  359.  * param  value    See above.
  360.  * assert
  361.  *    code encoder != NULL endcode
  362.  * retval FLAC__bool
  363.  *    c false if the encoder is already initialized, else c true.
  364.  */
  365. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_blocksize(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  366. /** This is inherited from FLAC__StreamEncoder; see
  367.  *  FLAC__stream_encoder_set_max_lpc_order().
  368.  *
  369.  * default c 0
  370.  * param  encoder  An encoder instance to set.
  371.  * param  value    See above.
  372.  * assert
  373.  *    code encoder != NULL endcode
  374.  * retval FLAC__bool
  375.  *    c false if the encoder is already initialized, else c true.
  376.  */
  377. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_max_lpc_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  378. /** This is inherited from FLAC__StreamEncoder; see
  379.  *  FLAC__stream_encoder_set_qlp_coeff_precision().
  380.  *
  381.  * note
  382.  * In the current implementation, qlp_coeff_precision + bits_per_sample must
  383.  * be less than 32.
  384.  *
  385.  * default c 0
  386.  * param  encoder  An encoder instance to set.
  387.  * param  value    See above.
  388.  * assert
  389.  *    code encoder != NULL endcode
  390.  * retval FLAC__bool
  391.  *    c false if the encoder is already initialized, else c true.
  392.  */
  393. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_qlp_coeff_precision(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  394. /** This is inherited from FLAC__StreamEncoder; see
  395.  *  FLAC__stream_encoder_set_do_qlp_coeff_prec_search().
  396.  *
  397.  * default c false
  398.  * param  encoder  An encoder instance to set.
  399.  * param  value    See above.
  400.  * assert
  401.  *    code encoder != NULL endcode
  402.  * retval FLAC__bool
  403.  *    c false if the encoder is already initialized, else c true.
  404.  */
  405. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
  406. /** This is inherited from FLAC__StreamEncoder; see
  407.  *  FLAC__stream_encoder_set_do_escape_coding().
  408.  *
  409.  * default c false
  410.  * param  encoder  An encoder instance to set.
  411.  * param  value    See above.
  412.  * assert
  413.  *    code encoder != NULL endcode
  414.  * retval FLAC__bool
  415.  *    c false if the encoder is already initialized, else c true.
  416.  */
  417. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_do_escape_coding(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
  418. /** This is inherited from FLAC__StreamEncoder; see
  419.  *  FLAC__stream_encoder_set_do_exhaustive_model_search().
  420.  *
  421.  * default c false
  422.  * param  encoder  An encoder instance to set.
  423.  * param  value    See above.
  424.  * assert
  425.  *    code encoder != NULL endcode
  426.  * retval FLAC__bool
  427.  *    c false if the encoder is already initialized, else c true.
  428.  */
  429. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_do_exhaustive_model_search(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
  430. /** This is inherited from FLAC__StreamEncoder; see
  431.  *  FLAC__stream_encoder_set_min_residual_partition_order().
  432.  *
  433.  * default c 0
  434.  * param  encoder  An encoder instance to set.
  435.  * param  value    See above.
  436.  * assert
  437.  *    code encoder != NULL endcode
  438.  * retval FLAC__bool
  439.  *    c false if the encoder is already initialized, else c true.
  440.  */
  441. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_min_residual_partition_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  442. /** This is inherited from FLAC__StreamEncoder; see
  443.  *  FLAC__stream_encoder_set_max_residual_partition_order().
  444.  *
  445.  * default c 0
  446.  * param  encoder  An encoder instance to set.
  447.  * param  value    See above.
  448.  * assert
  449.  *    code encoder != NULL endcode
  450.  * retval FLAC__bool
  451.  *    c false if the encoder is already initialized, else c true.
  452.  */
  453. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_max_residual_partition_order(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  454. /** This is inherited from FLAC__StreamEncoder; see
  455.  *  FLAC__stream_encoder_set_rice_parameter_search_dist().
  456.  *
  457.  * default c 0
  458.  * param  encoder  An encoder instance to set.
  459.  * param  value    See above.
  460.  * assert
  461.  *    code encoder != NULL endcode
  462.  * retval FLAC__bool
  463.  *    c false if the encoder is already initialized, else c true.
  464.  */
  465. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_rice_parameter_search_dist(FLAC__SeekableStreamEncoder *encoder, unsigned value);
  466. /** This is inherited from FLAC__StreamEncoder; see
  467.  *  FLAC__stream_encoder_set_total_samples_estimate().
  468.  *
  469.  * default c 0
  470.  * param  encoder  An encoder instance to set.
  471.  * param  value    See above.
  472.  * assert
  473.  *    code encoder != NULL endcode
  474.  * retval FLAC__bool
  475.  *    c false if the encoder is already initialized, else c true.
  476.  */
  477. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_total_samples_estimate(FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 value);
  478. /** This is inherited from FLAC__StreamEncoder; see
  479.  *  FLAC__stream_encoder_set_metadata().
  480.  *
  481.  * note
  482.  * SEEKTABLE blocks are handled specially.  Since you will not know
  483.  * the values for the seek point stream offsets, you should pass in
  484.  * a SEEKTABLE 'template', that is, a SEEKTABLE object with the
  485.  * required sample numbers (or placeholder points), with c 0 for the
  486.  * a frame_samples and a stream_offset fields for each point.  While
  487.  * encoding, the encoder will fill them in for you and when encoding
  488.  * is finished, it will seek back and write the real values into the
  489.  * SEEKTABLE block in the stream.  There are helper routines for
  490.  * manipulating seektable template blocks; see metadata.h:
  491.  * FLAC__metadata_object_seektable_template_*().
  492.  *
  493.  * note
  494.  * The encoder instance b will modify the first c SEEKTABLE block
  495.  * as it transforms the template to a valid seektable while encoding,
  496.  * but it is still up to the caller to free all metadata blocks after
  497.  * encoding.
  498.  *
  499.  * default c NULL, 0
  500.  * param  encoder     An encoder instance to set.
  501.  * param  metadata    See above.
  502.  * param  num_blocks  See above.
  503.  * assert
  504.  *    code encoder != NULL endcode
  505.  * retval FLAC__bool
  506.  *    c false if the encoder is already initialized, else c true.
  507.  */
  508. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_metadata(FLAC__SeekableStreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
  509. /** Set the seek callback.
  510.  *  The supplied function will be called when the encoder needs to seek
  511.  *  the output stream.  The encoder will pass the absolute byte offset
  512.  *  to seek to, 0 meaning the beginning of the stream.
  513.  *
  514.  * note
  515.  * The callback is mandatory and must be set before initialization.
  516.  *
  517.  * default c NULL
  518.  * param  encoder  An encoder instance to set.
  519.  * param  value    See above.
  520.  * assert
  521.  *    code encoder != NULL endcode
  522.  *    code value != NULL endcode
  523.  * retval FLAC__bool
  524.  *    c false if the encoder is already initialized, else c true.
  525.  */
  526. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_seek_callback(FLAC__SeekableStreamEncoder *encoder, FLAC__SeekableStreamEncoderSeekCallback value);
  527. /** Set the tell callback.
  528.  *  The supplied function will be called when the encoder needs to know
  529.  *  the current position of the output stream.
  530.  *
  531.  * note
  532.  * The callback is mandatory and must be set before initialization.
  533.  *
  534.  * default c NULL
  535.  * param  encoder  An encoder instance to set.
  536.  * param  value    See above.
  537.  * assert
  538.  *    code encoder != NULL endcode
  539.  *    code value != NULL endcode
  540.  * retval FLAC__bool
  541.  *    c false if the encoder is already initialized, else c true.
  542.  */
  543. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_tell_callback(FLAC__SeekableStreamEncoder *encoder, FLAC__SeekableStreamEncoderTellCallback value);
  544. /** Set the write callback.
  545.  *  This is inherited from FLAC__StreamEncoder; see
  546.  *  FLAC__stream_encoder_set_write_callback().
  547.  *
  548.  * note
  549.  * The callback is mandatory and must be set before initialization.
  550.  *
  551.  * default c NULL
  552.  * param  encoder  An encoder instance to set.
  553.  * param  value    See above.
  554.  * assert
  555.  *    code encoder != NULL endcode
  556.  *    code value != NULL endcode
  557.  * retval FLAC__bool
  558.  *    c false if the encoder is already initialized, else c true.
  559.  */
  560. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_write_callback(FLAC__SeekableStreamEncoder *encoder, FLAC__SeekableStreamEncoderWriteCallback value);
  561. /** Set the client data to be passed back to callbacks.
  562.  *  This value will be supplied to callbacks in their a client_data
  563.  *  argument.
  564.  *
  565.  * default c NULL
  566.  * param  encoder  An encoder instance to set.
  567.  * param  value    See above.
  568.  * assert
  569.  *    code encoder != NULL endcode
  570.  * retval FLAC__bool
  571.  *    c false if the encoder is already initialized, else c true.
  572.  */
  573. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_set_client_data(FLAC__SeekableStreamEncoder *encoder, void *value);
  574. /** Get the current encoder state.
  575.  *
  576.  * param  encoder  An encoder instance to query.
  577.  * assert
  578.  *    code encoder != NULL endcode
  579.  * retval FLAC__SeekableStreamEncoderState
  580.  *    The current encoder state.
  581.  */
  582. FLAC_API FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_get_state(const FLAC__SeekableStreamEncoder *encoder);
  583. /** Get the state of the underlying stream encoder.
  584.  *  Useful when the seekable stream encoder state is
  585.  *  c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR.
  586.  *
  587.  * param  encoder  An encoder instance to query.
  588.  * assert
  589.  *    code encoder != NULL endcode
  590.  * retval FLAC__StreamEncoderState
  591.  *    The stream encoder state.
  592.  */
  593. FLAC_API FLAC__StreamEncoderState FLAC__seekable_stream_encoder_get_stream_encoder_state(const FLAC__SeekableStreamEncoder *encoder);
  594. /** Get the state of the underlying stream encoder's verify decoder.
  595.  *  Useful when the seekable stream encoder state is
  596.  *  c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
  597.  *  stream encoder state is c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
  598.  *
  599.  * param  encoder  An encoder instance to query.
  600.  * assert
  601.  *    code encoder != NULL endcode
  602.  * retval FLAC__StreamDecoderState
  603.  *    The stream encoder state.
  604.  */
  605. FLAC_API FLAC__StreamDecoderState FLAC__seekable_stream_encoder_get_verify_decoder_state(const FLAC__SeekableStreamEncoder *encoder);
  606. /** Get the current encoder state as a C string.
  607.  *  This version automatically resolves
  608.  *  c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR by getting the
  609.  *  stream encoder's state.
  610.  *
  611.  * param  encoder  A encoder instance to query.
  612.  * assert
  613.  *    code encoder != NULL endcode
  614.  * retval const char *
  615.  *    The encoder state as a C string.  Do not modify the contents.
  616.  */
  617. FLAC_API const char *FLAC__seekable_stream_encoder_get_resolved_state_string(const FLAC__SeekableStreamEncoder *encoder);
  618. /** Get relevant values about the nature of a verify decoder error.
  619.  *  Inherited from FLAC__stream_encoder_get_verify_decoder_error_stats().
  620.  *  Useful when the seekable stream encoder state is
  621.  *  c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
  622.  *  stream encoder state is
  623.  *  c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
  624.  *
  625.  * param  encoder  An encoder instance to query.
  626.  * param  absolute_sample  The absolute sample number of the mismatch.
  627.  * param  frame_number  The number of the frame in which the mismatch occurred.
  628.  * param  channel       The channel in which the mismatch occurred.
  629.  * param  sample        The number of the sample (relative to the frame) in
  630.  *                       which the mismatch occurred.
  631.  * param  expected      The expected value for the sample in question.
  632.  * param  got           The actual value returned by the decoder.
  633.  * assert
  634.  *    code encoder != NULL endcode
  635.  */
  636. FLAC_API void FLAC__seekable_stream_encoder_get_verify_decoder_error_stats(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
  637. /** Get the "verify" flag.
  638.  *  This is inherited from FLAC__StreamEncoder; see
  639.  *  FLAC__stream_encoder_get_verify().
  640.  *
  641.  * param  encoder  An encoder instance to query.
  642.  * assert
  643.  *    code encoder != NULL endcode
  644.  * retval FLAC__bool
  645.  *    See FLAC__seekable_stream_encoder_set_verify().
  646.  */
  647. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_verify(const FLAC__SeekableStreamEncoder *encoder);
  648. /** Get the "streamable subset" flag.
  649.  *  This is inherited from FLAC__StreamEncoder; see
  650.  *  FLAC__stream_encoder_get_streamable_subset().
  651.  *
  652.  * param  encoder  An encoder instance to query.
  653.  * assert
  654.  *    code encoder != NULL endcode
  655.  * retval FLAC__bool
  656.  *    See FLAC__seekable_stream_encoder_set_streamable_subset().
  657.  */
  658. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_streamable_subset(const FLAC__SeekableStreamEncoder *encoder);
  659. /** Get the "mid/side stereo coding" flag.
  660.  *  This is inherited from FLAC__StreamEncoder; see
  661.  *  FLAC__stream_encoder_get_do_mid_side_stereo().
  662.  *
  663.  * param  encoder  An encoder instance to query.
  664.  * assert
  665.  *    code encoder != NULL endcode
  666.  * retval FLAC__bool
  667.  *    See FLAC__seekable_stream_encoder_get_do_mid_side_stereo().
  668.  */
  669. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_mid_side_stereo(const FLAC__SeekableStreamEncoder *encoder);
  670. /** Get the "adaptive mid/side switching" flag.
  671.  *  This is inherited from FLAC__StreamEncoder; see
  672.  *  FLAC__stream_encoder_get_loose_mid_side_stereo().
  673.  *
  674.  * param  encoder  An encoder instance to query.
  675.  * assert
  676.  *    code encoder != NULL endcode
  677.  * retval FLAC__bool
  678.  *    See FLAC__seekable_stream_encoder_set_loose_mid_side_stereo().
  679.  */
  680. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_loose_mid_side_stereo(const FLAC__SeekableStreamEncoder *encoder);
  681. /** Get the number of input channels being processed.
  682.  *  This is inherited from FLAC__StreamEncoder; see
  683.  *  FLAC__stream_encoder_get_channels().
  684.  *
  685.  * param  encoder  An encoder instance to query.
  686.  * assert
  687.  *    code encoder != NULL endcode
  688.  * retval unsigned
  689.  *    See FLAC__seekable_stream_encoder_set_channels().
  690.  */
  691. FLAC_API unsigned FLAC__seekable_stream_encoder_get_channels(const FLAC__SeekableStreamEncoder *encoder);
  692. /** Get the input sample resolution setting.
  693.  *  This is inherited from FLAC__StreamEncoder; see
  694.  *  FLAC__stream_encoder_get_bits_per_sample().
  695.  *
  696.  * param  encoder  An encoder instance to query.
  697.  * assert
  698.  *    code encoder != NULL endcode
  699.  * retval unsigned
  700.  *    See FLAC__seekable_stream_encoder_set_bits_per_sample().
  701.  */
  702. FLAC_API unsigned FLAC__seekable_stream_encoder_get_bits_per_sample(const FLAC__SeekableStreamEncoder *encoder);
  703. /** Get the input sample rate setting.
  704.  *  This is inherited from FLAC__StreamEncoder; see
  705.  *  FLAC__stream_encoder_get_sample_rate().
  706.  *
  707.  * param  encoder  An encoder instance to query.
  708.  * assert
  709.  *    code encoder != NULL endcode
  710.  * retval unsigned
  711.  *    See FLAC__seekable_stream_encoder_set_sample_rate().
  712.  */
  713. FLAC_API unsigned FLAC__seekable_stream_encoder_get_sample_rate(const FLAC__SeekableStreamEncoder *encoder);
  714. /** Get the blocksize setting.
  715.  *  This is inherited from FLAC__StreamEncoder; see
  716.  *  FLAC__stream_encoder_get_blocksize().
  717.  *
  718.  * param  encoder  An encoder instance to query.
  719.  * assert
  720.  *    code encoder != NULL endcode
  721.  * retval unsigned
  722.  *    See FLAC__seekable_stream_encoder_set_blocksize().
  723.  */
  724. FLAC_API unsigned FLAC__seekable_stream_encoder_get_blocksize(const FLAC__SeekableStreamEncoder *encoder);
  725. /** Get the maximum LPC order setting.
  726.  *  This is inherited from FLAC__StreamEncoder; see
  727.  *  FLAC__stream_encoder_get_max_lpc_order().
  728.  *
  729.  * param  encoder  An encoder instance to query.
  730.  * assert
  731.  *    code encoder != NULL endcode
  732.  * retval unsigned
  733.  *    See FLAC__seekable_stream_encoder_set_max_lpc_order().
  734.  */
  735. FLAC_API unsigned FLAC__seekable_stream_encoder_get_max_lpc_order(const FLAC__SeekableStreamEncoder *encoder);
  736. /** Get the quantized linear predictor coefficient precision setting.
  737.  *  This is inherited from FLAC__StreamEncoder; see
  738.  *  FLAC__stream_encoder_get_qlp_coeff_precision().
  739.  *
  740.  * param  encoder  An encoder instance to query.
  741.  * assert
  742.  *    code encoder != NULL endcode
  743.  * retval unsigned
  744.  *    See FLAC__seekable_stream_encoder_set_qlp_coeff_precision().
  745.  */
  746. FLAC_API unsigned FLAC__seekable_stream_encoder_get_qlp_coeff_precision(const FLAC__SeekableStreamEncoder *encoder);
  747. /** Get the qlp coefficient precision search flag.
  748.  *  This is inherited from FLAC__StreamEncoder; see
  749.  *  FLAC__stream_encoder_get_do_qlp_coeff_prec_search().
  750.  *
  751.  * param  encoder  An encoder instance to query.
  752.  * assert
  753.  *    code encoder != NULL endcode
  754.  * retval FLAC__bool
  755.  *    See FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search().
  756.  */
  757. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__SeekableStreamEncoder *encoder);
  758. /** Get the "escape coding" flag.
  759.  *  This is inherited from FLAC__StreamEncoder; see
  760.  *  FLAC__stream_encoder_get_do_escape_coding().
  761.  *
  762.  * param  encoder  An encoder instance to query.
  763.  * assert
  764.  *    code encoder != NULL endcode
  765.  * retval FLAC__bool
  766.  *    See FLAC__seekable_stream_encoder_set_do_escape_coding().
  767.  */
  768. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_escape_coding(const FLAC__SeekableStreamEncoder *encoder);
  769. /** Get the exhaustive model search flag.
  770.  *  This is inherited from FLAC__StreamEncoder; see
  771.  *  FLAC__stream_encoder_get_do_exhaustive_model_search().
  772.  *
  773.  * param  encoder  An encoder instance to query.
  774.  * assert
  775.  *    code encoder != NULL endcode
  776.  * retval FLAC__bool
  777.  *    See FLAC__seekable_stream_encoder_set_do_exhaustive_model_search().
  778.  */
  779. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_get_do_exhaustive_model_search(const FLAC__SeekableStreamEncoder *encoder);
  780. /** Get the minimum residual partition order setting.
  781.  *  This is inherited from FLAC__StreamEncoder; see
  782.  *  FLAC__stream_encoder_get_min_residual_partition_order().
  783.  *
  784.  * param  encoder  An encoder instance to query.
  785.  * assert
  786.  *    code encoder != NULL endcode
  787.  * retval unsigned
  788.  *    See FLAC__seekable_stream_encoder_set_min_residual_partition_order().
  789.  */
  790. FLAC_API unsigned FLAC__seekable_stream_encoder_get_min_residual_partition_order(const FLAC__SeekableStreamEncoder *encoder);
  791. /** Get maximum residual partition order setting.
  792.  *  This is inherited from FLAC__StreamEncoder; see
  793.  *  FLAC__stream_encoder_get_max_residual_partition_order().
  794.  *
  795.  * param  encoder  An encoder instance to query.
  796.  * assert
  797.  *    code encoder != NULL endcode
  798.  * retval unsigned
  799.  *    See FLAC__seekable_stream_encoder_set_max_residual_partition_order().
  800.  */
  801. FLAC_API unsigned FLAC__seekable_stream_encoder_get_max_residual_partition_order(const FLAC__SeekableStreamEncoder *encoder);
  802. /** Get the Rice parameter search distance setting.
  803.  *  This is inherited from FLAC__StreamEncoder; see
  804.  *  FLAC__stream_encoder_get_rice_parameter_search_dist().
  805.  *
  806.  * param  encoder  An encoder instance to query.
  807.  * assert
  808.  *    code encoder != NULL endcode
  809.  * retval unsigned
  810.  *    See FLAC__seekable_stream_encoder_set_rice_parameter_search_dist().
  811.  */
  812. FLAC_API unsigned FLAC__seekable_stream_encoder_get_rice_parameter_search_dist(const FLAC__SeekableStreamEncoder *encoder);
  813. /** Get the previously set estimate of the total samples to be encoded.
  814.  *  This is inherited from FLAC__StreamEncoder; see
  815.  *  FLAC__stream_encoder_get_total_samples_estimate().
  816.  *
  817.  * param  encoder  An encoder instance to query.
  818.  * assert
  819.  *    code encoder != NULL endcode
  820.  * retval FLAC__uint64
  821.  *    See FLAC__seekable_stream_encoder_set_total_samples_estimate().
  822.  */
  823. FLAC_API FLAC__uint64 FLAC__seekable_stream_encoder_get_total_samples_estimate(const FLAC__SeekableStreamEncoder *encoder);
  824. /** Initialize the encoder instance.
  825.  *  Should be called after FLAC__seekable_stream_encoder_new() and
  826.  *  FLAC__seekable_stream_encoder_set_*() but before FLAC__seekable_stream_encoder_process()
  827.  *  or FLAC__seekable_stream_encoder_process_interleaved().  Will set and return
  828.  *  the encoder state, which will be FLAC__SEEKABLE_STREAM_ENCODER_OK if
  829.  *  initialization succeeded.
  830.  *
  831.  *  The call to FLAC__seekable_stream_encoder_init() currently will also immediately
  832.  *  call the write callback with the c fLaC signature and all the encoded
  833.  *  metadata.
  834.  *
  835.  * param  encoder  An uninitialized encoder instance.
  836.  * assert
  837.  *    code encoder != NULL endcode
  838.  * retval FLAC__SeekableStreamEncoderState
  839.  *    c FLAC__SEEKABLE_STREAM_ENCODER_OK if initialization was successful; see
  840.  *    FLAC__SeekableStreamEncoderState for the meanings of other return values.
  841.  */
  842. FLAC_API FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_init(FLAC__SeekableStreamEncoder *encoder);
  843. /** Finish the encoding process.
  844.  *  Flushes the encoding buffer, releases resources, resets the encoder
  845.  *  settings to their defaults, and returns the encoder state to
  846.  *  FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED.
  847.  *
  848.  *  In the event of a prematurely-terminated encode, it is not strictly
  849.  *  necessary to call this immediately before FLAC__seekable_stream_encoder_delete()
  850.  *  but it is good practice to match every FLAC__seekable_stream_encoder_init()
  851.  *  with a FLAC__seekable_stream_encoder_finish().
  852.  *
  853.  * param  encoder  An uninitialized encoder instance.
  854.  * assert
  855.  *    code encoder != NULL endcode
  856.  */
  857. FLAC_API void FLAC__seekable_stream_encoder_finish(FLAC__SeekableStreamEncoder *encoder);
  858. /** Submit data for encoding.
  859.  *  This is inherited from FLAC__StreamEncoder; see
  860.  *  FLAC__stream_encoder_process().
  861.  *
  862.  * param  encoder  An initialized encoder instance in the OK state.
  863.  * param  buffer   An array of pointers to each channel's signal.
  864.  * param  samples  The number of samples in one channel.
  865.  * assert
  866.  *    code encoder != NULL endcode
  867.  *    code FLAC__seekable_stream_encoder_get_state(encoder) == FLAC__SEEKABLE_STREAM_ENCODER_OK endcode
  868.  * retval FLAC__bool
  869.  *    c true if successful, else c false; in this case, check the
  870.  *    encoder state with FLAC__seekable_stream_encoder_get_state() to see what
  871.  *    went wrong.
  872.  */
  873. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_process(FLAC__SeekableStreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
  874. /** Submit data for encoding.
  875.  *  This is inherited from FLAC__StreamEncoder; see
  876.  *  FLAC__stream_encoder_process_interleaved().
  877.  *
  878.  * param  encoder  An initialized encoder instance in the OK state.
  879.  * param  buffer   An array of channel-interleaved data (see above).
  880.  * param  samples  The number of samples in one channel, the same as for
  881.  *                  FLAC__seekable_stream_encoder_process().  For example, if
  882.  *                  encoding two channels, c 1000 a samples corresponds
  883.  *                  to a a buffer of 2000 values.
  884.  * assert
  885.  *    code encoder != NULL endcode
  886.  *    code FLAC__seekable_stream_encoder_get_state(encoder) == FLAC__SEEKABLE_STREAM_ENCODER_OK endcode
  887.  * retval FLAC__bool
  888.  *    c true if successful, else c false; in this case, check the
  889.  *    encoder state with FLAC__seekable_stream_encoder_get_state() to see what
  890.  *    went wrong.
  891.  */
  892. FLAC_API FLAC__bool FLAC__seekable_stream_encoder_process_interleaved(FLAC__SeekableStreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);
  893. /* } */
  894. #ifdef __cplusplus
  895. }
  896. #endif
  897. #endif