# stream_encoder.h

Go to the documentation of this file.

    00001 /* libFLAC - Free Lossless Audio Codec library
    00002  * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007  Josh Coalson
    00003  *
    00004  * Redistribution and use in source and binary forms, with or without
    00005  * modification, are permitted provided that the following conditions
    00006  * are met:
    00007  *
    00008  * - Redistributions of source code must retain the above copyright
    00009  * notice, this list of conditions and the following disclaimer.
    00010  *
    00011  * - Redistributions in binary form must reproduce the above copyright
    00012  * notice, this list of conditions and the following disclaimer in the
    00013  * documentation and/or other materials provided with the distribution.
    00014  *
    00015  * - Neither the name of the Xiph.org Foundation nor the names of its
    00016  * contributors may be used to endorse or promote products derived from
    00017  * this software without specific prior written permission.
    00018  *
    00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    00022  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
    00023  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    00024  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    00025  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    00026  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00027  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00028  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00030  */
    00031
    00032 #ifndef FLAC__STREAM_ENCODER_H
    00033 #define FLAC__STREAM_ENCODER_H
    00034
    00035 #include <stdio.h> /* for FILE */
    00036 #include "export.h"
    00037 #include "format.h"
    00038 #include "stream_decoder.h"
    00039
    00040 #ifdef __cplusplus
    00041 extern "C" {
    00042 #endif
    00043
    00044
    00240 typedef enum {
    00241
    00242     FLAC__STREAM_ENCODER_OK = 0,
    00245     FLAC__STREAM_ENCODER_UNINITIALIZED,
    00251     FLAC__STREAM_ENCODER_OGG_ERROR,
    00254     FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
    00259     FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA,
    00264     FLAC__STREAM_ENCODER_CLIENT_ERROR,
    00267     FLAC__STREAM_ENCODER_IO_ERROR,
    00272     FLAC__STREAM_ENCODER_FRAMING_ERROR,
    00277     FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR
    00280 } FLAC__StreamEncoderState;
    00281
    00287 extern FLAC_API const char * const FLAC__StreamEncoderStateString[];
    00288
    00289
    00292 typedef enum {
    00293
    00294     FLAC__STREAM_ENCODER_INIT_STATUS_OK = 0,
    00297     FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR,
    00300     FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
    00305     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS,
    00308     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS,
    00311     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE,
    00317     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE,
    00320     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE,
    00323     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER,
    00326     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION,
    00329     FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER,
    00332     FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE,
    00335     FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA,
    00344     FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED
    00350 } FLAC__StreamEncoderInitStatus;
    00351
    00357 extern FLAC_API const char * const FLAC__StreamEncoderInitStatusString[];
    00358
    00359
    00362 typedef enum {
    00363
    00364     FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE,
    00367     FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM,
    00370     FLAC__STREAM_ENCODER_READ_STATUS_ABORT,
    00373     FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED
    00376 } FLAC__StreamEncoderReadStatus;
    00377
    00383 extern FLAC_API const char * const FLAC__StreamEncoderReadStatusString[];
    00384
    00385
    00388 typedef enum {
    00389
    00390     FLAC__STREAM_ENCODER_WRITE_STATUS_OK = 0,
    00393     FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR
    00396 } FLAC__StreamEncoderWriteStatus;
    00397
    00403 extern FLAC_API const char * const FLAC__StreamEncoderWriteStatusString[];
    00404
    00405
    00408 typedef enum {
    00409
    00410     FLAC__STREAM_ENCODER_SEEK_STATUS_OK,
    00413     FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR,
    00416     FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED
    00419 } FLAC__StreamEncoderSeekStatus;
    00420
    00426 extern FLAC_API const char * const FLAC__StreamEncoderSeekStatusString[];
    00427
    00428
    00431 typedef enum {
    00432
    00433     FLAC__STREAM_ENCODER_TELL_STATUS_OK,
    00436     FLAC__STREAM_ENCODER_TELL_STATUS_ERROR,
    00439     FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED
    00442 } FLAC__StreamEncoderTellStatus;
    00443
    00449 extern FLAC_API const char * const FLAC__StreamEncoderTellStatusString[];
    00450
    00451
    00452 /***********************************************************************
    00453  *
    00454  * class FLAC__StreamEncoder
    00455  *
    00456  ***********************************************************************/
    00457
    00458 struct FLAC__StreamEncoderProtected;
    00459 struct FLAC__StreamEncoderPrivate;
    00464 typedef struct {
    00465     struct FLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
    00466     struct FLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
    00467 } FLAC__StreamEncoder;
    00468
    00518 typedef FLAC__StreamEncoderReadStatus (*FLAC__StreamEncoderReadCallback)(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
    00519
    00556 typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
    00557
    00590 typedef FLAC__StreamEncoderSeekStatus (*FLAC__StreamEncoderSeekCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
    00591
    00635 typedef FLAC__StreamEncoderTellStatus (*FLAC__StreamEncoderTellCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
    00636
    00654 typedef void (*FLAC__StreamEncoderMetadataCallback)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data);
    00655
    00677 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);
    00678
    00679
    00680 /***********************************************************************
    00681  *
    00682  * Class constructor/destructor
    00683  *
    00684  ***********************************************************************/
    00685
    00693 FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void);
    00694
    00701 FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder);
    00702
    00703
    00704 /***********************************************************************
    00705  *
    00706  * Public class method prototypes
    00707  *
    00708  ***********************************************************************/
    00709
    00727 FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncoder *encoder, long serial_number);
    00728
    00743 FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value);
    00744
    00761 FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value);
    00762
    00773 FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value);
    00774
    00789 FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value);
    00790
    00801 FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value);
    00802
    00864 FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, unsigned value);
    00865
    00879 FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value);
    00880
    00893 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
    00894
    00909 FLAC_API FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
    00910
    00954 FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *encoder, const char *specification);
    00955
    00966 FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value);
    00967
    00984 FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value);
    00985
    00998 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
    00999
    01010 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_escape_coding(FLAC__StreamEncoder *encoder, FLAC__bool value);
    01011
    01024 FLAC_API FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
    01025
    01047 FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
    01048
    01070 FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
    01071
    01082 FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value);
    01083
    01098 FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value);
    01099
    01181 FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
    01182
    01191 FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder);
    01192
    01203 FLAC_API FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder);
    01204
    01216 FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder);
    01217
    01235 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);
    01236
    01245 FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder);
    01246
    01255 FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder);
    01256
    01265 FLAC_API unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder);
    01266
    01275 FLAC_API unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder);
    01276
    01285 FLAC_API unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder);
    01286
    01295 FLAC_API unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder);
    01296
    01305 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder);
    01306
    01315 FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder);
    01316
    01325 FLAC_API unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder);
    01326
    01335 FLAC_API unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder);
    01336
    01345 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder);
    01346
    01355 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder);
    01356
    01365 FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder);
    01366
    01375 FLAC_API unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder);
    01376
    01385 FLAC_API unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder);
    01386
    01395 FLAC_API unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder);
    01396
    01408 FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC__StreamEncoder *encoder);
    01409
    01471 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);
    01472
    01539 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);
    01540
    01574 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
    01575
    01609 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
    01610
    01641 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
    01642
    01673 FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
    01674
    01701 FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder);
    01702
    01728 FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
    01729
    01760 FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);
    01761
    01762 /* \} */
    01763
    01764 #ifdef __cplusplus
    01765 }
    01766 #endif
    01767
    01768 #endif

Copyright (c) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson |