*
***********************************************************************/
+static void stream_encoder_set_defaults_(FLAC__StreamEncoder *encoder);
static FLAC__bool stream_encoder_resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_size);
static FLAC__bool stream_encoder_process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_frame);
static FLAC__bool stream_encoder_process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_frame);
return 0;
}
- encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED;
-
- encoder->protected_->streamable_subset = true;
- encoder->protected_->do_mid_side_stereo = false;
- encoder->protected_->loose_mid_side_stereo = false;
- encoder->protected_->channels = 2;
- encoder->protected_->bits_per_sample = 16;
- encoder->protected_->sample_rate = 44100;
- encoder->protected_->blocksize = 1152;
- encoder->protected_->max_lpc_order = 0;
- encoder->protected_->qlp_coeff_precision = 0;
- encoder->protected_->do_qlp_coeff_prec_search = false;
- encoder->protected_->do_exhaustive_model_search = false;
- encoder->protected_->do_escape_coding = false;
- encoder->protected_->min_residual_partition_order = 0;
- encoder->protected_->max_residual_partition_order = 0;
- encoder->protected_->rice_parameter_search_dist = 0;
- encoder->protected_->total_samples_estimate = 0;
- encoder->protected_->metadata = 0;
- encoder->protected_->num_metadata_blocks = 0;
+ stream_encoder_set_defaults_(encoder);
- encoder->private_->write_callback = 0;
- encoder->private_->metadata_callback = 0;
- encoder->private_->client_data = 0;
+ encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED;
return encoder;
}
}
FLAC__bitbuffer_free(encoder->private_->frame);
+ stream_encoder_set_defaults_(encoder);
+
encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED;
}
FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->streamable_subset = value;
FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->do_mid_side_stereo = value;
FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->loose_mid_side_stereo = value;
FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->channels = value;
FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->bits_per_sample = value;
FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->sample_rate = value;
FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->blocksize = value;
FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->max_lpc_order = value;
FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->qlp_coeff_precision = value;
FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(FLAC__StreamEncoder *encoder, FLAC__bool value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->do_qlp_coeff_prec_search = value;
FLAC__bool FLAC__stream_encoder_set_do_escape_coding(FLAC__StreamEncoder *encoder, FLAC__bool value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->do_escape_coding = value;
FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__StreamEncoder *encoder, FLAC__bool value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->do_exhaustive_model_search = value;
FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->min_residual_partition_order = value;
FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->max_residual_partition_order = value;
FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->rice_parameter_search_dist = value;
FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->total_samples_estimate = value;
FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->protected_->metadata = metadata;
FLAC__bool FLAC__stream_encoder_set_write_callback(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteStatus (*value)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data))
{
+ FLAC__ASSERT(0 != encoder);
+ FLAC__ASSERT(0 != value);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->private_->write_callback = value;
FLAC__bool FLAC__stream_encoder_set_metadata_callback(FLAC__StreamEncoder *encoder, void (*value)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data))
{
+ FLAC__ASSERT(0 != encoder);
+ FLAC__ASSERT(0 != value);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->private_->metadata_callback = value;
FLAC__bool FLAC__stream_encoder_set_client_data(FLAC__StreamEncoder *encoder, void *value)
{
+ FLAC__ASSERT(0 != encoder);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
encoder->private_->client_data = value;
FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->state;
}
FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->streamable_subset;
}
FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->do_mid_side_stereo;
}
FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->loose_mid_side_stereo;
}
unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->channels;
}
unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->bits_per_sample;
}
unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->sample_rate;
}
unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->blocksize;
}
unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->max_lpc_order;
}
unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->qlp_coeff_precision;
}
FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->do_qlp_coeff_prec_search;
}
FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->do_escape_coding;
}
FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->do_exhaustive_model_search;
}
unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->min_residual_partition_order;
}
unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->max_residual_partition_order;
}
unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder)
{
+ FLAC__ASSERT(0 != encoder);
return encoder->protected_->rice_parameter_search_dist;
}
return true;
}
+void stream_encoder_set_defaults_(FLAC__StreamEncoder *encoder)
+{
+ FLAC__ASSERT(0 != encoder);
+
+ encoder->protected_->streamable_subset = true;
+ encoder->protected_->do_mid_side_stereo = false;
+ encoder->protected_->loose_mid_side_stereo = false;
+ encoder->protected_->channels = 2;
+ encoder->protected_->bits_per_sample = 16;
+ encoder->protected_->sample_rate = 44100;
+ encoder->protected_->blocksize = 1152;
+ encoder->protected_->max_lpc_order = 0;
+ encoder->protected_->qlp_coeff_precision = 0;
+ encoder->protected_->do_qlp_coeff_prec_search = false;
+ encoder->protected_->do_exhaustive_model_search = false;
+ encoder->protected_->do_escape_coding = false;
+ encoder->protected_->min_residual_partition_order = 0;
+ encoder->protected_->max_residual_partition_order = 0;
+ encoder->protected_->rice_parameter_search_dist = 0;
+ encoder->protected_->total_samples_estimate = 0;
+ encoder->protected_->metadata = 0;
+ encoder->protected_->num_metadata_blocks = 0;
+
+ encoder->private_->write_callback = 0;
+ encoder->private_->metadata_callback = 0;
+ encoder->private_->client_data = 0;
+}
+
FLAC__bool stream_encoder_resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_size)
{
FLAC__bool ok;