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  Josh Coalson
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef FLACPP__ENCODER_H
00021 #define FLACPP__ENCODER_H
00022 
00023 #include "FLAC/file_encoder.h"
00024 #include "FLAC/seekable_stream_encoder.h"
00025 #include "FLAC/stream_encoder.h"
00026 #include "decoder.h"
00027 
00028 
00056 namespace FLAC {
00057     namespace Encoder {
00058 
00059         // ============================================================
00060         //
00061         //  Equivalent: FLAC__StreamEncoder
00062         //
00063         // ============================================================
00064 
00078         class Stream {
00079         public:
00080             class State {
00081             public:
00082                 inline State(::FLAC__StreamEncoderState state): state_(state) { }
00083                 inline operator ::FLAC__StreamEncoderState() const { return state_; }
00084                 inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; }
00085                 const char *resolved_as_cstring(const Stream &) const;
00086             protected:
00087                 ::FLAC__StreamEncoderState state_;
00088             };
00089 
00090             Stream();
00091             virtual ~Stream();
00092 
00093             bool is_valid() const;
00094             inline operator bool() const { return is_valid(); }
00095 
00096             bool set_verify(bool value);
00097             bool set_streamable_subset(bool value);
00098             bool set_do_mid_side_stereo(bool value);
00099             bool set_loose_mid_side_stereo(bool value);
00100             bool set_channels(unsigned value);
00101             bool set_bits_per_sample(unsigned value);
00102             bool set_sample_rate(unsigned value);
00103             bool set_blocksize(unsigned value);
00104             bool set_max_lpc_order(unsigned value);
00105             bool set_qlp_coeff_precision(unsigned value);
00106             bool set_do_qlp_coeff_prec_search(bool value);
00107             bool set_do_escape_coding(bool value);
00108             bool set_do_exhaustive_model_search(bool value);
00109             bool set_min_residual_partition_order(unsigned value);
00110             bool set_max_residual_partition_order(unsigned value);
00111             bool set_rice_parameter_search_dist(unsigned value);
00112             bool set_total_samples_estimate(FLAC__uint64 value);
00113             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00114 
00115             State    get_state() const;
00116             Decoder::Stream::State get_verify_decoder_state() const;
00117             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00118             bool     get_verify() const;
00119             bool     get_streamable_subset() const;
00120             bool     get_do_mid_side_stereo() const;
00121             bool     get_loose_mid_side_stereo() const;
00122             unsigned get_channels() const;
00123             unsigned get_bits_per_sample() const;
00124             unsigned get_sample_rate() const;
00125             unsigned get_blocksize() const;
00126             unsigned get_max_lpc_order() const;
00127             unsigned get_qlp_coeff_precision() const;
00128             bool     get_do_qlp_coeff_prec_search() const;
00129             bool     get_do_escape_coding() const;
00130             bool     get_do_exhaustive_model_search() const;
00131             unsigned get_min_residual_partition_order() const;
00132             unsigned get_max_residual_partition_order() const;
00133             unsigned get_rice_parameter_search_dist() const;
00134             FLAC__uint64 get_total_samples_estimate() const;
00135 
00136             State init();
00137 
00138             void finish();
00139 
00140             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00141             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00142         protected:
00143             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00144             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00145 
00146             ::FLAC__StreamEncoder *encoder_;
00147         private:
00148             static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00149             static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00150 
00151             // Private and undefined so you can't use them:
00152             Stream(const Stream &);
00153             void operator=(const Stream &);
00154         };
00155 
00156         /* \} */
00157 
00171         class SeekableStream {
00172         public:
00173             class State {
00174             public:
00175                 inline State(::FLAC__SeekableStreamEncoderState state): state_(state) { }
00176                 inline operator ::FLAC__SeekableStreamEncoderState() const { return state_; }
00177                 inline const char *as_cstring() const { return ::FLAC__SeekableStreamEncoderStateString[state_]; }
00178                 const char *resolved_as_cstring(const SeekableStream &) const;
00179             protected:
00180                 ::FLAC__SeekableStreamEncoderState state_;
00181             };
00182 
00183             SeekableStream();
00184             virtual ~SeekableStream();
00185 
00186             bool is_valid() const;
00187             inline operator bool() const { return is_valid(); }
00188 
00189             bool set_verify(bool value);
00190             bool set_streamable_subset(bool value);
00191             bool set_do_mid_side_stereo(bool value);
00192             bool set_loose_mid_side_stereo(bool value);
00193             bool set_channels(unsigned value);
00194             bool set_bits_per_sample(unsigned value);
00195             bool set_sample_rate(unsigned value);
00196             bool set_blocksize(unsigned value);
00197             bool set_max_lpc_order(unsigned value);
00198             bool set_qlp_coeff_precision(unsigned value);
00199             bool set_do_qlp_coeff_prec_search(bool value);
00200             bool set_do_escape_coding(bool value);
00201             bool set_do_exhaustive_model_search(bool value);
00202             bool set_min_residual_partition_order(unsigned value);
00203             bool set_max_residual_partition_order(unsigned value);
00204             bool set_rice_parameter_search_dist(unsigned value);
00205             bool set_total_samples_estimate(FLAC__uint64 value);
00206             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00207 
00208             State    get_state() const;
00209             Stream::State get_stream_encoder_state() const;
00210             Decoder::Stream::State get_verify_decoder_state() const;
00211             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00212             bool     get_verify() const;
00213             bool     get_streamable_subset() const;
00214             bool     get_do_mid_side_stereo() const;
00215             bool     get_loose_mid_side_stereo() const;
00216             unsigned get_channels() const;
00217             unsigned get_bits_per_sample() const;
00218             unsigned get_sample_rate() const;
00219             unsigned get_blocksize() const;
00220             unsigned get_max_lpc_order() const;
00221             unsigned get_qlp_coeff_precision() const;
00222             bool     get_do_qlp_coeff_prec_search() const;
00223             bool     get_do_escape_coding() const;
00224             bool     get_do_exhaustive_model_search() const;
00225             unsigned get_min_residual_partition_order() const;
00226             unsigned get_max_residual_partition_order() const;
00227             unsigned get_rice_parameter_search_dist() const;
00228             FLAC__uint64 get_total_samples_estimate() const;
00229 
00230             State init();
00231 
00232             void finish();
00233 
00234             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00235             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00236         protected:
00237             virtual ::FLAC__SeekableStreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset) = 0;
00238             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00239 
00240             ::FLAC__SeekableStreamEncoder *encoder_;
00241         private:
00242             static ::FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00243             static ::FLAC__StreamEncoderWriteStatus write_callback_(const FLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00244 
00245             // Private and undefined so you can't use them:
00246             SeekableStream(const SeekableStream &);
00247             void operator=(const SeekableStream &);
00248         };
00249 
00250         /* \} */
00251 
00265         class File {
00266         public:
00267             class State {
00268             public:
00269                 inline State(::FLAC__FileEncoderState state): state_(state) { }
00270                 inline operator ::FLAC__FileEncoderState() const { return state_; }
00271                 inline const char *as_cstring() const { return ::FLAC__FileEncoderStateString[state_]; }
00272                 const char *resolved_as_cstring(const File &) const;
00273             protected:
00274                 ::FLAC__FileEncoderState state_;
00275             };
00276 
00277             File();
00278             virtual ~File();
00279 
00280             bool is_valid() const;
00281             inline operator bool() const { return is_valid(); }
00282 
00283             bool set_verify(bool value);
00284             bool set_streamable_subset(bool value);
00285             bool set_do_mid_side_stereo(bool value);
00286             bool set_loose_mid_side_stereo(bool value);
00287             bool set_channels(unsigned value);
00288             bool set_bits_per_sample(unsigned value);
00289             bool set_sample_rate(unsigned value);
00290             bool set_blocksize(unsigned value);
00291             bool set_max_lpc_order(unsigned value);
00292             bool set_qlp_coeff_precision(unsigned value);
00293             bool set_do_qlp_coeff_prec_search(bool value);
00294             bool set_do_escape_coding(bool value);
00295             bool set_do_exhaustive_model_search(bool value);
00296             bool set_min_residual_partition_order(unsigned value);
00297             bool set_max_residual_partition_order(unsigned value);
00298             bool set_rice_parameter_search_dist(unsigned value);
00299             bool set_total_samples_estimate(FLAC__uint64 value);
00300             bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00301             bool set_filename(const char *value);
00302 
00303             State    get_state() const;
00304             SeekableStream::State get_seekable_stream_encoder_state() const;
00305             Stream::State get_stream_encoder_state() const;
00306             Decoder::Stream::State get_verify_decoder_state() const;
00307             void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00308             bool     get_verify() const;
00309             bool     get_streamable_subset() const;
00310             bool     get_do_mid_side_stereo() const;
00311             bool     get_loose_mid_side_stereo() const;
00312             unsigned get_channels() const;
00313             unsigned get_bits_per_sample() const;
00314             unsigned get_sample_rate() const;
00315             unsigned get_blocksize() const;
00316             unsigned get_max_lpc_order() const;
00317             unsigned get_qlp_coeff_precision() const;
00318             bool     get_do_qlp_coeff_prec_search() const;
00319             bool     get_do_escape_coding() const;
00320             bool     get_do_exhaustive_model_search() const;
00321             unsigned get_min_residual_partition_order() const;
00322             unsigned get_max_residual_partition_order() const;
00323             unsigned get_rice_parameter_search_dist() const;
00324             FLAC__uint64 get_total_samples_estimate() const;
00325 
00326             State init();
00327 
00328             void finish();
00329 
00330             bool process(const FLAC__int32 * const buffer[], unsigned samples);
00331             bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00332         protected:
00333             virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
00334 
00335             ::FLAC__FileEncoder *encoder_;
00336         private:
00337             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);
00338 
00339             // Private and undefined so you can't use them:
00340             File(const Stream &);
00341             void operator=(const Stream &);
00342         };
00343 
00344         /* \} */
00345 
00346     };
00347 };
00348 
00349 #endif

Generated on Tue Sep 24 21:54:25 2002 for FLAC by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002