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 OggFLACPP__ENCODER_H
00033 #define OggFLACPP__ENCODER_H
00034
00035 #include "export.h"
00036
00037 #include "OggFLAC/file_encoder.h"
00038 #include "OggFLAC/seekable_stream_encoder.h"
00039 #include "OggFLAC/stream_encoder.h"
00040 #include "decoder.h"
00041
00042 #include "FLAC++/decoder.h"
00043 #include "FLAC++/encoder.h"
00044
00045
00073 namespace OggFLAC {
00074 namespace Encoder {
00075
00076
00077
00078
00079
00080
00081
00095 class OggFLACPP_API Stream {
00096 public:
00097 class OggFLACPP_API State {
00098 public:
00099 inline State(::OggFLAC__StreamEncoderState state): state_(state) { }
00100 inline operator ::OggFLAC__StreamEncoderState() const { return state_; }
00101 inline const char *as_cstring() const { return ::OggFLAC__StreamEncoderStateString[state_]; }
00102 inline const char *resolved_as_cstring(const Stream &encoder) const { return ::OggFLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); }
00103 protected:
00104 ::OggFLAC__StreamEncoderState state_;
00105 };
00106
00107 Stream();
00108 virtual ~Stream();
00109
00110 bool is_valid() const;
00111 inline operator bool() const { return is_valid(); }
00112
00113 bool set_serial_number(long value);
00114 bool set_verify(bool value);
00115 bool set_streamable_subset(bool value);
00116 bool set_do_mid_side_stereo(bool value);
00117 bool set_loose_mid_side_stereo(bool value);
00118 bool set_channels(unsigned value);
00119 bool set_bits_per_sample(unsigned value);
00120 bool set_sample_rate(unsigned value);
00121 bool set_blocksize(unsigned value);
00122 bool set_max_lpc_order(unsigned value);
00123 bool set_qlp_coeff_precision(unsigned value);
00124 bool set_do_qlp_coeff_prec_search(bool value);
00125 bool set_do_escape_coding(bool value);
00126 bool set_do_exhaustive_model_search(bool value);
00127 bool set_min_residual_partition_order(unsigned value);
00128 bool set_max_residual_partition_order(unsigned value);
00129 bool set_rice_parameter_search_dist(unsigned value);
00130 bool set_total_samples_estimate(FLAC__uint64 value);
00131 bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00132
00133 State get_state() const;
00134 FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00135 FLAC::Decoder::Stream::State get_verify_decoder_state() const;
00136 void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00137 bool get_verify() const;
00138 bool get_streamable_subset() const;
00139 bool get_do_mid_side_stereo() const;
00140 bool get_loose_mid_side_stereo() const;
00141 unsigned get_channels() const;
00142 unsigned get_bits_per_sample() const;
00143 unsigned get_sample_rate() const;
00144 unsigned get_blocksize() const;
00145 unsigned get_max_lpc_order() const;
00146 unsigned get_qlp_coeff_precision() const;
00147 bool get_do_qlp_coeff_prec_search() const;
00148 bool get_do_escape_coding() const;
00149 bool get_do_exhaustive_model_search() const;
00150 unsigned get_min_residual_partition_order() const;
00151 unsigned get_max_residual_partition_order() const;
00152 unsigned get_rice_parameter_search_dist() const;
00153 FLAC__uint64 get_total_samples_estimate() const;
00154
00155 State init();
00156
00157 void finish();
00158
00159 bool process(const FLAC__int32 * const buffer[], unsigned samples);
00160 bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00161 protected:
00162 virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00163 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata) = 0;
00164
00165 ::OggFLAC__StreamEncoder *encoder_;
00166 private:
00167 static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00168 static void metadata_callback_(const ::OggFLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
00169
00170
00171 Stream(const Stream &);
00172 void operator=(const Stream &);
00173 };
00174
00175
00176
00190 class OggFLACPP_API SeekableStream {
00191 public:
00192 class OggFLACPP_API State {
00193 public:
00194 inline State(::OggFLAC__SeekableStreamEncoderState state): state_(state) { }
00195 inline operator ::OggFLAC__SeekableStreamEncoderState() const { return state_; }
00196 inline const char *as_cstring() const { return ::OggFLAC__SeekableStreamEncoderStateString[state_]; }
00197 inline const char *resolved_as_cstring(const SeekableStream &encoder) const { return ::OggFLAC__seekable_stream_encoder_get_resolved_state_string(encoder.encoder_); }
00198 protected:
00199 ::OggFLAC__SeekableStreamEncoderState state_;
00200 };
00201
00202 SeekableStream();
00203 virtual ~SeekableStream();
00204
00205 bool is_valid() const;
00206 inline operator bool() const { return is_valid(); }
00207
00208 bool set_serial_number(long value);
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
00228 State get_state() const;
00229 FLAC::Encoder::SeekableStream::State get_FLAC_seekable_stream_encoder_state() const;
00230 FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00231 FLAC::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 ::OggFLAC__SeekableStreamEncoder *encoder_;
00263 private:
00264 static ::FLAC__SeekableStreamEncoderSeekStatus seek_callback_(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
00265 static ::FLAC__SeekableStreamEncoderTellStatus tell_callback_(const OggFLAC__SeekableStreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
00266 static ::FLAC__StreamEncoderWriteStatus write_callback_(const OggFLAC__SeekableStreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00267
00268
00269 SeekableStream(const SeekableStream &);
00270 void operator=(const SeekableStream &);
00271 };
00272
00273
00274
00288 class OggFLACPP_API File {
00289 public:
00290 class OggFLACPP_API State {
00291 public:
00292 inline State(::OggFLAC__FileEncoderState state): state_(state) { }
00293 inline operator ::OggFLAC__FileEncoderState() const { return state_; }
00294 inline const char *as_cstring() const { return ::OggFLAC__FileEncoderStateString[state_]; }
00295 inline const char *resolved_as_cstring(const File &encoder) const { return ::OggFLAC__file_encoder_get_resolved_state_string(encoder.encoder_); }
00296 protected:
00297 ::OggFLAC__FileEncoderState state_;
00298 };
00299
00300 File();
00301 virtual ~File();
00302
00303 bool is_valid() const;
00304 inline operator bool() const { return is_valid(); }
00305
00306 bool set_serial_number(long value);
00307 bool set_verify(bool value);
00308 bool set_streamable_subset(bool value);
00309 bool set_do_mid_side_stereo(bool value);
00310 bool set_loose_mid_side_stereo(bool value);
00311 bool set_channels(unsigned value);
00312 bool set_bits_per_sample(unsigned value);
00313 bool set_sample_rate(unsigned value);
00314 bool set_blocksize(unsigned value);
00315 bool set_max_lpc_order(unsigned value);
00316 bool set_qlp_coeff_precision(unsigned value);
00317 bool set_do_qlp_coeff_prec_search(bool value);
00318 bool set_do_escape_coding(bool value);
00319 bool set_do_exhaustive_model_search(bool value);
00320 bool set_min_residual_partition_order(unsigned value);
00321 bool set_max_residual_partition_order(unsigned value);
00322 bool set_rice_parameter_search_dist(unsigned value);
00323 bool set_total_samples_estimate(FLAC__uint64 value);
00324 bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00325 bool set_filename(const char *value);
00326
00327 State get_state() const;
00328 SeekableStream::State get_seekable_stream_encoder_state() const;
00329 FLAC::Encoder::SeekableStream::State get_FLAC_seekable_stream_encoder_state() const;
00330 FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00331 FLAC::Decoder::Stream::State get_verify_decoder_state() const;
00332 void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00333 bool get_verify() const;
00334 bool get_streamable_subset() const;
00335 bool get_do_mid_side_stereo() const;
00336 bool get_loose_mid_side_stereo() const;
00337 unsigned get_channels() const;
00338 unsigned get_bits_per_sample() const;
00339 unsigned get_sample_rate() const;
00340 unsigned get_blocksize() const;
00341 unsigned get_max_lpc_order() const;
00342 unsigned get_qlp_coeff_precision() const;
00343 bool get_do_qlp_coeff_prec_search() const;
00344 bool get_do_escape_coding() const;
00345 bool get_do_exhaustive_model_search() const;
00346 unsigned get_min_residual_partition_order() const;
00347 unsigned get_max_residual_partition_order() const;
00348 unsigned get_rice_parameter_search_dist() const;
00349 FLAC__uint64 get_total_samples_estimate() const;
00350
00351 State init();
00352
00353 void finish();
00354
00355 bool process(const FLAC__int32 * const buffer[], unsigned samples);
00356 bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00357 protected:
00358 virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
00359
00360 ::OggFLAC__FileEncoder *encoder_;
00361 private:
00362 static void progress_callback_(const ::OggFLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
00363
00364
00365 File(const Stream &);
00366 void operator=(const Stream &);
00367 };
00368
00369
00370
00371 };
00372 };
00373
00374 #endif