00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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
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
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
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
00356 File(const Stream &);
00357 void operator=(const Stream &);
00358 };
00359
00360
00361
00362 };
00363 };
00364
00365 #endif