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  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 
00042 
00070 namespace FLAC {
00071     namespace Encoder {
00072 
00073         // ============================================================
00074         //
00075         //  Equivalent: FLAC__StreamEncoder
00076         //
00077         // ============================================================
00078 
00092         class FLACPP_API Stream {
00093         public:
00094             class FLACPP_API State {
00095             public:
00096                 inline State(::FLAC__StreamEncoderState state): state_(state) { }
00097                 inline operator ::FLAC__StreamEncoderState() const { return state_; }
00098                 inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; }
00099                 inline const char *resolved_as_cstring(const Stream &encoder) const { return ::FLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); }
00100             protected:
00101                 ::FLAC__StreamEncoderState state_;
00102             };
00103 
00104             Stream();
00105             virtual ~Stream();
00106 
00107             bool is_valid() const;
00108             inline operator bool() const { return is_valid(); }
00109 
00110             bool set_verify(bool value);
00111             bool set_streamable_subset(bool value);
00112             bool set_do_mid_side_stereo(bool value);
00113             bool set_loose_mid_side_stereo(bool value);
00114             bool set_channels(unsigned value);
00115             bool set_bits_per_sample(unsigned value);
00116             bool set_sample_rate(unsigned value);
00117             bool set_blocksize(unsigned value);
00118             bool set_max_lpc_order(unsigned value);
00119             bool set_qlp_coeff_precision(unsigned value);
00120             bool set_do_qlp_coeff_prec_search(bool value);
00121             bool set_do_escape_coding(bool value);
00122             bool set_do_exhaustive_model_search(bool value);
00123             bool set_min_residual_partition_order(unsigned value);
00124             bool set_max_residual_partition_order(unsigned value);
00125             bool set_rice_parameter_search_dist(unsigned value);
00126             bool set_total_samples_estimate(FLAC__uint64 value);
00127             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00128 
00129             State    get_state() const;
00130             Decoder::Stream::State get_verify_decoder_state() const;
00131             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00132             bool     get_verify() const;
00133             bool     get_streamable_subset() const;
00134             bool     get_do_mid_side_stereo() const;
00135             bool     get_loose_mid_side_stereo() const;
00136             unsigned get_channels() const;
00137             unsigned get_bits_per_sample() const;
00138             unsigned get_sample_rate() const;
00139             unsigned get_blocksize() const;
00140             unsigned get_max_lpc_order() const;
00141             unsigned get_qlp_coeff_precision() const;
00142             bool     get_do_qlp_coeff_prec_search() const;
00143             bool     get_do_escape_coding() const;
00144             bool     get_do_exhaustive_model_search() const;
00145             unsigned get_min_residual_partition_order() const;
00146             unsigned get_max_residual_partition_order() const;
00147             unsigned get_rice_parameter_search_dist() const;
00148             FLAC__uint64 get_total_samples_estimate() const;
00149 
00150             State init();
00151 
00152             void finish();
00153 
00154             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00155             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00156         protected:
00157             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00158             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00159 
00160             ::FLAC__StreamEncoder *encoder_;
00161         private:
00162             static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00163             static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00164 
00165             // Private and undefined so you can't use them:
00166             Stream(const Stream &);
00167             void operator=(const Stream &);
00168         };
00169 
00170         /* \} */
00171 
00185         class FLACPP_API SeekableStream {
00186         public:
00187             class FLACPP_API State {
00188             public:
00189                 inline State(::FLAC__SeekableStreamEncoderState state): state_(state) { }
00190                 inline operator ::FLAC__SeekableStreamEncoderState() const { return state_; }
00191                 inline const char *as_cstring() const { return ::FLAC__SeekableStreamEncoderStateString[state_]; }
00192                 inline const char *resolved_as_cstring(const SeekableStream &encoder) const { return ::FLAC__seekable_stream_encoder_get_resolved_state_string(encoder.encoder_); }
00193             protected:
00194                 ::FLAC__SeekableStreamEncoderState state_;
00195             };
00196 
00197             SeekableStream();
00198             virtual ~SeekableStream();
00199 
00200             bool is_valid() const;
00201             inline operator bool() const { return is_valid(); }
00202 
00203             bool set_verify(bool value);
00204             bool set_streamable_subset(bool value);
00205             bool set_do_mid_side_stereo(bool value);
00206             bool set_loose_mid_side_stereo(bool value);
00207             bool set_channels(unsigned value);
00208             bool set_bits_per_sample(unsigned value);
00209             bool set_sample_rate(unsigned value);
00210             bool set_blocksize(unsigned value);
00211             bool set_max_lpc_order(unsigned value);
00212             bool set_qlp_coeff_precision(unsigned value);
00213             bool set_do_qlp_coeff_prec_search(bool value);
00214             bool set_do_escape_coding(bool value);
00215             bool set_do_exhaustive_model_search(bool value);
00216             bool set_min_residual_partition_order(unsigned value);
00217             bool set_max_residual_partition_order(unsigned value);
00218             bool set_rice_parameter_search_dist(unsigned value);
00219             bool set_total_samples_estimate(FLAC__uint64 value);
00220             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00221 
00222             State    get_state() const;
00223             Stream::State get_stream_encoder_state() const;
00224             Decoder::Stream::State get_verify_decoder_state() const;
00225             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00226             bool     get_verify() const;
00227             bool     get_streamable_subset() const;
00228             bool     get_do_mid_side_stereo() const;
00229             bool     get_loose_mid_side_stereo() const;
00230             unsigned get_channels() const;
00231             unsigned get_bits_per_sample() const;
00232             unsigned get_sample_rate() const;
00233             unsigned get_blocksize() const;
00234             unsigned get_max_lpc_order() const;
00235             unsigned get_qlp_coeff_precision() const;
00236             bool     get_do_qlp_coeff_prec_search() const;
00237             bool     get_do_escape_coding() const;
00238             bool     get_do_exhaustive_model_search() const;
00239             unsigned get_min_residual_partition_order() const;
00240             unsigned get_max_residual_partition_order() const;
00241             unsigned get_rice_parameter_search_dist() const;
00242             FLAC__uint64 get_total_samples_estimate() const;
00243 
00244             State init();
00245 
00246             void finish();
00247 
00248             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00249             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00250         protected:
00251             virtual ::FLAC__SeekableStreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00252             virtual ::FLAC__SeekableStreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset) = 0;
00253             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00254 
00255             ::FLAC__SeekableStreamEncoder *encoder_;
00256         private:
00257             static ::FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00258             static ::FLAC__SeekableStreamEncoderTellStatus tell_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00259             static ::FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00260 
00261             // Private and undefined so you can't use them:
00262             SeekableStream(const SeekableStream &);
00263             void operator=(const SeekableStream &);
00264         };
00265 
00266         /* \} */
00267 
00281         class FLACPP_API File {
00282         public:
00283             class FLACPP_API State {
00284             public:
00285                 inline State(::FLAC__FileEncoderState state): state_(state) { }
00286                 inline operator ::FLAC__FileEncoderState() const { return state_; }
00287                 inline const char *as_cstring() const { return ::FLAC__FileEncoderStateString[state_]; }
00288                 inline const char *resolved_as_cstring(const File &encoder) const { return ::FLAC__file_encoder_get_resolved_state_string(encoder.encoder_); }
00289             protected:
00290                 ::FLAC__FileEncoderState state_;
00291             };
00292 
00293             File();
00294             virtual ~File();
00295 
00296             bool is_valid() const;
00297             inline operator bool() const { return is_valid(); }
00298 
00299             bool set_verify(bool value);
00300             bool set_streamable_subset(bool value);
00301             bool set_do_mid_side_stereo(bool value);
00302             bool set_loose_mid_side_stereo(bool value);
00303             bool set_channels(unsigned value);
00304             bool set_bits_per_sample(unsigned value);
00305             bool set_sample_rate(unsigned value);
00306             bool set_blocksize(unsigned value);
00307             bool set_max_lpc_order(unsigned value);
00308             bool set_qlp_coeff_precision(unsigned value);
00309             bool set_do_qlp_coeff_prec_search(bool value);
00310             bool set_do_escape_coding(bool value);
00311             bool set_do_exhaustive_model_search(bool value);
00312             bool set_min_residual_partition_order(unsigned value);
00313             bool set_max_residual_partition_order(unsigned value);
00314             bool set_rice_parameter_search_dist(unsigned value);
00315             bool set_total_samples_estimate(FLAC__uint64 value);
00316             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00317             bool set_filename(const char *value);
00318 
00319             State    get_state() const;
00320             SeekableStream::State get_seekable_stream_encoder_state() const;
00321             Stream::State get_stream_encoder_state() const;
00322             Decoder::Stream::State get_verify_decoder_state() const;
00323             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00324             bool     get_verify() const;
00325             bool     get_streamable_subset() const;
00326             bool     get_do_mid_side_stereo() const;
00327             bool     get_loose_mid_side_stereo() const;
00328             unsigned get_channels() const;
00329             unsigned get_bits_per_sample() const;
00330             unsigned get_sample_rate() const;
00331             unsigned get_blocksize() const;
00332             unsigned get_max_lpc_order() const;
00333             unsigned get_qlp_coeff_precision() const;
00334             bool     get_do_qlp_coeff_prec_search() const;
00335             bool     get_do_escape_coding() const;
00336             bool     get_do_exhaustive_model_search() const;
00337             unsigned get_min_residual_partition_order() const;
00338             unsigned get_max_residual_partition_order() const;
00339             unsigned get_rice_parameter_search_dist() const;
00340             FLAC__uint64 get_total_samples_estimate() const;
00341 
00342             State init();
00343 
00344             void finish();
00345 
00346             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00347             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00348         protected:
00349             virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
00350 
00351             ::FLAC__FileEncoder *encoder_;
00352         private:
00353             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);
00354 
00355             // Private and undefined so you can't use them:
00356             File(const Stream &);
00357             void operator=(const Stream &);
00358         };
00359 
00360         /* \} */
00361 
00362     };
00363 };
00364 
00365 #endif

Generated on Fri Oct 3 00:07:09 2003 for FLAC by doxygen1.3