include/FLAC++/encoder.h Source File

Main Page Modules Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# include/FLAC++/encoder.h

Go to the documentation of this file.

    00001 /* libFLAC++ - Free Lossless Audio Codec library
    00002  * Copyright (C) 2002,2003,2004,2005  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 FLACPP__ENCODER_H
    00033 #define FLACPP__ENCODER_H
    00034
    00035 #include "export.h"
    00036
    00037 #include "FLAC/file_encoder.h"
    00038 #include "FLAC/seekable_stream_encoder.h"
    00039 #include "FLAC/stream_encoder.h"
    00040 #include "decoder.h"
    00041 #include "metadata.h"
    00042
    00043
    00071 namespace FLAC {
    00072     namespace Encoder {
    00073
    00074         // ============================================================
    00075         //
    00076         //  Equivalent: FLAC__StreamEncoder
    00077         //
    00078         // ============================================================
    00079
    00093         class FLACPP_API Stream {
    00094         public:
    00095             class FLACPP_API State {
    00096             public:
    00097                 inline State(::FLAC__StreamEncoderState state): state_(state) { }
    00098                 inline operator ::FLAC__StreamEncoderState() const { return state_; }
    00099                 inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; }
    00100                 inline const char *resolved_as_cstring(const Stream &encoder) const { return ::FLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); }
    00101             protected:
    00102                 ::FLAC__StreamEncoderState state_;
    00103             };
    00104
    00105             Stream();
    00106             virtual ~Stream();
    00107
    00108             bool is_valid() const;
    00109             inline operator bool() const { return is_valid(); }
    00110
    00111             bool set_verify(bool value);
    00112             bool set_streamable_subset(bool value);
    00113             bool set_do_mid_side_stereo(bool value);
    00114             bool set_loose_mid_side_stereo(bool value);
    00115             bool set_channels(unsigned value);
    00116             bool set_bits_per_sample(unsigned value);
    00117             bool set_sample_rate(unsigned value);
    00118             bool set_blocksize(unsigned value);
    00119             bool set_max_lpc_order(unsigned value);
    00120             bool set_qlp_coeff_precision(unsigned value);
    00121             bool set_do_qlp_coeff_prec_search(bool value);
    00122             bool set_do_escape_coding(bool value);
    00123             bool set_do_exhaustive_model_search(bool value);
    00124             bool set_min_residual_partition_order(unsigned value);
    00125             bool set_max_residual_partition_order(unsigned value);
    00126             bool set_rice_parameter_search_dist(unsigned value);
    00127             bool set_total_samples_estimate(FLAC__uint64 value);
    00128             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
    00129             bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks);
    00130
    00131             State    get_state() const;
    00132             Decoder::Stream::State get_verify_decoder_state() const;
    00133             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
    00134             bool     get_verify() const;
    00135             bool     get_streamable_subset() const;
    00136             bool     get_do_mid_side_stereo() const;
    00137             bool     get_loose_mid_side_stereo() const;
    00138             unsigned get_channels() const;
    00139             unsigned get_bits_per_sample() const;
    00140             unsigned get_sample_rate() const;
    00141             unsigned get_blocksize() const;
    00142             unsigned get_max_lpc_order() const;
    00143             unsigned get_qlp_coeff_precision() const;
    00144             bool     get_do_qlp_coeff_prec_search() const;
    00145             bool     get_do_escape_coding() const;
    00146             bool     get_do_exhaustive_model_search() const;
    00147             unsigned get_min_residual_partition_order() const;
    00148             unsigned get_max_residual_partition_order() const;
    00149             unsigned get_rice_parameter_search_dist() const;
    00150             FLAC__uint64 get_total_samples_estimate() const;
    00151
    00152             State init();
    00153
    00154             void finish();
    00155
    00156             bool process(const FLAC__int32 * const buffer[], unsigned samples);
    00157             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
    00158         protected:
    00159             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
    00160             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
    00161
    00162 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
    00163             // lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
    00164             friend State;
    00165 #endif
    00166             ::FLAC__StreamEncoder *encoder_;
    00167         private:
    00168             static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
    00169             static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
    00170
    00171             // Private and undefined so you can't use them:
    00172             Stream(const Stream &);
    00173             void operator=(const Stream &);
    00174         };
    00175
    00176         /* \} */
    00177
    00191         class FLACPP_API SeekableStream {
    00192         public:
    00193             class FLACPP_API State {
    00194             public:
    00195                 inline State(::FLAC__SeekableStreamEncoderState state): state_(state) { }
    00196                 inline operator ::FLAC__SeekableStreamEncoderState() const { return state_; }
    00197                 inline const char *as_cstring() const { return ::FLAC__SeekableStreamEncoderStateString[state_]; }
    00198                 inline const char *resolved_as_cstring(const SeekableStream &encoder) const { return ::FLAC__seekable_stream_encoder_get_resolved_state_string(encoder.encoder_); }
    00199             protected:
    00200                 ::FLAC__SeekableStreamEncoderState state_;
    00201             };
    00202
    00203             SeekableStream();
    00204             virtual ~SeekableStream();
    00205
    00206             bool is_valid() const;
    00207             inline operator bool() const { return is_valid(); }
    00208
    00209             bool set_verify(bool value);
    00210             bool set_streamable_subset(bool value);
    00211             bool set_do_mid_side_stereo(bool value);
    00212             bool set_loose_mid_side_stereo(bool value);
    00213             bool set_channels(unsigned value);
    00214             bool set_bits_per_sample(unsigned value);
    00215             bool set_sample_rate(unsigned value);
    00216             bool set_blocksize(unsigned value);
    00217             bool set_max_lpc_order(unsigned value);
    00218             bool set_qlp_coeff_precision(unsigned value);
    00219             bool set_do_qlp_coeff_prec_search(bool value);
    00220             bool set_do_escape_coding(bool value);
    00221             bool set_do_exhaustive_model_search(bool value);
    00222             bool set_min_residual_partition_order(unsigned value);
    00223             bool set_max_residual_partition_order(unsigned value);
    00224             bool set_rice_parameter_search_dist(unsigned value);
    00225             bool set_total_samples_estimate(FLAC__uint64 value);
    00226             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
    00227             bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks);
    00228
    00229             State    get_state() const;
    00230             Stream::State get_stream_encoder_state() const;
    00231             Decoder::Stream::State get_verify_decoder_state() const;
    00232             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
    00233             bool     get_verify() const;
    00234             bool     get_streamable_subset() const;
    00235             bool     get_do_mid_side_stereo() const;
    00236             bool     get_loose_mid_side_stereo() const;
    00237             unsigned get_channels() const;
    00238             unsigned get_bits_per_sample() const;
    00239             unsigned get_sample_rate() const;
    00240             unsigned get_blocksize() const;
    00241             unsigned get_max_lpc_order() const;
    00242             unsigned get_qlp_coeff_precision() const;
    00243             bool     get_do_qlp_coeff_prec_search() const;
    00244             bool     get_do_escape_coding() const;
    00245             bool     get_do_exhaustive_model_search() const;
    00246             unsigned get_min_residual_partition_order() const;
    00247             unsigned get_max_residual_partition_order() const;
    00248             unsigned get_rice_parameter_search_dist() const;
    00249             FLAC__uint64 get_total_samples_estimate() const;
    00250
    00251             State init();
    00252
    00253             void finish();
    00254
    00255             bool process(const FLAC__int32 * const buffer[], unsigned samples);
    00256             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
    00257         protected:
    00258             virtual ::FLAC__SeekableStreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
    00259             virtual ::FLAC__SeekableStreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
    00260             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
    00261
    00262 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
    00263             // lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
    00264             friend State;
    00265 #endif
    00266             ::FLAC__SeekableStreamEncoder *encoder_;
    00267         private:
    00268             static ::FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
    00269             static ::FLAC__SeekableStreamEncoderTellStatus tell_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
    00270             static ::FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
    00271
    00272             // Private and undefined so you can't use them:
    00273             SeekableStream(const SeekableStream &);
    00274             void operator=(const SeekableStream &);
    00275         };
    00276
    00277         /* \} */
    00278
    00292         class FLACPP_API File {
    00293         public:
    00294             class FLACPP_API State {
    00295             public:
    00296                 inline State(::FLAC__FileEncoderState state): state_(state) { }
    00297                 inline operator ::FLAC__FileEncoderState() const { return state_; }
    00298                 inline const char *as_cstring() const { return ::FLAC__FileEncoderStateString[state_]; }
    00299                 inline const char *resolved_as_cstring(const File &encoder) const { return ::FLAC__file_encoder_get_resolved_state_string(encoder.encoder_); }
    00300             protected:
    00301                 ::FLAC__FileEncoderState state_;
    00302             };
    00303
    00304             File();
    00305             virtual ~File();
    00306
    00307             bool is_valid() const;
    00308             inline operator bool() const { return is_valid(); }
    00309
    00310             bool set_verify(bool value);
    00311             bool set_streamable_subset(bool value);
    00312             bool set_do_mid_side_stereo(bool value);
    00313             bool set_loose_mid_side_stereo(bool value);
    00314             bool set_channels(unsigned value);
    00315             bool set_bits_per_sample(unsigned value);
    00316             bool set_sample_rate(unsigned value);
    00317             bool set_blocksize(unsigned value);
    00318             bool set_max_lpc_order(unsigned value);
    00319             bool set_qlp_coeff_precision(unsigned value);
    00320             bool set_do_qlp_coeff_prec_search(bool value);
    00321             bool set_do_escape_coding(bool value);
    00322             bool set_do_exhaustive_model_search(bool value);
    00323             bool set_min_residual_partition_order(unsigned value);
    00324             bool set_max_residual_partition_order(unsigned value);
    00325             bool set_rice_parameter_search_dist(unsigned value);
    00326             bool set_total_samples_estimate(FLAC__uint64 value);
    00327             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
    00328             bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks);
    00329             bool set_filename(const char *value);
    00330
    00331             State    get_state() const;
    00332             SeekableStream::State get_seekable_stream_encoder_state() const;
    00333             Stream::State get_stream_encoder_state() const;
    00334             Decoder::Stream::State get_verify_decoder_state() const;
    00335             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
    00336             bool     get_verify() const;
    00337             bool     get_streamable_subset() const;
    00338             bool     get_do_mid_side_stereo() const;
    00339             bool     get_loose_mid_side_stereo() const;
    00340             unsigned get_channels() const;
    00341             unsigned get_bits_per_sample() const;
    00342             unsigned get_sample_rate() const;
    00343             unsigned get_blocksize() const;
    00344             unsigned get_max_lpc_order() const;
    00345             unsigned get_qlp_coeff_precision() const;
    00346             bool     get_do_qlp_coeff_prec_search() const;
    00347             bool     get_do_escape_coding() const;
    00348             bool     get_do_exhaustive_model_search() const;
    00349             unsigned get_min_residual_partition_order() const;
    00350             unsigned get_max_residual_partition_order() const;
    00351             unsigned get_rice_parameter_search_dist() const;
    00352             FLAC__uint64 get_total_samples_estimate() const;
    00353
    00354             State init();
    00355
    00356             void finish();
    00357
    00358             bool process(const FLAC__int32 * const buffer[], unsigned samples);
    00359             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
    00360         protected:
    00361             virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
    00362
    00363 #if (defined _MSC_VER) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
    00364             // lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
    00365             friend State;
    00366 #endif
    00367             ::FLAC__FileEncoder *encoder_;
    00368         private:
    00369             static void progress_callback_(const ::FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
    00370
    00371             // Private and undefined so you can't use them:
    00372             File(const Stream &);
    00373             void operator=(const Stream &);
    00374         };
    00375
    00376         /* \} */
    00377
    00378     }
    00379 }
    00380
    00381 #endif