FLAC 1.3.3

encoder.h
Go to the documentation of this file.
1 /* libFLAC++ - Free Lossless Audio Codec library
2 * Copyright (C) 2002-2009 Josh Coalson
3 * Copyright (C) 2011-2016 Xiph.Org Foundation
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of the Xiph.org Foundation nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef FLACPP__ENCODER_H
34 #define FLACPP__ENCODER_H
35
36 #include "export.h"
37
38 #include "FLAC/stream_encoder.h"
39 #include "decoder.h"
40 #include "metadata.h"
41
42
79 namespace FLAC {
80 namespace Encoder {
81
102 class FLACPP_API Stream {
103 public:
106 class FLACPP_API State {
107 public:
108 inline State(::FLAC__StreamEncoderState state): state_(state) { }
109 inline operator ::FLAC__StreamEncoderState() const { return state_; }
110 inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; }
111 inline const char *resolved_as_cstring(const Stream &encoder) const { return ::FLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); }
112 protected:
113 ::FLAC__StreamEncoderState state_;
114 };
115
116 Stream();
117 virtual ~Stream();
118
120
124 virtual bool is_valid() const;
125 inline operator bool() const { return is_valid(); }
126
127
128 virtual bool set_ogg_serial_number(long value);
129 virtual bool set_verify(bool value);
130 virtual bool set_streamable_subset(bool value);
131 virtual bool set_channels(uint32_t value);
132 virtual bool set_bits_per_sample(uint32_t value);
133 virtual bool set_sample_rate(uint32_t value);
134 virtual bool set_compression_level(uint32_t value);
135 virtual bool set_blocksize(uint32_t value);
136 virtual bool set_do_mid_side_stereo(bool value);
137 virtual bool set_loose_mid_side_stereo(bool value);
138 virtual bool set_apodization(const char *specification);
139 virtual bool set_max_lpc_order(uint32_t value);
140 virtual bool set_qlp_coeff_precision(uint32_t value);
141 virtual bool set_do_qlp_coeff_prec_search(bool value);
142 virtual bool set_do_escape_coding(bool value);
143 virtual bool set_do_exhaustive_model_search(bool value);
144 virtual bool set_min_residual_partition_order(uint32_t value);
145 virtual bool set_max_residual_partition_order(uint32_t value);
146 virtual bool set_rice_parameter_search_dist(uint32_t value);
147 virtual bool set_total_samples_estimate(FLAC__uint64 value);
148 virtual bool set_metadata(::FLAC__StreamMetadata **metadata, uint32_t num_blocks);
149 virtual bool set_metadata(FLAC::Metadata::Prototype **metadata, uint32_t num_blocks);
150
151 /* get_state() is not virtual since we want subclasses to be able to return their own state */
152 State get_state() const;
153 virtual Decoder::Stream::State get_verify_decoder_state() const;
154 virtual void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got);
155 virtual bool get_verify() const;
156 virtual bool get_streamable_subset() const;
157 virtual bool get_do_mid_side_stereo() const;
158 virtual bool get_loose_mid_side_stereo() const;
159 virtual uint32_t get_channels() const;
160 virtual uint32_t get_bits_per_sample() const;
161 virtual uint32_t get_sample_rate() const;
162 virtual uint32_t get_blocksize() const;
163 virtual uint32_t get_max_lpc_order() const;
164 virtual uint32_t get_qlp_coeff_precision() const;
165 virtual bool get_do_qlp_coeff_prec_search() const;
166 virtual bool get_do_escape_coding() const;
167 virtual bool get_do_exhaustive_model_search() const;
168 virtual uint32_t get_min_residual_partition_order() const;
169 virtual uint32_t get_max_residual_partition_order() const;
170 virtual uint32_t get_rice_parameter_search_dist() const;
171 virtual FLAC__uint64 get_total_samples_estimate() const;
172
173 virtual ::FLAC__StreamEncoderInitStatus init();
174 virtual ::FLAC__StreamEncoderInitStatus init_ogg();
175
176 virtual bool finish();
177
178 virtual bool process(const FLAC__int32 * const buffer[], uint32_t samples);
179 virtual bool process_interleaved(const FLAC__int32 buffer[], uint32_t samples);
180 protected:
182 virtual ::FLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
183
185 virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame) = 0;
186
188 virtual ::FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
189
191 virtual ::FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
192
194 virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
195
196 #if (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
197 // lame hack: some compilers can't see a protected encoder_ from nested State::resolved_as_cstring()
198 friend State;
199 #endif
200 ::FLAC__StreamEncoder *encoder_;
201
202 static ::FLAC__StreamEncoderReadStatus read_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
203 static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data);
204 static ::FLAC__StreamEncoderSeekStatus seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
205 static ::FLAC__StreamEncoderTellStatus tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
206 static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
207 private:
208 // Private and undefined so you can't use them:
209 Stream(const Stream &);
210 void operator=(const Stream &);
211 };
212
233 class FLACPP_API File: public Stream {
234 public:
235 File();
236 virtual ~File();
237
238 using Stream::init;
239 virtual ::FLAC__StreamEncoderInitStatus init(FILE *file);
240 virtual ::FLAC__StreamEncoderInitStatus init(const char *filename);
241 virtual ::FLAC__StreamEncoderInitStatus init(const std::string &filename);
242 using Stream::init_ogg;
243 virtual ::FLAC__StreamEncoderInitStatus init_ogg(FILE *file);
244 virtual ::FLAC__StreamEncoderInitStatus init_ogg(const char *filename);
245 virtual ::FLAC__StreamEncoderInitStatus init_ogg(const std::string &filename);
246 protected:
248 virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate);
249
251 virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame);
252 private:
253 static void progress_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data);
254
255 // Private and undefined so you can't use them:
256 File(const Stream &);
257 void operator=(const Stream &);
258 };
259
260 }
261 }
262
263 #endif
stream_encoder.h
This module contains the functions which implement the stream encoder.
FLAC::Encoder::Stream::State
Definition: encoder.h:106
FLAC::Encoder::Stream
This class wraps the FLAC__StreamEncoder. If you are encoding to a file, FLAC::Encoder::File may be m...
Definition: encoder.h:102
FLAC__StreamEncoderTellStatus
FLAC__StreamEncoderTellStatus
Definition: stream_encoder.h:432
FLAC
Definition: decoder.h:78
FLAC__StreamEncoderSeekStatus
FLAC__StreamEncoderSeekStatus
Definition: stream_encoder.h:409
metadata.h
This module provides classes for creating and manipulating FLAC metadata blocks in memory...
FLAC__StreamEncoderReadStatus
FLAC__StreamEncoderReadStatus
Definition: stream_encoder.h:363
FLAC__StreamEncoderState
FLAC__StreamEncoderState
Definition: stream_encoder.h:241
FLAC::Encoder::Stream::init
virtual ::FLAC__StreamEncoderInitStatus init()
See FLAC__stream_encoder_init_stream()
FLAC__stream_encoder_get_resolved_state_string
const char * FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder)
export.h
This module contains #defines and symbols for exporting function calls, and providing version informa...
FLAC__StreamMetadata
Definition: format.h:834
FLAC::Encoder::File
This class wraps the FLAC__StreamEncoder. If you are not encoding to a file, you may need to use FLAC...
Definition: encoder.h:233
decoder.h
This module contains the classes which implement the various decoders.
FLAC__StreamEncoderInitStatus
FLAC__StreamEncoderInitStatus
Definition: stream_encoder.h:293
FLAC__StreamEncoderWriteStatus
FLAC__StreamEncoderWriteStatus
Definition: stream_encoder.h:389
FLAC::Metadata::Prototype
Definition: metadata.h:109
FLAC::Decoder::Stream::State
Definition: decoder.h:104
FLAC::Encoder::Stream::init_ogg
virtual ::FLAC__StreamEncoderInitStatus init_ogg()
See FLAC__stream_encoder_init_ogg_stream()
FLAC__StreamEncoder
Definition: stream_encoder.h:465
FLAC__StreamEncoderStateString
const char *const FLAC__StreamEncoderStateString[]

Copyright (c) 2000-2009 Josh Coalson Copyright (c) 2011-2016 Xiph.Org Foundation |