mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
add total sample estimation
This commit is contained in:
@@ -66,6 +66,7 @@ typedef struct {
|
|||||||
bool do_qlp_coeff_prec_search; /* 0 => use qlp_coeff_precision, 1 => search around qlp_coeff_precision, take best */
|
bool do_qlp_coeff_prec_search; /* 0 => use qlp_coeff_precision, 1 => search around qlp_coeff_precision, take best */
|
||||||
bool do_exhaustive_model_search; /* 0 => use estimated bits per residual for scoring, 1 => generate all, take shortest */
|
bool do_exhaustive_model_search; /* 0 => use estimated bits per residual for scoring, 1 => generate all, take shortest */
|
||||||
unsigned rice_optimization_level; /* 0 => estimate Rice parameter based on residual variance, 1-8 => partition residual, use parameter for each */
|
unsigned rice_optimization_level; /* 0 => estimate Rice parameter based on residual variance, 1-8 => partition residual, use parameter for each */
|
||||||
|
uint64 total_samples_estimate; /* may be 0 if unknown. this will be a placeholder in the metadata block until the actual total is calculated */
|
||||||
} FLAC__Encoder;
|
} FLAC__Encoder;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ FLAC__EncoderState FLAC__encoder_init(FLAC__Encoder *encoder, FLAC__EncoderWrite
|
|||||||
encoder->guts->metadata.data.encoding.sample_rate = encoder->sample_rate;
|
encoder->guts->metadata.data.encoding.sample_rate = encoder->sample_rate;
|
||||||
encoder->guts->metadata.data.encoding.channels = encoder->channels;
|
encoder->guts->metadata.data.encoding.channels = encoder->channels;
|
||||||
encoder->guts->metadata.data.encoding.bits_per_sample = encoder->bits_per_sample;
|
encoder->guts->metadata.data.encoding.bits_per_sample = encoder->bits_per_sample;
|
||||||
encoder->guts->metadata.data.encoding.total_samples = 0; /* we don't know this yet; have to fill it in later */
|
encoder->guts->metadata.data.encoding.total_samples = encoder->total_samples_estimate; /* we will replace this later with the real total */
|
||||||
memset(encoder->guts->metadata.data.encoding.md5sum, 0, 16); /* we don't know this yet; have to fill it in later */
|
memset(encoder->guts->metadata.data.encoding.md5sum, 0, 16); /* we don't know this yet; have to fill it in later */
|
||||||
MD5Init(&encoder->guts->md5context);
|
MD5Init(&encoder->guts->md5context);
|
||||||
if(!FLAC__add_metadata_block(&encoder->guts->metadata, &encoder->guts->frame))
|
if(!FLAC__add_metadata_block(&encoder->guts->metadata, &encoder->guts->frame))
|
||||||
@@ -354,8 +354,10 @@ FLAC__EncoderState FLAC__encoder_init(FLAC__Encoder *encoder, FLAC__EncoderWrite
|
|||||||
if(encoder->guts->write_callback(encoder, encoder->guts->frame.buffer, encoder->guts->frame.bytes, 0, encoder->guts->current_frame_number, encoder->guts->client_data) != FLAC__ENCODER_WRITE_OK)
|
if(encoder->guts->write_callback(encoder, encoder->guts->frame.buffer, encoder->guts->frame.bytes, 0, encoder->guts->current_frame_number, encoder->guts->client_data) != FLAC__ENCODER_WRITE_OK)
|
||||||
return encoder->state = FLAC__ENCODER_FATAL_ERROR_WHILE_WRITING;
|
return encoder->state = FLAC__ENCODER_FATAL_ERROR_WHILE_WRITING;
|
||||||
|
|
||||||
/* now that the metadata block is written, we can init this to an absurdly-high value */
|
/* now that the metadata block is written, we can init this to an absurdly-high value... */
|
||||||
encoder->guts->metadata.data.encoding.min_framesize = (1u << FLAC__STREAM_METADATA_ENCODING_MIN_FRAME_SIZE_LEN) - 1;
|
encoder->guts->metadata.data.encoding.min_framesize = (1u << FLAC__STREAM_METADATA_ENCODING_MIN_FRAME_SIZE_LEN) - 1;
|
||||||
|
/* ... and clear this to 0 */
|
||||||
|
encoder->guts->metadata.data.encoding.total_samples = 0;
|
||||||
|
|
||||||
return encoder->state;
|
return encoder->state;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user