struct FLAC__FileDecoderProtected;
struct FLAC__FileDecoderPrivate;
typedef struct {
- struct FLAC__FileDecoderProtected *protected;
- struct FLAC__FileDecoderPrivate *private;
+ struct FLAC__FileDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
+ struct FLAC__FileDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
} FLAC__FileDecoder;
/***********************************************************************
struct FLAC__StreamDecoderProtected;
struct FLAC__StreamDecoderPrivate;
typedef struct {
- struct FLAC__StreamDecoderProtected *protected;
- struct FLAC__StreamDecoderPrivate *private;
+ struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
+ struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
} FLAC__StreamDecoder;
/***********************************************************************
struct FLAC__StreamEncoderProtected;
struct FLAC__StreamEncoderPrivate;
typedef struct {
- struct FLAC__StreamEncoderProtected *protected;
- struct FLAC__StreamEncoderPrivate *private;
+ struct FLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
+ struct FLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
} FLAC__StreamEncoder;
/***********************************************************************
if(decoder == 0) {
return 0;
}
- decoder->protected = (FLAC__FileDecoderProtected*)malloc(sizeof(FLAC__FileDecoderProtected));
- if(decoder->protected == 0) {
+ decoder->protected_ = (FLAC__FileDecoderProtected*)malloc(sizeof(FLAC__FileDecoderProtected));
+ if(decoder->protected_ == 0) {
free(decoder);
return 0;
}
- decoder->private = (FLAC__FileDecoderPrivate*)malloc(sizeof(FLAC__FileDecoderPrivate));
- if(decoder->private == 0) {
- free(decoder->protected);
+ decoder->private_ = (FLAC__FileDecoderPrivate*)malloc(sizeof(FLAC__FileDecoderPrivate));
+ if(decoder->private_ == 0) {
+ free(decoder->protected_);
free(decoder);
return 0;
}
- decoder->protected->state = FLAC__FILE_DECODER_UNINITIALIZED;
+ decoder->protected_->state = FLAC__FILE_DECODER_UNINITIALIZED;
- decoder->private->filename = 0;
- decoder->private->write_callback = 0;
- decoder->private->metadata_callback = 0;
- decoder->private->error_callback = 0;
- decoder->private->client_data = 0;
+ decoder->private_->filename = 0;
+ decoder->private_->write_callback = 0;
+ decoder->private_->metadata_callback = 0;
+ decoder->private_->error_callback = 0;
+ decoder->private_->client_data = 0;
return decoder;
}
void FLAC__file_decoder_delete(FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
- FLAC__ASSERT(decoder->protected != 0);
- FLAC__ASSERT(decoder->private != 0);
+ FLAC__ASSERT(decoder->protected_ != 0);
+ FLAC__ASSERT(decoder->private_ != 0);
- free(decoder->private);
- free(decoder->protected);
+ free(decoder->private_);
+ free(decoder->protected_);
free(decoder);
}
{
FLAC__ASSERT(decoder != 0);
- if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED)
- return decoder->protected->state = FLAC__FILE_DECODER_ALREADY_INITIALIZED;
+ if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
+ return decoder->protected_->state = FLAC__FILE_DECODER_ALREADY_INITIALIZED;
- decoder->protected->state = FLAC__FILE_DECODER_OK;
+ decoder->protected_->state = FLAC__FILE_DECODER_OK;
- if(0 == decoder->private->write_callback || 0 == decoder->private->metadata_callback || 0 == decoder->private->error_callback)
- return decoder->protected->state = FLAC__FILE_DECODER_INVALID_CALLBACK;
+ if(0 == decoder->private_->write_callback || 0 == decoder->private_->metadata_callback || 0 == decoder->private_->error_callback)
+ return decoder->protected_->state = FLAC__FILE_DECODER_INVALID_CALLBACK;
- decoder->private->file = 0;
- decoder->private->stream_decoder = 0;
- decoder->private->seek_table = 0;
+ decoder->private_->file = 0;
+ decoder->private_->stream_decoder = 0;
+ decoder->private_->seek_table = 0;
- if(0 == strcmp(decoder->private->filename, "-"))
- decoder->private->file = stdin;
+ if(0 == strcmp(decoder->private_->filename, "-"))
+ decoder->private_->file = stdin;
else
- decoder->private->file = fopen(decoder->private->filename, "rb");
+ decoder->private_->file = fopen(decoder->private_->filename, "rb");
- if(decoder->private->file == 0)
- return decoder->protected->state = FLAC__FILE_DECODER_ERROR_OPENING_FILE;
+ if(decoder->private_->file == 0)
+ return decoder->protected_->state = FLAC__FILE_DECODER_ERROR_OPENING_FILE;
/* We initialize the MD5Context even though we may never use it. This is
* because md5_checking may be turned on to start and then turned off if a
* FLAC__file_decoder_finish() to make sure things are always cleaned up
* properly.
*/
- MD5Init(&decoder->private->md5context);
+ MD5Init(&decoder->private_->md5context);
- decoder->private->stream_decoder = FLAC__stream_decoder_new();
+ decoder->private_->stream_decoder = FLAC__stream_decoder_new();
- FLAC__stream_decoder_set_read_callback(decoder->private->stream_decoder, read_callback_);
- FLAC__stream_decoder_set_write_callback(decoder->private->stream_decoder, write_callback_);
- FLAC__stream_decoder_set_metadata_callback(decoder->private->stream_decoder, metadata_callback_);
- FLAC__stream_decoder_set_error_callback(decoder->private->stream_decoder, error_callback_);
- FLAC__stream_decoder_set_client_data(decoder->private->stream_decoder, decoder);
+ FLAC__stream_decoder_set_read_callback(decoder->private_->stream_decoder, read_callback_);
+ FLAC__stream_decoder_set_write_callback(decoder->private_->stream_decoder, write_callback_);
+ FLAC__stream_decoder_set_metadata_callback(decoder->private_->stream_decoder, metadata_callback_);
+ FLAC__stream_decoder_set_error_callback(decoder->private_->stream_decoder, error_callback_);
+ FLAC__stream_decoder_set_client_data(decoder->private_->stream_decoder, decoder);
- if(FLAC__stream_decoder_init(decoder->private->stream_decoder) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
- return decoder->protected->state = FLAC__FILE_DECODER_STREAM_DECODER_ERROR;
+ if(FLAC__stream_decoder_init(decoder->private_->stream_decoder) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
+ return decoder->protected_->state = FLAC__FILE_DECODER_STREAM_DECODER_ERROR;
- return decoder->protected->state;
+ return decoder->protected_->state;
}
FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder)
FLAC__bool md5_failed = false;
FLAC__ASSERT(decoder != 0);
- if(decoder->protected->state == FLAC__FILE_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state == FLAC__FILE_DECODER_UNINITIALIZED)
return true;
- if(decoder->private->file != 0 && decoder->private->file != stdin)
- fclose(decoder->private->file);
- if(0 != decoder->private->filename)
- free(decoder->private->filename);
+ if(decoder->private_->file != 0 && decoder->private_->file != stdin)
+ fclose(decoder->private_->file);
+ if(0 != decoder->private_->filename)
+ free(decoder->private_->filename);
/* see the comment in FLAC__file_decoder_init() as to why we always
* call MD5Final()
*/
- MD5Final(decoder->private->computed_md5sum, &decoder->private->md5context);
- if(decoder->private->stream_decoder != 0) {
- FLAC__stream_decoder_finish(decoder->private->stream_decoder);
- FLAC__stream_decoder_delete(decoder->private->stream_decoder);
+ MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context);
+ if(decoder->private_->stream_decoder != 0) {
+ FLAC__stream_decoder_finish(decoder->private_->stream_decoder);
+ FLAC__stream_decoder_delete(decoder->private_->stream_decoder);
}
- if(decoder->protected->md5_checking) {
- if(memcmp(decoder->private->stored_md5sum, decoder->private->computed_md5sum, 16))
+ if(decoder->protected_->md5_checking) {
+ if(memcmp(decoder->private_->stored_md5sum, decoder->private_->computed_md5sum, 16))
md5_failed = true;
}
- decoder->protected->state = FLAC__FILE_DECODER_UNINITIALIZED;
+ decoder->protected_->state = FLAC__FILE_DECODER_UNINITIALIZED;
return !md5_failed;
}
FLAC__bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, FLAC__bool value)
{
- if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
- decoder->protected->md5_checking = value;
+ decoder->protected_->md5_checking = value;
return true;
}
FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value)
{
- if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
- if(0 == (decoder->private->filename = (char*)malloc(strlen(value)+1))) {
- decoder->protected->state = FLAC__FILE_DECODER_MEMORY_ALLOCATION_ERROR;
+ if(0 == (decoder->private_->filename = (char*)malloc(strlen(value)+1))) {
+ decoder->protected_->state = FLAC__FILE_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
- strcpy(decoder->private->filename, value);
+ strcpy(decoder->private_->filename, value);
return true;
}
FLAC__bool FLAC__file_decoder_set_write_callback(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data))
{
- if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
- decoder->private->write_callback = value;
+ decoder->private_->write_callback = value;
return true;
}
FLAC__bool FLAC__file_decoder_set_metadata_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data))
{
- if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
- decoder->private->metadata_callback = value;
+ decoder->private_->metadata_callback = value;
return true;
}
FLAC__bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data))
{
- if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
- decoder->private->error_callback = value;
+ decoder->private_->error_callback = value;
return true;
}
FLAC__bool FLAC__file_decoder_set_client_data(const FLAC__FileDecoder *decoder, void *value)
{
- if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
- decoder->private->client_data = value;
+ decoder->private_->client_data = value;
return true;
}
FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *decoder)
{
- return decoder->protected->state;
+ return decoder->protected_->state;
}
FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder)
{
- return decoder->protected->md5_checking;
+ return decoder->protected_->md5_checking;
}
FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder)
FLAC__bool ret;
FLAC__ASSERT(decoder != 0);
- if(decoder->private->stream_decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM)
- decoder->protected->state = FLAC__FILE_DECODER_END_OF_FILE;
+ if(decoder->private_->stream_decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
+ decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
- if(decoder->protected->state == FLAC__FILE_DECODER_END_OF_FILE)
+ if(decoder->protected_->state == FLAC__FILE_DECODER_END_OF_FILE)
return true;
- FLAC__ASSERT(decoder->protected->state == FLAC__FILE_DECODER_OK);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
- ret = FLAC__stream_decoder_process_whole_stream(decoder->private->stream_decoder);
+ ret = FLAC__stream_decoder_process_whole_stream(decoder->private_->stream_decoder);
if(!ret)
- decoder->protected->state = FLAC__FILE_DECODER_STREAM_ERROR;
+ decoder->protected_->state = FLAC__FILE_DECODER_STREAM_ERROR;
return ret;
}
FLAC__bool ret;
FLAC__ASSERT(decoder != 0);
- if(decoder->private->stream_decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM)
- decoder->protected->state = FLAC__FILE_DECODER_END_OF_FILE;
+ if(decoder->private_->stream_decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
+ decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
- if(decoder->protected->state == FLAC__FILE_DECODER_END_OF_FILE)
+ if(decoder->protected_->state == FLAC__FILE_DECODER_END_OF_FILE)
return true;
- FLAC__ASSERT(decoder->protected->state == FLAC__FILE_DECODER_OK);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
- ret = FLAC__stream_decoder_process_metadata(decoder->private->stream_decoder);
+ ret = FLAC__stream_decoder_process_metadata(decoder->private_->stream_decoder);
if(!ret)
- decoder->protected->state = FLAC__FILE_DECODER_STREAM_ERROR;
+ decoder->protected_->state = FLAC__FILE_DECODER_STREAM_ERROR;
return ret;
}
FLAC__bool ret;
FLAC__ASSERT(decoder != 0);
- if(decoder->private->stream_decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM)
- decoder->protected->state = FLAC__FILE_DECODER_END_OF_FILE;
+ if(decoder->private_->stream_decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
+ decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
- if(decoder->protected->state == FLAC__FILE_DECODER_END_OF_FILE)
+ if(decoder->protected_->state == FLAC__FILE_DECODER_END_OF_FILE)
return true;
- FLAC__ASSERT(decoder->protected->state == FLAC__FILE_DECODER_OK);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
- ret = FLAC__stream_decoder_process_one_frame(decoder->private->stream_decoder);
+ ret = FLAC__stream_decoder_process_one_frame(decoder->private_->stream_decoder);
if(!ret)
- decoder->protected->state = FLAC__FILE_DECODER_STREAM_ERROR;
+ decoder->protected_->state = FLAC__FILE_DECODER_STREAM_ERROR;
return ret;
}
FLAC__bool ret;
FLAC__ASSERT(decoder != 0);
- if(decoder->private->stream_decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM)
- decoder->protected->state = FLAC__FILE_DECODER_END_OF_FILE;
+ if(decoder->private_->stream_decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
+ decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
- if(decoder->protected->state == FLAC__FILE_DECODER_END_OF_FILE)
+ if(decoder->protected_->state == FLAC__FILE_DECODER_END_OF_FILE)
return true;
- FLAC__ASSERT(decoder->protected->state == FLAC__FILE_DECODER_OK);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
- ret = FLAC__stream_decoder_process_remaining_frames(decoder->private->stream_decoder);
+ ret = FLAC__stream_decoder_process_remaining_frames(decoder->private_->stream_decoder);
if(!ret)
- decoder->protected->state = FLAC__FILE_DECODER_STREAM_ERROR;
+ decoder->protected_->state = FLAC__FILE_DECODER_STREAM_ERROR;
return ret;
}
struct stat filestats;
FLAC__ASSERT(decoder != 0);
- FLAC__ASSERT(decoder->protected->state == FLAC__FILE_DECODER_OK);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
- if(decoder->private->filename == 0) { /* means the file is stdin... */
- decoder->protected->state = FLAC__FILE_DECODER_SEEK_ERROR;
+ if(decoder->private_->filename == 0) { /* means the file is stdin... */
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR;
return false;
}
- decoder->protected->state = FLAC__FILE_DECODER_SEEKING;
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEKING;
/* turn off md5 checking if a seek is attempted */
- decoder->protected->md5_checking = false;
+ decoder->protected_->md5_checking = false;
- if(!FLAC__stream_decoder_reset(decoder->private->stream_decoder)) {
- decoder->protected->state = FLAC__FILE_DECODER_STREAM_ERROR;
+ if(!FLAC__stream_decoder_reset(decoder->private_->stream_decoder)) {
+ decoder->protected_->state = FLAC__FILE_DECODER_STREAM_ERROR;
return false;
}
/* get the file length */
- if(stat(decoder->private->filename, &filestats) != 0) {
- decoder->protected->state = FLAC__FILE_DECODER_SEEK_ERROR;
+ if(stat(decoder->private_->filename, &filestats) != 0) {
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR;
return false;
}
filesize = filestats.st_size;
/* rewind */
- if(0 != fseek(decoder->private->file, 0, SEEK_SET)) {
- decoder->protected->state = FLAC__FILE_DECODER_SEEK_ERROR;
+ if(0 != fseek(decoder->private_->file, 0, SEEK_SET)) {
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR;
return false;
}
- if(!FLAC__stream_decoder_process_metadata(decoder->private->stream_decoder)) {
- decoder->protected->state = FLAC__FILE_DECODER_STREAM_ERROR;
+ if(!FLAC__stream_decoder_process_metadata(decoder->private_->stream_decoder)) {
+ decoder->protected_->state = FLAC__FILE_DECODER_STREAM_ERROR;
return false;
}
- if(sample > decoder->private->stream_info.total_samples) {
- decoder->protected->state = FLAC__FILE_DECODER_SEEK_ERROR;
+ if(sample > decoder->private_->stream_info.total_samples) {
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR;
return false;
}
{
FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data;
(void)decoder;
- if(feof(file_decoder->private->file)) {
- file_decoder->protected->state = FLAC__FILE_DECODER_END_OF_FILE;
+ if(feof(file_decoder->private_->file)) {
+ file_decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
return FLAC__STREAM_DECODER_READ_END_OF_STREAM;
}
else if(*bytes > 0) {
- size_t bytes_read = fread(buffer, sizeof(FLAC__byte), *bytes, file_decoder->private->file);
+ size_t bytes_read = fread(buffer, sizeof(FLAC__byte), *bytes, file_decoder->private_->file);
if(bytes_read == 0) {
- if(feof(file_decoder->private->file)) {
- file_decoder->protected->state = FLAC__FILE_DECODER_END_OF_FILE;
+ if(feof(file_decoder->private_->file)) {
+ file_decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
return FLAC__STREAM_DECODER_READ_END_OF_STREAM;
}
else
FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data;
(void)decoder;
- if(file_decoder->protected->state == FLAC__FILE_DECODER_SEEKING) {
+ if(file_decoder->protected_->state == FLAC__FILE_DECODER_SEEKING) {
FLAC__uint64 this_frame_sample = frame->header.number.sample_number;
FLAC__uint64 next_frame_sample = this_frame_sample + (FLAC__uint64)frame->header.blocksize;
- FLAC__uint64 target_sample = file_decoder->private->target_sample;
+ FLAC__uint64 target_sample = file_decoder->private_->target_sample;
FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
- file_decoder->private->last_frame = *frame; /* save the frame in the private */
+ file_decoder->private_->last_frame = *frame; /* save the frame */
if(this_frame_sample <= target_sample && target_sample < next_frame_sample) { /* we hit our target frame */
unsigned delta = (unsigned)(target_sample - this_frame_sample);
/* kick out of seek mode */
- file_decoder->protected->state = FLAC__FILE_DECODER_OK;
+ file_decoder->protected_->state = FLAC__FILE_DECODER_OK;
/* shift out the samples before target_sample */
if(delta > 0) {
unsigned channel;
const FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS];
for(channel = 0; channel < frame->header.channels; channel++)
newbuffer[channel] = buffer[channel] + delta;
- file_decoder->private->last_frame.header.blocksize -= delta;
- file_decoder->private->last_frame.header.number.sample_number += (FLAC__uint64)delta;
+ file_decoder->private_->last_frame.header.blocksize -= delta;
+ file_decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta;
/* write the relevant samples */
- return file_decoder->private->write_callback(file_decoder, &file_decoder->private->last_frame, newbuffer, file_decoder->private->client_data);
+ return file_decoder->private_->write_callback(file_decoder, &file_decoder->private_->last_frame, newbuffer, file_decoder->private_->client_data);
}
else {
/* write the relevant samples */
- return file_decoder->private->write_callback(file_decoder, frame, buffer, file_decoder->private->client_data);
+ return file_decoder->private_->write_callback(file_decoder, frame, buffer, file_decoder->private_->client_data);
}
}
else {
}
}
else {
- if(file_decoder->protected->md5_checking) {
- if(!FLAC__MD5Accumulate(&file_decoder->private->md5context, buffer, frame->header.channels, frame->header.blocksize, (frame->header.bits_per_sample+7) / 8))
+ if(file_decoder->protected_->md5_checking) {
+ if(!FLAC__MD5Accumulate(&file_decoder->private_->md5context, buffer, frame->header.channels, frame->header.blocksize, (frame->header.bits_per_sample+7) / 8))
return FLAC__STREAM_DECODER_WRITE_ABORT;
}
- return file_decoder->private->write_callback(file_decoder, frame, buffer, file_decoder->private->client_data);
+ return file_decoder->private_->write_callback(file_decoder, frame, buffer, file_decoder->private_->client_data);
}
}
(void)decoder;
if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
- file_decoder->private->stream_info = metadata->data.stream_info;
+ file_decoder->private_->stream_info = metadata->data.stream_info;
/* save the MD5 signature for comparison later */
- memcpy(file_decoder->private->stored_md5sum, metadata->data.stream_info.md5sum, 16);
- if(0 == memcmp(file_decoder->private->stored_md5sum, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16))
- file_decoder->protected->md5_checking = false;
+ memcpy(file_decoder->private_->stored_md5sum, metadata->data.stream_info.md5sum, 16);
+ if(0 == memcmp(file_decoder->private_->stored_md5sum, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16))
+ file_decoder->protected_->md5_checking = false;
}
else if(metadata->type == FLAC__METADATA_TYPE_SEEKTABLE) {
- file_decoder->private->seek_table = &metadata->data.seek_table;
+ file_decoder->private_->seek_table = &metadata->data.seek_table;
}
- if(file_decoder->protected->state != FLAC__FILE_DECODER_SEEKING)
- file_decoder->private->metadata_callback(file_decoder, metadata, file_decoder->private->client_data);
+ if(file_decoder->protected_->state != FLAC__FILE_DECODER_SEEKING)
+ file_decoder->private_->metadata_callback(file_decoder, metadata, file_decoder->private_->client_data);
}
void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data;
(void)decoder;
- if(file_decoder->protected->state != FLAC__FILE_DECODER_SEEKING)
- file_decoder->private->error_callback(file_decoder, status, file_decoder->private->client_data);
+ if(file_decoder->protected_->state != FLAC__FILE_DECODER_SEEKING)
+ file_decoder->private_->error_callback(file_decoder, status, file_decoder->private_->client_data);
}
FLAC__bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, FLAC__uint64 target_sample)
unsigned approx_bytes_per_frame;
FLAC__uint64 last_frame_sample = 0xffffffffffffffff;
FLAC__bool needs_seek;
- const FLAC__bool is_variable_blocksize_stream = (decoder->private->stream_info.min_blocksize != decoder->private->stream_info.max_blocksize);
+ const FLAC__bool is_variable_blocksize_stream = (decoder->private_->stream_info.min_blocksize != decoder->private_->stream_info.max_blocksize);
/* we are just guessing here, but we want to guess high, not low */
- if(decoder->private->stream_info.max_framesize > 0) {
- approx_bytes_per_frame = decoder->private->stream_info.max_framesize;
+ if(decoder->private_->stream_info.max_framesize > 0) {
+ approx_bytes_per_frame = decoder->private_->stream_info.max_framesize;
}
else if(!is_variable_blocksize_stream) {
- /* note there are no () around 'decoder->private->stream_info.bits_per_sample/8' to keep precision up since it's an integer calulation */
- approx_bytes_per_frame = decoder->private->stream_info.min_blocksize * decoder->private->stream_info.channels * decoder->private->stream_info.bits_per_sample/8 + 64;
+ /* note there are no () around 'decoder->private_->stream_info.bits_per_sample/8' to keep precision up since it's an integer calulation */
+ approx_bytes_per_frame = decoder->private_->stream_info.min_blocksize * decoder->private_->stream_info.channels * decoder->private_->stream_info.bits_per_sample/8 + 64;
}
else
- approx_bytes_per_frame = 1152 * decoder->private->stream_info.channels * decoder->private->stream_info.bits_per_sample/8 + 64;
+ approx_bytes_per_frame = 1152 * decoder->private_->stream_info.channels * decoder->private_->stream_info.bits_per_sample/8 + 64;
/*
* The file pointer is currently at the first frame plus any read
* uncomsumed bytes to get the position of the first frame in the
* file.
*/
- if(-1 == (first_frame_offset = ftell(decoder->private->file))) {
- decoder->protected->state = FLAC__FILE_DECODER_SEEK_ERROR;
+ if(-1 == (first_frame_offset = ftell(decoder->private_->file))) {
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR;
return false;
}
- first_frame_offset -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder->private->stream_decoder);
+ first_frame_offset -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder->private_->stream_decoder);
FLAC__ASSERT(first_frame_offset >= 0);
/*
lower_bound = first_frame_offset;
/* calc the upper_bound, beyond which we never want to seek */
- if(decoder->private->stream_info.max_framesize > 0)
- upper_bound = filesize - (decoder->private->stream_info.max_framesize + 128 + 2); /* 128 for a possible ID3V1 tag, 2 for indexing differences */
+ if(decoder->private_->stream_info.max_framesize > 0)
+ upper_bound = filesize - (decoder->private_->stream_info.max_framesize + 128 + 2); /* 128 for a possible ID3V1 tag, 2 for indexing differences */
else
- upper_bound = filesize - ((decoder->private->stream_info.channels * decoder->private->stream_info.bits_per_sample * FLAC__MAX_BLOCK_SIZE) / 8 + 128 + 2);
+ upper_bound = filesize - ((decoder->private_->stream_info.channels * decoder->private_->stream_info.bits_per_sample * FLAC__MAX_BLOCK_SIZE) / 8 + 128 + 2);
/*
* Now we refine the bounds if we have a seektable with
* suitable points. Note that according to the spec they
* must be ordered by ascending sample number.
*/
- if(0 != decoder->private->seek_table) {
+ if(0 != decoder->private_->seek_table) {
/* find the closest seek point <= target_sample, if it exists */
- for(i = (int)decoder->private->seek_table->num_points - 1; i >= 0; i--) {
- if(decoder->private->seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && decoder->private->seek_table->points[i].sample_number <= target_sample)
+ for(i = (int)decoder->private_->seek_table->num_points - 1; i >= 0; i--) {
+ if(decoder->private_->seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && decoder->private_->seek_table->points[i].sample_number <= target_sample)
break;
}
if(i >= 0) { /* i.e. we found a suitable seek point... */
- lower_bound = first_frame_offset + (long)decoder->private->seek_table->points[i].stream_offset;
+ lower_bound = first_frame_offset + (long)decoder->private_->seek_table->points[i].stream_offset;
lower_seek_point = i;
}
/* find the closest seek point > target_sample, if it exists */
- for(i = 0; i < (int)decoder->private->seek_table->num_points; i++) {
- if(decoder->private->seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && decoder->private->seek_table->points[i].sample_number > target_sample)
+ for(i = 0; i < (int)decoder->private_->seek_table->num_points; i++) {
+ if(decoder->private_->seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER && decoder->private_->seek_table->points[i].sample_number > target_sample)
break;
}
- if(i < (int)decoder->private->seek_table->num_points) { /* i.e. we found a suitable seek point... */
- upper_bound = first_frame_offset + (long)decoder->private->seek_table->points[i].stream_offset;
+ if(i < (int)decoder->private_->seek_table->num_points) { /* i.e. we found a suitable seek point... */
+ upper_bound = first_frame_offset + (long)decoder->private_->seek_table->points[i].stream_offset;
upper_seek_point = i;
}
}
*/
if(lower_seek_point >= 0) {
/* first see if our sample is within a few frames of the lower seekpoint */
- if(decoder->private->seek_table->points[lower_seek_point].sample_number <= target_sample && target_sample < decoder->private->seek_table->points[lower_seek_point].sample_number + (decoder->private->seek_table->points[lower_seek_point].frame_samples * 4)) {
+ if(decoder->private_->seek_table->points[lower_seek_point].sample_number <= target_sample && target_sample < decoder->private_->seek_table->points[lower_seek_point].sample_number + (decoder->private_->seek_table->points[lower_seek_point].frame_samples * 4)) {
pos = lower_bound;
}
else if(upper_seek_point >= 0) {
- const FLAC__uint64 target_offset = target_sample - decoder->private->seek_table->points[lower_seek_point].sample_number;
- const FLAC__uint64 range_samples = decoder->private->seek_table->points[upper_seek_point].sample_number - decoder->private->seek_table->points[lower_seek_point].sample_number;
+ const FLAC__uint64 target_offset = target_sample - decoder->private_->seek_table->points[lower_seek_point].sample_number;
+ const FLAC__uint64 range_samples = decoder->private_->seek_table->points[upper_seek_point].sample_number - decoder->private_->seek_table->points[lower_seek_point].sample_number;
const long range_bytes = upper_bound - lower_bound;
#ifdef _MSC_VER
/* with VC++ you have to spoon feed it the casting */
/* We need to use the metadata and the filelength to estimate the position of the frame with the correct sample */
#ifdef _MSC_VER
/* with VC++ you have to spoon feed it the casting */
- pos = first_frame_offset + (long)((double)(FLAC__int64)target_sample / (double)(FLAC__int64)decoder->private->stream_info.total_samples * (double)(filesize-first_frame_offset-1)) - approx_bytes_per_frame;
+ pos = first_frame_offset + (long)((double)(FLAC__int64)target_sample / (double)(FLAC__int64)decoder->private_->stream_info.total_samples * (double)(filesize-first_frame_offset-1)) - approx_bytes_per_frame;
#else
- pos = first_frame_offset + (long)((double)target_sample / (double)decoder->private->stream_info.total_samples * (double)(filesize-first_frame_offset-1)) - approx_bytes_per_frame;
+ pos = first_frame_offset + (long)((double)target_sample / (double)decoder->private_->stream_info.total_samples * (double)(filesize-first_frame_offset-1)) - approx_bytes_per_frame;
#endif
}
pos = lower_bound;
needs_seek = true;
- decoder->private->target_sample = target_sample;
+ decoder->private_->target_sample = target_sample;
while(1) {
if(needs_seek) {
- if(-1 == fseek(decoder->private->file, pos, SEEK_SET)) {
- decoder->protected->state = FLAC__FILE_DECODER_SEEK_ERROR;
+ if(-1 == fseek(decoder->private_->file, pos, SEEK_SET)) {
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR;
return false;
}
- if(!FLAC__stream_decoder_flush(decoder->private->stream_decoder)) {
- decoder->protected->state = FLAC__FILE_DECODER_STREAM_ERROR;
+ if(!FLAC__stream_decoder_flush(decoder->private_->stream_decoder)) {
+ decoder->protected_->state = FLAC__FILE_DECODER_STREAM_ERROR;
return false;
}
}
- if(!FLAC__stream_decoder_process_one_frame(decoder->private->stream_decoder)) {
- decoder->protected->state = FLAC__FILE_DECODER_SEEK_ERROR;
+ if(!FLAC__stream_decoder_process_one_frame(decoder->private_->stream_decoder)) {
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR;
return false;
}
/* our write callback will change the state when it gets to the target frame */
- if(decoder->protected->state != FLAC__FILE_DECODER_SEEKING) {
+ if(decoder->protected_->state != FLAC__FILE_DECODER_SEEKING) {
break;
}
else { /* we need to narrow the search */
- FLAC__uint64 this_frame_sample = decoder->private->last_frame.header.number.sample_number;
- FLAC__ASSERT(decoder->private->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
+ FLAC__uint64 this_frame_sample = decoder->private_->last_frame.header.number.sample_number;
+ FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
if(this_frame_sample == last_frame_sample) {
/* our last move backwards wasn't big enough */
pos -= (last_pos - pos);
else {
if(target_sample < this_frame_sample) {
last_pos = pos;
- approx_bytes_per_frame = decoder->private->last_frame.header.blocksize * decoder->private->last_frame.header.channels * decoder->private->last_frame.header.bits_per_sample/8 + 64;
+ approx_bytes_per_frame = decoder->private_->last_frame.header.blocksize * decoder->private_->last_frame.header.channels * decoder->private_->last_frame.header.bits_per_sample/8 + 64;
pos -= approx_bytes_per_frame;
needs_seek = true;
}
else { /* target_sample >= this_frame_sample + this frame's blocksize */
last_pos = pos;
- if(-1 == (pos = ftell(decoder->private->file))) {
- decoder->protected->state = FLAC__FILE_DECODER_SEEK_ERROR;
+ if(-1 == (pos = ftell(decoder->private_->file))) {
+ decoder->protected_->state = FLAC__FILE_DECODER_SEEK_ERROR;
return false;
}
- pos -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder->private->stream_decoder);
+ pos -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder->private_->stream_decoder);
needs_seek = false;
}
}
if(decoder == 0) {
return 0;
}
- decoder->protected = (FLAC__StreamDecoderProtected*)malloc(sizeof(FLAC__StreamDecoderProtected));
- if(decoder->protected == 0) {
+ decoder->protected_ = (FLAC__StreamDecoderProtected*)malloc(sizeof(FLAC__StreamDecoderProtected));
+ if(decoder->protected_ == 0) {
free(decoder);
return 0;
}
- decoder->private = (FLAC__StreamDecoderPrivate*)malloc(sizeof(FLAC__StreamDecoderPrivate));
- if(decoder->private == 0) {
- free(decoder->protected);
+ decoder->private_ = (FLAC__StreamDecoderPrivate*)malloc(sizeof(FLAC__StreamDecoderPrivate));
+ if(decoder->private_ == 0) {
+ free(decoder->protected_);
free(decoder);
return 0;
}
- decoder->protected->state = FLAC__STREAM_DECODER_UNINITIALIZED;
+ decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED;
- decoder->private->read_callback = 0;
- decoder->private->write_callback = 0;
- decoder->private->metadata_callback = 0;
- decoder->private->error_callback = 0;
- decoder->private->client_data = 0;
+ decoder->private_->read_callback = 0;
+ decoder->private_->write_callback = 0;
+ decoder->private_->metadata_callback = 0;
+ decoder->private_->error_callback = 0;
+ decoder->private_->client_data = 0;
return decoder;
}
void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
- FLAC__ASSERT(decoder->protected != 0);
- FLAC__ASSERT(decoder->private != 0);
+ FLAC__ASSERT(decoder->protected_ != 0);
+ FLAC__ASSERT(decoder->private_ != 0);
- free(decoder->private);
- free(decoder->protected);
+ free(decoder->private_);
+ free(decoder->protected_);
free(decoder);
}
FLAC__ASSERT(decoder != 0);
- if(decoder->protected->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return decoder->protected->state = FLAC__STREAM_DECODER_ALREADY_INITIALIZED;
+ if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
+ return decoder->protected_->state = FLAC__STREAM_DECODER_ALREADY_INITIALIZED;
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA;
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA;
- if(0 == decoder->private->read_callback || 0 == decoder->private->write_callback || 0 == decoder->private->metadata_callback || 0 == decoder->private->error_callback)
- return decoder->protected->state = FLAC__STREAM_DECODER_INVALID_CALLBACK;
+ if(0 == decoder->private_->read_callback || 0 == decoder->private_->write_callback || 0 == decoder->private_->metadata_callback || 0 == decoder->private_->error_callback)
+ return decoder->protected_->state = FLAC__STREAM_DECODER_INVALID_CALLBACK;
- FLAC__bitbuffer_init(&decoder->private->input);
+ FLAC__bitbuffer_init(&decoder->private_->input);
for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- decoder->private->output[i] = 0;
- decoder->private->residual[i] = 0;
+ decoder->private_->output[i] = 0;
+ decoder->private_->residual[i] = 0;
}
- decoder->private->output_capacity = 0;
- decoder->private->output_channels = 0;
- decoder->private->last_frame_number = 0;
- decoder->private->samples_decoded = 0;
- decoder->private->has_stream_info = false;
- decoder->private->has_seek_table = false;
- decoder->private->cached = false;
+ decoder->private_->output_capacity = 0;
+ decoder->private_->output_channels = 0;
+ decoder->private_->last_frame_number = 0;
+ decoder->private_->samples_decoded = 0;
+ decoder->private_->has_stream_info = false;
+ decoder->private_->has_seek_table = false;
+ decoder->private_->cached = false;
/*
* get the CPU info and set the function pointers
*/
- FLAC__cpu_info(&decoder->private->cpuinfo);
+ FLAC__cpu_info(&decoder->private_->cpuinfo);
/* first default to the non-asm routines */
- decoder->private->local_lpc_restore_signal = FLAC__lpc_restore_signal;
- decoder->private->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal;
+ decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal;
+ decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal;
/* now override with asm where appropriate */
#ifndef FLAC__NO_ASM
- if(decoder->private->cpuinfo.use_asm) {
+ if(decoder->private_->cpuinfo.use_asm) {
#ifdef FLAC__CPU_IA32
- FLAC__ASSERT(decoder->private->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
+ FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
#ifdef FLAC__HAS_NASM
- if(decoder->private->cpuinfo.data.ia32.mmx) {
- decoder->private->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32;
- decoder->private->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32_mmx;
+ if(decoder->private_->cpuinfo.data.ia32.mmx) {
+ decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32;
+ decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32_mmx;
}
else {
- decoder->private->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32;
- decoder->private->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32;
+ decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32;
+ decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32;
}
#endif
#endif
}
#endif
- return decoder->protected->state;
+ return decoder->protected_->state;
}
void FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
{
unsigned i;
FLAC__ASSERT(decoder != 0);
- if(decoder->protected->state == FLAC__STREAM_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED)
return;
- if(decoder->private->has_seek_table) {
- free(decoder->private->seek_table.data.seek_table.points);
- decoder->private->seek_table.data.seek_table.points = 0;
+ if(decoder->private_->has_seek_table) {
+ free(decoder->private_->seek_table.data.seek_table.points);
+ decoder->private_->seek_table.data.seek_table.points = 0;
}
- FLAC__bitbuffer_free(&decoder->private->input);
+ FLAC__bitbuffer_free(&decoder->private_->input);
for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
/* WATCHOUT: FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the output arrays have a buffer of up to 3 zeroes in front (at negative indices) for alignment purposes; we use 4 to keep the data well-aligned. */
- if(decoder->private->output[i] != 0) {
- free(decoder->private->output[i]-4);
- decoder->private->output[i] = 0;
+ if(decoder->private_->output[i] != 0) {
+ free(decoder->private_->output[i]-4);
+ decoder->private_->output[i] = 0;
}
- if(decoder->private->residual[i] != 0) {
- free(decoder->private->residual[i]);
- decoder->private->residual[i] = 0;
+ if(decoder->private_->residual[i] != 0) {
+ free(decoder->private_->residual[i]);
+ decoder->private_->residual[i] = 0;
}
}
- decoder->private->output_capacity = 0;
- decoder->private->output_channels = 0;
- decoder->protected->state = FLAC__STREAM_DECODER_UNINITIALIZED;
+ decoder->private_->output_capacity = 0;
+ decoder->private_->output_channels = 0;
+ decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED;
}
FLAC__bool FLAC__stream_decoder_set_read_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderReadStatus (*value)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data))
{
- if(decoder->protected->state != FLAC__STREAM_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
return false;
- decoder->private->read_callback = value;
+ decoder->private_->read_callback = value;
return true;
}
FLAC__bool FLAC__stream_decoder_set_write_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data))
{
- if(decoder->protected->state != FLAC__STREAM_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
return false;
- decoder->private->write_callback = value;
+ decoder->private_->write_callback = value;
return true;
}
FLAC__bool FLAC__stream_decoder_set_metadata_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data))
{
- if(decoder->protected->state != FLAC__STREAM_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
return false;
- decoder->private->metadata_callback = value;
+ decoder->private_->metadata_callback = value;
return true;
}
FLAC__bool FLAC__stream_decoder_set_error_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data))
{
- if(decoder->protected->state != FLAC__STREAM_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
return false;
- decoder->private->error_callback = value;
+ decoder->private_->error_callback = value;
return true;
}
FLAC__bool FLAC__stream_decoder_set_client_data(const FLAC__StreamDecoder *decoder, void *value)
{
- if(decoder->protected->state != FLAC__STREAM_DECODER_UNINITIALIZED)
+ if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
return false;
- decoder->private->client_data = value;
+ decoder->private_->client_data = value;
return true;
}
FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder)
{
- return decoder->protected->state;
+ return decoder->protected_->state;
}
unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder)
{
- return decoder->protected->channels;
+ return decoder->protected_->channels;
}
FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder)
{
- return decoder->protected->channel_assignment;
+ return decoder->protected_->channel_assignment;
}
unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder)
{
- return decoder->protected->bits_per_sample;
+ return decoder->protected_->bits_per_sample;
}
unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder)
{
- return decoder->protected->sample_rate;
+ return decoder->protected_->sample_rate;
}
unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder)
{
- return decoder->protected->blocksize;
+ return decoder->protected_->blocksize;
}
FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
- if(!FLAC__bitbuffer_clear(&decoder->private->input)) {
- decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
+ if(!FLAC__bitbuffer_clear(&decoder->private_->input)) {
+ decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
FLAC__ASSERT(decoder != 0);
if(!FLAC__stream_decoder_flush(decoder)) {
- decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
+ decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA;
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA;
- decoder->private->samples_decoded = 0;
+ decoder->private_->samples_decoded = 0;
return true;
}
FLAC__bool dummy;
FLAC__ASSERT(decoder != 0);
- if(decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM)
+ if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
return true;
- FLAC__ASSERT(decoder->protected->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA);
if(!FLAC__stream_decoder_reset(decoder)) {
- decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
+ decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
while(1) {
- switch(decoder->protected->state) {
+ switch(decoder->protected_->state) {
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
if(!stream_decoder_find_metadata_(decoder))
return false; /* above function sets the status for us */
{
FLAC__ASSERT(decoder != 0);
- if(decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM)
+ if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
return true;
- FLAC__ASSERT(decoder->protected->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA);
if(!FLAC__stream_decoder_reset(decoder)) {
- decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
+ decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
while(1) {
- switch(decoder->protected->state) {
+ switch(decoder->protected_->state) {
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
if(!stream_decoder_find_metadata_(decoder))
return false; /* above function sets the status for us */
FLAC__bool got_a_frame;
FLAC__ASSERT(decoder != 0);
- if(decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM)
+ if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
return true;
- FLAC__ASSERT(decoder->protected->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC);
while(1) {
- switch(decoder->protected->state) {
+ switch(decoder->protected_->state) {
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
if(!stream_decoder_frame_sync_(decoder))
return true; /* above function sets the status for us */
FLAC__bool dummy;
FLAC__ASSERT(decoder != 0);
- if(decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM)
+ if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
return true;
- FLAC__ASSERT(decoder->protected->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC);
+ FLAC__ASSERT(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC);
while(1) {
- switch(decoder->protected->state) {
+ switch(decoder->protected_->state) {
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
if(!stream_decoder_frame_sync_(decoder))
return true; /* above function sets the status for us */
unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder)
{
FLAC__ASSERT(decoder != 0);
- return decoder->private->input.bytes - decoder->private->input.consumed_bytes;
+ return decoder->private_->input.bytes - decoder->private_->input.consumed_bytes;
}
/***********************************************************************
unsigned i;
FLAC__int32 *tmp;
- if(size <= decoder->private->output_capacity && channels <= decoder->private->output_channels)
+ if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels)
return true;
/* @@@ should change to use realloc() */
for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- if(decoder->private->output[i] != 0) {
- free(decoder->private->output[i]);
- decoder->private->output[i] = 0;
+ if(decoder->private_->output[i] != 0) {
+ free(decoder->private_->output[i]);
+ decoder->private_->output[i] = 0;
}
- if(decoder->private->residual[i] != 0) {
- free(decoder->private->residual[i]);
- decoder->private->residual[i] = 0;
+ if(decoder->private_->residual[i] != 0) {
+ free(decoder->private_->residual[i]);
+ decoder->private_->residual[i] = 0;
}
}
/* WATCHOUT: FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the output arrays have a buffer of up to 3 zeroes in front (at negative indices) for alignment purposes; we use 4 to keep the data well-aligned. */
tmp = (FLAC__int32*)malloc(sizeof(FLAC__int32)*(size+4));
if(tmp == 0) {
- decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
+ decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
memset(tmp, 0, sizeof(FLAC__int32)*4);
- decoder->private->output[i] = tmp + 4;
+ decoder->private_->output[i] = tmp + 4;
tmp = (FLAC__int32*)malloc(sizeof(FLAC__int32)*size);
if(tmp == 0) {
- decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
+ decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
- decoder->private->residual[i] = tmp;
+ decoder->private_->residual[i] = tmp;
}
- decoder->private->output_capacity = size;
- decoder->private->output_channels = channels;
+ decoder->private_->output_capacity = size;
+ decoder->private_->output_channels = channels;
return true;
}
unsigned i, id;
FLAC__bool first = true;
- FLAC__ASSERT(decoder->private->input.consumed_bits == 0); /* make sure we're byte aligned */
+ FLAC__ASSERT(decoder->private_->input.consumed_bits == 0); /* make sure we're byte aligned */
for(i = id = 0; i < 4; ) {
- if(decoder->private->cached) {
- x = (FLAC__uint32)decoder->private->lookahead;
- decoder->private->cached = false;
+ if(decoder->private_->cached) {
+ x = (FLAC__uint32)decoder->private_->lookahead;
+ decoder->private_->cached = false;
}
else {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
}
if(x == FLAC__STREAM_SYNC_STRING[i]) {
continue;
}
if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- decoder->private->header_warmup[0] = (FLAC__byte)x;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ decoder->private_->header_warmup[0] = (FLAC__byte)x;
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
/* we have to check if we just read two 0xff's in a row; the second may actually be the beginning of the sync code */
/* else we have to check if the second byte is the end of a sync code */
if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- decoder->private->lookahead = (FLAC__byte)x;
- decoder->private->cached = true;
+ decoder->private_->lookahead = (FLAC__byte)x;
+ decoder->private_->cached = true;
}
else if(x >> 2 == 0x3e) { /* MAGIC NUMBER for the last 6 sync bits */
- decoder->private->header_warmup[1] = (FLAC__byte)x;
- decoder->protected->state = FLAC__STREAM_DECODER_READ_FRAME;
+ decoder->private_->header_warmup[1] = (FLAC__byte)x;
+ decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME;
return true;
}
}
i = 0;
if(first) {
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private->client_data);
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private_->client_data);
first = false;
}
}
- decoder->protected->state = FLAC__STREAM_DECODER_READ_METADATA;
+ decoder->protected_->state = FLAC__STREAM_DECODER_READ_METADATA;
return true;
}
FLAC__uint32 i, x, last_block, type, length;
FLAC__uint64 xx;
- FLAC__ASSERT(decoder->private->input.consumed_bits == 0); /* make sure we're byte aligned */
+ FLAC__ASSERT(decoder->private_->input.consumed_bits == 0); /* make sure we're byte aligned */
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &last_block, FLAC__STREAM_METADATA_IS_LAST_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &last_block, FLAC__STREAM_METADATA_IS_LAST_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &type, FLAC__STREAM_METADATA_TYPE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &type, FLAC__STREAM_METADATA_TYPE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &length, FLAC__STREAM_METADATA_LENGTH_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &length, FLAC__STREAM_METADATA_LENGTH_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(type == FLAC__METADATA_TYPE_STREAMINFO) {
unsigned used_bits = 0;
- decoder->private->stream_info.type = type;
- decoder->private->stream_info.is_last = last_block;
- decoder->private->stream_info.length = length;
+ decoder->private_->stream_info.type = type;
+ decoder->private_->stream_info.is_last = last_block;
+ decoder->private_->stream_info.length = length;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->stream_info.data.stream_info.min_blocksize = x;
+ decoder->private_->stream_info.data.stream_info.min_blocksize = x;
used_bits += FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->stream_info.data.stream_info.max_blocksize = x;
+ decoder->private_->stream_info.data.stream_info.max_blocksize = x;
used_bits += FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->stream_info.data.stream_info.min_framesize = x;
+ decoder->private_->stream_info.data.stream_info.min_framesize = x;
used_bits += FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->stream_info.data.stream_info.max_framesize = x;
+ decoder->private_->stream_info.data.stream_info.max_framesize = x;
used_bits += FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->stream_info.data.stream_info.sample_rate = x;
+ decoder->private_->stream_info.data.stream_info.sample_rate = x;
used_bits += FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->stream_info.data.stream_info.channels = x+1;
+ decoder->private_->stream_info.data.stream_info.channels = x+1;
used_bits += FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->stream_info.data.stream_info.bits_per_sample = x+1;
+ decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1;
used_bits += FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN;
- if(!FLAC__bitbuffer_read_raw_uint64(&decoder->private->input, &decoder->private->stream_info.data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint64(&decoder->private_->input, &decoder->private_->stream_info.data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
used_bits += FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN;
for(i = 0; i < 16; i++) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->stream_info.data.stream_info.md5sum[i] = (FLAC__byte)x;
+ decoder->private_->stream_info.data.stream_info.md5sum[i] = (FLAC__byte)x;
}
used_bits += i*8;
FLAC__ASSERT(used_bits % 8 == 0);
length -= (used_bits / 8);
for(i = 0; i < length; i++) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
}
- decoder->private->has_stream_info = true;
- decoder->private->metadata_callback(decoder, &decoder->private->stream_info, decoder->private->client_data);
+ decoder->private_->has_stream_info = true;
+ decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->client_data);
}
else if(type == FLAC__METADATA_TYPE_SEEKTABLE) {
unsigned real_points;
- decoder->private->seek_table.type = type;
- decoder->private->seek_table.is_last = last_block;
- decoder->private->seek_table.length = length;
+ decoder->private_->seek_table.type = type;
+ decoder->private_->seek_table.is_last = last_block;
+ decoder->private_->seek_table.length = length;
- decoder->private->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOINT_LEN;
+ decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOINT_LEN;
- if(0 == (decoder->private->seek_table.data.seek_table.points = (FLAC__StreamMetaData_SeekPoint*)malloc(decoder->private->seek_table.data.seek_table.num_points * sizeof(FLAC__StreamMetaData_SeekPoint)))) {
- decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
+ if(0 == (decoder->private_->seek_table.data.seek_table.points = (FLAC__StreamMetaData_SeekPoint*)malloc(decoder->private_->seek_table.data.seek_table.num_points * sizeof(FLAC__StreamMetaData_SeekPoint)))) {
+ decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
- for(i = real_points = 0; i < decoder->private->seek_table.data.seek_table.num_points; i++) {
- if(!FLAC__bitbuffer_read_raw_uint64(&decoder->private->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN, read_callback_, decoder))
+ for(i = real_points = 0; i < decoder->private_->seek_table.data.seek_table.num_points; i++) {
+ if(!FLAC__bitbuffer_read_raw_uint64(&decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->seek_table.data.seek_table.points[real_points].sample_number = xx;
+ decoder->private_->seek_table.data.seek_table.points[real_points].sample_number = xx;
- if(!FLAC__bitbuffer_read_raw_uint64(&decoder->private->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint64(&decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->seek_table.data.seek_table.points[real_points].stream_offset = xx;
+ decoder->private_->seek_table.data.seek_table.points[real_points].stream_offset = xx;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->seek_table.data.seek_table.points[real_points].frame_samples = x;
+ decoder->private_->seek_table.data.seek_table.points[real_points].frame_samples = x;
- if(decoder->private->seek_table.data.seek_table.points[real_points].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER)
+ if(decoder->private_->seek_table.data.seek_table.points[real_points].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER)
real_points++;
}
- decoder->private->seek_table.data.seek_table.num_points = real_points;
+ decoder->private_->seek_table.data.seek_table.num_points = real_points;
- decoder->private->has_seek_table = true;
- decoder->private->metadata_callback(decoder, &decoder->private->seek_table, decoder->private->client_data);
+ decoder->private_->has_seek_table = true;
+ decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->client_data);
}
else {
/* skip other metadata blocks */
for(i = 0; i < length; i++) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
}
}
if(last_block)
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
unsigned i, skip;
/* skip the version and flags bytes */
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 24, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 24, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
/* get the size (in bytes) to skip */
skip = 0;
for(i = 0; i < 4; i++) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
skip <<= 7;
skip |= (x & 0x7f);
}
/* skip the rest of the tag */
for(i = 0; i < skip; i++) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
}
return true;
/* If we know the total number of samples in the stream, stop if we've read that many. */
/* This will stop us, for example, from wasting time trying to sync on an ID3V1 tag. */
- if(decoder->private->has_stream_info && decoder->private->stream_info.data.stream_info.total_samples) {
- if(decoder->private->samples_decoded >= decoder->private->stream_info.data.stream_info.total_samples) {
- decoder->protected->state = FLAC__STREAM_DECODER_END_OF_STREAM;
+ if(decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.total_samples) {
+ if(decoder->private_->samples_decoded >= decoder->private_->stream_info.data.stream_info.total_samples) {
+ decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM;
return true;
}
}
/* make sure we're byte aligned */
- if(decoder->private->input.consumed_bits != 0) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8-decoder->private->input.consumed_bits, read_callback_, decoder))
+ if(decoder->private_->input.consumed_bits != 0) {
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8-decoder->private_->input.consumed_bits, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
}
while(1) {
- if(decoder->private->cached) {
- x = (FLAC__uint32)decoder->private->lookahead;
- decoder->private->cached = false;
+ if(decoder->private_->cached) {
+ x = (FLAC__uint32)decoder->private_->lookahead;
+ decoder->private_->cached = false;
}
else {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
}
if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- decoder->private->header_warmup[0] = (FLAC__byte)x;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ decoder->private_->header_warmup[0] = (FLAC__byte)x;
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
/* we have to check if we just read two 0xff's in a row; the second may actually be the beginning of the sync code */
/* else we have to check if the second byte is the end of a sync code */
if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- decoder->private->lookahead = (FLAC__byte)x;
- decoder->private->cached = true;
+ decoder->private_->lookahead = (FLAC__byte)x;
+ decoder->private_->cached = true;
}
else if(x >> 2 == 0x3e) { /* MAGIC NUMBER for the last 6 sync bits */
- decoder->private->header_warmup[1] = (FLAC__byte)x;
- decoder->protected->state = FLAC__STREAM_DECODER_READ_FRAME;
+ decoder->private_->header_warmup[1] = (FLAC__byte)x;
+ decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME;
return true;
}
}
if(first) {
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private->client_data);
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private_->client_data);
first = 0;
}
}
/* init the CRC */
frame_crc = 0;
- FLAC__CRC16_UPDATE(decoder->private->header_warmup[0], frame_crc);
- FLAC__CRC16_UPDATE(decoder->private->header_warmup[1], frame_crc);
- FLAC__bitbuffer_init_read_crc16(&decoder->private->input, frame_crc);
+ FLAC__CRC16_UPDATE(decoder->private_->header_warmup[0], frame_crc);
+ FLAC__CRC16_UPDATE(decoder->private_->header_warmup[1], frame_crc);
+ FLAC__bitbuffer_init_read_crc16(&decoder->private_->input, frame_crc);
if(!stream_decoder_read_frame_header_(decoder))
return false;
- if(decoder->protected->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC)
+ if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC)
return true;
- if(!stream_decoder_allocate_output_(decoder, decoder->private->frame.header.blocksize, decoder->private->frame.header.channels))
+ if(!stream_decoder_allocate_output_(decoder, decoder->private_->frame.header.blocksize, decoder->private_->frame.header.channels))
return false;
- for(channel = 0; channel < decoder->private->frame.header.channels; channel++) {
+ for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) {
/*
* first figure the correct bits-per-sample of the subframe
*/
- unsigned bps = decoder->private->frame.header.bits_per_sample;
- switch(decoder->private->frame.header.channel_assignment) {
+ unsigned bps = decoder->private_->frame.header.bits_per_sample;
+ switch(decoder->private_->frame.header.channel_assignment) {
case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
/* no adjustment needed */
break;
case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- FLAC__ASSERT(decoder->private->frame.header.channels == 2);
+ FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
if(channel == 1)
bps++;
break;
case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- FLAC__ASSERT(decoder->private->frame.header.channels == 2);
+ FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
if(channel == 0)
bps++;
break;
case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- FLAC__ASSERT(decoder->private->frame.header.channels == 2);
+ FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
if(channel == 1)
bps++;
break;
*/
if(!stream_decoder_read_subframe_(decoder, channel, bps))
return false;
- if(decoder->protected->state != FLAC__STREAM_DECODER_READ_FRAME) {
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ if(decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME) {
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
}
/*
* Read the frame CRC-16 from the footer and check
*/
- frame_crc = decoder->private->input.read_crc16;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, FLAC__FRAME_FOOTER_CRC_LEN, read_callback_, decoder))
+ frame_crc = decoder->private_->input.read_crc16;
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(frame_crc == (FLAC__uint16)x) {
/* Undo any special channel coding */
- switch(decoder->private->frame.header.channel_assignment) {
+ switch(decoder->private_->frame.header.channel_assignment) {
case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
/* do nothing */
break;
case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- FLAC__ASSERT(decoder->private->frame.header.channels == 2);
- for(i = 0; i < decoder->private->frame.header.blocksize; i++)
- decoder->private->output[1][i] = decoder->private->output[0][i] - decoder->private->output[1][i];
+ FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
+ decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i];
break;
case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- FLAC__ASSERT(decoder->private->frame.header.channels == 2);
- for(i = 0; i < decoder->private->frame.header.blocksize; i++)
- decoder->private->output[0][i] += decoder->private->output[1][i];
+ FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
+ decoder->private_->output[0][i] += decoder->private_->output[1][i];
break;
case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- FLAC__ASSERT(decoder->private->frame.header.channels == 2);
- for(i = 0; i < decoder->private->frame.header.blocksize; i++) {
- mid = decoder->private->output[0][i];
- side = decoder->private->output[1][i];
+ FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++) {
+ mid = decoder->private_->output[0][i];
+ side = decoder->private_->output[1][i];
mid <<= 1;
if(side & 1) /* i.e. if 'side' is odd... */
mid++;
left = mid + side;
right = mid - side;
- decoder->private->output[0][i] = left >> 1;
- decoder->private->output[1][i] = right >> 1;
+ decoder->private_->output[0][i] = left >> 1;
+ decoder->private_->output[1][i] = right >> 1;
}
break;
default:
}
else {
/* Bad frame, emit error and zero the output signal */
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_FRAME_CRC_MISMATCH, decoder->private->client_data);
- for(channel = 0; channel < decoder->private->frame.header.channels; channel++) {
- memset(decoder->private->output[channel], 0, sizeof(FLAC__int32) * decoder->private->frame.header.blocksize);
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_FRAME_CRC_MISMATCH, decoder->private_->client_data);
+ for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) {
+ memset(decoder->private_->output[channel], 0, sizeof(FLAC__int32) * decoder->private_->frame.header.blocksize);
}
}
*got_a_frame = true;
/* put the latest values into the public section of the decoder instance */
- decoder->protected->channels = decoder->private->frame.header.channels;
- decoder->protected->channel_assignment = decoder->private->frame.header.channel_assignment;
- decoder->protected->bits_per_sample = decoder->private->frame.header.bits_per_sample;
- decoder->protected->sample_rate = decoder->private->frame.header.sample_rate;
- decoder->protected->blocksize = decoder->private->frame.header.blocksize;
+ decoder->protected_->channels = decoder->private_->frame.header.channels;
+ decoder->protected_->channel_assignment = decoder->private_->frame.header.channel_assignment;
+ decoder->protected_->bits_per_sample = decoder->private_->frame.header.bits_per_sample;
+ decoder->protected_->sample_rate = decoder->private_->frame.header.sample_rate;
+ decoder->protected_->blocksize = decoder->private_->frame.header.blocksize;
- FLAC__ASSERT(decoder->private->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
- decoder->private->samples_decoded = decoder->private->frame.header.number.sample_number + decoder->private->frame.header.blocksize;
+ FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
+ decoder->private_->samples_decoded = decoder->private_->frame.header.number.sample_number + decoder->private_->frame.header.blocksize;
/* write it */
/* NOTE: some versions of GCC can't figure out const-ness right and will give you an 'incompatible pointer type' warning on arg 3 here: */
- if(decoder->private->write_callback(decoder, &decoder->private->frame, decoder->private->output, decoder->private->client_data) != FLAC__STREAM_DECODER_WRITE_CONTINUE)
+ if(decoder->private_->write_callback(decoder, &decoder->private_->frame, decoder->private_->output, decoder->private_->client_data) != FLAC__STREAM_DECODER_WRITE_CONTINUE)
return false;
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
FLAC__byte crc8, raw_header[16]; /* MAGIC NUMBER based on the maximum frame header size, including CRC */
unsigned raw_header_len;
FLAC__bool is_unparseable = false;
- const FLAC__bool is_known_variable_blocksize_stream = (decoder->private->has_stream_info && decoder->private->stream_info.data.stream_info.min_blocksize != decoder->private->stream_info.data.stream_info.max_blocksize);
- const FLAC__bool is_known_fixed_blocksize_stream = (decoder->private->has_stream_info && decoder->private->stream_info.data.stream_info.min_blocksize == decoder->private->stream_info.data.stream_info.max_blocksize);
+ const FLAC__bool is_known_variable_blocksize_stream = (decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksize != decoder->private_->stream_info.data.stream_info.max_blocksize);
+ const FLAC__bool is_known_fixed_blocksize_stream = (decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksize == decoder->private_->stream_info.data.stream_info.max_blocksize);
- FLAC__ASSERT(decoder->private->input.consumed_bits == 0); /* make sure we're byte aligned */
+ FLAC__ASSERT(decoder->private_->input.consumed_bits == 0); /* make sure we're byte aligned */
/* init the raw header with the saved bits from synchronization */
- raw_header[0] = decoder->private->header_warmup[0];
- raw_header[1] = decoder->private->header_warmup[1];
+ raw_header[0] = decoder->private_->header_warmup[0];
+ raw_header[1] = decoder->private_->header_warmup[1];
raw_header_len = 2;
/*
* read in the raw header as bytes so we can CRC it, and parse it on the way
*/
for(i = 0; i < 2; i++) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
/* if we get here it means our original sync was erroneous since the sync code cannot appear in the header */
- decoder->private->lookahead = (FLAC__byte)x;
- decoder->private->cached = true;
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->lookahead = (FLAC__byte)x;
+ decoder->private_->cached = true;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
raw_header[raw_header_len++] = (FLAC__byte)x;
switch(x = raw_header[2] >> 4) {
case 0:
if(is_known_fixed_blocksize_stream)
- decoder->private->frame.header.blocksize = decoder->private->stream_info.data.stream_info.min_blocksize;
+ decoder->private_->frame.header.blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize;
else
is_unparseable = true;
break;
case 1:
- decoder->private->frame.header.blocksize = 192;
+ decoder->private_->frame.header.blocksize = 192;
break;
case 2:
case 3:
case 4:
case 5:
- decoder->private->frame.header.blocksize = 576 << (x-2);
+ decoder->private_->frame.header.blocksize = 576 << (x-2);
break;
case 6:
case 7:
case 13:
case 14:
case 15:
- decoder->private->frame.header.blocksize = 256 << (x-8);
+ decoder->private_->frame.header.blocksize = 256 << (x-8);
break;
default:
FLAC__ASSERT(0);
switch(x = raw_header[2] & 0x0f) {
case 0:
- if(decoder->private->has_stream_info)
- decoder->private->frame.header.sample_rate = decoder->private->stream_info.data.stream_info.sample_rate;
+ if(decoder->private_->has_stream_info)
+ decoder->private_->frame.header.sample_rate = decoder->private_->stream_info.data.stream_info.sample_rate;
else
is_unparseable = true;
break;
is_unparseable = true;
break;
case 4:
- decoder->private->frame.header.sample_rate = 8000;
+ decoder->private_->frame.header.sample_rate = 8000;
break;
case 5:
- decoder->private->frame.header.sample_rate = 16000;
+ decoder->private_->frame.header.sample_rate = 16000;
break;
case 6:
- decoder->private->frame.header.sample_rate = 22050;
+ decoder->private_->frame.header.sample_rate = 22050;
break;
case 7:
- decoder->private->frame.header.sample_rate = 24000;
+ decoder->private_->frame.header.sample_rate = 24000;
break;
case 8:
- decoder->private->frame.header.sample_rate = 32000;
+ decoder->private_->frame.header.sample_rate = 32000;
break;
case 9:
- decoder->private->frame.header.sample_rate = 44100;
+ decoder->private_->frame.header.sample_rate = 44100;
break;
case 10:
- decoder->private->frame.header.sample_rate = 48000;
+ decoder->private_->frame.header.sample_rate = 48000;
break;
case 11:
- decoder->private->frame.header.sample_rate = 96000;
+ decoder->private_->frame.header.sample_rate = 96000;
break;
case 12:
case 13:
sample_rate_hint = x;
break;
case 15:
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
default:
FLAC__ASSERT(0);
x = (unsigned)(raw_header[3] >> 4);
if(x & 8) {
- decoder->private->frame.header.channels = 2;
+ decoder->private_->frame.header.channels = 2;
switch(x & 7) {
case 0:
- decoder->private->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE;
+ decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE;
break;
case 1:
- decoder->private->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE;
+ decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE;
break;
case 2:
- decoder->private->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE;
+ decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE;
break;
default:
is_unparseable = true;
}
}
else {
- decoder->private->frame.header.channels = (unsigned)x + 1;
- decoder->private->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT;
+ decoder->private_->frame.header.channels = (unsigned)x + 1;
+ decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT;
}
switch(x = (unsigned)(raw_header[3] & 0x0e) >> 1) {
case 0:
- if(decoder->private->has_stream_info)
- decoder->private->frame.header.bits_per_sample = decoder->private->stream_info.data.stream_info.bits_per_sample;
+ if(decoder->private_->has_stream_info)
+ decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.bits_per_sample;
else
is_unparseable = true;
break;
case 1:
- decoder->private->frame.header.bits_per_sample = 8;
+ decoder->private_->frame.header.bits_per_sample = 8;
break;
case 2:
- decoder->private->frame.header.bits_per_sample = 12;
+ decoder->private_->frame.header.bits_per_sample = 12;
break;
case 4:
- decoder->private->frame.header.bits_per_sample = 16;
+ decoder->private_->frame.header.bits_per_sample = 16;
break;
case 5:
- decoder->private->frame.header.bits_per_sample = 20;
+ decoder->private_->frame.header.bits_per_sample = 20;
break;
case 6:
- decoder->private->frame.header.bits_per_sample = 24;
+ decoder->private_->frame.header.bits_per_sample = 24;
break;
case 3:
case 7:
}
if(raw_header[3] & 0x01) { /* this should be a zero padding bit */
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
if(blocksize_hint && is_known_variable_blocksize_stream) {
- if(!FLAC__bitbuffer_read_utf8_uint64(&decoder->private->input, &xx, read_callback_, decoder, raw_header, &raw_header_len))
+ if(!FLAC__bitbuffer_read_utf8_uint64(&decoder->private_->input, &xx, read_callback_, decoder, raw_header, &raw_header_len))
return false; /* the read_callback_ sets the state for us */
if(xx == 0xffffffffffffffff) { /* i.e. non-UTF8 code... */
- decoder->private->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */
- decoder->private->cached = true;
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */
+ decoder->private_->cached = true;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
- decoder->private->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
- decoder->private->frame.header.number.sample_number = xx;
+ decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
+ decoder->private_->frame.header.number.sample_number = xx;
}
else {
- if(!FLAC__bitbuffer_read_utf8_uint32(&decoder->private->input, &x, read_callback_, decoder, raw_header, &raw_header_len))
+ if(!FLAC__bitbuffer_read_utf8_uint32(&decoder->private_->input, &x, read_callback_, decoder, raw_header, &raw_header_len))
return false; /* the read_callback_ sets the state for us */
if(x == 0xffffffff) { /* i.e. non-UTF8 code... */
- decoder->private->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */
- decoder->private->cached = true;
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */
+ decoder->private_->cached = true;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
- decoder->private->last_frame_number = x;
- if(decoder->private->has_stream_info) {
- decoder->private->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
- decoder->private->frame.header.number.sample_number = (FLAC__int64)decoder->private->stream_info.data.stream_info.min_blocksize * (FLAC__int64)x;
+ decoder->private_->last_frame_number = x;
+ if(decoder->private_->has_stream_info) {
+ decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
+ decoder->private_->frame.header.number.sample_number = (FLAC__int64)decoder->private_->stream_info.data.stream_info.min_blocksize * (FLAC__int64)x;
}
else {
is_unparseable = true;
}
if(blocksize_hint) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
raw_header[raw_header_len++] = (FLAC__byte)x;
if(blocksize_hint == 7) {
FLAC__uint32 _x;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &_x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &_x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
raw_header[raw_header_len++] = (FLAC__byte)_x;
x = (x << 8) | _x;
}
- decoder->private->frame.header.blocksize = x+1;
+ decoder->private_->frame.header.blocksize = x+1;
}
if(sample_rate_hint) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
raw_header[raw_header_len++] = (FLAC__byte)x;
if(sample_rate_hint != 12) {
FLAC__uint32 _x;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &_x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &_x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
raw_header[raw_header_len++] = (FLAC__byte)_x;
x = (x << 8) | _x;
}
if(sample_rate_hint == 12)
- decoder->private->frame.header.sample_rate = x*1000;
+ decoder->private_->frame.header.sample_rate = x*1000;
else if(sample_rate_hint == 13)
- decoder->private->frame.header.sample_rate = x;
+ decoder->private_->frame.header.sample_rate = x;
else
- decoder->private->frame.header.sample_rate = x*10;
+ decoder->private_->frame.header.sample_rate = x*10;
}
/* read the CRC-8 byte */
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
crc8 = (FLAC__byte)x;
if(FLAC__crc8(raw_header, raw_header_len) != crc8) {
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_BAD_HEADER, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
if(is_unparseable) {
- decoder->protected->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
+ decoder->protected_->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
return false;
}
FLAC__uint32 x;
FLAC__bool wasted_bits;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &x, 8, read_callback_, decoder)) /* MAGIC NUMBER */
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &x, 8, read_callback_, decoder)) /* MAGIC NUMBER */
return false; /* the read_callback_ sets the state for us */
wasted_bits = (x & 1);
if(wasted_bits) {
unsigned u;
- if(!FLAC__bitbuffer_read_unary_unsigned(&decoder->private->input, &u, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_unary_unsigned(&decoder->private_->input, &u, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
- decoder->private->frame.subframes[channel].wasted_bits = u+1;
- bps -= decoder->private->frame.subframes[channel].wasted_bits;
+ decoder->private_->frame.subframes[channel].wasted_bits = u+1;
+ bps -= decoder->private_->frame.subframes[channel].wasted_bits;
}
else
- decoder->private->frame.subframes[channel].wasted_bits = 0;
+ decoder->private_->frame.subframes[channel].wasted_bits = 0;
/*
* Lots of magic numbers here
*/
if(x & 0x80) {
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
else if(x == 0) {
return false;
}
else if(x < 16) {
- decoder->protected->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
+ decoder->protected_->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
return false;
}
else if(x <= 24) {
return false;
}
else if(x < 64) {
- decoder->protected->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
+ decoder->protected_->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
return false;
}
else {
if(wasted_bits) {
unsigned i;
- x = decoder->private->frame.subframes[channel].wasted_bits;
- for(i = 0; i < decoder->private->frame.header.blocksize; i++)
- decoder->private->output[channel][i] <<= x;
+ x = decoder->private_->frame.subframes[channel].wasted_bits;
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
+ decoder->private_->output[channel][i] <<= x;
}
return true;
FLAC__bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps)
{
- FLAC__Subframe_Constant *subframe = &decoder->private->frame.subframes[channel].data.constant;
+ FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant;
FLAC__int32 x;
unsigned i;
- FLAC__int32 *output = decoder->private->output[channel];
+ FLAC__int32 *output = decoder->private_->output[channel];
- decoder->private->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT;
+ decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT;
- if(!FLAC__bitbuffer_read_raw_int32(&decoder->private->input, &x, bps, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_int32(&decoder->private_->input, &x, bps, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->value = x;
/* decode the subframe */
- for(i = 0; i < decoder->private->frame.header.blocksize; i++)
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
output[i] = x;
return true;
FLAC__bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order)
{
- FLAC__Subframe_Fixed *subframe = &decoder->private->frame.subframes[channel].data.fixed;
+ FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed;
FLAC__int32 i32;
FLAC__uint32 u32;
unsigned u;
- decoder->private->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED;
+ decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED;
- subframe->residual = decoder->private->residual[channel];
+ subframe->residual = decoder->private_->residual[channel];
subframe->order = order;
/* read warm-up samples */
for(u = 0; u < order; u++) {
- if(!FLAC__bitbuffer_read_raw_int32(&decoder->private->input, &i32, bps, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_int32(&decoder->private_->input, &i32, bps, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->warmup[u] = i32;
}
/* read entropy coding method info */
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->entropy_coding_method.type = u32;
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->entropy_coding_method.data.partitioned_rice.order = u32;
break;
default:
- decoder->protected->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
+ decoder->protected_->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
return false;
}
/* read residual */
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- if(!stream_decoder_read_residual_partitioned_rice_(decoder, order, &subframe->entropy_coding_method.data.partitioned_rice, decoder->private->residual[channel]))
+ if(!stream_decoder_read_residual_partitioned_rice_(decoder, order, &subframe->entropy_coding_method.data.partitioned_rice, decoder->private_->residual[channel]))
return false;
break;
default:
}
/* decode the subframe */
- memcpy(decoder->private->output[channel], subframe->warmup, sizeof(FLAC__int32) * order);
- FLAC__fixed_restore_signal(decoder->private->residual[channel], decoder->private->frame.header.blocksize-order, order, decoder->private->output[channel]+order);
+ memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order);
+ FLAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->output[channel]+order);
return true;
}
FLAC__bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order)
{
- FLAC__Subframe_LPC *subframe = &decoder->private->frame.subframes[channel].data.lpc;
+ FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc;
FLAC__int32 i32;
FLAC__uint32 u32;
unsigned u;
- decoder->private->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC;
+ decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC;
- subframe->residual = decoder->private->residual[channel];
+ subframe->residual = decoder->private_->residual[channel];
subframe->order = order;
/* read warm-up samples */
for(u = 0; u < order; u++) {
- if(!FLAC__bitbuffer_read_raw_int32(&decoder->private->input, &i32, bps, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_int32(&decoder->private_->input, &i32, bps, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->warmup[u] = i32;
}
/* read qlp coeff precision */
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(u32 == (1u << FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN) - 1) {
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
return true;
}
subframe->qlp_coeff_precision = u32+1;
/* read qlp shift */
- if(!FLAC__bitbuffer_read_raw_int32(&decoder->private->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_int32(&decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->quantization_level = i32;
/* read quantized lp coefficiencts */
for(u = 0; u < order; u++) {
- if(!FLAC__bitbuffer_read_raw_int32(&decoder->private->input, &i32, subframe->qlp_coeff_precision, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_int32(&decoder->private_->input, &i32, subframe->qlp_coeff_precision, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->qlp_coeff[u] = i32;
}
/* read entropy coding method info */
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->entropy_coding_method.type = u32;
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
subframe->entropy_coding_method.data.partitioned_rice.order = u32;
break;
default:
- decoder->protected->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
+ decoder->protected_->state = FLAC__STREAM_DECODER_UNPARSEABLE_STREAM;
return false;
}
/* read residual */
switch(subframe->entropy_coding_method.type) {
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- if(!stream_decoder_read_residual_partitioned_rice_(decoder, order, &subframe->entropy_coding_method.data.partitioned_rice, decoder->private->residual[channel]))
+ if(!stream_decoder_read_residual_partitioned_rice_(decoder, order, &subframe->entropy_coding_method.data.partitioned_rice, decoder->private_->residual[channel]))
return false;
break;
default:
}
/* decode the subframe */
- memcpy(decoder->private->output[channel], subframe->warmup, sizeof(FLAC__int32) * order);
+ memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order);
if(bps <= 16 && subframe->qlp_coeff_precision <= 16)
- decoder->private->local_lpc_restore_signal_16bit(decoder->private->residual[channel], decoder->private->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private->output[channel]+order);
+ decoder->private_->local_lpc_restore_signal_16bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order);
else
- decoder->private->local_lpc_restore_signal(decoder->private->residual[channel], decoder->private->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private->output[channel]+order);
+ decoder->private_->local_lpc_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order);
return true;
}
FLAC__bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps)
{
- FLAC__Subframe_Verbatim *subframe = &decoder->private->frame.subframes[channel].data.verbatim;
- FLAC__int32 x, *residual = decoder->private->residual[channel];
+ FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim;
+ FLAC__int32 x, *residual = decoder->private_->residual[channel];
unsigned i;
- decoder->private->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM;
+ decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM;
subframe->data = residual;
- for(i = 0; i < decoder->private->frame.header.blocksize; i++) {
- if(!FLAC__bitbuffer_read_raw_int32(&decoder->private->input, &x, bps, read_callback_, decoder))
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++) {
+ if(!FLAC__bitbuffer_read_raw_int32(&decoder->private_->input, &x, bps, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
residual[i] = x;
}
/* decode the subframe */
- memcpy(decoder->private->output[channel], subframe->data, sizeof(FLAC__int32) * decoder->private->frame.header.blocksize);
+ memcpy(decoder->private_->output[channel], subframe->data, sizeof(FLAC__int32) * decoder->private_->frame.header.blocksize);
return true;
}
unsigned partition, sample, u;
const unsigned partition_order = partitioned_rice->order;
const unsigned partitions = 1u << partition_order;
- const unsigned partition_samples = partition_order > 0? decoder->private->frame.header.blocksize >> partition_order : decoder->private->frame.header.blocksize - predictor_order;
+ const unsigned partition_samples = partition_order > 0? decoder->private_->frame.header.blocksize >> partition_order : decoder->private_->frame.header.blocksize - predictor_order;
sample = 0;
for(partition = 0; partition < partitions; partition++) {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &rice_parameter, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
partitioned_rice->parameters[partition] = rice_parameter;
if(rice_parameter < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) {
for(u = (partition_order == 0 || partition > 0)? 0 : predictor_order; u < partition_samples; u++, sample++) {
#ifdef FLAC__SYMMETRIC_RICE
- if(!FLAC__bitbuffer_read_symmetric_rice_signed(&decoder->private->input, &i, rice_parameter, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_symmetric_rice_signed(&decoder->private_->input, &i, rice_parameter, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
#else
- if(!FLAC__bitbuffer_read_rice_signed(&decoder->private->input, &i, rice_parameter, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_rice_signed(&decoder->private_->input, &i, rice_parameter, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
#endif
residual[sample] = i;
}
}
else {
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &rice_parameter, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
partitioned_rice->raw_bits[partition] = rice_parameter;
for(u = (partition_order == 0 || partition > 0)? 0 : predictor_order; u < partition_samples; u++, sample++) {
- if(!FLAC__bitbuffer_read_raw_int32(&decoder->private->input, &i, rice_parameter, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_int32(&decoder->private_->input, &i, rice_parameter, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
residual[sample] = i;
}
FLAC__bool stream_decoder_read_zero_padding_(FLAC__StreamDecoder *decoder)
{
- if(decoder->private->input.consumed_bits != 0) {
+ if(decoder->private_->input.consumed_bits != 0) {
FLAC__uint32 zero = 0;
- if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private->input, &zero, 8-decoder->private->input.consumed_bits, read_callback_, decoder))
+ if(!FLAC__bitbuffer_read_raw_uint32(&decoder->private_->input, &zero, 8-decoder->private_->input.consumed_bits, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */
if(zero != 0) {
- decoder->private->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private->client_data);
- decoder->protected->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
+ decoder->private_->error_callback(decoder, FLAC__STREAM_DECODER_ERROR_LOST_SYNC, decoder->private_->client_data);
+ decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
}
}
return true;
{
FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data;
FLAC__StreamDecoderReadStatus status;
- status = decoder->private->read_callback(decoder, buffer, bytes, decoder->private->client_data);
+ status = decoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data);
if(status == FLAC__STREAM_DECODER_READ_END_OF_STREAM)
- decoder->protected->state = FLAC__STREAM_DECODER_END_OF_STREAM;
+ decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM;
else if(status == FLAC__STREAM_DECODER_READ_ABORT)
- decoder->protected->state = FLAC__STREAM_DECODER_ABORTED;
+ decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;
return status == FLAC__STREAM_DECODER_READ_CONTINUE;
}
if(encoder == 0) {
return 0;
}
- encoder->protected = (FLAC__StreamEncoderProtected*)malloc(sizeof(FLAC__StreamEncoderProtected));
- if(encoder->protected == 0) {
+ encoder->protected_ = (FLAC__StreamEncoderProtected*)malloc(sizeof(FLAC__StreamEncoderProtected));
+ if(encoder->protected_ == 0) {
free(encoder);
return 0;
}
- encoder->private = (FLAC__StreamEncoderPrivate*)malloc(sizeof(FLAC__StreamEncoderPrivate));
- if(encoder->private == 0) {
- free(encoder->protected);
+ encoder->private_ = (FLAC__StreamEncoderPrivate*)malloc(sizeof(FLAC__StreamEncoderPrivate));
+ if(encoder->private_ == 0) {
+ free(encoder->protected_);
free(encoder);
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->seek_table = 0;
- encoder->protected->padding = 0;
- encoder->protected->last_metadata_is_last = true;
-
- encoder->private->write_callback = 0;
- encoder->private->metadata_callback = 0;
- encoder->private->client_data = 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_->seek_table = 0;
+ encoder->protected_->padding = 0;
+ encoder->protected_->last_metadata_is_last = true;
+
+ encoder->private_->write_callback = 0;
+ encoder->private_->metadata_callback = 0;
+ encoder->private_->client_data = 0;
return encoder;
}
void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder)
{
FLAC__ASSERT(encoder != 0);
- FLAC__ASSERT(encoder->protected != 0);
- FLAC__ASSERT(encoder->private != 0);
+ FLAC__ASSERT(encoder->protected_ != 0);
+ FLAC__ASSERT(encoder->private_ != 0);
- free(encoder->private);
- free(encoder->protected);
+ free(encoder->private_);
+ free(encoder->protected_);
free(encoder);
}
FLAC__ASSERT(encoder != 0);
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return encoder->protected->state = FLAC__STREAM_ENCODER_ALREADY_INITIALIZED;
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_ALREADY_INITIALIZED;
- encoder->protected->state = FLAC__STREAM_ENCODER_OK;
+ encoder->protected_->state = FLAC__STREAM_ENCODER_OK;
- if(0 == encoder->private->write_callback || 0 == encoder->private->metadata_callback)
- return encoder->protected->state = FLAC__STREAM_ENCODER_INVALID_CALLBACK;
+ if(0 == encoder->private_->write_callback || 0 == encoder->private_->metadata_callback)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_CALLBACK;
- if(encoder->protected->channels == 0 || encoder->protected->channels > FLAC__MAX_CHANNELS)
- return encoder->protected->state = FLAC__STREAM_ENCODER_INVALID_NUMBER_OF_CHANNELS;
+ if(encoder->protected_->channels == 0 || encoder->protected_->channels > FLAC__MAX_CHANNELS)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_NUMBER_OF_CHANNELS;
- if(encoder->protected->do_mid_side_stereo && encoder->protected->channels != 2)
- return encoder->protected->state = FLAC__STREAM_ENCODER_MID_SIDE_CHANNELS_MISMATCH;
+ if(encoder->protected_->do_mid_side_stereo && encoder->protected_->channels != 2)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_MID_SIDE_CHANNELS_MISMATCH;
- if(encoder->protected->loose_mid_side_stereo && !encoder->protected->do_mid_side_stereo)
- return encoder->protected->state = FLAC__STREAM_ENCODER_ILLEGAL_MID_SIDE_FORCE;
+ if(encoder->protected_->loose_mid_side_stereo && !encoder->protected_->do_mid_side_stereo)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_ILLEGAL_MID_SIDE_FORCE;
- if(encoder->protected->bits_per_sample >= 32)
- encoder->protected->do_mid_side_stereo = false; /* since we do 32-bit math, the side channel would have 33 bps and overflow */
+ if(encoder->protected_->bits_per_sample >= 32)
+ encoder->protected_->do_mid_side_stereo = false; /* since we do 32-bit math, the side channel would have 33 bps and overflow */
- if(encoder->protected->bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || encoder->protected->bits_per_sample > FLAC__MAX_BITS_PER_SAMPLE)
- return encoder->protected->state = FLAC__STREAM_ENCODER_INVALID_BITS_PER_SAMPLE;
+ if(encoder->protected_->bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || encoder->protected_->bits_per_sample > FLAC__MAX_BITS_PER_SAMPLE)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_BITS_PER_SAMPLE;
- if(encoder->protected->sample_rate == 0 || encoder->protected->sample_rate > FLAC__MAX_SAMPLE_RATE)
- return encoder->protected->state = FLAC__STREAM_ENCODER_INVALID_SAMPLE_RATE;
+ if(encoder->protected_->sample_rate == 0 || encoder->protected_->sample_rate > FLAC__MAX_SAMPLE_RATE)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_SAMPLE_RATE;
- if(encoder->protected->blocksize < FLAC__MIN_BLOCK_SIZE || encoder->protected->blocksize > FLAC__MAX_BLOCK_SIZE)
- return encoder->protected->state = FLAC__STREAM_ENCODER_INVALID_BLOCK_SIZE;
+ if(encoder->protected_->blocksize < FLAC__MIN_BLOCK_SIZE || encoder->protected_->blocksize > FLAC__MAX_BLOCK_SIZE)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_BLOCK_SIZE;
- if(encoder->protected->blocksize < encoder->protected->max_lpc_order)
- return encoder->protected->state = FLAC__STREAM_ENCODER_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER;
+ if(encoder->protected_->blocksize < encoder->protected_->max_lpc_order)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER;
- if(encoder->protected->qlp_coeff_precision == 0) {
- if(encoder->protected->bits_per_sample < 16) {
+ if(encoder->protected_->qlp_coeff_precision == 0) {
+ if(encoder->protected_->bits_per_sample < 16) {
/* @@@ need some data about how to set this here w.r.t. blocksize and sample rate */
/* @@@ until then we'll make a guess */
- encoder->protected->qlp_coeff_precision = max(5, 2 + encoder->protected->bits_per_sample / 2);
+ encoder->protected_->qlp_coeff_precision = max(5, 2 + encoder->protected_->bits_per_sample / 2);
}
- else if(encoder->protected->bits_per_sample == 16) {
- if(encoder->protected->blocksize <= 192)
- encoder->protected->qlp_coeff_precision = 7;
- else if(encoder->protected->blocksize <= 384)
- encoder->protected->qlp_coeff_precision = 8;
- else if(encoder->protected->blocksize <= 576)
- encoder->protected->qlp_coeff_precision = 9;
- else if(encoder->protected->blocksize <= 1152)
- encoder->protected->qlp_coeff_precision = 10;
- else if(encoder->protected->blocksize <= 2304)
- encoder->protected->qlp_coeff_precision = 11;
- else if(encoder->protected->blocksize <= 4608)
- encoder->protected->qlp_coeff_precision = 12;
+ else if(encoder->protected_->bits_per_sample == 16) {
+ if(encoder->protected_->blocksize <= 192)
+ encoder->protected_->qlp_coeff_precision = 7;
+ else if(encoder->protected_->blocksize <= 384)
+ encoder->protected_->qlp_coeff_precision = 8;
+ else if(encoder->protected_->blocksize <= 576)
+ encoder->protected_->qlp_coeff_precision = 9;
+ else if(encoder->protected_->blocksize <= 1152)
+ encoder->protected_->qlp_coeff_precision = 10;
+ else if(encoder->protected_->blocksize <= 2304)
+ encoder->protected_->qlp_coeff_precision = 11;
+ else if(encoder->protected_->blocksize <= 4608)
+ encoder->protected_->qlp_coeff_precision = 12;
else
- encoder->protected->qlp_coeff_precision = 13;
+ encoder->protected_->qlp_coeff_precision = 13;
}
else {
- encoder->protected->qlp_coeff_precision = min(13, 8*sizeof(FLAC__int32) - encoder->protected->bits_per_sample - 1 - 2); /* @@@ -2 to keep things 32-bit safe */
+ encoder->protected_->qlp_coeff_precision = min(13, 8*sizeof(FLAC__int32) - encoder->protected_->bits_per_sample - 1 - 2); /* @@@ -2 to keep things 32-bit safe */
}
}
- else if(encoder->protected->qlp_coeff_precision < FLAC__MIN_QLP_COEFF_PRECISION || encoder->protected->qlp_coeff_precision + encoder->protected->bits_per_sample >= 8*sizeof(FLAC__uint32) || encoder->protected->qlp_coeff_precision >= (1u<<FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN))
- return encoder->protected->state = FLAC__STREAM_ENCODER_INVALID_QLP_COEFF_PRECISION;
+ else if(encoder->protected_->qlp_coeff_precision < FLAC__MIN_QLP_COEFF_PRECISION || encoder->protected_->qlp_coeff_precision + encoder->protected_->bits_per_sample >= 8*sizeof(FLAC__uint32) || encoder->protected_->qlp_coeff_precision >= (1u<<FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN))
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_QLP_COEFF_PRECISION;
- if(encoder->protected->streamable_subset) {
+ if(encoder->protected_->streamable_subset) {
/*@@@ add check for blocksize here */
- if(encoder->protected->bits_per_sample != 8 && encoder->protected->bits_per_sample != 12 && encoder->protected->bits_per_sample != 16 && encoder->protected->bits_per_sample != 20 && encoder->protected->bits_per_sample != 24)
- return encoder->protected->state = FLAC__STREAM_ENCODER_NOT_STREAMABLE;
- if(encoder->protected->sample_rate > 655350)
- return encoder->protected->state = FLAC__STREAM_ENCODER_NOT_STREAMABLE;
+ if(encoder->protected_->bits_per_sample != 8 && encoder->protected_->bits_per_sample != 12 && encoder->protected_->bits_per_sample != 16 && encoder->protected_->bits_per_sample != 20 && encoder->protected_->bits_per_sample != 24)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_NOT_STREAMABLE;
+ if(encoder->protected_->sample_rate > 655350)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_NOT_STREAMABLE;
}
- if(encoder->protected->max_residual_partition_order >= (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN))
- encoder->protected->max_residual_partition_order = (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN) - 1;
- if(encoder->protected->min_residual_partition_order >= encoder->protected->max_residual_partition_order)
- encoder->protected->min_residual_partition_order = encoder->protected->max_residual_partition_order;
+ if(encoder->protected_->max_residual_partition_order >= (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN))
+ encoder->protected_->max_residual_partition_order = (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN) - 1;
+ if(encoder->protected_->min_residual_partition_order >= encoder->protected_->max_residual_partition_order)
+ encoder->protected_->min_residual_partition_order = encoder->protected_->max_residual_partition_order;
- encoder->private->input_capacity = 0;
- for(i = 0; i < encoder->protected->channels; i++) {
- encoder->private->integer_signal_unaligned[i] = encoder->private->integer_signal[i] = 0;
- encoder->private->real_signal_unaligned[i] = encoder->private->real_signal[i] = 0;
+ encoder->private_->input_capacity = 0;
+ for(i = 0; i < encoder->protected_->channels; i++) {
+ encoder->private_->integer_signal_unaligned[i] = encoder->private_->integer_signal[i] = 0;
+ encoder->private_->real_signal_unaligned[i] = encoder->private_->real_signal[i] = 0;
}
for(i = 0; i < 2; i++) {
- encoder->private->integer_signal_mid_side_unaligned[i] = encoder->private->integer_signal_mid_side[i] = 0;
- encoder->private->real_signal_mid_side_unaligned[i] = encoder->private->real_signal_mid_side[i] = 0;
+ encoder->private_->integer_signal_mid_side_unaligned[i] = encoder->private_->integer_signal_mid_side[i] = 0;
+ encoder->private_->real_signal_mid_side_unaligned[i] = encoder->private_->real_signal_mid_side[i] = 0;
}
- for(i = 0; i < encoder->protected->channels; i++) {
- encoder->private->residual_workspace_unaligned[i][0] = encoder->private->residual_workspace[i][0] = 0;
- encoder->private->residual_workspace_unaligned[i][1] = encoder->private->residual_workspace[i][1] = 0;
- encoder->private->best_subframe[i] = 0;
+ for(i = 0; i < encoder->protected_->channels; i++) {
+ encoder->private_->residual_workspace_unaligned[i][0] = encoder->private_->residual_workspace[i][0] = 0;
+ encoder->private_->residual_workspace_unaligned[i][1] = encoder->private_->residual_workspace[i][1] = 0;
+ encoder->private_->best_subframe[i] = 0;
}
for(i = 0; i < 2; i++) {
- encoder->private->residual_workspace_mid_side_unaligned[i][0] = encoder->private->residual_workspace_mid_side[i][0] = 0;
- encoder->private->residual_workspace_mid_side_unaligned[i][1] = encoder->private->residual_workspace_mid_side[i][1] = 0;
- encoder->private->best_subframe_mid_side[i] = 0;
+ encoder->private_->residual_workspace_mid_side_unaligned[i][0] = encoder->private_->residual_workspace_mid_side[i][0] = 0;
+ encoder->private_->residual_workspace_mid_side_unaligned[i][1] = encoder->private_->residual_workspace_mid_side[i][1] = 0;
+ encoder->private_->best_subframe_mid_side[i] = 0;
}
- for(i = 0; i < encoder->protected->channels; i++) {
- encoder->private->subframe_workspace_ptr[i][0] = &encoder->private->subframe_workspace[i][0];
- encoder->private->subframe_workspace_ptr[i][1] = &encoder->private->subframe_workspace[i][1];
+ for(i = 0; i < encoder->protected_->channels; i++) {
+ encoder->private_->subframe_workspace_ptr[i][0] = &encoder->private_->subframe_workspace[i][0];
+ encoder->private_->subframe_workspace_ptr[i][1] = &encoder->private_->subframe_workspace[i][1];
}
for(i = 0; i < 2; i++) {
- encoder->private->subframe_workspace_ptr_mid_side[i][0] = &encoder->private->subframe_workspace_mid_side[i][0];
- encoder->private->subframe_workspace_ptr_mid_side[i][1] = &encoder->private->subframe_workspace_mid_side[i][1];
- }
- encoder->private->abs_residual_unaligned = encoder->private->abs_residual = 0;
- encoder->private->abs_residual_partition_sums_unaligned = encoder->private->abs_residual_partition_sums = 0;
- encoder->private->raw_bits_per_partition_unaligned = encoder->private->raw_bits_per_partition = 0;
- encoder->private->loose_mid_side_stereo_frames_exact = (double)encoder->protected->sample_rate * 0.4 / (double)encoder->protected->blocksize;
- encoder->private->loose_mid_side_stereo_frames = (unsigned)(encoder->private->loose_mid_side_stereo_frames_exact + 0.5);
- if(encoder->private->loose_mid_side_stereo_frames == 0)
- encoder->private->loose_mid_side_stereo_frames = 1;
- encoder->private->loose_mid_side_stereo_frame_count = 0;
- encoder->private->current_sample_number = 0;
- encoder->private->current_frame_number = 0;
-
- encoder->private->use_wide_by_block = (encoder->protected->bits_per_sample + FLAC__bitmath_ilog2(encoder->protected->blocksize)+1 > 30);
- encoder->private->use_wide_by_order = (encoder->protected->bits_per_sample + FLAC__bitmath_ilog2(max(encoder->protected->max_lpc_order, FLAC__MAX_FIXED_ORDER))+1 > 30); /*@@@ need to use this? */
- encoder->private->use_wide_by_partition = (false); /*@@@ need to set this */
+ encoder->private_->subframe_workspace_ptr_mid_side[i][0] = &encoder->private_->subframe_workspace_mid_side[i][0];
+ encoder->private_->subframe_workspace_ptr_mid_side[i][1] = &encoder->private_->subframe_workspace_mid_side[i][1];
+ }
+ encoder->private_->abs_residual_unaligned = encoder->private_->abs_residual = 0;
+ encoder->private_->abs_residual_partition_sums_unaligned = encoder->private_->abs_residual_partition_sums = 0;
+ encoder->private_->raw_bits_per_partition_unaligned = encoder->private_->raw_bits_per_partition = 0;
+ encoder->private_->loose_mid_side_stereo_frames_exact = (double)encoder->protected_->sample_rate * 0.4 / (double)encoder->protected_->blocksize;
+ encoder->private_->loose_mid_side_stereo_frames = (unsigned)(encoder->private_->loose_mid_side_stereo_frames_exact + 0.5);
+ if(encoder->private_->loose_mid_side_stereo_frames == 0)
+ encoder->private_->loose_mid_side_stereo_frames = 1;
+ encoder->private_->loose_mid_side_stereo_frame_count = 0;
+ encoder->private_->current_sample_number = 0;
+ encoder->private_->current_frame_number = 0;
+
+ encoder->private_->use_wide_by_block = (encoder->protected_->bits_per_sample + FLAC__bitmath_ilog2(encoder->protected_->blocksize)+1 > 30);
+ encoder->private_->use_wide_by_order = (encoder->protected_->bits_per_sample + FLAC__bitmath_ilog2(max(encoder->protected_->max_lpc_order, FLAC__MAX_FIXED_ORDER))+1 > 30); /*@@@ need to use this? */
+ encoder->private_->use_wide_by_partition = (false); /*@@@ need to set this */
/*
* get the CPU info and set the function pointers
*/
- FLAC__cpu_info(&encoder->private->cpuinfo);
+ FLAC__cpu_info(&encoder->private_->cpuinfo);
/* first default to the non-asm routines */
- encoder->private->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation;
- encoder->private->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor;
- encoder->private->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients;
- encoder->private->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients;
+ encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation;
+ encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor;
+ encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients;
+ encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients;
/* now override with asm where appropriate */
#ifndef FLAC__NO_ASM
- if(encoder->private->cpuinfo.use_asm) {
+ if(encoder->private_->cpuinfo.use_asm) {
#ifdef FLAC__CPU_IA32
- FLAC__ASSERT(encoder->private->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
+ FLAC__ASSERT(encoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
#ifdef FLAC__HAS_NASM
- if(0 && encoder->private->cpuinfo.data.ia32.sse) {
- if(encoder->protected->max_lpc_order < 4)
- encoder->private->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4;
- else if(encoder->protected->max_lpc_order < 8)
- encoder->private->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8;
- else if(encoder->protected->max_lpc_order < 12)
- encoder->private->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12;
+ if(0 && encoder->private_->cpuinfo.data.ia32.sse) {
+ if(encoder->protected_->max_lpc_order < 4)
+ encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4;
+ else if(encoder->protected_->max_lpc_order < 8)
+ encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8;
+ else if(encoder->protected_->max_lpc_order < 12)
+ encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12;
else
- encoder->private->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32;
+ encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32;
}
- else if(0 && encoder->private->cpuinfo.data.ia32._3dnow) /*@@@ turn back on in first beta after 1.0 */
- encoder->private->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow;
+ else if(0 && encoder->private_->cpuinfo.data.ia32._3dnow) /*@@@ turn back on in first beta after 1.0 */
+ encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow;
else
- encoder->private->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32;
- if(encoder->private->cpuinfo.data.ia32.mmx && encoder->private->cpuinfo.data.ia32.cmov)
- encoder->private->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov;
- if(encoder->private->cpuinfo.data.ia32.mmx) {
- encoder->private->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
- encoder->private->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx;
+ encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32;
+ if(encoder->private_->cpuinfo.data.ia32.mmx && encoder->private_->cpuinfo.data.ia32.cmov)
+ encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov;
+ if(encoder->private_->cpuinfo.data.ia32.mmx) {
+ encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
+ encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx;
}
else {
- encoder->private->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
- encoder->private->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
+ encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
+ encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
}
#endif
#endif
}
#endif
/* finally override based on wide-ness if necessary */
- if(encoder->private->use_wide_by_block) {
- encoder->private->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_wide;
+ if(encoder->private_->use_wide_by_block) {
+ encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_wide;
}
/* we require precompute_partition_sums if do_escape_coding because of their intertwined nature */
- encoder->private->precompute_partition_sums = (encoder->protected->max_residual_partition_order > encoder->protected->min_residual_partition_order) || encoder->protected->do_escape_coding;
+ encoder->private_->precompute_partition_sums = (encoder->protected_->max_residual_partition_order > encoder->protected_->min_residual_partition_order) || encoder->protected_->do_escape_coding;
- if(!stream_encoder_resize_buffers_(encoder, encoder->protected->blocksize)) {
+ if(!stream_encoder_resize_buffers_(encoder, encoder->protected_->blocksize)) {
/* the above function sets the state for us in case of an error */
- return encoder->protected->state;
+ return encoder->protected_->state;
}
- FLAC__bitbuffer_init(&encoder->private->frame);
+ FLAC__bitbuffer_init(&encoder->private_->frame);
/*
* write the stream header
*/
- if(!FLAC__bitbuffer_clear(&encoder->private->frame))
- return encoder->protected->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- if(!FLAC__bitbuffer_write_raw_uint32(&encoder->private->frame, FLAC__STREAM_SYNC, FLAC__STREAM_SYNC_LEN))
- return encoder->protected->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
-
- encoder->private->metadata.type = FLAC__METADATA_TYPE_STREAMINFO;
- encoder->private->metadata.is_last = (encoder->protected->seek_table == 0 && encoder->protected->padding == 0 && encoder->protected->last_metadata_is_last);
- encoder->private->metadata.length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH;
- encoder->private->metadata.data.stream_info.min_blocksize = encoder->protected->blocksize; /* this encoder uses the same blocksize for the whole stream */
- encoder->private->metadata.data.stream_info.max_blocksize = encoder->protected->blocksize;
- encoder->private->metadata.data.stream_info.min_framesize = 0; /* we don't know this yet; have to fill it in later */
- encoder->private->metadata.data.stream_info.max_framesize = 0; /* we don't know this yet; have to fill it in later */
- encoder->private->metadata.data.stream_info.sample_rate = encoder->protected->sample_rate;
- encoder->private->metadata.data.stream_info.channels = encoder->protected->channels;
- encoder->private->metadata.data.stream_info.bits_per_sample = encoder->protected->bits_per_sample;
- encoder->private->metadata.data.stream_info.total_samples = encoder->protected->total_samples_estimate; /* we will replace this later with the real total */
- memset(encoder->private->metadata.data.stream_info.md5sum, 0, 16); /* we don't know this yet; have to fill it in later */
- MD5Init(&encoder->private->md5context);
- if(!FLAC__add_metadata_block(&encoder->private->metadata, &encoder->private->frame))
- return encoder->protected->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
-
- if(0 != encoder->protected->seek_table) {
- if(!FLAC__seek_table_is_valid(encoder->protected->seek_table))
- return encoder->protected->state = FLAC__STREAM_ENCODER_INVALID_SEEK_TABLE;
+ if(!FLAC__bitbuffer_clear(&encoder->private_->frame))
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
+ if(!FLAC__bitbuffer_write_raw_uint32(&encoder->private_->frame, FLAC__STREAM_SYNC, FLAC__STREAM_SYNC_LEN))
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
+
+ encoder->private_->metadata.type = FLAC__METADATA_TYPE_STREAMINFO;
+ encoder->private_->metadata.is_last = (encoder->protected_->seek_table == 0 && encoder->protected_->padding == 0 && encoder->protected_->last_metadata_is_last);
+ encoder->private_->metadata.length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH;
+ encoder->private_->metadata.data.stream_info.min_blocksize = encoder->protected_->blocksize; /* this encoder uses the same blocksize for the whole stream */
+ encoder->private_->metadata.data.stream_info.max_blocksize = encoder->protected_->blocksize;
+ encoder->private_->metadata.data.stream_info.min_framesize = 0; /* we don't know this yet; have to fill it in later */
+ encoder->private_->metadata.data.stream_info.max_framesize = 0; /* we don't know this yet; have to fill it in later */
+ encoder->private_->metadata.data.stream_info.sample_rate = encoder->protected_->sample_rate;
+ encoder->private_->metadata.data.stream_info.channels = encoder->protected_->channels;
+ encoder->private_->metadata.data.stream_info.bits_per_sample = encoder->protected_->bits_per_sample;
+ encoder->private_->metadata.data.stream_info.total_samples = encoder->protected_->total_samples_estimate; /* we will replace this later with the real total */
+ memset(encoder->private_->metadata.data.stream_info.md5sum, 0, 16); /* we don't know this yet; have to fill it in later */
+ MD5Init(&encoder->private_->md5context);
+ if(!FLAC__add_metadata_block(&encoder->private_->metadata, &encoder->private_->frame))
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
+
+ if(0 != encoder->protected_->seek_table) {
+ if(!FLAC__seek_table_is_valid(encoder->protected_->seek_table))
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_INVALID_SEEK_TABLE;
seek_table_block.type = FLAC__METADATA_TYPE_SEEKTABLE;
- seek_table_block.is_last = (encoder->protected->padding == 0 && encoder->protected->last_metadata_is_last);
- seek_table_block.length = encoder->protected->seek_table->num_points * FLAC__STREAM_METADATA_SEEKPOINT_LEN;
- seek_table_block.data.seek_table = *encoder->protected->seek_table;
- if(!FLAC__add_metadata_block(&seek_table_block, &encoder->private->frame))
- return encoder->protected->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
+ seek_table_block.is_last = (encoder->protected_->padding == 0 && encoder->protected_->last_metadata_is_last);
+ seek_table_block.length = encoder->protected_->seek_table->num_points * FLAC__STREAM_METADATA_SEEKPOINT_LEN;
+ seek_table_block.data.seek_table = *encoder->protected_->seek_table;
+ if(!FLAC__add_metadata_block(&seek_table_block, &encoder->private_->frame))
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
}
/* add a PADDING block if requested */
- if(encoder->protected->padding > 0) {
+ if(encoder->protected_->padding > 0) {
padding_block.type = FLAC__METADATA_TYPE_PADDING;
- padding_block.is_last = encoder->protected->last_metadata_is_last;
- padding_block.length = encoder->protected->padding;
- if(!FLAC__add_metadata_block(&padding_block, &encoder->private->frame))
- return encoder->protected->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
+ padding_block.is_last = encoder->protected_->last_metadata_is_last;
+ padding_block.length = encoder->protected_->padding;
+ if(!FLAC__add_metadata_block(&padding_block, &encoder->private_->frame))
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
}
- FLAC__ASSERT(encoder->private->frame.bits == 0); /* assert that we're byte-aligned before writing */
- FLAC__ASSERT(encoder->private->frame.total_consumed_bits == 0); /* assert that no reading of the buffer was done */
- if(encoder->private->write_callback(encoder, encoder->private->frame.buffer, encoder->private->frame.bytes, 0, encoder->private->current_frame_number, encoder->private->client_data) != FLAC__STREAM_ENCODER_WRITE_OK)
- return encoder->protected->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_WRITING;
+ FLAC__ASSERT(encoder->private_->frame.bits == 0); /* assert that we're byte-aligned before writing */
+ FLAC__ASSERT(encoder->private_->frame.total_consumed_bits == 0); /* assert that no reading of the buffer was done */
+ if(encoder->private_->write_callback(encoder, encoder->private_->frame.buffer, encoder->private_->frame.bytes, 0, encoder->private_->current_frame_number, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_OK)
+ return encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_WRITING;
/* now that the metadata block is written, we can init this to an absurdly-high value... */
- encoder->private->metadata.data.stream_info.min_framesize = (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN) - 1;
+ encoder->private_->metadata.data.stream_info.min_framesize = (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN) - 1;
/* ... and clear this to 0 */
- encoder->private->metadata.data.stream_info.total_samples = 0;
+ encoder->private_->metadata.data.stream_info.total_samples = 0;
- return encoder->protected->state;
+ return encoder->protected_->state;
}
void FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder)
unsigned i, channel;
FLAC__ASSERT(encoder != 0);
- if(encoder->protected->state == FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state == FLAC__STREAM_ENCODER_UNINITIALIZED)
return;
- if(encoder->private->current_sample_number != 0) {
- encoder->protected->blocksize = encoder->private->current_sample_number;
+ if(encoder->private_->current_sample_number != 0) {
+ encoder->protected_->blocksize = encoder->private_->current_sample_number;
stream_encoder_process_frame_(encoder, true); /* true => is last frame */
}
- MD5Final(encoder->private->metadata.data.stream_info.md5sum, &encoder->private->md5context);
- encoder->private->metadata_callback(encoder, &encoder->private->metadata, encoder->private->client_data);
- for(i = 0; i < encoder->protected->channels; i++) {
- if(encoder->private->integer_signal_unaligned[i] != 0) {
- free(encoder->private->integer_signal_unaligned[i]);
- encoder->private->integer_signal_unaligned[i] = 0;
+ MD5Final(encoder->private_->metadata.data.stream_info.md5sum, &encoder->private_->md5context);
+ encoder->private_->metadata_callback(encoder, &encoder->private_->metadata, encoder->private_->client_data);
+ for(i = 0; i < encoder->protected_->channels; i++) {
+ if(encoder->private_->integer_signal_unaligned[i] != 0) {
+ free(encoder->private_->integer_signal_unaligned[i]);
+ encoder->private_->integer_signal_unaligned[i] = 0;
}
- if(encoder->private->real_signal_unaligned[i] != 0) {
- free(encoder->private->real_signal_unaligned[i]);
- encoder->private->real_signal_unaligned[i] = 0;
+ if(encoder->private_->real_signal_unaligned[i] != 0) {
+ free(encoder->private_->real_signal_unaligned[i]);
+ encoder->private_->real_signal_unaligned[i] = 0;
}
}
for(i = 0; i < 2; i++) {
- if(encoder->private->integer_signal_mid_side_unaligned[i] != 0) {
- free(encoder->private->integer_signal_mid_side_unaligned[i]);
- encoder->private->integer_signal_mid_side_unaligned[i] = 0;
+ if(encoder->private_->integer_signal_mid_side_unaligned[i] != 0) {
+ free(encoder->private_->integer_signal_mid_side_unaligned[i]);
+ encoder->private_->integer_signal_mid_side_unaligned[i] = 0;
}
- if(encoder->private->real_signal_mid_side_unaligned[i] != 0) {
- free(encoder->private->real_signal_mid_side_unaligned[i]);
- encoder->private->real_signal_mid_side_unaligned[i] = 0;
+ if(encoder->private_->real_signal_mid_side_unaligned[i] != 0) {
+ free(encoder->private_->real_signal_mid_side_unaligned[i]);
+ encoder->private_->real_signal_mid_side_unaligned[i] = 0;
}
}
- for(channel = 0; channel < encoder->protected->channels; channel++) {
+ for(channel = 0; channel < encoder->protected_->channels; channel++) {
for(i = 0; i < 2; i++) {
- if(encoder->private->residual_workspace_unaligned[channel][i] != 0) {
- free(encoder->private->residual_workspace_unaligned[channel][i]);
- encoder->private->residual_workspace_unaligned[channel][i] = 0;
+ if(encoder->private_->residual_workspace_unaligned[channel][i] != 0) {
+ free(encoder->private_->residual_workspace_unaligned[channel][i]);
+ encoder->private_->residual_workspace_unaligned[channel][i] = 0;
}
}
}
for(channel = 0; channel < 2; channel++) {
for(i = 0; i < 2; i++) {
- if(encoder->private->residual_workspace_mid_side_unaligned[channel][i] != 0) {
- free(encoder->private->residual_workspace_mid_side_unaligned[channel][i]);
- encoder->private->residual_workspace_mid_side_unaligned[channel][i] = 0;
+ if(encoder->private_->residual_workspace_mid_side_unaligned[channel][i] != 0) {
+ free(encoder->private_->residual_workspace_mid_side_unaligned[channel][i]);
+ encoder->private_->residual_workspace_mid_side_unaligned[channel][i] = 0;
}
}
}
- if(encoder->private->abs_residual_unaligned != 0) {
- free(encoder->private->abs_residual_unaligned);
- encoder->private->abs_residual_unaligned = 0;
+ if(encoder->private_->abs_residual_unaligned != 0) {
+ free(encoder->private_->abs_residual_unaligned);
+ encoder->private_->abs_residual_unaligned = 0;
}
- if(encoder->private->abs_residual_partition_sums_unaligned != 0) {
- free(encoder->private->abs_residual_partition_sums_unaligned);
- encoder->private->abs_residual_partition_sums_unaligned = 0;
+ if(encoder->private_->abs_residual_partition_sums_unaligned != 0) {
+ free(encoder->private_->abs_residual_partition_sums_unaligned);
+ encoder->private_->abs_residual_partition_sums_unaligned = 0;
}
- if(encoder->private->raw_bits_per_partition_unaligned != 0) {
- free(encoder->private->raw_bits_per_partition_unaligned);
- encoder->private->raw_bits_per_partition_unaligned = 0;
+ if(encoder->private_->raw_bits_per_partition_unaligned != 0) {
+ free(encoder->private_->raw_bits_per_partition_unaligned);
+ encoder->private_->raw_bits_per_partition_unaligned = 0;
}
- FLAC__bitbuffer_free(&encoder->private->frame);
+ FLAC__bitbuffer_free(&encoder->private_->frame);
- encoder->protected->state = FLAC__STREAM_ENCODER_UNINITIALIZED;
+ encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED;
}
FLAC__bool FLAC__stream_encoder_set_streamable_subset(const FLAC__StreamEncoder *encoder, FLAC__bool value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->streamable_subset = value;
+ encoder->protected_->streamable_subset = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(const FLAC__StreamEncoder *encoder, FLAC__bool value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->do_mid_side_stereo = value;
+ encoder->protected_->do_mid_side_stereo = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder, FLAC__bool value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->loose_mid_side_stereo = value;
+ encoder->protected_->loose_mid_side_stereo = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_channels(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->channels = value;
+ encoder->protected_->channels = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_bits_per_sample(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->bits_per_sample = value;
+ encoder->protected_->bits_per_sample = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_sample_rate(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->sample_rate = value;
+ encoder->protected_->sample_rate = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_blocksize(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->blocksize = value;
+ encoder->protected_->blocksize = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_max_lpc_order(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->max_lpc_order = value;
+ encoder->protected_->max_lpc_order = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->qlp_coeff_precision = value;
+ encoder->protected_->qlp_coeff_precision = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder, FLAC__bool value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->do_qlp_coeff_prec_search = value;
+ encoder->protected_->do_qlp_coeff_prec_search = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_do_escape_coding(const FLAC__StreamEncoder *encoder, FLAC__bool value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->do_escape_coding = value;
+ encoder->protected_->do_escape_coding = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder, FLAC__bool value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->do_exhaustive_model_search = value;
+ encoder->protected_->do_exhaustive_model_search = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->min_residual_partition_order = value;
+ encoder->protected_->min_residual_partition_order = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->max_residual_partition_order = value;
+ encoder->protected_->max_residual_partition_order = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->rice_parameter_search_dist = value;
+ encoder->protected_->rice_parameter_search_dist = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(const FLAC__StreamEncoder *encoder, FLAC__uint64 value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->total_samples_estimate = value;
+ encoder->protected_->total_samples_estimate = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_seek_table(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData_SeekTable *value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->seek_table = value;
+ encoder->protected_->seek_table = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_padding(const FLAC__StreamEncoder *encoder, unsigned value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->padding = value;
+ encoder->protected_->padding = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_last_metadata_is_last(const FLAC__StreamEncoder *encoder, FLAC__bool value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->protected->last_metadata_is_last = value;
+ encoder->protected_->last_metadata_is_last = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_write_callback(const FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteStatus (*value)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data))
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->private->write_callback = value;
+ encoder->private_->write_callback = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_metadata_callback(const FLAC__StreamEncoder *encoder, void (*value)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data))
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->private->metadata_callback = value;
+ encoder->private_->metadata_callback = value;
return true;
}
FLAC__bool FLAC__stream_encoder_set_client_data(const FLAC__StreamEncoder *encoder, void *value)
{
- if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
+ if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
- encoder->private->client_data = value;
+ encoder->private_->client_data = value;
return true;
}
FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->state;
+ return encoder->protected_->state;
}
FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->streamable_subset;
+ return encoder->protected_->streamable_subset;
}
FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->do_mid_side_stereo;
+ return encoder->protected_->do_mid_side_stereo;
}
FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->loose_mid_side_stereo;
+ return encoder->protected_->loose_mid_side_stereo;
}
unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->channels;
+ return encoder->protected_->channels;
}
unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->bits_per_sample;
+ return encoder->protected_->bits_per_sample;
}
unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->sample_rate;
+ return encoder->protected_->sample_rate;
}
unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->blocksize;
+ return encoder->protected_->blocksize;
}
unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->max_lpc_order;
+ return encoder->protected_->max_lpc_order;
}
unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->qlp_coeff_precision;
+ return encoder->protected_->qlp_coeff_precision;
}
FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->do_qlp_coeff_prec_search;
+ return encoder->protected_->do_qlp_coeff_prec_search;
}
FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->do_escape_coding;
+ return encoder->protected_->do_escape_coding;
}
FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->do_exhaustive_model_search;
+ return encoder->protected_->do_exhaustive_model_search;
}
unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->min_residual_partition_order;
+ return encoder->protected_->min_residual_partition_order;
}
unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->max_residual_partition_order;
+ return encoder->protected_->max_residual_partition_order;
}
unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder)
{
- return encoder->protected->rice_parameter_search_dist;
+ return encoder->protected_->rice_parameter_search_dist;
}
FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 *buf[], unsigned samples)
{
unsigned i, j, channel;
FLAC__int32 x, mid, side;
- const unsigned channels = encoder->protected->channels, blocksize = encoder->protected->blocksize;
+ const unsigned channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize;
FLAC__ASSERT(encoder != 0);
- FLAC__ASSERT(encoder->protected->state == FLAC__STREAM_ENCODER_OK);
+ FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
j = 0;
- if(encoder->protected->do_mid_side_stereo && channels == 2) {
+ if(encoder->protected_->do_mid_side_stereo && channels == 2) {
do {
- for(i = encoder->private->current_sample_number; i < blocksize && j < samples; i++, j++) {
+ for(i = encoder->private_->current_sample_number; i < blocksize && j < samples; i++, j++) {
x = mid = side = buf[0][j];
- encoder->private->integer_signal[0][i] = x;
- encoder->private->real_signal[0][i] = (FLAC__real)x;
+ encoder->private_->integer_signal[0][i] = x;
+ encoder->private_->real_signal[0][i] = (FLAC__real)x;
x = buf[1][j];
- encoder->private->integer_signal[1][i] = x;
- encoder->private->real_signal[1][i] = (FLAC__real)x;
+ encoder->private_->integer_signal[1][i] = x;
+ encoder->private_->real_signal[1][i] = (FLAC__real)x;
mid += x;
side -= x;
mid >>= 1; /* NOTE: not the same as 'mid = (buf[0][j] + buf[1][j]) / 2' ! */
- encoder->private->integer_signal_mid_side[1][i] = side;
- encoder->private->integer_signal_mid_side[0][i] = mid;
- encoder->private->real_signal_mid_side[1][i] = (FLAC__real)side;
- encoder->private->real_signal_mid_side[0][i] = (FLAC__real)mid;
- encoder->private->current_sample_number++;
+ encoder->private_->integer_signal_mid_side[1][i] = side;
+ encoder->private_->integer_signal_mid_side[0][i] = mid;
+ encoder->private_->real_signal_mid_side[1][i] = (FLAC__real)side;
+ encoder->private_->real_signal_mid_side[0][i] = (FLAC__real)mid;
+ encoder->private_->current_sample_number++;
}
if(i == blocksize) {
if(!stream_encoder_process_frame_(encoder, false)) /* false => not last frame */
}
else {
do {
- for(i = encoder->private->current_sample_number; i < blocksize && j < samples; i++, j++) {
+ for(i = encoder->private_->current_sample_number; i < blocksize && j < samples; i++, j++) {
for(channel = 0; channel < channels; channel++) {
x = buf[channel][j];
- encoder->private->integer_signal[channel][i] = x;
- encoder->private->real_signal[channel][i] = (FLAC__real)x;
+ encoder->private_->integer_signal[channel][i] = x;
+ encoder->private_->real_signal[channel][i] = (FLAC__real)x;
}
- encoder->private->current_sample_number++;
+ encoder->private_->current_sample_number++;
}
if(i == blocksize) {
if(!stream_encoder_process_frame_(encoder, false)) /* false => not last frame */
{
unsigned i, j, k, channel;
FLAC__int32 x, mid, side;
- const unsigned channels = encoder->protected->channels, blocksize = encoder->protected->blocksize;
+ const unsigned channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize;
FLAC__ASSERT(encoder != 0);
- FLAC__ASSERT(encoder->protected->state == FLAC__STREAM_ENCODER_OK);
+ FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
j = k = 0;
- if(encoder->protected->do_mid_side_stereo && channels == 2) {
+ if(encoder->protected_->do_mid_side_stereo && channels == 2) {
do {
- for(i = encoder->private->current_sample_number; i < blocksize && j < samples; i++, j++) {
+ for(i = encoder->private_->current_sample_number; i < blocksize && j < samples; i++, j++) {
x = mid = side = buf[k++];
- encoder->private->integer_signal[0][i] = x;
- encoder->private->real_signal[0][i] = (FLAC__real)x;
+ encoder->private_->integer_signal[0][i] = x;
+ encoder->private_->real_signal[0][i] = (FLAC__real)x;
x = buf[k++];
- encoder->private->integer_signal[1][i] = x;
- encoder->private->real_signal[1][i] = (FLAC__real)x;
+ encoder->private_->integer_signal[1][i] = x;
+ encoder->private_->real_signal[1][i] = (FLAC__real)x;
mid += x;
side -= x;
mid >>= 1; /* NOTE: not the same as 'mid = (left + right) / 2' ! */
- encoder->private->integer_signal_mid_side[1][i] = side;
- encoder->private->integer_signal_mid_side[0][i] = mid;
- encoder->private->real_signal_mid_side[1][i] = (FLAC__real)side;
- encoder->private->real_signal_mid_side[0][i] = (FLAC__real)mid;
- encoder->private->current_sample_number++;
+ encoder->private_->integer_signal_mid_side[1][i] = side;
+ encoder->private_->integer_signal_mid_side[0][i] = mid;
+ encoder->private_->real_signal_mid_side[1][i] = (FLAC__real)side;
+ encoder->private_->real_signal_mid_side[0][i] = (FLAC__real)mid;
+ encoder->private_->current_sample_number++;
}
if(i == blocksize) {
if(!stream_encoder_process_frame_(encoder, false)) /* false => not last frame */
}
else {
do {
- for(i = encoder->private->current_sample_number; i < blocksize && j < samples; i++, j++) {
+ for(i = encoder->private_->current_sample_number; i < blocksize && j < samples; i++, j++) {
for(channel = 0; channel < channels; channel++) {
x = buf[k++];
- encoder->private->integer_signal[channel][i] = x;
- encoder->private->real_signal[channel][i] = (FLAC__real)x;
+ encoder->private_->integer_signal[channel][i] = x;
+ encoder->private_->real_signal[channel][i] = (FLAC__real)x;
}
- encoder->private->current_sample_number++;
+ encoder->private_->current_sample_number++;
}
if(i == blocksize) {
if(!stream_encoder_process_frame_(encoder, false)) /* false => not last frame */
unsigned i, channel;
FLAC__ASSERT(new_size > 0);
- FLAC__ASSERT(encoder->protected->state == FLAC__STREAM_ENCODER_OK);
- FLAC__ASSERT(encoder->private->current_sample_number == 0);
+ FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
+ FLAC__ASSERT(encoder->private_->current_sample_number == 0);
/* To avoid excessive malloc'ing, we only grow the buffer; no shrinking. */
- if(new_size <= encoder->private->input_capacity)
+ if(new_size <= encoder->private_->input_capacity)
return true;
ok = true;
/* WATCHOUT: FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx() requires that the input arrays (in our case the integer signals) have a buffer of up to 3 zeroes in front (at negative indices) for alignment purposes; we use 4 to keep the data well-aligned. */
- for(i = 0; ok && i < encoder->protected->channels; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_size+4, &encoder->private->integer_signal_unaligned[i], &encoder->private->integer_signal[i]);
- ok = ok && FLAC__memory_alloc_aligned_real_array(new_size, &encoder->private->real_signal_unaligned[i], &encoder->private->real_signal[i]);
- memset(encoder->private->integer_signal[i], 0, sizeof(FLAC__int32)*4);
- encoder->private->integer_signal[i] += 4;
+ for(i = 0; ok && i < encoder->protected_->channels; i++) {
+ ok = ok && FLAC__memory_alloc_aligned_int32_array(new_size+4, &encoder->private_->integer_signal_unaligned[i], &encoder->private_->integer_signal[i]);
+ ok = ok && FLAC__memory_alloc_aligned_real_array(new_size, &encoder->private_->real_signal_unaligned[i], &encoder->private_->real_signal[i]);
+ memset(encoder->private_->integer_signal[i], 0, sizeof(FLAC__int32)*4);
+ encoder->private_->integer_signal[i] += 4;
}
for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_size+4, &encoder->private->integer_signal_mid_side_unaligned[i], &encoder->private->integer_signal_mid_side[i]);
- ok = ok && FLAC__memory_alloc_aligned_real_array(new_size, &encoder->private->real_signal_mid_side_unaligned[i], &encoder->private->real_signal_mid_side[i]);
- memset(encoder->private->integer_signal_mid_side[i], 0, sizeof(FLAC__int32)*4);
- encoder->private->integer_signal_mid_side[i] += 4;
+ ok = ok && FLAC__memory_alloc_aligned_int32_array(new_size+4, &encoder->private_->integer_signal_mid_side_unaligned[i], &encoder->private_->integer_signal_mid_side[i]);
+ ok = ok && FLAC__memory_alloc_aligned_real_array(new_size, &encoder->private_->real_signal_mid_side_unaligned[i], &encoder->private_->real_signal_mid_side[i]);
+ memset(encoder->private_->integer_signal_mid_side[i], 0, sizeof(FLAC__int32)*4);
+ encoder->private_->integer_signal_mid_side[i] += 4;
}
- for(channel = 0; ok && channel < encoder->protected->channels; channel++) {
+ for(channel = 0; ok && channel < encoder->protected_->channels; channel++) {
for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_size, &encoder->private->residual_workspace_unaligned[channel][i], &encoder->private->residual_workspace[channel][i]);
+ ok = ok && FLAC__memory_alloc_aligned_int32_array(new_size, &encoder->private_->residual_workspace_unaligned[channel][i], &encoder->private_->residual_workspace[channel][i]);
}
}
for(channel = 0; ok && channel < 2; channel++) {
for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_size, &encoder->private->residual_workspace_mid_side_unaligned[channel][i], &encoder->private->residual_workspace_mid_side[channel][i]);
+ ok = ok && FLAC__memory_alloc_aligned_int32_array(new_size, &encoder->private_->residual_workspace_mid_side_unaligned[channel][i], &encoder->private_->residual_workspace_mid_side[channel][i]);
}
}
- ok = ok && FLAC__memory_alloc_aligned_uint32_array(new_size, &encoder->private->abs_residual_unaligned, &encoder->private->abs_residual);
- if(encoder->private->precompute_partition_sums || encoder->protected->do_escape_coding) /* we require precompute_partition_sums if do_escape_coding because of their intertwined nature */
- ok = ok && FLAC__memory_alloc_aligned_uint64_array(new_size * 2, &encoder->private->abs_residual_partition_sums_unaligned, &encoder->private->abs_residual_partition_sums);
- if(encoder->protected->do_escape_coding)
- ok = ok && FLAC__memory_alloc_aligned_unsigned_array(new_size * 2, &encoder->private->raw_bits_per_partition_unaligned, &encoder->private->raw_bits_per_partition);
+ ok = ok && FLAC__memory_alloc_aligned_uint32_array(new_size, &encoder->private_->abs_residual_unaligned, &encoder->private_->abs_residual);
+ if(encoder->private_->precompute_partition_sums || encoder->protected_->do_escape_coding) /* we require precompute_partition_sums if do_escape_coding because of their intertwined nature */
+ ok = ok && FLAC__memory_alloc_aligned_uint64_array(new_size * 2, &encoder->private_->abs_residual_partition_sums_unaligned, &encoder->private_->abs_residual_partition_sums);
+ if(encoder->protected_->do_escape_coding)
+ ok = ok && FLAC__memory_alloc_aligned_unsigned_array(new_size * 2, &encoder->private_->raw_bits_per_partition_unaligned, &encoder->private_->raw_bits_per_partition);
if(ok)
- encoder->private->input_capacity = new_size;
+ encoder->private_->input_capacity = new_size;
else
- encoder->protected->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
+ encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
return ok;
}
FLAC__bool stream_encoder_process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_frame)
{
- FLAC__ASSERT(encoder->protected->state == FLAC__STREAM_ENCODER_OK);
+ FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
/*
* Accumulate raw signal to the MD5 signature
*/
/* NOTE: some versions of GCC can't figure out const-ness right and will give you an 'incompatible pointer type' warning on arg 2 here: */
- if(!FLAC__MD5Accumulate(&encoder->private->md5context, encoder->private->integer_signal, encoder->protected->channels, encoder->protected->blocksize, (encoder->protected->bits_per_sample+7) / 8)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
+ if(!FLAC__MD5Accumulate(&encoder->private_->md5context, encoder->private_->integer_signal, encoder->protected_->channels, encoder->protected_->blocksize, (encoder->protected_->bits_per_sample+7) / 8)) {
+ encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
return false;
}
/*
* Zero-pad the frame to a byte_boundary
*/
- if(!FLAC__bitbuffer_zero_pad_to_byte_boundary(&encoder->private->frame)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
+ if(!FLAC__bitbuffer_zero_pad_to_byte_boundary(&encoder->private_->frame)) {
+ encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
return false;
}
/*
* CRC-16 the whole thing
*/
- FLAC__ASSERT(encoder->private->frame.bits == 0); /* assert that we're byte-aligned */
- FLAC__ASSERT(encoder->private->frame.total_consumed_bits == 0); /* assert that no reading of the buffer was done */
- FLAC__bitbuffer_write_raw_uint32(&encoder->private->frame, FLAC__crc16(encoder->private->frame.buffer, encoder->private->frame.bytes), FLAC__FRAME_FOOTER_CRC_LEN);
+ FLAC__ASSERT(encoder->private_->frame.bits == 0); /* assert that we're byte-aligned */
+ FLAC__ASSERT(encoder->private_->frame.total_consumed_bits == 0); /* assert that no reading of the buffer was done */
+ FLAC__bitbuffer_write_raw_uint32(&encoder->private_->frame, FLAC__crc16(encoder->private_->frame.buffer, encoder->private_->frame.bytes), FLAC__FRAME_FOOTER_CRC_LEN);
/*
* Write it
*/
- if(encoder->private->write_callback(encoder, encoder->private->frame.buffer, encoder->private->frame.bytes, encoder->protected->blocksize, encoder->private->current_frame_number, encoder->private->client_data) != FLAC__STREAM_ENCODER_WRITE_OK) {
- encoder->protected->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_WRITING;
+ if(encoder->private_->write_callback(encoder, encoder->private_->frame.buffer, encoder->private_->frame.bytes, encoder->protected_->blocksize, encoder->private_->current_frame_number, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_OK) {
+ encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_WRITING;
return false;
}
/*
* Get ready for the next frame
*/
- encoder->private->current_sample_number = 0;
- encoder->private->current_frame_number++;
- encoder->private->metadata.data.stream_info.total_samples += (FLAC__uint64)encoder->protected->blocksize;
- encoder->private->metadata.data.stream_info.min_framesize = min(encoder->private->frame.bytes, encoder->private->metadata.data.stream_info.min_framesize);
- encoder->private->metadata.data.stream_info.max_framesize = max(encoder->private->frame.bytes, encoder->private->metadata.data.stream_info.max_framesize);
+ encoder->private_->current_sample_number = 0;
+ encoder->private_->current_frame_number++;
+ encoder->private_->metadata.data.stream_info.total_samples += (FLAC__uint64)encoder->protected_->blocksize;
+ encoder->private_->metadata.data.stream_info.min_framesize = min(encoder->private_->frame.bytes, encoder->private_->metadata.data.stream_info.min_framesize);
+ encoder->private_->metadata.data.stream_info.max_framesize = max(encoder->private_->frame.bytes, encoder->private_->metadata.data.stream_info.max_framesize);
return true;
}
FLAC__bool stream_encoder_process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_frame)
{
FLAC__FrameHeader frame_header;
- unsigned channel, min_partition_order = encoder->protected->min_residual_partition_order, max_partition_order;
+ unsigned channel, min_partition_order = encoder->protected_->min_residual_partition_order, max_partition_order;
FLAC__bool do_independent, do_mid_side, precompute_partition_sums;
/*
max_partition_order = 0;
}
else {
- unsigned limit = 0, b = encoder->protected->blocksize;
+ unsigned limit = 0, b = encoder->protected_->blocksize;
while(!(b & 1)) {
limit++;
b >>= 1;
}
- max_partition_order = min(encoder->protected->max_residual_partition_order, limit);
+ max_partition_order = min(encoder->protected_->max_residual_partition_order, limit);
}
min_partition_order = min(min_partition_order, max_partition_order);
- precompute_partition_sums = encoder->private->precompute_partition_sums && ((max_partition_order > min_partition_order) || encoder->protected->do_escape_coding);
+ precompute_partition_sums = encoder->private_->precompute_partition_sums && ((max_partition_order > min_partition_order) || encoder->protected_->do_escape_coding);
/*
* Setup the frame
*/
- if(!FLAC__bitbuffer_clear(&encoder->private->frame)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
+ if(!FLAC__bitbuffer_clear(&encoder->private_->frame)) {
+ encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
return false;
}
- frame_header.blocksize = encoder->protected->blocksize;
- frame_header.sample_rate = encoder->protected->sample_rate;
- frame_header.channels = encoder->protected->channels;
+ frame_header.blocksize = encoder->protected_->blocksize;
+ frame_header.sample_rate = encoder->protected_->sample_rate;
+ frame_header.channels = encoder->protected_->channels;
frame_header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; /* the default unless the encoder determines otherwise */
- frame_header.bits_per_sample = encoder->protected->bits_per_sample;
+ frame_header.bits_per_sample = encoder->protected_->bits_per_sample;
frame_header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER;
- frame_header.number.frame_number = encoder->private->current_frame_number;
+ frame_header.number.frame_number = encoder->private_->current_frame_number;
/*
* Figure out what channel assignments to try
*/
- if(encoder->protected->do_mid_side_stereo) {
- if(encoder->protected->loose_mid_side_stereo) {
- if(encoder->private->loose_mid_side_stereo_frame_count == 0) {
+ if(encoder->protected_->do_mid_side_stereo) {
+ if(encoder->protected_->loose_mid_side_stereo) {
+ if(encoder->private_->loose_mid_side_stereo_frame_count == 0) {
do_independent = true;
do_mid_side = true;
}
else {
- do_independent = (encoder->private->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT);
+ do_independent = (encoder->private_->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT);
do_mid_side = !do_independent;
}
}
*/
if(do_independent) {
unsigned w;
- for(channel = 0; channel < encoder->protected->channels; channel++) {
- w = stream_encoder_get_wasted_bits_(encoder->private->integer_signal[channel], encoder->protected->blocksize);
- encoder->private->subframe_workspace[channel][0].wasted_bits = encoder->private->subframe_workspace[channel][1].wasted_bits = w;
- encoder->private->subframe_bps[channel] = encoder->protected->bits_per_sample - w;
+ for(channel = 0; channel < encoder->protected_->channels; channel++) {
+ w = stream_encoder_get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize);
+ encoder->private_->subframe_workspace[channel][0].wasted_bits = encoder->private_->subframe_workspace[channel][1].wasted_bits = w;
+ encoder->private_->subframe_bps[channel] = encoder->protected_->bits_per_sample - w;
}
}
if(do_mid_side) {
unsigned w;
- FLAC__ASSERT(encoder->protected->channels == 2);
+ FLAC__ASSERT(encoder->protected_->channels == 2);
for(channel = 0; channel < 2; channel++) {
- w = stream_encoder_get_wasted_bits_(encoder->private->integer_signal_mid_side[channel], encoder->protected->blocksize);
- encoder->private->subframe_workspace_mid_side[channel][0].wasted_bits = encoder->private->subframe_workspace_mid_side[channel][1].wasted_bits = w;
- encoder->private->subframe_bps_mid_side[channel] = encoder->protected->bits_per_sample - w + (channel==0? 0:1);
+ w = stream_encoder_get_wasted_bits_(encoder->private_->integer_signal_mid_side[channel], encoder->protected_->blocksize);
+ encoder->private_->subframe_workspace_mid_side[channel][0].wasted_bits = encoder->private_->subframe_workspace_mid_side[channel][1].wasted_bits = w;
+ encoder->private_->subframe_bps_mid_side[channel] = encoder->protected_->bits_per_sample - w + (channel==0? 0:1);
}
}
* First do a normal encoding pass of each independent channel
*/
if(do_independent) {
- for(channel = 0; channel < encoder->protected->channels; channel++) {
- if(!stream_encoder_process_subframe_(encoder, min_partition_order, max_partition_order, precompute_partition_sums, false, &frame_header, encoder->private->subframe_bps[channel], encoder->private->integer_signal[channel], encoder->private->real_signal[channel], encoder->private->subframe_workspace_ptr[channel], encoder->private->residual_workspace[channel], encoder->private->best_subframe+channel, encoder->private->best_subframe_bits+channel))
+ for(channel = 0; channel < encoder->protected_->channels; channel++) {
+ if(!stream_encoder_process_subframe_(encoder, min_partition_order, max_partition_order, precompute_partition_sums, false, &frame_header, encoder->private_->subframe_bps[channel], encoder->private_->integer_signal[channel], encoder->private_->real_signal[channel], encoder->private_->subframe_workspace_ptr[channel], encoder->private_->residual_workspace[channel], encoder->private_->best_subframe+channel, encoder->private_->best_subframe_bits+channel))
return false;
}
}
* Now do mid and side channels if requested
*/
if(do_mid_side) {
- FLAC__ASSERT(encoder->protected->channels == 2);
+ FLAC__ASSERT(encoder->protected_->channels == 2);
for(channel = 0; channel < 2; channel++) {
- if(!stream_encoder_process_subframe_(encoder, min_partition_order, max_partition_order, precompute_partition_sums, false, &frame_header, encoder->private->subframe_bps_mid_side[channel], encoder->private->integer_signal_mid_side[channel], encoder->private->real_signal_mid_side[channel], encoder->private->subframe_workspace_ptr_mid_side[channel], encoder->private->residual_workspace_mid_side[channel], encoder->private->best_subframe_mid_side+channel, encoder->private->best_subframe_bits_mid_side+channel))
+ if(!stream_encoder_process_subframe_(encoder, min_partition_order, max_partition_order, precompute_partition_sums, false, &frame_header, encoder->private_->subframe_bps_mid_side[channel], encoder->private_->integer_signal_mid_side[channel], encoder->private_->real_signal_mid_side[channel], encoder->private_->subframe_workspace_ptr_mid_side[channel], encoder->private_->residual_workspace_mid_side[channel], encoder->private_->best_subframe_mid_side+channel, encoder->private_->best_subframe_bits_mid_side+channel))
return false;
}
}
FLAC__Subframe *left_subframe = 0, *right_subframe = 0; /* initialized only to prevent superfluous compiler warning */
FLAC__ChannelAssignment channel_assignment;
- FLAC__ASSERT(encoder->protected->channels == 2);
+ FLAC__ASSERT(encoder->protected_->channels == 2);
- if(encoder->protected->loose_mid_side_stereo && encoder->private->loose_mid_side_stereo_frame_count > 0) {
- channel_assignment = (encoder->private->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT? FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT : FLAC__CHANNEL_ASSIGNMENT_MID_SIDE);
+ if(encoder->protected_->loose_mid_side_stereo && encoder->private_->loose_mid_side_stereo_frame_count > 0) {
+ channel_assignment = (encoder->private_->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT? FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT : FLAC__CHANNEL_ASSIGNMENT_MID_SIDE);
}
else {
unsigned bits[4]; /* WATCHOUT - indexed by FLAC__ChannelAssignment */
FLAC__ASSERT(do_independent && do_mid_side);
/* We have to figure out which channel assignent results in the smallest frame */
- bits[FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT] = encoder->private->best_subframe_bits [0] + encoder->private->best_subframe_bits [1];
- bits[FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE ] = encoder->private->best_subframe_bits [0] + encoder->private->best_subframe_bits_mid_side[1];
- bits[FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE ] = encoder->private->best_subframe_bits [1] + encoder->private->best_subframe_bits_mid_side[1];
- bits[FLAC__CHANNEL_ASSIGNMENT_MID_SIDE ] = encoder->private->best_subframe_bits_mid_side[0] + encoder->private->best_subframe_bits_mid_side[1];
+ bits[FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT] = encoder->private_->best_subframe_bits [0] + encoder->private_->best_subframe_bits [1];
+ bits[FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE ] = encoder->private_->best_subframe_bits [0] + encoder->private_->best_subframe_bits_mid_side[1];
+ bits[FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE ] = encoder->private_->best_subframe_bits [1] + encoder->private_->best_subframe_bits_mid_side[1];
+ bits[FLAC__CHANNEL_ASSIGNMENT_MID_SIDE ] = encoder->private_->best_subframe_bits_mid_side[0] + encoder->private_->best_subframe_bits_mid_side[1];
for(channel_assignment = 0, min_bits = bits[0], ca = 1; ca <= 3; ca++) {
if(bits[ca] < min_bits) {
frame_header.channel_assignment = channel_assignment;
- if(!FLAC__frame_add_header(&frame_header, encoder->protected->streamable_subset, is_last_frame, &encoder->private->frame)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
+ if(!FLAC__frame_add_header(&frame_header, encoder->protected_->streamable_subset, is_last_frame, &encoder->private_->frame)) {
+ encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
return false;
}
switch(channel_assignment) {
case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
- left_subframe = &encoder->private->subframe_workspace [0][encoder->private->best_subframe [0]];
- right_subframe = &encoder->private->subframe_workspace [1][encoder->private->best_subframe [1]];
+ left_subframe = &encoder->private_->subframe_workspace [0][encoder->private_->best_subframe [0]];
+ right_subframe = &encoder->private_->subframe_workspace [1][encoder->private_->best_subframe [1]];
break;
case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- left_subframe = &encoder->private->subframe_workspace [0][encoder->private->best_subframe [0]];
- right_subframe = &encoder->private->subframe_workspace_mid_side[1][encoder->private->best_subframe_mid_side[1]];
+ left_subframe = &encoder->private_->subframe_workspace [0][encoder->private_->best_subframe [0]];
+ right_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]];
break;
case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- left_subframe = &encoder->private->subframe_workspace_mid_side[1][encoder->private->best_subframe_mid_side[1]];
- right_subframe = &encoder->private->subframe_workspace [1][encoder->private->best_subframe [1]];
+ left_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]];
+ right_subframe = &encoder->private_->subframe_workspace [1][encoder->private_->best_subframe [1]];
break;
case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- left_subframe = &encoder->private->subframe_workspace_mid_side[0][encoder->private->best_subframe_mid_side[0]];
- right_subframe = &encoder->private->subframe_workspace_mid_side[1][encoder->private->best_subframe_mid_side[1]];
+ left_subframe = &encoder->private_->subframe_workspace_mid_side[0][encoder->private_->best_subframe_mid_side[0]];
+ right_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]];
break;
default:
FLAC__ASSERT(0);
switch(channel_assignment) {
case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
- left_bps = encoder->private->subframe_bps [0];
- right_bps = encoder->private->subframe_bps [1];
+ left_bps = encoder->private_->subframe_bps [0];
+ right_bps = encoder->private_->subframe_bps [1];
break;
case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- left_bps = encoder->private->subframe_bps [0];
- right_bps = encoder->private->subframe_bps_mid_side[1];
+ left_bps = encoder->private_->subframe_bps [0];
+ right_bps = encoder->private_->subframe_bps_mid_side[1];
break;
case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- left_bps = encoder->private->subframe_bps_mid_side[1];
- right_bps = encoder->private->subframe_bps [1];
+ left_bps = encoder->private_->subframe_bps_mid_side[1];
+ right_bps = encoder->private_->subframe_bps [1];
break;
case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- left_bps = encoder->private->subframe_bps_mid_side[0];
- right_bps = encoder->private->subframe_bps_mid_side[1];
+ left_bps = encoder->private_->subframe_bps_mid_side[0];
+ right_bps = encoder->private_->subframe_bps_mid_side[1];
break;
default:
FLAC__ASSERT(0);
}
/* note that encoder_add_subframe_ sets the state for us in case of an error */
- if(!stream_encoder_add_subframe_(encoder, &frame_header, left_bps , left_subframe , &encoder->private->frame))
+ if(!stream_encoder_add_subframe_(encoder, &frame_header, left_bps , left_subframe , &encoder->private_->frame))
return false;
- if(!stream_encoder_add_subframe_(encoder, &frame_header, right_bps, right_subframe, &encoder->private->frame))
+ if(!stream_encoder_add_subframe_(encoder, &frame_header, right_bps, right_subframe, &encoder->private_->frame))
return false;
}
else {
- if(!FLAC__frame_add_header(&frame_header, encoder->protected->streamable_subset, is_last_frame, &encoder->private->frame)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
+ if(!FLAC__frame_add_header(&frame_header, encoder->protected_->streamable_subset, is_last_frame, &encoder->private_->frame)) {
+ encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
return false;
}
- for(channel = 0; channel < encoder->protected->channels; channel++) {
- if(!stream_encoder_add_subframe_(encoder, &frame_header, encoder->private->subframe_bps[channel], &encoder->private->subframe_workspace[channel][encoder->private->best_subframe[channel]], &encoder->private->frame)) {
+ for(channel = 0; channel < encoder->protected_->channels; channel++) {
+ if(!stream_encoder_add_subframe_(encoder, &frame_header, encoder->private_->subframe_bps[channel], &encoder->private_->subframe_workspace[channel][encoder->private_->best_subframe[channel]], &encoder->private_->frame)) {
/* the above function sets the state for us in case of an error */
return false;
}
}
}
- if(encoder->protected->loose_mid_side_stereo) {
- encoder->private->loose_mid_side_stereo_frame_count++;
- if(encoder->private->loose_mid_side_stereo_frame_count >= encoder->private->loose_mid_side_stereo_frames)
- encoder->private->loose_mid_side_stereo_frame_count = 0;
+ if(encoder->protected_->loose_mid_side_stereo) {
+ encoder->private_->loose_mid_side_stereo_frame_count++;
+ if(encoder->private_->loose_mid_side_stereo_frame_count >= encoder->private_->loose_mid_side_stereo_frames)
+ encoder->private_->loose_mid_side_stereo_frame_count = 0;
}
- encoder->private->last_channel_assignment = frame_header.channel_assignment;
+ encoder->private_->last_channel_assignment = frame_header.channel_assignment;
return true;
}
{
FLAC__real fixed_residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1];
FLAC__real lpc_residual_bits_per_sample;
- FLAC__real autoc[FLAC__MAX_LPC_ORDER+1]; /* WATCHOUT: the size is important even though encoder->protected->max_lpc_order might be less; some asm routines need all the space */
+ FLAC__real autoc[FLAC__MAX_LPC_ORDER+1]; /* WATCHOUT: the size is important even though encoder->protected_->max_lpc_order might be less; some asm routines need all the space */
FLAC__real lp_coeff[FLAC__MAX_LPC_ORDER][FLAC__MAX_LPC_ORDER];
FLAC__real lpc_error[FLAC__MAX_LPC_ORDER];
unsigned min_lpc_order, max_lpc_order, lpc_order;
if(!verbatim_only && frame_header->blocksize >= FLAC__MAX_FIXED_ORDER) {
/* check for constant subframe */
- guess_fixed_order = encoder->private->local_fixed_compute_best_predictor(integer_signal+FLAC__MAX_FIXED_ORDER, frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample);
+ guess_fixed_order = encoder->private_->local_fixed_compute_best_predictor(integer_signal+FLAC__MAX_FIXED_ORDER, frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample);
if(fixed_residual_bits_per_sample[1] == 0.0) {
/* the above means integer_signal+FLAC__MAX_FIXED_ORDER is constant, now we just have to check the warmup samples */
unsigned i, signal_is_constant = true;
}
else {
/* encode fixed */
- if(encoder->protected->do_exhaustive_model_search) {
+ if(encoder->protected_->do_exhaustive_model_search) {
min_fixed_order = 0;
max_fixed_order = FLAC__MAX_FIXED_ORDER;
}
#endif
rice_parameter = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER - 1;
}
- _candidate_bits = stream_encoder_evaluate_fixed_subframe_(integer_signal, residual[!_best_subframe], encoder->private->abs_residual, encoder->private->abs_residual_partition_sums, encoder->private->raw_bits_per_partition, frame_header->blocksize, subframe_bps, fixed_order, rice_parameter, min_partition_order, max_partition_order, precompute_partition_sums, encoder->protected->do_escape_coding, encoder->protected->rice_parameter_search_dist, subframe[!_best_subframe]);
+ _candidate_bits = stream_encoder_evaluate_fixed_subframe_(integer_signal, residual[!_best_subframe], encoder->private_->abs_residual, encoder->private_->abs_residual_partition_sums, encoder->private_->raw_bits_per_partition, frame_header->blocksize, subframe_bps, fixed_order, rice_parameter, min_partition_order, max_partition_order, precompute_partition_sums, encoder->protected_->do_escape_coding, encoder->protected_->rice_parameter_search_dist, subframe[!_best_subframe]);
if(_candidate_bits < _best_bits) {
_best_subframe = !_best_subframe;
_best_bits = _candidate_bits;
}
/* encode lpc */
- if(encoder->protected->max_lpc_order > 0) {
- if(encoder->protected->max_lpc_order >= frame_header->blocksize)
+ if(encoder->protected_->max_lpc_order > 0) {
+ if(encoder->protected_->max_lpc_order >= frame_header->blocksize)
max_lpc_order = frame_header->blocksize-1;
else
- max_lpc_order = encoder->protected->max_lpc_order;
+ max_lpc_order = encoder->protected_->max_lpc_order;
if(max_lpc_order > 0) {
- encoder->private->local_lpc_compute_autocorrelation(real_signal, frame_header->blocksize, max_lpc_order+1, autoc);
+ encoder->private_->local_lpc_compute_autocorrelation(real_signal, frame_header->blocksize, max_lpc_order+1, autoc);
/* if autoc[0] == 0.0, the signal is constant and we usually won't get here, but it can happen */
if(autoc[0] != 0.0) {
FLAC__lpc_compute_lp_coefficients(autoc, max_lpc_order, lp_coeff, lpc_error);
- if(encoder->protected->do_exhaustive_model_search) {
+ if(encoder->protected_->do_exhaustive_model_search) {
min_lpc_order = 1;
}
else {
unsigned guess_lpc_order = FLAC__lpc_compute_best_order(lpc_error, max_lpc_order, frame_header->blocksize, subframe_bps);
min_lpc_order = max_lpc_order = guess_lpc_order;
}
- if(encoder->protected->do_qlp_coeff_prec_search) {
+ if(encoder->protected_->do_qlp_coeff_prec_search) {
min_qlp_coeff_precision = FLAC__MIN_QLP_COEFF_PRECISION;
max_qlp_coeff_precision = min(8*sizeof(FLAC__int32) - subframe_bps - 1 - 2, (1u<<FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN)-1); /* -2 to keep things 32-bit safe */
}
else {
- min_qlp_coeff_precision = max_qlp_coeff_precision = encoder->protected->qlp_coeff_precision;
+ min_qlp_coeff_precision = max_qlp_coeff_precision = encoder->protected_->qlp_coeff_precision;
}
for(lpc_order = min_lpc_order; lpc_order <= max_lpc_order; lpc_order++) {
lpc_residual_bits_per_sample = FLAC__lpc_compute_expected_bits_per_residual_sample(lpc_error[lpc_order-1], frame_header->blocksize-lpc_order);
rice_parameter = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER - 1;
}
for(qlp_coeff_precision = min_qlp_coeff_precision; qlp_coeff_precision <= max_qlp_coeff_precision; qlp_coeff_precision++) {
- _candidate_bits = stream_encoder_evaluate_lpc_subframe_(encoder, integer_signal, residual[!_best_subframe], encoder->private->abs_residual, encoder->private->abs_residual_partition_sums, encoder->private->raw_bits_per_partition, lp_coeff[lpc_order-1], frame_header->blocksize, subframe_bps, lpc_order, qlp_coeff_precision, rice_parameter, min_partition_order, max_partition_order, precompute_partition_sums, encoder->protected->do_escape_coding, encoder->protected->rice_parameter_search_dist, subframe[!_best_subframe]);
+ _candidate_bits = stream_encoder_evaluate_lpc_subframe_(encoder, integer_signal, residual[!_best_subframe], encoder->private_->abs_residual, encoder->private_->abs_residual_partition_sums, encoder->private_->raw_bits_per_partition, lp_coeff[lpc_order-1], frame_header->blocksize, subframe_bps, lpc_order, qlp_coeff_precision, rice_parameter, min_partition_order, max_partition_order, precompute_partition_sums, encoder->protected_->do_escape_coding, encoder->protected_->rice_parameter_search_dist, subframe[!_best_subframe]);
if(_candidate_bits > 0) { /* if == 0, there was a problem quantizing the lpcoeffs */
if(_candidate_bits < _best_bits) {
_best_subframe = !_best_subframe;
switch(subframe->type) {
case FLAC__SUBFRAME_TYPE_CONSTANT:
if(!FLAC__subframe_add_constant(&(subframe->data.constant), subframe_bps, subframe->wasted_bits, frame)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
+ encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
return false;
}
break;
case FLAC__SUBFRAME_TYPE_FIXED:
if(!FLAC__subframe_add_fixed(&(subframe->data.fixed), frame_header->blocksize - subframe->data.fixed.order, subframe_bps, subframe->wasted_bits, frame)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
+ encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
return false;
}
break;
case FLAC__SUBFRAME_TYPE_LPC:
if(!FLAC__subframe_add_lpc(&(subframe->data.lpc), frame_header->blocksize - subframe->data.lpc.order, subframe_bps, subframe->wasted_bits, frame)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
+ encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
return false;
}
break;
case FLAC__SUBFRAME_TYPE_VERBATIM:
if(!FLAC__subframe_add_verbatim(&(subframe->data.verbatim), frame_header->blocksize, subframe_bps, subframe->wasted_bits, frame)) {
- encoder->protected->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
+ encoder->protected_->state = FLAC__STREAM_ENCODER_FATAL_ERROR_WHILE_ENCODING;
return false;
}
break;
return 0; /* this is a hack to indicate to the caller that we can't do lp at this order on this subframe */
if(subframe_bps <= 16 && qlp_coeff_precision <= 16)
- encoder->private->local_lpc_compute_residual_from_qlp_coefficients_16bit(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
+ encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
else
- encoder->private->local_lpc_compute_residual_from_qlp_coefficients(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
+ encoder->private_->local_lpc_compute_residual_from_qlp_coefficients(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
subframe->type = FLAC__SUBFRAME_TYPE_LPC;