From 77e3f319a561894960a3667244df630f8468e60f Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Sat, 23 Jun 2001 03:03:24 +0000 Subject: [PATCH] revamp the ordinal types --- include/FLAC/file_decoder.h | 36 +-- include/FLAC/format.h | 42 ++-- include/FLAC/ordinals.h | 60 +---- include/FLAC/seek_table.h | 2 +- include/FLAC/stream_decoder.h | 22 +- include/FLAC/stream_encoder.h | 114 ++++----- src/flac/analyze.c | 10 +- src/flac/analyze.h | 4 +- src/flac/decode.c | 92 +++---- src/flac/decode.h | 4 +- src/flac/encode.c | 160 ++++++------ src/flac/encode.h | 4 +- src/flac/main.c | 18 +- src/libFLAC/bitbuffer.c | 230 +++++++++--------- src/libFLAC/crc.c | 20 +- src/libFLAC/file_decoder.c | 84 +++---- src/libFLAC/fixed.c | 62 ++--- src/libFLAC/format.c | 4 +- src/libFLAC/ia32/fixed_asm.nasm | 46 ++-- src/libFLAC/ia32/lpc_asm-unrolled.nasm | 4 +- src/libFLAC/ia32/lpc_asm.nasm | 10 +- src/libFLAC/include/private/bitbuffer.h | 80 +++--- src/libFLAC/include/private/cpu.h | 12 +- src/libFLAC/include/private/crc.h | 16 +- src/libFLAC/include/private/fixed.h | 10 +- src/libFLAC/include/private/lpc.h | 34 +-- src/libFLAC/include/private/md5.h | 12 +- src/libFLAC/include/private/memory.h | 10 +- .../include/private/stream_encoder_framing.h | 12 +- src/libFLAC/include/protected/file_decoder.h | 2 +- .../include/protected/stream_encoder.h | 14 +- src/libFLAC/lpc.c | 64 ++--- src/libFLAC/md5.c | 28 +-- src/libFLAC/memory.c | 20 +- src/libFLAC/seek_table.c | 6 +- src/libFLAC/stream_decoder.c | 222 ++++++++--------- src/libFLAC/stream_encoder.c | 218 ++++++++--------- src/libFLAC/stream_encoder_framing.c | 26 +- src/metaflac/main.c | 34 +-- src/plugin_winamp2/in_flac.c | 16 +- src/plugin_winamp3/in_flac.cpp | 42 ++-- src/plugin_xmms/plugin.c | 40 +-- src/test_streams/main.c | 90 +++---- src/test_unit/bitbuffer.c | 24 +- 44 files changed, 1013 insertions(+), 1047 deletions(-) diff --git a/include/FLAC/file_decoder.h b/include/FLAC/file_decoder.h index d234d682..83141a7d 100644 --- a/include/FLAC/file_decoder.h +++ b/include/FLAC/file_decoder.h @@ -62,11 +62,11 @@ typedef struct { * will take on the defaults from the constructor, shown below. * For more on what the parameters mean, see the documentation. * - * bool md5_checking (DEFAULT: false) MD5 checking will be turned off if a seek is requested - * (*write_callback)() (DEFAULT: NULL ) The callbacks are the only values that MUST be set before FLAC__file_decoder_init() - * (*metadata_callback)() (DEFAULT: NULL ) - * (*error_callback)() (DEFAULT: NULL ) - * void* client_data (DEFAULT: NULL ) passed back through the callbacks + * FLAC__bool md5_checking (DEFAULT: false) MD5 checking will be turned off if a seek is requested + * (*write_callback)() (DEFAULT: NULL ) The callbacks are the only values that MUST be set before FLAC__file_decoder_init() + * (*metadata_callback)() (DEFAULT: NULL ) + * (*error_callback)() (DEFAULT: NULL ) + * void* client_data (DEFAULT: NULL ) passed back through the callbacks */ FLAC__FileDecoder *FLAC__file_decoder_new(); void FLAC__file_decoder_delete(FLAC__FileDecoder *); @@ -94,18 +94,18 @@ void FLAC__file_decoder_delete(FLAC__FileDecoder *); * FLAC__file_decoder_flush() or FLAC__file_decoder_reset() do * NOT reset the values to the constructor defaults. */ -bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, bool value); -bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value); -bool FLAC__file_decoder_set_write_callback(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data)); -bool FLAC__file_decoder_set_metadata_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data)); -bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)); -bool FLAC__file_decoder_set_client_data(const FLAC__FileDecoder *decoder, void *value); +FLAC__bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, FLAC__bool value); +FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value); +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)); +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)); +FLAC__bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)); +FLAC__bool FLAC__file_decoder_set_client_data(const FLAC__FileDecoder *decoder, void *value); /* * Various "get" methods */ FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *decoder); -bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder); +FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder); /* * Initialize the instance; should be called after construction and @@ -121,16 +121,16 @@ FLAC__FileDecoderState FLAC__file_decoder_init(FLAC__FileDecoder *decoder); * md5_checking is set AND the stored MD5 sum is non-zero AND the stored * MD5 sum and computed MD5 sum do not match. */ -bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder); +FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder); /* * Methods for decoding the data */ -bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder); -bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder); -bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder); -bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder); +FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder); +FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder); +FLAC__bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder); +FLAC__bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder); -bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, uint64 sample); +FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__uint64 sample); #endif diff --git a/include/FLAC/format.h b/include/FLAC/format.h index 0714c3a0..0bdda0bc 100644 --- a/include/FLAC/format.h +++ b/include/FLAC/format.h @@ -27,7 +27,7 @@ #define FLAC__MAX_BLOCK_SIZE (65535u) #define FLAC__MAX_CHANNELS (8u) #define FLAC__MIN_BITS_PER_SAMPLE (4u) -/*NOTE: only up to 24 because of the current predictor coefficient quantization and the fact we use int32s for all work */ +/*NOTE: only up to 24 because of the current predictor coefficient quantization and the fact we use FLAC__int32s for all work */ #define FLAC__MAX_BITS_PER_SAMPLE (24u) /* the following is ((2 ** 20) - 1) div 10 */ #define FLAC__MAX_SAMPLE_RATE (1048570u) @@ -42,7 +42,7 @@ #define FLAC__VERSION_STRING VERSION #endif -extern const byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */; +extern const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */; extern const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */; extern const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */; @@ -115,7 +115,7 @@ extern const char *FLAC__SubframeTypeString[]; * n: constant value for signal; n = frame's bits-per-sample */ typedef struct { - int32 value; + FLAC__int32 value; } FLAC__Subframe_Constant; /***************************************************************************** @@ -123,7 +123,7 @@ typedef struct { * n*i: unencoded signal; n = frame's bits-per-sample, i = frame's blocksize */ typedef struct { - const int32 *data; + const FLAC__int32 *data; } FLAC__Subframe_Verbatim; /***************************************************************************** @@ -136,8 +136,8 @@ typedef struct { typedef struct { FLAC__EntropyCodingMethod entropy_coding_method; unsigned order; - int32 warmup[FLAC__MAX_FIXED_ORDER]; - const int32 *residual; + FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER]; + const FLAC__int32 *residual; } FLAC__Subframe_Fixed; /***************************************************************************** @@ -155,9 +155,9 @@ typedef struct { unsigned order; unsigned qlp_coeff_precision; int quantization_level; - int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; - int32 warmup[FLAC__MAX_LPC_ORDER]; - const int32 *residual; + FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; + FLAC__int32 warmup[FLAC__MAX_LPC_ORDER]; + const FLAC__int32 *residual; } FLAC__Subframe_LPC; extern const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /* = 4 bits */ @@ -278,10 +278,10 @@ typedef struct { FLAC__ChannelAssignment channel_assignment; unsigned bits_per_sample; union { - uint32 frame_number; - uint64 sample_number; + FLAC__uint32 frame_number; + FLAC__uint64 sample_number; } number; - uint8 crc; + FLAC__uint8 crc; } FLAC__FrameHeader; extern const unsigned FLAC__FRAME_HEADER_SYNC; /* = 0x3ffe */ @@ -299,7 +299,7 @@ extern const unsigned FLAC__FRAME_HEADER_CRC_LEN; /* = 8 bits */ * 16: CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with 0) of everything before the crc, back to and including the frame header sync code */ typedef struct { - uint16 crc; + FLAC__uint16 crc; } FLAC__FrameFooter; extern const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /* = 16 bits */ @@ -347,8 +347,8 @@ typedef struct { unsigned sample_rate; unsigned channels; unsigned bits_per_sample; - uint64 total_samples; - byte md5sum[16]; + FLAC__uint64 total_samples; + FLAC__byte md5sum[16]; } FLAC__StreamMetaData_StreamInfo; extern const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /* = 16 bits */ @@ -381,8 +381,8 @@ typedef struct { * 4+n/8 bytes total */ typedef struct { - byte id[4]; - byte *data; + FLAC__byte id[4]; + FLAC__byte *data; } FLAC__StreamMetaData_Application; extern const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /* = 32 bits */ @@ -396,8 +396,8 @@ extern const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /* = 32 bits */ * 18 bytes total */ typedef struct { - uint64 sample_number; - uint64 stream_offset; + FLAC__uint64 sample_number; + FLAC__uint64 stream_offset; unsigned frame_samples; } FLAC__StreamMetaData_SeekPoint; @@ -406,7 +406,7 @@ extern const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /* = 64 extern const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /* = 16 bits */ extern const unsigned FLAC__STREAM_METADATA_SEEKPOINT_LEN; /* = 18 bytes */ -extern const uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; /* = 0xffffffffffffffff */ +extern const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; /* = 0xffffffffffffffff */ /***************************************************************************** * @@ -436,7 +436,7 @@ typedef struct { */ typedef struct { FLAC__MetaDataType type; - bool is_last; + FLAC__bool is_last; unsigned length; /* in bytes */ union { FLAC__StreamMetaData_StreamInfo stream_info; diff --git a/include/FLAC/ordinals.h b/include/FLAC/ordinals.h index b76f8b7b..b4c03f41 100644 --- a/include/FLAC/ordinals.h +++ b/include/FLAC/ordinals.h @@ -20,64 +20,30 @@ #ifndef FLAC__ORDINALS_H #define FLAC__ORDINALS_H -#ifdef bool -#undef bool -#endif #ifdef true #undef true #endif #ifdef false #undef false #endif -#ifdef int8 -#undef int8 -#endif -#ifdef uint8 -#undef uint8 -#endif -#ifdef int16 -#undef int16 -#endif -#ifdef uint16 -#undef uint16 -#endif -#ifdef int32 -#undef int32 -#endif -#ifdef uint32 -#undef uint32 -#endif -#ifdef int64 -#undef int64 -#endif -#ifdef uint64 -#undef uint64 -#endif -#ifdef byte -#undef byte -#endif -#ifdef real -#undef real -#endif - #define true 1 #define false 0 -typedef int bool; -typedef signed char int8; -typedef unsigned char uint8; -typedef signed short int16; -typedef unsigned short uint16; -typedef signed int int32; -typedef unsigned int uint32; +typedef int FLAC__bool; +typedef signed char FLAC__int8; +typedef unsigned char FLAC__uint8; +typedef signed short FLAC__int16; +typedef unsigned short FLAC__uint16; +typedef signed int FLAC__int32; +typedef unsigned int FLAC__uint32; #if defined _WIN32 && !defined __CYGWIN__ -typedef __int64 int64; -typedef unsigned __int64 uint64; +typedef __int64 FLAC__int64; +typedef unsigned __int64 FLAC__uint64; #else -typedef long long int int64; -typedef unsigned long long uint64; +typedef long long int FLAC__int64; +typedef unsigned long long FLAC__uint64; #endif -typedef uint8 byte; -typedef float real; +typedef FLAC__uint8 FLAC__byte; +typedef float FLAC__real; #endif diff --git a/include/FLAC/seek_table.h b/include/FLAC/seek_table.h index 7088885d..84b4a5cd 100644 --- a/include/FLAC/seek_table.h +++ b/include/FLAC/seek_table.h @@ -22,6 +22,6 @@ #include "format.h" -bool FLAC__seek_table_is_valid(const FLAC__StreamMetaData_SeekTable *seek_table); +FLAC__bool FLAC__seek_table_is_valid(const FLAC__StreamMetaData_SeekTable *seek_table); #endif diff --git a/include/FLAC/stream_decoder.h b/include/FLAC/stream_decoder.h index 91cdf802..920a3a3c 100644 --- a/include/FLAC/stream_decoder.h +++ b/include/FLAC/stream_decoder.h @@ -113,11 +113,11 @@ void FLAC__stream_decoder_delete(FLAC__StreamDecoder *); * FLAC__stream_decoder_flush() or FLAC__stream_decoder_reset() do * NOT reset the values to the constructor defaults. */ -bool FLAC__stream_decoder_set_read_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderReadStatus (*value)(const FLAC__StreamDecoder *decoder, byte buffer[], unsigned *bytes, void *client_data)); -bool FLAC__stream_decoder_set_write_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data)); -bool FLAC__stream_decoder_set_metadata_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data)); -bool FLAC__stream_decoder_set_error_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)); -bool FLAC__stream_decoder_set_client_data(const FLAC__StreamDecoder *decoder, void *value); +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)); +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)); +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)); +FLAC__bool FLAC__stream_decoder_set_error_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)); +FLAC__bool FLAC__stream_decoder_set_client_data(const FLAC__StreamDecoder *decoder, void *value); /* * Methods to return the current stream decoder state, number @@ -150,15 +150,15 @@ void FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder); /* * state control methods */ -bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder); -bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder); +FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder); +FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder); /* * Methods for decoding the data */ -bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decoder); -bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder); -bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder); -bool FLAC__stream_decoder_process_remaining_frames(FLAC__StreamDecoder *decoder); +FLAC__bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decoder); +FLAC__bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder); +FLAC__bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder); +FLAC__bool FLAC__stream_decoder_process_remaining_frames(FLAC__StreamDecoder *decoder); #endif diff --git a/include/FLAC/stream_encoder.h b/include/FLAC/stream_encoder.h index aa714f20..e5c36e42 100644 --- a/include/FLAC/stream_encoder.h +++ b/include/FLAC/stream_encoder.h @@ -75,29 +75,29 @@ typedef struct { * will take on the defaults from the constructor, shown below. * For more on what the parameters mean, see the documentation. * - * bool streamable_subset (DEFAULT: true ) true to limit encoder to generating a Subset stream, else false - * bool do_mid_side_stereo (DEFAULT: false) if true then channels must be 2 - * bool loose_mid_side_stereo (DEFAULT: false) if true then do_mid_side_stereo must be true - * unsigned channels (DEFAULT: 2 ) must be <= FLAC__MAX_CHANNELS - * unsigned bits_per_sample (DEFAULT: 16 ) do not give the encoder wider data than what you specify here or bad things will happen! - * unsigned sample_rate (DEFAULT: 44100) - * unsigned blocksize (DEFAULT: 1152 ) - * unsigned max_lpc_order (DEFAULT: 0 ) 0 => encoder will not try general LPC, only fixed predictors; must be <= FLAC__MAX_LPC_ORDER - * unsigned qlp_coeff_precision (DEFAULT: 0 ) >= FLAC__MIN_QLP_COEFF_PRECISION, or 0 to let encoder select based on blocksize; + * FLAC__bool streamable_subset (DEFAULT: true ) true to limit encoder to generating a Subset stream, else false + * FLAC__bool do_mid_side_stereo (DEFAULT: false) if true then channels must be 2 + * FLAC__bool loose_mid_side_stereo (DEFAULT: false) if true then do_mid_side_stereo must be true + * unsigned channels (DEFAULT: 2 ) must be <= FLAC__MAX_CHANNELS + * unsigned bits_per_sample (DEFAULT: 16 ) do not give the encoder wider data than what you specify here or bad things will happen! + * unsigned sample_rate (DEFAULT: 44100) + * unsigned blocksize (DEFAULT: 1152 ) + * unsigned max_lpc_order (DEFAULT: 0 ) 0 => encoder will not try general LPC, only fixed predictors; must be <= FLAC__MAX_LPC_ORDER + * unsigned qlp_coeff_precision (DEFAULT: 0 ) >= FLAC__MIN_QLP_COEFF_PRECISION, or 0 to let encoder select based on blocksize; * qlp_coeff_precision+bits_per_sample must be < 32 - * bool do_qlp_coeff_prec_search (DEFAULT: false) false => use qlp_coeff_precision, true => search around qlp_coeff_precision, take best - * bool do_exhaustive_model_search (DEFAULT: false) false => use estimated bits per residual for scoring, true => generate all, take shortest - * unsigned min_residual_partition_order (DEFAULT: 0 ) 0 => estimate Rice parameter based on residual variance; >0 => partition residual, use parameter - * unsigned max_residual_partition_order (DEFAULT: 0 ) for each based on mean; min_ and max_ specify the min and max Rice partition order - * unsigned rice_parameter_search_dist (DEFAULT: 0 ) 0 => try only calc'd parameter k; else try all [k-dist..k+dist] parameters, use best - * uint64 total_samples_estimate (DEFAULT: 0 ) may be 0 if unknown. acts as a placeholder in the STREAMINFO until the actual total is calculated + * FLAC__bool do_qlp_coeff_prec_search (DEFAULT: false) false => use qlp_coeff_precision, true => search around qlp_coeff_precision, take best + * FLAC__bool do_exhaustive_model_search (DEFAULT: false) false => use estimated bits per residual for scoring, true => generate all, take shortest + * unsigned min_residual_partition_order (DEFAULT: 0 ) 0 => estimate Rice parameter based on residual variance; >0 => partition residual, use parameter + * unsigned max_residual_partition_order (DEFAULT: 0 ) for each based on mean; min_ and max_ specify the min and max Rice partition order + * unsigned rice_parameter_search_dist (DEFAULT: 0 ) 0 => try only calc'd parameter k; else try all [k-dist..k+dist] parameters, use best + * FLAC__uint64 total_samples_estimate (DEFAULT: 0 ) may be 0 if unknown. acts as a placeholder in the STREAMINFO until the actual total is calculated * const FLAC__StreamMetaData_SeekTable *seek_table (DEFAULT: NULL) optional seek_table to prepend, NULL => no seek table - * unsigned padding (DEFAULT: 0 ) size of PADDING block to add (goes after seek table); 0 => do not add a PADDING block - * bool last_metadata_is_last (DEFAULT: true ) the value the encoder will use for the 'is_last' flag of the last metadata block it writes; set + * unsigned padding (DEFAULT: 0 ) size of PADDING block to add (goes after seek table); 0 => do not add a PADDING block + * FLAC__bool last_metadata_is_last (DEFAULT: true ) the value the encoder will use for the 'is_last' flag of the last metadata block it writes; set * this to false if you will be adding more metadata blocks before the audio frames, else true - * (*write_callback)() (DEFAULT: NULL ) The callbacks are the only values that MUST be set before FLAC__stream_encoder_init() - * (*metadata_callback)() (DEFAULT: NULL ) - * void* client_data (DEFAULT: NULL ) passed back through the callbacks + * (*write_callback)() (DEFAULT: NULL ) The callbacks are the only values that MUST be set before FLAC__stream_encoder_init() + * (*metadata_callback)() (DEFAULT: NULL ) + * void* client_data (DEFAULT: NULL ) passed back through the callbacks */ FLAC__StreamEncoder *FLAC__stream_encoder_new(); void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder); @@ -125,46 +125,46 @@ void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder); * FLAC__stream_encoder_finish() does NOT reset the values to the * constructor defaults. */ -bool FLAC__stream_encoder_set_streamable_subset(const FLAC__StreamEncoder *encoder, bool value); -bool FLAC__stream_encoder_set_do_mid_side_stereo(const FLAC__StreamEncoder *encoder, bool value); -bool FLAC__stream_encoder_set_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder, bool value); -bool FLAC__stream_encoder_set_channels(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_bits_per_sample(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_sample_rate(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_blocksize(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_max_lpc_order(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_qlp_coeff_precision(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder, bool value); -bool FLAC__stream_encoder_set_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder, bool value); -bool FLAC__stream_encoder_set_min_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_max_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_total_samples_estimate(const FLAC__StreamEncoder *encoder, uint64 value); -bool FLAC__stream_encoder_set_seek_table(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData_SeekTable *value); -bool FLAC__stream_encoder_set_padding(const FLAC__StreamEncoder *encoder, unsigned value); -bool FLAC__stream_encoder_set_last_metadata_is_last(const FLAC__StreamEncoder *encoder, bool value); -bool FLAC__stream_encoder_set_write_callback(const FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteStatus (*value)(const FLAC__StreamEncoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)); -bool FLAC__stream_encoder_set_metadata_callback(const FLAC__StreamEncoder *encoder, void (*value)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data)); -bool FLAC__stream_encoder_set_client_data(const FLAC__StreamEncoder *encoder, void *value); +FLAC__bool FLAC__stream_encoder_set_streamable_subset(const FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(const FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC__bool FLAC__stream_encoder_set_channels(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_bits_per_sample(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_sample_rate(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_blocksize(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_max_lpc_order(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder, FLAC__bool value); +FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(const FLAC__StreamEncoder *encoder, FLAC__uint64 value); +FLAC__bool FLAC__stream_encoder_set_seek_table(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData_SeekTable *value); +FLAC__bool FLAC__stream_encoder_set_padding(const FLAC__StreamEncoder *encoder, unsigned value); +FLAC__bool FLAC__stream_encoder_set_last_metadata_is_last(const FLAC__StreamEncoder *encoder, FLAC__bool value); +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)); +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)); +FLAC__bool FLAC__stream_encoder_set_client_data(const FLAC__StreamEncoder *encoder, void *value); /* * Various "get" methods */ FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder); -bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder); -bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder); -bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder); -bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder); -bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder); -unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder); +FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder); +FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder); +FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder); +FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder); +FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder); +unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder); /* * Initialize the instance; should be called after construction and @@ -184,7 +184,7 @@ void FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder); /* * Methods for encoding the data */ -bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const int32 *buf[], unsigned samples); -bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const int32 buf[], unsigned samples); +FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 *buf[], unsigned samples); +FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buf[], unsigned samples); #endif diff --git a/src/flac/analyze.c b/src/flac/analyze.c index 41a83153..ec13b52c 100644 --- a/src/flac/analyze.c +++ b/src/flac/analyze.c @@ -24,7 +24,7 @@ #include "analyze.h" typedef struct { - int32 residual; + FLAC__int32 residual; unsigned count; } pair_t; @@ -42,9 +42,9 @@ typedef struct { static subframe_stats_t all_; static void init_stats(subframe_stats_t *stats); -static void update_stats(subframe_stats_t *stats, int32 residual, unsigned incr); +static void update_stats(subframe_stats_t *stats, FLAC__int32 residual, unsigned incr); static void compute_stats(subframe_stats_t *stats); -static bool dump_stats(const subframe_stats_t *stats, const char *filename); +static FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename); void flac__analyze_init(analysis_options aopts) { @@ -147,7 +147,7 @@ void init_stats(subframe_stats_t *stats) stats->sos = 0.0; } -void update_stats(subframe_stats_t *stats, int32 residual, unsigned incr) +void update_stats(subframe_stats_t *stats, FLAC__int32 residual, unsigned incr) { unsigned i; const double r = (double)residual, a = r*incr; @@ -179,7 +179,7 @@ void compute_stats(subframe_stats_t *stats) stats->stddev = sqrt(stats->variance); } -bool dump_stats(const subframe_stats_t *stats, const char *filename) +FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename) { FILE *outfile; unsigned i; diff --git a/src/flac/analyze.h b/src/flac/analyze.h index 9a98b5ac..b2763636 100644 --- a/src/flac/analyze.h +++ b/src/flac/analyze.h @@ -20,8 +20,8 @@ #define flac__analyze_h typedef struct { - bool do_residual_text; - bool do_residual_gnuplot; + FLAC__bool do_residual_text; + FLAC__bool do_residual_gnuplot; } analysis_options; void flac__analyze_init(analysis_options aopts); diff --git a/src/flac/decode.c b/src/flac/decode.c index f79aa958..7bee2e14 100644 --- a/src/flac/decode.c +++ b/src/flac/decode.c @@ -32,39 +32,39 @@ typedef struct { const char *inbasefilename; FILE *fout; - bool abort_flag; - bool analysis_mode; + FLAC__bool abort_flag; + FLAC__bool analysis_mode; analysis_options aopts; - bool test_only; - bool is_wave_out; - bool is_big_endian; - bool is_unsigned_samples; - uint64 total_samples; + FLAC__bool test_only; + FLAC__bool is_wave_out; + FLAC__bool is_big_endian; + FLAC__bool is_unsigned_samples; + FLAC__uint64 total_samples; unsigned bps; unsigned channels; unsigned sample_rate; - bool verbose; - uint64 skip; - bool skip_count_too_high; - uint64 samples_processed; + FLAC__bool verbose; + FLAC__uint64 skip; + FLAC__bool skip_count_too_high; + FLAC__uint64 samples_processed; unsigned frame_counter; } stream_info_struct; static FLAC__FileDecoder *decoder; -static bool is_big_endian_host; +static FLAC__bool is_big_endian_host; /* local routines */ -static bool init(const char *infilename, stream_info_struct *stream_info); -static bool write_little_endian_uint16(FILE *f, uint16 val); -static bool write_little_endian_uint32(FILE *f, uint32 val); -static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data); +static FLAC__bool init(const char *infilename, stream_info_struct *stream_info); +static FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 val); +static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 val); +static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data); static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data); static void error_callback(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); static void print_stats(const stream_info_struct *stream_info); -int flac__decode_wav(const char *infile, const char *outfile, bool analysis_mode, analysis_options aopts, bool verbose, uint64 skip) +int flac__decode_wav(const char *infile, const char *outfile, FLAC__bool analysis_mode, analysis_options aopts, FLAC__bool verbose, FLAC__uint64 skip) { - bool md5_failure = false; + FLAC__bool md5_failure = false; stream_info_struct stream_info; decoder = 0; @@ -171,9 +171,9 @@ wav_abort_: return 1; } -int flac__decode_raw(const char *infile, const char *outfile, bool analysis_mode, analysis_options aopts, bool verbose, uint64 skip, bool is_big_endian, bool is_unsigned_samples) +int flac__decode_raw(const char *infile, const char *outfile, FLAC__bool analysis_mode, analysis_options aopts, FLAC__bool verbose, FLAC__uint64 skip, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples) { - bool md5_failure = false; + FLAC__bool md5_failure = false; stream_info_struct stream_info; decoder = 0; @@ -282,11 +282,11 @@ raw_abort_: return 1; } -bool init(const char *infilename, stream_info_struct *stream_info) +FLAC__bool init(const char *infilename, stream_info_struct *stream_info) { - uint32 test = 1; + FLAC__uint32 test = 1; - is_big_endian_host = (*((byte*)(&test)))? false : true; + is_big_endian_host = (*((FLAC__byte*)(&test)))? false : true; decoder = FLAC__file_decoder_new(); if(0 == decoder) { @@ -309,42 +309,42 @@ bool init(const char *infilename, stream_info_struct *stream_info) return true; } -bool write_little_endian_uint16(FILE *f, uint16 val) +FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 val) { - byte *b = (byte*)(&val); + FLAC__byte *b = (FLAC__byte*)(&val); if(is_big_endian_host) { - byte tmp; + FLAC__byte tmp; tmp = b[1]; b[1] = b[0]; b[0] = tmp; } return fwrite(b, 1, 2, f) == 2; } -bool write_little_endian_uint32(FILE *f, uint32 val) +FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 val) { - byte *b = (byte*)(&val); + FLAC__byte *b = (FLAC__byte*)(&val); if(is_big_endian_host) { - byte tmp; + FLAC__byte tmp; tmp = b[3]; b[3] = b[0]; b[0] = tmp; tmp = b[2]; b[2] = b[1]; b[1] = tmp; } return fwrite(b, 1, 4, f) == 4; } -FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data) +FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data) { stream_info_struct *stream_info = (stream_info_struct *)client_data; FILE *fout = stream_info->fout; unsigned bps = stream_info->bps, channels = stream_info->channels; - bool is_big_endian = (stream_info->is_wave_out? false : stream_info->is_big_endian); - bool is_unsigned_samples = (stream_info->is_wave_out? bps<=8 : stream_info->is_unsigned_samples); + FLAC__bool is_big_endian = (stream_info->is_wave_out? false : stream_info->is_big_endian); + FLAC__bool is_unsigned_samples = (stream_info->is_wave_out? bps<=8 : stream_info->is_unsigned_samples); unsigned wide_samples = frame->header.blocksize, wide_sample, sample, channel, byte; - static int8 s8buffer[FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(int32)]; /* WATCHOUT: can be up to 2 megs */ - /* WATCHOUT: we say 'sizeof(int32)' above instead of '(FLAC__MAX_BITS_PER_SAMPLE+7)/8' because we have to use an array int32 even for 24 bps */ - uint8 *u8buffer = (uint8 *)s8buffer; - int16 *s16buffer = (int16 *)s8buffer; - uint16 *u16buffer = (uint16 *)s8buffer; - int32 *s32buffer = (int32 *)s8buffer; - uint32 *u32buffer = (uint32 *)s8buffer; + static FLAC__int8 s8buffer[FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * sizeof(FLAC__int32)]; /* WATCHOUT: can be up to 2 megs */ + /* WATCHOUT: we say 'sizeof(FLAC__int32)' above instead of '(FLAC__MAX_BITS_PER_SAMPLE+7)/8' because we have to use an array FLAC__int32 even for 24 bps */ + FLAC__uint8 *u8buffer = (FLAC__uint8 *)s8buffer; + FLAC__int16 *s16buffer = (FLAC__int16 *)s8buffer; + FLAC__uint16 *u16buffer = (FLAC__uint16 *)s8buffer; + FLAC__int32 *s32buffer = (FLAC__int32 *)s8buffer; + FLAC__uint32 *u32buffer = (FLAC__uint32 *)s8buffer; (void)decoder; @@ -475,24 +475,24 @@ void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaD /* write the WAVE headers if necessary */ if(!stream_info->analysis_mode && !stream_info->test_only && stream_info->is_wave_out) { - uint64 data_size = stream_info->total_samples * stream_info->channels * ((stream_info->bps+7)/8); + FLAC__uint64 data_size = stream_info->total_samples * stream_info->channels * ((stream_info->bps+7)/8); if(data_size >= 0xFFFFFFDC) { fprintf(stderr, "%s: ERROR: stream is too big to fit in a single WAVE file chunk\n", stream_info->inbasefilename); stream_info->abort_flag = true; return; } if(fwrite("RIFF", 1, 4, stream_info->fout) != 4) stream_info->abort_flag = true; - if(!write_little_endian_uint32(stream_info->fout, (uint32)(data_size+36))) stream_info->abort_flag = true; /* filesize-8 */ + if(!write_little_endian_uint32(stream_info->fout, (FLAC__uint32)(data_size+36))) stream_info->abort_flag = true; /* filesize-8 */ if(fwrite("WAVEfmt ", 1, 8, stream_info->fout) != 8) stream_info->abort_flag = true; if(fwrite("\020\000\000\000", 1, 4, stream_info->fout) != 4) stream_info->abort_flag = true; /* chunk size = 16 */ if(fwrite("\001\000", 1, 2, stream_info->fout) != 2) stream_info->abort_flag = true; /* compression code == 1 */ - if(!write_little_endian_uint16(stream_info->fout, (uint16)(stream_info->channels))) stream_info->abort_flag = true; + if(!write_little_endian_uint16(stream_info->fout, (FLAC__uint16)(stream_info->channels))) stream_info->abort_flag = true; if(!write_little_endian_uint32(stream_info->fout, stream_info->sample_rate)) stream_info->abort_flag = true; if(!write_little_endian_uint32(stream_info->fout, stream_info->sample_rate * stream_info->channels * ((stream_info->bps+7) / 8))) stream_info->abort_flag = true; /* @@@ or is it (sample_rate*channels*bps) / 8 ??? */ - if(!write_little_endian_uint16(stream_info->fout, (uint16)(stream_info->channels * ((stream_info->bps+7) / 8)))) stream_info->abort_flag = true; /* block align */ - if(!write_little_endian_uint16(stream_info->fout, (uint16)(stream_info->bps))) stream_info->abort_flag = true; /* bits per sample */ + if(!write_little_endian_uint16(stream_info->fout, (FLAC__uint16)(stream_info->channels * ((stream_info->bps+7) / 8)))) stream_info->abort_flag = true; /* block align */ + if(!write_little_endian_uint16(stream_info->fout, (FLAC__uint16)(stream_info->bps))) stream_info->abort_flag = true; /* bits per sample */ if(fwrite("data", 1, 4, stream_info->fout) != 4) stream_info->abort_flag = true; - if(!write_little_endian_uint32(stream_info->fout, (uint32)data_size)) stream_info->abort_flag = true; /* data size */ + if(!write_little_endian_uint32(stream_info->fout, (FLAC__uint32)data_size)) stream_info->abort_flag = true; /* data size */ } } } @@ -510,7 +510,7 @@ void print_stats(const stream_info_struct *stream_info) if(stream_info->verbose) { #ifdef _MSC_VER /* with VC++ you have to spoon feed it the casting */ - const double progress = (double)(int64)stream_info->samples_processed / (double)(int64)stream_info->total_samples * 100.0; + const double progress = (double)(FLAC__int64)stream_info->samples_processed / (double)(FLAC__int64)stream_info->total_samples * 100.0; #else const double progress = (double)stream_info->samples_processed / (double)stream_info->total_samples * 100.0; #endif diff --git a/src/flac/decode.h b/src/flac/decode.h index d74a064f..7b9aee33 100644 --- a/src/flac/decode.h +++ b/src/flac/decode.h @@ -22,7 +22,7 @@ #include "analyze.h" /* outfile == 0 => test only */ -int flac__decode_wav(const char *infile, const char *outfile, bool analysis_mode, analysis_options aopts, bool verbose, uint64 skip); -int flac__decode_raw(const char *infile, const char *outfile, bool analysis_mode, analysis_options aopts, bool verbose, uint64 skip, bool is_big_endian, bool is_unsigned_samples); +int flac__decode_wav(const char *infile, const char *outfile, FLAC__bool analysis_mode, analysis_options aopts, FLAC__bool verbose, FLAC__uint64 skip); +int flac__decode_raw(const char *infile, const char *outfile, FLAC__bool analysis_mode, analysis_options aopts, FLAC__bool verbose, FLAC__uint64 skip, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples); #endif diff --git a/src/flac/encode.c b/src/flac/encode.c index 0af5b4fe..1f3dda10 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -50,13 +50,13 @@ static const char *verify_code_string[] = { }; typedef struct { - int32 *original[FLAC__MAX_CHANNELS]; + FLAC__int32 *original[FLAC__MAX_CHANNELS]; unsigned size; /* of each original[] in samples */ unsigned tail; /* in wide samples */ - const byte *encoded_signal; + const FLAC__byte *encoded_signal; unsigned encoded_signal_capacity; unsigned encoded_bytes; - bool into_frames; + FLAC__bool into_frames; verify_code result; FLAC__StreamDecoder *decoder; } verify_fifo_struct; @@ -66,57 +66,57 @@ typedef struct { FILE *fout; const char *outfilename; FLAC__StreamEncoder *encoder; - bool verify; - bool verbose; - uint64 unencoded_size; - uint64 total_samples_to_encode; - uint64 bytes_written; - uint64 samples_written; - uint64 stream_offset; /* i.e. number of bytes before the first byte of the the first frame's header */ + FLAC__bool verify; + FLAC__bool verbose; + FLAC__uint64 unencoded_size; + FLAC__uint64 total_samples_to_encode; + FLAC__uint64 bytes_written; + FLAC__uint64 samples_written; + FLAC__uint64 stream_offset; /* i.e. number of bytes before the first byte of the the first frame's header */ unsigned current_frame; verify_fifo_struct verify_fifo; FLAC__StreamMetaData_SeekTable seek_table; unsigned first_seek_point_to_check; } encoder_wrapper_struct; -static bool is_big_endian_host; +static FLAC__bool is_big_endian_host; static unsigned char ucbuffer[CHUNK_OF_SAMPLES*FLAC__MAX_CHANNELS*((FLAC__MAX_BITS_PER_SAMPLE+7)/8)]; static signed char *scbuffer = (signed char *)ucbuffer; -static uint16 *usbuffer = (uint16 *)ucbuffer; -static int16 *ssbuffer = (int16 *)ucbuffer; +static FLAC__uint16 *usbuffer = (FLAC__uint16 *)ucbuffer; +static FLAC__int16 *ssbuffer = (FLAC__int16 *)ucbuffer; -static int32 in[FLAC__MAX_CHANNELS][CHUNK_OF_SAMPLES]; -static int32 *input[FLAC__MAX_CHANNELS]; +static FLAC__int32 in[FLAC__MAX_CHANNELS][CHUNK_OF_SAMPLES]; +static FLAC__int32 *input[FLAC__MAX_CHANNELS]; /* local routines */ -static bool init(encoder_wrapper_struct *encoder_wrapper); -static bool init_encoder(bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned channels, unsigned bps, unsigned sample_rate, unsigned padding, char *requested_seek_points, int num_requested_seek_points, encoder_wrapper_struct *encoder_wrapper); -static bool convert_to_seek_table(char *requested_seek_points, int num_requested_seek_points, uint64 stream_samples, unsigned blocksize, FLAC__StreamMetaData_SeekTable *seek_table); -static void append_point_to_seek_table(FLAC__StreamMetaData_SeekTable *seek_table, uint64 sample, uint64 stream_samples, uint64 blocksize); +static FLAC__bool init(encoder_wrapper_struct *encoder_wrapper); +static FLAC__bool init_encoder(FLAC__bool lax, FLAC__bool do_mid_side, FLAC__bool loose_mid_side, FLAC__bool do_exhaustive_model_search, FLAC__bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned channels, unsigned bps, unsigned sample_rate, unsigned padding, char *requested_seek_points, int num_requested_seek_points, encoder_wrapper_struct *encoder_wrapper); +static FLAC__bool convert_to_seek_table(char *requested_seek_points, int num_requested_seek_points, FLAC__uint64 stream_samples, unsigned blocksize, FLAC__StreamMetaData_SeekTable *seek_table); +static void append_point_to_seek_table(FLAC__StreamMetaData_SeekTable *seek_table, FLAC__uint64 sample, FLAC__uint64 stream_samples, FLAC__uint64 blocksize); static int seekpoint_compare(const FLAC__StreamMetaData_SeekPoint *l, const FLAC__StreamMetaData_SeekPoint *r); -static void format_input(unsigned wide_samples, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, encoder_wrapper_struct *encoder_wrapper); -static FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data); +static void format_input(unsigned wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, unsigned channels, unsigned bps, encoder_wrapper_struct *encoder_wrapper); +static FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data); static void metadata_callback(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data); -static FLAC__StreamDecoderReadStatus verify_read_callback(const FLAC__StreamDecoder *decoder, byte buffer[], unsigned *bytes, void *client_data); -static FLAC__StreamDecoderWriteStatus verify_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data); +static FLAC__StreamDecoderReadStatus verify_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data); +static FLAC__StreamDecoderWriteStatus verify_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data); static void verify_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data); static void verify_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); static void print_stats(const encoder_wrapper_struct *encoder_wrapper); -static bool read_little_endian_uint16(FILE *f, uint16 *val, bool eof_ok, const char *fn); -static bool read_little_endian_uint32(FILE *f, uint32 *val, bool eof_ok, const char *fn); -static bool write_big_endian_uint16(FILE *f, uint16 val); -static bool write_big_endian_uint64(FILE *f, uint64 val); +static FLAC__bool read_little_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn); +static FLAC__bool read_little_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn); +static FLAC__bool write_big_endian_uint16(FILE *f, FLAC__uint16 val); +static FLAC__bool write_big_endian_uint64(FILE *f, FLAC__uint64 val); -int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const byte *lookahead, unsigned lookahead_length, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned padding, char *requested_seek_points, int num_requested_seek_points) +int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, FLAC__bool verbose, FLAC__uint64 skip, FLAC__bool verify, FLAC__bool lax, FLAC__bool do_mid_side, FLAC__bool loose_mid_side, FLAC__bool do_exhaustive_model_search, FLAC__bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned padding, char *requested_seek_points, int num_requested_seek_points) { encoder_wrapper_struct encoder_wrapper; - bool is_unsigned_samples = false; + FLAC__bool is_unsigned_samples = false; unsigned channels = 0, bps = 0, sample_rate = 0, data_bytes; size_t bytes_per_wide_sample, bytes_read; - uint16 x; - uint32 xx; - bool got_fmt_chunk = false, got_data_chunk = false; + FLAC__uint16 x; + FLAC__uint32 xx; + FLAC__bool got_fmt_chunk = false, got_data_chunk = false; encoder_wrapper.encoder = 0; encoder_wrapper.verify = verify; @@ -358,7 +358,7 @@ wav_abort_: return 1; } -int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const byte *lookahead, unsigned lookahead_length, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned padding, char *requested_seek_points, int num_requested_seek_points, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned sample_rate) +int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, FLAC__bool verbose, FLAC__uint64 skip, FLAC__bool verify, FLAC__bool lax, FLAC__bool do_mid_side, FLAC__bool loose_mid_side, FLAC__bool do_exhaustive_model_search, FLAC__bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned padding, char *requested_seek_points, int num_requested_seek_points, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned sample_rate) { encoder_wrapper_struct encoder_wrapper; size_t bytes_read; @@ -521,12 +521,12 @@ raw_abort_: return 1; } -bool init(encoder_wrapper_struct *encoder_wrapper) +FLAC__bool init(encoder_wrapper_struct *encoder_wrapper) { unsigned i; - uint32 test = 1; + FLAC__uint32 test = 1; - is_big_endian_host = (*((byte*)(&test)))? false : true; + is_big_endian_host = (*((FLAC__byte*)(&test)))? false : true; for(i = 0; i < FLAC__MAX_CHANNELS; i++) input[i] = &(in[i][0]); @@ -540,7 +540,7 @@ bool init(encoder_wrapper_struct *encoder_wrapper) return true; } -bool init_encoder(bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned channels, unsigned bps, unsigned sample_rate, unsigned padding, char *requested_seek_points, int num_requested_seek_points, encoder_wrapper_struct *encoder_wrapper) +FLAC__bool init_encoder(FLAC__bool lax, FLAC__bool do_mid_side, FLAC__bool loose_mid_side, FLAC__bool do_exhaustive_model_search, FLAC__bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned channels, unsigned bps, unsigned sample_rate, unsigned padding, char *requested_seek_points, int num_requested_seek_points, encoder_wrapper_struct *encoder_wrapper) { unsigned i; @@ -551,7 +551,7 @@ bool init_encoder(bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhau /* set up the fifo which will hold the original signal to compare against */ encoder_wrapper->verify_fifo.size = blocksize + CHUNK_OF_SAMPLES; for(i = 0; i < channels; i++) { - if(0 == (encoder_wrapper->verify_fifo.original[i] = (int32*)malloc(sizeof(int32) * encoder_wrapper->verify_fifo.size))) { + if(0 == (encoder_wrapper->verify_fifo.original[i] = (FLAC__int32*)malloc(sizeof(FLAC__int32) * encoder_wrapper->verify_fifo.size))) { fprintf(stderr, "%s: ERROR allocating verify buffers\n", encoder_wrapper->inbasefilename); return false; } @@ -615,11 +615,11 @@ bool init_encoder(bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhau return true; } -bool convert_to_seek_table(char *requested_seek_points, int num_requested_seek_points, uint64 stream_samples, unsigned blocksize, FLAC__StreamMetaData_SeekTable *seek_table) +FLAC__bool convert_to_seek_table(char *requested_seek_points, int num_requested_seek_points, FLAC__uint64 stream_samples, unsigned blocksize, FLAC__StreamMetaData_SeekTable *seek_table) { unsigned i, j, real_points, placeholders; char *pt = requested_seek_points, *q; - bool first; + FLAC__bool first; seek_table->num_points = 0; @@ -678,11 +678,11 @@ bool convert_to_seek_table(char *requested_seek_points, int num_requested_seek_p unsigned j, n; n = (unsigned)atoi(pt); for(j = 0; j < n; j++) - append_point_to_seek_table(seek_table, stream_samples * (uint64)j / (uint64)n, stream_samples, blocksize); + append_point_to_seek_table(seek_table, stream_samples * (FLAC__uint64)j / (FLAC__uint64)n, stream_samples, blocksize); } } else { /* -S # */ - append_point_to_seek_table(seek_table, (uint64)atoi(pt), stream_samples, blocksize); + append_point_to_seek_table(seek_table, (FLAC__uint64)atoi(pt), stream_samples, blocksize); } pt = q; @@ -711,9 +711,9 @@ bool convert_to_seek_table(char *requested_seek_points, int num_requested_seek_p return true; } -void append_point_to_seek_table(FLAC__StreamMetaData_SeekTable *seek_table, uint64 sample, uint64 stream_samples, uint64 blocksize) +void append_point_to_seek_table(FLAC__StreamMetaData_SeekTable *seek_table, FLAC__uint64 sample, FLAC__uint64 stream_samples, FLAC__uint64 blocksize) { - const uint64 target_sample = (sample / blocksize) * blocksize; + const FLAC__uint64 target_sample = (sample / blocksize) * blocksize; if(stream_samples == 0 || target_sample < stream_samples) seek_table->points[seek_table->num_points++].sample_number = target_sample; @@ -721,7 +721,7 @@ void append_point_to_seek_table(FLAC__StreamMetaData_SeekTable *seek_table, uint int seekpoint_compare(const FLAC__StreamMetaData_SeekPoint *l, const FLAC__StreamMetaData_SeekPoint *r) { - /* we don't just 'return l->sample_number - r->sample_number' since the result (int64) might overflow an 'int' */ + /* we don't just 'return l->sample_number - r->sample_number' since the result (FLAC__int64) might overflow an 'int' */ if(l->sample_number == r->sample_number) return 0; else if(l->sample_number < r->sample_number) @@ -730,7 +730,7 @@ int seekpoint_compare(const FLAC__StreamMetaData_SeekPoint *l, const FLAC__Strea return 1; } -void format_input(unsigned wide_samples, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, encoder_wrapper_struct *encoder_wrapper) +void format_input(unsigned wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, unsigned channels, unsigned bps, encoder_wrapper_struct *encoder_wrapper) { unsigned wide_sample, sample, channel, byte; @@ -738,12 +738,12 @@ void format_input(unsigned wide_samples, bool is_big_endian, bool is_unsigned_sa if(is_unsigned_samples) { for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) - input[channel][wide_sample] = (int32)ucbuffer[sample] - 0x80; + input[channel][wide_sample] = (FLAC__int32)ucbuffer[sample] - 0x80; } else { for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) - input[channel][wide_sample] = (int32)scbuffer[sample]; + input[channel][wide_sample] = (FLAC__int32)scbuffer[sample]; } } else if(bps == 16) { @@ -759,12 +759,12 @@ void format_input(unsigned wide_samples, bool is_big_endian, bool is_unsigned_sa if(is_unsigned_samples) { for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) - input[channel][wide_sample] = (int32)usbuffer[sample] - 0x8000; + input[channel][wide_sample] = (FLAC__int32)usbuffer[sample] - 0x8000; } else { for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) - input[channel][wide_sample] = (int32)ssbuffer[sample]; + input[channel][wide_sample] = (FLAC__int32)ssbuffer[sample]; } } else if(bps == 24) { @@ -801,20 +801,20 @@ void format_input(unsigned wide_samples, bool is_big_endian, bool is_unsigned_sa if(encoder_wrapper->verify) { for(channel = 0; channel < channels; channel++) - memcpy(&encoder_wrapper->verify_fifo.original[channel][encoder_wrapper->verify_fifo.tail], &input[channel][0], sizeof(int32) * wide_samples); + memcpy(&encoder_wrapper->verify_fifo.original[channel][encoder_wrapper->verify_fifo.tail], &input[channel][0], sizeof(FLAC__int32) * wide_samples); encoder_wrapper->verify_fifo.tail += wide_samples; FLAC__ASSERT(encoder_wrapper->verify_fifo.tail <= encoder_wrapper->verify_fifo.size); } } -FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data) +FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data) { encoder_wrapper_struct *encoder_wrapper = (encoder_wrapper_struct *)client_data; const unsigned mask = (FLAC__stream_encoder_get_do_exhaustive_model_search(encoder) || FLAC__stream_encoder_get_do_qlp_coeff_prec_search(encoder))? 0x1f : 0x7f; /* mark the current seek point if hit (if stream_offset == 0 that means we're still writing metadata and haven't hit the first frame yet) */ if(encoder_wrapper->stream_offset > 0 && encoder_wrapper->seek_table.num_points > 0) { - uint64 current_sample = (uint64)current_frame * (uint64)FLAC__stream_encoder_get_blocksize(encoder), test_sample; + FLAC__uint64 current_sample = (FLAC__uint64)current_frame * (FLAC__uint64)FLAC__stream_encoder_get_blocksize(encoder), test_sample; unsigned i; for(i = encoder_wrapper->first_seek_point_to_check; i < encoder_wrapper->seek_table.num_points; i++) { test_sample = encoder_wrapper->seek_table.points[i].sample_number; @@ -857,7 +857,7 @@ FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder } } - if(fwrite(buffer, sizeof(byte), bytes, encoder_wrapper->fout) == bytes) + if(fwrite(buffer, sizeof(FLAC__byte), bytes, encoder_wrapper->fout) == bytes) return FLAC__STREAM_ENCODER_WRITE_OK; else return FLAC__STREAM_ENCODER_WRITE_FATAL_ERROR; @@ -866,9 +866,9 @@ FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder void metadata_callback(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data) { encoder_wrapper_struct *encoder_wrapper = (encoder_wrapper_struct *)client_data; - byte b; + FLAC__byte b; FILE *f; - const uint64 samples = metadata->data.stream_info.total_samples; + const FLAC__uint64 samples = metadata->data.stream_info.total_samples; const unsigned min_framesize = metadata->data.stream_info.min_framesize; const unsigned max_framesize = metadata->data.stream_info.max_framesize; @@ -901,30 +901,30 @@ samples_: if(-1 == fseek(f, 21, SEEK_SET)) goto framesize_; if(fread(&b, 1, 1, f) != 1) goto framesize_; if(-1 == fseek(f, 21, SEEK_SET)) goto framesize_; - b = (b & 0xf0) | (byte)((samples >> 32) & 0x0F); + b = (b & 0xf0) | (FLAC__byte)((samples >> 32) & 0x0F); if(fwrite(&b, 1, 1, f) != 1) goto framesize_; - b = (byte)((samples >> 24) & 0xFF); + b = (FLAC__byte)((samples >> 24) & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto framesize_; - b = (byte)((samples >> 16) & 0xFF); + b = (FLAC__byte)((samples >> 16) & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto framesize_; - b = (byte)((samples >> 8) & 0xFF); + b = (FLAC__byte)((samples >> 8) & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto framesize_; - b = (byte)(samples & 0xFF); + b = (FLAC__byte)(samples & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto framesize_; framesize_: if(-1 == fseek(f, 12, SEEK_SET)) goto seektable_; - b = (byte)((min_framesize >> 16) & 0xFF); + b = (FLAC__byte)((min_framesize >> 16) & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto seektable_; - b = (byte)((min_framesize >> 8) & 0xFF); + b = (FLAC__byte)((min_framesize >> 8) & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto seektable_; - b = (byte)(min_framesize & 0xFF); + b = (FLAC__byte)(min_framesize & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto seektable_; - b = (byte)((max_framesize >> 16) & 0xFF); + b = (FLAC__byte)((max_framesize >> 16) & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto seektable_; - b = (byte)((max_framesize >> 8) & 0xFF); + b = (FLAC__byte)((max_framesize >> 8) & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto seektable_; - b = (byte)(max_framesize & 0xFF); + b = (FLAC__byte)(max_framesize & 0xFF); if(fwrite(&b, 1, 1, f) != 1) goto seektable_; seektable_: @@ -957,7 +957,7 @@ end_: return; } -FLAC__StreamDecoderReadStatus verify_read_callback(const FLAC__StreamDecoder *decoder, byte buffer[], unsigned *bytes, void *client_data) +FLAC__StreamDecoderReadStatus verify_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) { encoder_wrapper_struct *encoder_wrapper = (encoder_wrapper_struct *)client_data; const unsigned encoded_bytes = encoder_wrapper->verify_fifo.encoded_bytes; @@ -976,12 +976,12 @@ FLAC__StreamDecoderReadStatus verify_read_callback(const FLAC__StreamDecoder *de return FLAC__STREAM_DECODER_READ_CONTINUE; } -FLAC__StreamDecoderWriteStatus verify_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data) +FLAC__StreamDecoderWriteStatus verify_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data) { encoder_wrapper_struct *encoder_wrapper = (encoder_wrapper_struct *)client_data; unsigned channel, l, r; const unsigned channels = FLAC__stream_decoder_get_channels(decoder); - const unsigned bytes_per_block = sizeof(int32) * FLAC__stream_decoder_get_blocksize(decoder); + const unsigned bytes_per_block = sizeof(FLAC__int32) * FLAC__stream_decoder_get_blocksize(decoder); for(channel = 0; channel < channels; channel++) { if(0 != memcmp(buffer[channel], encoder_wrapper->verify_fifo.original[channel], bytes_per_block)) { @@ -1021,8 +1021,8 @@ void print_stats(const encoder_wrapper_struct *encoder_wrapper) { #ifdef _MSC_VER /* with VC++ you have to spoon feed it the casting */ - const double progress = (double)(int64)encoder_wrapper->samples_written / (double)(int64)encoder_wrapper->total_samples_to_encode; - const double ratio = (double)(int64)encoder_wrapper->bytes_written / ((double)(int64)encoder_wrapper->unencoded_size * progress); + const double progress = (double)(FLAC__int64)encoder_wrapper->samples_written / (double)(FLAC__int64)encoder_wrapper->total_samples_to_encode; + const double ratio = (double)(FLAC__int64)encoder_wrapper->bytes_written / ((double)(FLAC__int64)encoder_wrapper->unencoded_size * progress); #else const double progress = (double)encoder_wrapper->samples_written / (double)encoder_wrapper->total_samples_to_encode; const double ratio = (double)encoder_wrapper->bytes_written / ((double)encoder_wrapper->unencoded_size * progress); @@ -1041,7 +1041,7 @@ void print_stats(const encoder_wrapper_struct *encoder_wrapper) } } -bool read_little_endian_uint16(FILE *f, uint16 *val, bool eof_ok, const char *fn) +FLAC__bool read_little_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn) { size_t bytes_read = fread(val, 1, 2, f); @@ -1059,14 +1059,14 @@ bool read_little_endian_uint16(FILE *f, uint16 *val, bool eof_ok, const char *fn } else { if(is_big_endian_host) { - byte tmp, *b = (byte*)val; + FLAC__byte tmp, *b = (FLAC__byte*)val; tmp = b[1]; b[1] = b[0]; b[0] = tmp; } return true; } } -bool read_little_endian_uint32(FILE *f, uint32 *val, bool eof_ok, const char *fn) +FLAC__bool read_little_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn) { size_t bytes_read = fread(val, 1, 4, f); @@ -1084,7 +1084,7 @@ bool read_little_endian_uint32(FILE *f, uint32 *val, bool eof_ok, const char *fn } else { if(is_big_endian_host) { - byte tmp, *b = (byte*)val; + FLAC__byte tmp, *b = (FLAC__byte*)val; tmp = b[3]; b[3] = b[0]; b[0] = tmp; tmp = b[2]; b[2] = b[1]; b[1] = tmp; } @@ -1092,19 +1092,19 @@ bool read_little_endian_uint32(FILE *f, uint32 *val, bool eof_ok, const char *fn } } -bool write_big_endian_uint16(FILE *f, uint16 val) +FLAC__bool write_big_endian_uint16(FILE *f, FLAC__uint16 val) { if(!is_big_endian_host) { - byte *b = (byte *)&val, tmp; + FLAC__byte *b = (FLAC__byte *)&val, tmp; tmp = b[0]; b[0] = b[1]; b[1] = tmp; } return fwrite(&val, 1, 2, f) == 2; } -bool write_big_endian_uint64(FILE *f, uint64 val) +FLAC__bool write_big_endian_uint64(FILE *f, FLAC__uint64 val) { if(!is_big_endian_host) { - byte *b = (byte *)&val, tmp; + FLAC__byte *b = (FLAC__byte *)&val, tmp; tmp = b[0]; b[0] = b[7]; b[7] = tmp; tmp = b[1]; b[1] = b[6]; b[6] = tmp; tmp = b[2]; b[2] = b[5]; b[5] = tmp; diff --git a/src/flac/encode.h b/src/flac/encode.h index fd2c1b44..d2de9215 100644 --- a/src/flac/encode.h +++ b/src/flac/encode.h @@ -21,7 +21,7 @@ #include "FLAC/ordinals.h" -int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const byte *lookahead, unsigned lookahead_length, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned padding, char *requested_seek_points, int num_requested_seek_points); -int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const byte *lookahead, unsigned lookahead_length, bool verbose, uint64 skip, bool verify, bool lax, bool do_mid_side, bool loose_mid_side, bool do_exhaustive_model_search, bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned padding, char *requested_seek_points, int num_requested_seek_points, bool is_big_endian, bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned sample_rate); +int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, FLAC__bool verbose, FLAC__uint64 skip, FLAC__bool verify, FLAC__bool lax, FLAC__bool do_mid_side, FLAC__bool loose_mid_side, FLAC__bool do_exhaustive_model_search, FLAC__bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned padding, char *requested_seek_points, int num_requested_seek_points); +int flac__encode_raw(FILE *infile, long infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, FLAC__bool verbose, FLAC__uint64 skip, FLAC__bool verify, FLAC__bool lax, FLAC__bool do_mid_side, FLAC__bool loose_mid_side, FLAC__bool do_exhaustive_model_search, FLAC__bool do_qlp_coeff_prec_search, unsigned min_residual_partition_order, unsigned max_residual_partition_order, unsigned rice_parameter_search_dist, unsigned max_lpc_order, unsigned blocksize, unsigned qlp_coeff_precision, unsigned padding, char *requested_seek_points, int num_requested_seek_points, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned sample_rate); #endif diff --git a/src/flac/main.c b/src/flac/main.c index 0bc451bf..782224ba 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -35,15 +35,15 @@ static int usage(const char *message, ...); static int encode_file(const char *infilename, const char *forced_outfilename); static int decode_file(const char *infilename, const char *forced_outfilename); -bool verify = false, verbose = true, lax = false, test_only = false, analyze = false; -bool do_mid_side = true, loose_mid_side = false, do_exhaustive_model_search = false, do_qlp_coeff_prec_search = false; -bool force_to_stdout = false, delete_input = false; +FLAC__bool verify = false, verbose = true, lax = false, test_only = false, analyze = false; +FLAC__bool do_mid_side = true, loose_mid_side = false, do_exhaustive_model_search = false, do_qlp_coeff_prec_search = false; +FLAC__bool force_to_stdout = false, delete_input = false; const char *cmdline_forced_outfilename = 0; analysis_options aopts = { false, false }; unsigned padding = 0; unsigned max_lpc_order = 8; unsigned qlp_coeff_precision = 0; -uint64 skip = 0; +FLAC__uint64 skip = 0; int format_is_wave = -1, format_is_big_endian = -1, format_is_unsigned_samples = false; int format_channels = -1, format_bps = -1, format_sample_rate = -1; int blocksize = -1, min_residual_partition_order = -1, max_residual_partition_order = -1, rice_parameter_search_dist = -1; @@ -53,7 +53,7 @@ int num_requested_seek_points = -1; /* -1 => no -S options were given, 0 => -S- int main(int argc, char *argv[]) { int i, retval = 0; - bool mode_decode = false; + FLAC__bool mode_decode = false; if(argc <= 1) return usage(0); @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) else if(0 == strcmp(argv[i], "--delete-input-file-")) delete_input = false; else if(0 == strcmp(argv[i], "--skip")) - skip = (uint64)atoi(argv[++i]); /* @@@ takes a pretty damn big file to overflow atoi() here, but it could happen */ + skip = (FLAC__uint64)atoi(argv[++i]); /* @@@ takes a pretty damn big file to overflow atoi() here, but it could happen */ else if(0 == strcmp(argv[i], "--lax")) lax = true; else if(0 == strcmp(argv[i], "--lax-")) @@ -341,7 +341,7 @@ int main(int argc, char *argv[]) } if(mode_decode) { - bool first = true; + FLAC__bool first = true; int save_format; if(i == argc) { @@ -361,7 +361,7 @@ int main(int argc, char *argv[]) } } else { /* encode */ - bool first = true; + FLAC__bool first = true; int save_format; if(i == argc) { @@ -512,7 +512,7 @@ int encode_file(const char *infilename, const char *forced_outfilename) FILE *encode_infile; char outfilename[4096]; /* @@@ bad MAGIC NUMBER */ char *p; - byte lookahead[12]; + FLAC__byte lookahead[12]; unsigned lookahead_length = 0; int retval; long infilesize; diff --git a/src/libFLAC/bitbuffer.c b/src/libFLAC/bitbuffer.c index ad5bc97a..f7868435 100644 --- a/src/libFLAC/bitbuffer.c +++ b/src/libFLAC/bitbuffer.c @@ -35,7 +35,7 @@ /* This should be at least twice as large as the largest number of bytes required to represent any 'number' (in any encoding) you are going to read. */ static const unsigned FLAC__BITBUFFER_DEFAULT_CAPACITY = 65536; /* bytes */ -#define BYTE_BIT_TO_MASK(b) (((byte)'\x80') >> (b)) +#define BYTE_BIT_TO_MASK(b) (((FLAC__byte)'\x80') >> (b)) #ifdef min #undef min @@ -46,9 +46,9 @@ static const unsigned FLAC__BITBUFFER_DEFAULT_CAPACITY = 65536; /* bytes */ #endif #define max(x,y) ((x)>(y)?(x):(y)) -static bool bitbuffer_resize_(FLAC__BitBuffer *bb, unsigned new_capacity) +static FLAC__bool bitbuffer_resize_(FLAC__BitBuffer *bb, unsigned new_capacity) { - byte *new_buffer; + FLAC__byte *new_buffer; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -56,11 +56,11 @@ static bool bitbuffer_resize_(FLAC__BitBuffer *bb, unsigned new_capacity) if(bb->capacity == new_capacity) return true; - new_buffer = (byte*)malloc(sizeof(byte) * new_capacity); + new_buffer = (FLAC__byte*)malloc(sizeof(FLAC__byte) * new_capacity); if(new_buffer == 0) return false; memset(new_buffer, 0, new_capacity); - memcpy(new_buffer, bb->buffer, sizeof(byte)*min(bb->bytes+(bb->bits?1:0), new_capacity)); + memcpy(new_buffer, bb->buffer, sizeof(FLAC__byte)*min(bb->bytes+(bb->bits?1:0), new_capacity)); if(new_capacity < bb->bytes+(bb->bits?1:0)) { bb->bytes = new_capacity; bb->bits = 0; @@ -76,7 +76,7 @@ static bool bitbuffer_resize_(FLAC__BitBuffer *bb, unsigned new_capacity) return true; } -static bool bitbuffer_grow_(FLAC__BitBuffer *bb, unsigned min_bytes_to_add) +static FLAC__bool bitbuffer_grow_(FLAC__BitBuffer *bb, unsigned min_bytes_to_add) { unsigned new_capacity; @@ -86,7 +86,7 @@ static bool bitbuffer_grow_(FLAC__BitBuffer *bb, unsigned min_bytes_to_add) return bitbuffer_resize_(bb, new_capacity); } -static bool bitbuffer_ensure_size_(FLAC__BitBuffer *bb, unsigned bits_to_add) +static FLAC__bool bitbuffer_ensure_size_(FLAC__BitBuffer *bb, unsigned bits_to_add) { FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -96,7 +96,7 @@ static bool bitbuffer_ensure_size_(FLAC__BitBuffer *bb, unsigned bits_to_add) return true; } -static bool bitbuffer_read_from_client_(FLAC__BitBuffer *bb, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +static FLAC__bool bitbuffer_read_from_client_(FLAC__BitBuffer *bb, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { unsigned bytes; @@ -136,7 +136,7 @@ void FLAC__bitbuffer_init(FLAC__BitBuffer *bb) bb->consumed_bytes = bb->consumed_bits = bb->total_consumed_bits = 0; } -bool FLAC__bitbuffer_init_from(FLAC__BitBuffer *bb, const byte buffer[], unsigned bytes) +FLAC__bool FLAC__bitbuffer_init_from(FLAC__BitBuffer *bb, const FLAC__byte buffer[], unsigned bytes) { FLAC__ASSERT(bb != 0); FLAC__bitbuffer_init(bb); @@ -145,10 +145,10 @@ bool FLAC__bitbuffer_init_from(FLAC__BitBuffer *bb, const byte buffer[], unsigne return true; else { FLAC__ASSERT(buffer != 0); - bb->buffer = (byte*)malloc(sizeof(byte)*bytes); + bb->buffer = (FLAC__byte*)malloc(sizeof(FLAC__byte)*bytes); if(bb->buffer == 0) return false; - memcpy(bb->buffer, buffer, sizeof(byte)*bytes); + memcpy(bb->buffer, buffer, sizeof(FLAC__byte)*bytes); bb->capacity = bb->bytes = bytes; bb->bits = 0; bb->total_bits = (bytes<<3); @@ -157,16 +157,16 @@ bool FLAC__bitbuffer_init_from(FLAC__BitBuffer *bb, const byte buffer[], unsigne } } -void FLAC__bitbuffer_init_read_crc16(FLAC__BitBuffer *bb, uint16 seed) +void FLAC__bitbuffer_init_read_crc16(FLAC__BitBuffer *bb, FLAC__uint16 seed) { FLAC__ASSERT(bb != 0); bb->read_crc16 = seed; } -bool FLAC__bitbuffer_concatenate_aligned(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src) +FLAC__bool FLAC__bitbuffer_concatenate_aligned(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src) { - static const byte mask_[9] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; + static const FLAC__byte mask_[9] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; unsigned bits_to_add = src->total_bits - src->total_consumed_bits; FLAC__ASSERT(dest != 0); @@ -209,11 +209,11 @@ void FLAC__bitbuffer_free(FLAC__BitBuffer *bb) bb->consumed_bytes = bb->consumed_bits = bb->total_consumed_bits = 0; } -bool FLAC__bitbuffer_clear(FLAC__BitBuffer *bb) +FLAC__bool FLAC__bitbuffer_clear(FLAC__BitBuffer *bb) { if(bb->buffer == 0) { bb->capacity = FLAC__BITBUFFER_DEFAULT_CAPACITY; - bb->buffer = (byte*)malloc(sizeof(byte) * bb->capacity); + bb->buffer = (FLAC__byte*)malloc(sizeof(FLAC__byte) * bb->capacity); if(bb->buffer == 0) return false; memset(bb->buffer, 0, bb->capacity); @@ -226,12 +226,12 @@ bool FLAC__bitbuffer_clear(FLAC__BitBuffer *bb) return true; } -bool FLAC__bitbuffer_clone(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src) +FLAC__bool FLAC__bitbuffer_clone(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src) { if(dest->capacity < src->capacity) if(!bitbuffer_resize_(dest, src->capacity)) return false; - memcpy(dest->buffer, src->buffer, sizeof(byte)*min(src->capacity, src->bytes+1)); + memcpy(dest->buffer, src->buffer, sizeof(FLAC__byte)*min(src->capacity, src->bytes+1)); dest->bytes = src->bytes; dest->bits = src->bits; dest->total_bits = src->total_bits; @@ -242,7 +242,7 @@ bool FLAC__bitbuffer_clone(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src) return true; } -bool FLAC__bitbuffer_write_zeroes(FLAC__BitBuffer *bb, unsigned bits) +FLAC__bool FLAC__bitbuffer_write_zeroes(FLAC__BitBuffer *bb, unsigned bits) { unsigned n, k; @@ -268,7 +268,7 @@ bool FLAC__bitbuffer_write_zeroes(FLAC__BitBuffer *bb, unsigned bits) return true; } -bool FLAC__bitbuffer_write_raw_uint32(FLAC__BitBuffer *bb, uint32 val, unsigned bits) +FLAC__bool FLAC__bitbuffer_write_raw_uint32(FLAC__BitBuffer *bb, FLAC__uint32 val, unsigned bits) { unsigned n, k; @@ -330,14 +330,14 @@ bool FLAC__bitbuffer_write_raw_uint32(FLAC__BitBuffer *bb, uint32 val, unsigned return true; } -bool FLAC__bitbuffer_write_raw_int32(FLAC__BitBuffer *bb, int32 val, unsigned bits) +FLAC__bool FLAC__bitbuffer_write_raw_int32(FLAC__BitBuffer *bb, FLAC__int32 val, unsigned bits) { - return FLAC__bitbuffer_write_raw_uint32(bb, (uint32)val, bits); + return FLAC__bitbuffer_write_raw_uint32(bb, (FLAC__uint32)val, bits); } -bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, uint64 val, unsigned bits) +FLAC__bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, FLAC__uint64 val, unsigned bits) { - static const uint64 mask[] = { + static const FLAC__uint64 mask[] = { 0, 0x0000000000000001, 0x0000000000000003, 0x0000000000000007, 0x000000000000000F, 0x000000000000001F, 0x000000000000003F, 0x000000000000007F, 0x00000000000000FF, @@ -404,12 +404,12 @@ bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, uint64 val, unsigned return true; } -bool FLAC__bitbuffer_write_raw_int64(FLAC__BitBuffer *bb, int64 val, unsigned bits) +FLAC__bool FLAC__bitbuffer_write_raw_int64(FLAC__BitBuffer *bb, FLAC__int64 val, unsigned bits) { - return FLAC__bitbuffer_write_raw_uint64(bb, (uint64)val, bits); + return FLAC__bitbuffer_write_raw_uint64(bb, (FLAC__uint64)val, bits); } -bool FLAC__bitbuffer_write_unary_unsigned(FLAC__BitBuffer *bb, unsigned val) +FLAC__bool FLAC__bitbuffer_write_unary_unsigned(FLAC__BitBuffer *bb, unsigned val) { if(val < 32) return FLAC__bitbuffer_write_raw_uint32(bb, 1, ++val); @@ -507,10 +507,10 @@ unsigned FLAC__bitbuffer_golomb_bits_unsigned(unsigned uval, unsigned parameter) return bits; } -bool FLAC__bitbuffer_write_symmetric_rice_signed(FLAC__BitBuffer *bb, int val, unsigned parameter) +FLAC__bool FLAC__bitbuffer_write_symmetric_rice_signed(FLAC__BitBuffer *bb, int val, unsigned parameter) { unsigned total_bits, interesting_bits, msbs; - uint32 pattern; + FLAC__uint32 pattern; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -545,10 +545,10 @@ bool FLAC__bitbuffer_write_symmetric_rice_signed(FLAC__BitBuffer *bb, int val, u return true; } -bool FLAC__bitbuffer_write_symmetric_rice_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, bool *overflow) +FLAC__bool FLAC__bitbuffer_write_symmetric_rice_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, FLAC__bool *overflow) { unsigned total_bits, interesting_bits, msbs; - uint32 pattern; + FLAC__uint32 pattern; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -589,10 +589,10 @@ bool FLAC__bitbuffer_write_symmetric_rice_signed_guarded(FLAC__BitBuffer *bb, in return true; } -bool FLAC__bitbuffer_write_symmetric_rice_signed_escape(FLAC__BitBuffer *bb, int val, unsigned parameter) +FLAC__bool FLAC__bitbuffer_write_symmetric_rice_signed_escape(FLAC__BitBuffer *bb, int val, unsigned parameter) { unsigned total_bits, val_bits; - uint32 pattern; + FLAC__uint32 pattern; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -624,10 +624,10 @@ bool FLAC__bitbuffer_write_symmetric_rice_signed_escape(FLAC__BitBuffer *bb, int return true; } -bool FLAC__bitbuffer_write_rice_signed(FLAC__BitBuffer *bb, int val, unsigned parameter) +FLAC__bool FLAC__bitbuffer_write_rice_signed(FLAC__BitBuffer *bb, int val, unsigned parameter) { unsigned total_bits, interesting_bits, msbs, uval; - uint32 pattern; + FLAC__uint32 pattern; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -664,10 +664,10 @@ bool FLAC__bitbuffer_write_rice_signed(FLAC__BitBuffer *bb, int val, unsigned pa return true; } -bool FLAC__bitbuffer_write_rice_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, bool *overflow) +FLAC__bool FLAC__bitbuffer_write_rice_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, FLAC__bool *overflow) { unsigned total_bits, interesting_bits, msbs, uval; - uint32 pattern; + FLAC__uint32 pattern; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -710,7 +710,7 @@ bool FLAC__bitbuffer_write_rice_signed_guarded(FLAC__BitBuffer *bb, int val, uns return true; } -bool FLAC__bitbuffer_write_golomb_signed(FLAC__BitBuffer *bb, int val, unsigned parameter) +FLAC__bool FLAC__bitbuffer_write_golomb_signed(FLAC__BitBuffer *bb, int val, unsigned parameter) { unsigned total_bits, msbs, uval; unsigned k; @@ -778,7 +778,7 @@ bool FLAC__bitbuffer_write_golomb_signed(FLAC__BitBuffer *bb, int val, unsigned return true; } -bool FLAC__bitbuffer_write_golomb_unsigned(FLAC__BitBuffer *bb, unsigned uval, unsigned parameter) +FLAC__bool FLAC__bitbuffer_write_golomb_unsigned(FLAC__BitBuffer *bb, unsigned uval, unsigned parameter) { unsigned total_bits, msbs; unsigned k; @@ -836,9 +836,9 @@ bool FLAC__bitbuffer_write_golomb_unsigned(FLAC__BitBuffer *bb, unsigned uval, u return true; } -bool FLAC__bitbuffer_write_utf8_uint32(FLAC__BitBuffer *bb, uint32 val) +FLAC__bool FLAC__bitbuffer_write_utf8_uint32(FLAC__BitBuffer *bb, FLAC__uint32 val) { - bool ok = 1; + FLAC__bool ok = 1; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -882,9 +882,9 @@ bool FLAC__bitbuffer_write_utf8_uint32(FLAC__BitBuffer *bb, uint32 val) return ok; } -bool FLAC__bitbuffer_write_utf8_uint64(FLAC__BitBuffer *bb, uint64 val) +FLAC__bool FLAC__bitbuffer_write_utf8_uint64(FLAC__BitBuffer *bb, FLAC__uint64 val) { - bool ok = 1; + FLAC__bool ok = 1; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -892,52 +892,52 @@ bool FLAC__bitbuffer_write_utf8_uint64(FLAC__BitBuffer *bb, uint64 val) FLAC__ASSERT(!(val & 0xFFFFFFF000000000)); /* this version only handles 36 bits */ if(val < 0x80) { - return FLAC__bitbuffer_write_raw_uint32(bb, (uint32)val, 8); + return FLAC__bitbuffer_write_raw_uint32(bb, (FLAC__uint32)val, 8); } else if(val < 0x800) { - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xC0 | (uint32)(val>>6), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)(val&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xC0 | (FLAC__uint32)(val>>6), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)(val&0x3F), 8); } else if(val < 0x10000) { - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xE0 | (uint32)(val>>12), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)(val&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xE0 | (FLAC__uint32)(val>>12), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)(val&0x3F), 8); } else if(val < 0x200000) { - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xF0 | (uint32)(val>>18), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>12)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)(val&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xF0 | (FLAC__uint32)(val>>18), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)(val&0x3F), 8); } else if(val < 0x4000000) { - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xF8 | (uint32)(val>>24), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>18)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>12)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)(val&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xF8 | (FLAC__uint32)(val>>24), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)(val&0x3F), 8); } else if(val < 0x80000000) { - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xFC | (uint32)(val>>30), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>24)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>18)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>12)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)(val&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xFC | (FLAC__uint32)(val>>30), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)(val&0x3F), 8); } else { ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0xFE, 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>30)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>24)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>18)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>12)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)((val>>6)&0x3F), 8); - ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (uint32)(val&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>30)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8); + ok &= FLAC__bitbuffer_write_raw_uint32(bb, 0x80 | (FLAC__uint32)(val&0x3F), 8); } return ok; } -bool FLAC__bitbuffer_zero_pad_to_byte_boundary(FLAC__BitBuffer *bb) +FLAC__bool FLAC__bitbuffer_zero_pad_to_byte_boundary(FLAC__BitBuffer *bb) { /* 0-pad to byte boundary */ if(bb->bits != 0) @@ -946,7 +946,7 @@ bool FLAC__bitbuffer_zero_pad_to_byte_boundary(FLAC__BitBuffer *bb) return true; } -bool FLAC__bitbuffer_peek_bit(FLAC__BitBuffer *bb, unsigned *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_peek_bit(FLAC__BitBuffer *bb, unsigned *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { /* to avoid a drastic speed penalty we don't: FLAC__ASSERT(bb != 0); @@ -966,7 +966,7 @@ bool FLAC__bitbuffer_peek_bit(FLAC__BitBuffer *bb, unsigned *val, bool (*read_ca } } -bool FLAC__bitbuffer_read_bit(FLAC__BitBuffer *bb, unsigned *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_bit(FLAC__BitBuffer *bb, unsigned *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { /* to avoid a drastic speed penalty we don't: FLAC__ASSERT(bb != 0); @@ -993,7 +993,7 @@ bool FLAC__bitbuffer_read_bit(FLAC__BitBuffer *bb, unsigned *val, bool (*read_ca } } -bool FLAC__bitbuffer_read_bit_to_uint32(FLAC__BitBuffer *bb, uint32 *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_bit_to_uint32(FLAC__BitBuffer *bb, FLAC__uint32 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { /* to avoid a drastic speed penalty we don't: FLAC__ASSERT(bb != 0); @@ -1021,7 +1021,7 @@ bool FLAC__bitbuffer_read_bit_to_uint32(FLAC__BitBuffer *bb, uint32 *val, bool ( } } -bool FLAC__bitbuffer_read_bit_to_uint64(FLAC__BitBuffer *bb, uint64 *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_bit_to_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { /* to avoid a drastic speed penalty we don't: FLAC__ASSERT(bb != 0); @@ -1049,7 +1049,7 @@ bool FLAC__bitbuffer_read_bit_to_uint64(FLAC__BitBuffer *bb, uint64 *val, bool ( } } -bool FLAC__bitbuffer_read_raw_uint32(FLAC__BitBuffer *bb, uint32 *val, const unsigned bits, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_raw_uint32(FLAC__BitBuffer *bb, FLAC__uint32 *val, const unsigned bits, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) #ifdef FLAC__NO_MANUAL_INLINING { unsigned i; @@ -1069,7 +1069,7 @@ bool FLAC__bitbuffer_read_raw_uint32(FLAC__BitBuffer *bb, uint32 *val, const uns #else { unsigned i, bits_ = bits; - uint32 v = 0; + FLAC__uint32 v = 0; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -1119,11 +1119,11 @@ bool FLAC__bitbuffer_read_raw_uint32(FLAC__BitBuffer *bb, uint32 *val, const uns } #endif -bool FLAC__bitbuffer_read_raw_int32(FLAC__BitBuffer *bb, int32 *val, const unsigned bits, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_raw_int32(FLAC__BitBuffer *bb, FLAC__int32 *val, const unsigned bits, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) #ifdef FLAC__NO_MANUAL_INLINING { unsigned i; - uint32 v; + FLAC__uint32 v; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -1140,18 +1140,18 @@ bool FLAC__bitbuffer_read_raw_int32(FLAC__BitBuffer *bb, int32 *val, const unsig i = 32 - bits; if(i) { v <<= i; - *val = (int32)v; + *val = (FLAC__int32)v; *val >>= i; } else - *val = (int32)v; + *val = (FLAC__int32)v; return true; } #else { unsigned i, bits_ = bits; - uint32 v = 0; + FLAC__uint32 v = 0; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -1177,7 +1177,7 @@ bool FLAC__bitbuffer_read_raw_int32(FLAC__BitBuffer *bb, int32 *val, const unsig /* bits_ must be < 7 if we get to here */ v = (bb->buffer[bb->consumed_bytes] & (0xff >> bb->consumed_bits)); v <<= (32-i); - *val = (int32)v; + *val = (FLAC__int32)v; *val >>= (32-bits_); bb->consumed_bits += bits_; bb->total_consumed_bits += bits_; @@ -1205,17 +1205,17 @@ bool FLAC__bitbuffer_read_raw_int32(FLAC__BitBuffer *bb, int32 *val, const unsig i = 32 - bits; if(i) { v <<= i; - *val = (int32)v; + *val = (FLAC__int32)v; *val >>= i; } else - *val = (int32)v; + *val = (FLAC__int32)v; return true; } #endif -bool FLAC__bitbuffer_read_raw_uint64(FLAC__BitBuffer *bb, uint64 *val, const unsigned bits, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_raw_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *val, const unsigned bits, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) #ifdef FLAC__NO_MANUAL_INLINING { unsigned i; @@ -1235,7 +1235,7 @@ bool FLAC__bitbuffer_read_raw_uint64(FLAC__BitBuffer *bb, uint64 *val, const uns #else { unsigned i, bits_ = bits; - uint64 v = 0; + FLAC__uint64 v = 0; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -1285,11 +1285,11 @@ bool FLAC__bitbuffer_read_raw_uint64(FLAC__BitBuffer *bb, uint64 *val, const uns } #endif -bool FLAC__bitbuffer_read_raw_int64(FLAC__BitBuffer *bb, int64 *val, const unsigned bits, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_raw_int64(FLAC__BitBuffer *bb, FLAC__int64 *val, const unsigned bits, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) #ifdef FLAC__NO_MANUAL_INLINING { unsigned i; - uint64 v; + FLAC__uint64 v; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -1305,18 +1305,18 @@ bool FLAC__bitbuffer_read_raw_int64(FLAC__BitBuffer *bb, int64 *val, const unsig i = 64 - bits; if(i) { v <<= i; - *val = (int64)v; + *val = (FLAC__int64)v; *val >>= i; } else - *val = (int64)v; + *val = (FLAC__int64)v; return true; } #else { unsigned i, bits_ = bits; - uint64 v = 0; + FLAC__uint64 v = 0; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -1342,7 +1342,7 @@ bool FLAC__bitbuffer_read_raw_int64(FLAC__BitBuffer *bb, int64 *val, const unsig /* bits_ must be < 7 if we get to here */ v = (bb->buffer[bb->consumed_bytes] & (0xff >> bb->consumed_bits)); v <<= (64-i); - *val = (int64)v; + *val = (FLAC__int64)v; *val >>= (64-bits_); bb->consumed_bits += bits_; bb->total_consumed_bits += bits_; @@ -1370,17 +1370,17 @@ bool FLAC__bitbuffer_read_raw_int64(FLAC__BitBuffer *bb, int64 *val, const unsig i = 64 - bits; if(i) { v <<= i; - *val = (int64)v; + *val = (FLAC__int64)v; *val >>= i; } else - *val = (int64)v; + *val = (FLAC__int64)v; return true; } #endif -bool FLAC__bitbuffer_read_unary_unsigned(FLAC__BitBuffer *bb, unsigned *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_unary_unsigned(FLAC__BitBuffer *bb, unsigned *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) #ifdef FLAC__NO_MANUAL_INLINING { unsigned bit, val_ = 0; @@ -1403,7 +1403,7 @@ bool FLAC__bitbuffer_read_unary_unsigned(FLAC__BitBuffer *bb, unsigned *val, boo { unsigned i, val_ = 0; unsigned total_bytes_ = (bb->total_bits + 7) / 8; - byte b; + FLAC__byte b; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -1466,9 +1466,9 @@ bool FLAC__bitbuffer_read_unary_unsigned(FLAC__BitBuffer *bb, unsigned *val, boo } #endif -bool FLAC__bitbuffer_read_symmetric_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_symmetric_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { - uint32 sign = 0, lsbs = 0, msbs = 0; + FLAC__uint32 sign = 0, lsbs = 0, msbs = 0; FLAC__ASSERT(bb != 0); FLAC__ASSERT(bb->buffer != 0); @@ -1494,9 +1494,9 @@ bool FLAC__bitbuffer_read_symmetric_rice_signed(FLAC__BitBuffer *bb, int *val, u return true; } -bool FLAC__bitbuffer_read_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { - uint32 lsbs = 0, msbs = 0; + FLAC__uint32 lsbs = 0, msbs = 0; unsigned uval; FLAC__ASSERT(bb != 0); @@ -1521,9 +1521,9 @@ bool FLAC__bitbuffer_read_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned pa return true; } -bool FLAC__bitbuffer_read_golomb_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_golomb_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { - uint32 lsbs = 0, msbs = 0; + FLAC__uint32 lsbs = 0, msbs = 0; unsigned bit, uval, k; FLAC__ASSERT(bb != 0); @@ -1565,9 +1565,9 @@ bool FLAC__bitbuffer_read_golomb_signed(FLAC__BitBuffer *bb, int *val, unsigned return true; } -bool FLAC__bitbuffer_read_golomb_unsigned(FLAC__BitBuffer *bb, unsigned *val, unsigned parameter, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data) +FLAC__bool FLAC__bitbuffer_read_golomb_unsigned(FLAC__BitBuffer *bb, unsigned *val, unsigned parameter, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data) { - uint32 lsbs, msbs = 0; + FLAC__uint32 lsbs, msbs = 0; unsigned bit, k; FLAC__ASSERT(bb != 0); @@ -1604,16 +1604,16 @@ bool FLAC__bitbuffer_read_golomb_unsigned(FLAC__BitBuffer *bb, unsigned *val, un } /* on return, if *val == 0xffffffff then the utf-8 sequence was invalid, but the return value will be true */ -bool FLAC__bitbuffer_read_utf8_uint32(FLAC__BitBuffer *bb, uint32 *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data, byte *raw, unsigned *rawlen) +FLAC__bool FLAC__bitbuffer_read_utf8_uint32(FLAC__BitBuffer *bb, FLAC__uint32 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data, FLAC__byte *raw, unsigned *rawlen) { - uint32 v = 0; - uint32 x; + FLAC__uint32 v = 0; + FLAC__uint32 x; unsigned i; if(!FLAC__bitbuffer_read_raw_uint32(bb, &x, 8, read_callback, client_data)) return false; if(raw) - raw[(*rawlen)++] = (byte)x; + raw[(*rawlen)++] = (FLAC__byte)x; if(!(x & 0x80)) { /* 0xxxxxxx */ v = x; i = 0; @@ -1646,7 +1646,7 @@ bool FLAC__bitbuffer_read_utf8_uint32(FLAC__BitBuffer *bb, uint32 *val, bool (*r if(!FLAC__bitbuffer_read_raw_uint32(bb, &x, 8, read_callback, client_data)) return false; if(raw) - raw[(*rawlen)++] = (byte)x; + raw[(*rawlen)++] = (FLAC__byte)x; if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */ *val = 0xffffffff; return true; @@ -1659,16 +1659,16 @@ bool FLAC__bitbuffer_read_utf8_uint32(FLAC__BitBuffer *bb, uint32 *val, bool (*r } /* on return, if *val == 0xffffffffffffffff then the utf-8 sequence was invalid, but the return value will be true */ -bool FLAC__bitbuffer_read_utf8_uint64(FLAC__BitBuffer *bb, uint64 *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data, byte *raw, unsigned *rawlen) +FLAC__bool FLAC__bitbuffer_read_utf8_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data, FLAC__byte *raw, unsigned *rawlen) { - uint64 v = 0; - uint32 x; + FLAC__uint64 v = 0; + FLAC__uint32 x; unsigned i; if(!FLAC__bitbuffer_read_raw_uint32(bb, &x, 8, read_callback, client_data)) return false; if(raw) - raw[(*rawlen)++] = (byte)x; + raw[(*rawlen)++] = (FLAC__byte)x; if(!(x & 0x80)) { /* 0xxxxxxx */ v = x; i = 0; @@ -1705,7 +1705,7 @@ bool FLAC__bitbuffer_read_utf8_uint64(FLAC__BitBuffer *bb, uint64 *val, bool (*r if(!FLAC__bitbuffer_read_raw_uint32(bb, &x, 8, read_callback, client_data)) return false; if(raw) - raw[(*rawlen)++] = (byte)x; + raw[(*rawlen)++] = (FLAC__byte)x; if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */ *val = 0xffffffffffffffff; return true; diff --git a/src/libFLAC/crc.c b/src/libFLAC/crc.c index b58cc0be..6d455ae2 100644 --- a/src/libFLAC/crc.c +++ b/src/libFLAC/crc.c @@ -21,7 +21,7 @@ /* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */ -byte const FLAC__crc8_table[256] = { +FLAC__byte const FLAC__crc8_table[256] = { 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, @@ -58,7 +58,7 @@ byte const FLAC__crc8_table[256] = { /* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */ -uint16 FLAC__crc16_table[256] = { +FLAC__uint16 FLAC__crc16_table[256] = { 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, @@ -94,20 +94,20 @@ uint16 FLAC__crc16_table[256] = { }; -void FLAC__crc8_update(const byte data, uint8 *crc) +void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc) { *crc = FLAC__crc8_table[*crc ^ data]; } -void FLAC__crc8_update_block(const byte *data, unsigned len, uint8 *crc) +void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc) { while(len--) *crc = FLAC__crc8_table[*crc ^ *data++]; } -uint8 FLAC__crc8(const byte *data, unsigned len) +FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len) { - uint8 crc = 0; + FLAC__uint8 crc = 0; while(len--) crc = FLAC__crc8_table[crc ^ *data++]; @@ -115,20 +115,20 @@ uint8 FLAC__crc8(const byte *data, unsigned len) return crc; } -void FLAC__crc16_update(const byte data, uint16 *crc) +void FLAC__crc16_update(const FLAC__byte data, FLAC__uint16 *crc) { *crc = (*crc<<8) ^ FLAC__crc16_table[(*crc>>8) ^ data]; } -void FLAC__crc16_update_block(const byte *data, unsigned len, uint16 *crc) +void FLAC__crc16_update_block(const FLAC__byte *data, unsigned len, FLAC__uint16 *crc) { while(len--) *crc = (*crc<<8) ^ FLAC__crc16_table[(*crc>>8) ^ *data++]; } -uint16 FLAC__crc16(const byte *data, unsigned len) +FLAC__uint16 FLAC__crc16(const FLAC__byte *data, unsigned len) { - uint16 crc = 0; + FLAC__uint16 crc = 0; while(len--) crc = (crc<<8) ^ FLAC__crc16_table[(crc>>8) ^ *data++]; diff --git a/src/libFLAC/file_decoder.c b/src/libFLAC/file_decoder.c index e9b9dd06..0bb50a88 100644 --- a/src/libFLAC/file_decoder.c +++ b/src/libFLAC/file_decoder.c @@ -32,11 +32,11 @@ * ***********************************************************************/ -static FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, byte buffer[], unsigned *bytes, void *client_data); -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data); +static FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data); +static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data); static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data); static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); -static bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, uint64 target_sample); +static FLAC__bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, FLAC__uint64 target_sample); /*********************************************************************** * @@ -45,7 +45,7 @@ static bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, ***********************************************************************/ typedef struct FLAC__FileDecoderPrivate { - FLAC__StreamDecoderWriteStatus (*write_callback)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data); + FLAC__StreamDecoderWriteStatus (*write_callback)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data); void (*metadata_callback)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data); void (*error_callback)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); void *client_data; @@ -53,13 +53,13 @@ typedef struct FLAC__FileDecoderPrivate { char *filename; /* == NULL if stdin */ FLAC__StreamDecoder *stream_decoder; struct MD5Context md5context; - byte stored_md5sum[16]; /* this is what is stored in the metadata */ - byte computed_md5sum[16]; /* this is the sum we computed from the decoded data */ + FLAC__byte stored_md5sum[16]; /* this is what is stored in the metadata */ + FLAC__byte computed_md5sum[16]; /* this is the sum we computed from the decoded data */ /* the rest of these are only used for seeking: */ FLAC__StreamMetaData_StreamInfo stream_info; /* we keep this around so we can figure out how to seek quickly */ const FLAC__StreamMetaData_SeekTable *seek_table; /* we hold a pointer to the stream decoder's seek table for the same reason */ FLAC__Frame last_frame; /* holds the info of the last frame we seeked to */ - uint64 target_sample; + FLAC__uint64 target_sample; } FLAC__FileDecoderPrivate; /*********************************************************************** @@ -184,9 +184,9 @@ FLAC__FileDecoderState FLAC__file_decoder_init(FLAC__FileDecoder *decoder) return decoder->protected->state; } -bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder) +FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder) { - bool md5_failed = false; + FLAC__bool md5_failed = false; FLAC__ASSERT(decoder != 0); if(decoder->protected->state == FLAC__FILE_DECODER_UNINITIALIZED) @@ -211,7 +211,7 @@ bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder) return !md5_failed; } -bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, bool value) +FLAC__bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, FLAC__bool value) { if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED) return false; @@ -219,7 +219,7 @@ bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, bool return true; } -bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value) +FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value) { if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED) return false; @@ -231,7 +231,7 @@ bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const cha return true; } -bool FLAC__file_decoder_set_write_callback(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data)) +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) return false; @@ -239,7 +239,7 @@ bool FLAC__file_decoder_set_write_callback(const FLAC__FileDecoder *decoder, FLA return true; } -bool FLAC__file_decoder_set_metadata_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data)) +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) return false; @@ -247,7 +247,7 @@ bool FLAC__file_decoder_set_metadata_callback(const FLAC__FileDecoder *decoder, return true; } -bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)) +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) return false; @@ -255,7 +255,7 @@ bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, voi return true; } -bool FLAC__file_decoder_set_client_data(const FLAC__FileDecoder *decoder, void *value) +FLAC__bool FLAC__file_decoder_set_client_data(const FLAC__FileDecoder *decoder, void *value) { if(decoder->protected->state != FLAC__FILE_DECODER_UNINITIALIZED) return false; @@ -268,14 +268,14 @@ FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *dec return decoder->protected->state; } -bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder) +FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder) { return decoder->protected->md5_checking; } -bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder) +FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder) { - bool ret; + FLAC__bool ret; FLAC__ASSERT(decoder != 0); if(decoder->private->stream_decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM) @@ -293,9 +293,9 @@ bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder) return ret; } -bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder) +FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder) { - bool ret; + FLAC__bool ret; FLAC__ASSERT(decoder != 0); if(decoder->private->stream_decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM) @@ -313,9 +313,9 @@ bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder) return ret; } -bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder) +FLAC__bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder) { - bool ret; + FLAC__bool ret; FLAC__ASSERT(decoder != 0); if(decoder->private->stream_decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM) @@ -333,9 +333,9 @@ bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder) return ret; } -bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder) +FLAC__bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder) { - bool ret; + FLAC__bool ret; FLAC__ASSERT(decoder != 0); if(decoder->private->stream_decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM) @@ -359,7 +359,7 @@ bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder) * ***********************************************************************/ -bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, uint64 sample) +FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__uint64 sample) { long filesize; struct stat filestats; @@ -404,7 +404,7 @@ bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, uint64 sample) return seek_to_absolute_sample_(decoder, filesize, sample); } -FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, byte buffer[], unsigned *bytes, void *client_data) +FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) { FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data; (void)decoder; @@ -413,7 +413,7 @@ FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, return FLAC__STREAM_DECODER_READ_END_OF_STREAM; } else if(*bytes > 0) { - size_t bytes_read = fread(buffer, sizeof(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; @@ -431,15 +431,15 @@ FLAC__StreamDecoderReadStatus read_callback_(const FLAC__StreamDecoder *decoder, return FLAC__STREAM_DECODER_READ_ABORT; /* abort to avoid a deadlock */ } -FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data) +FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data) { FLAC__FileDecoder *file_decoder = (FLAC__FileDecoder *)client_data; (void)decoder; if(file_decoder->protected->state == FLAC__FILE_DECODER_SEEKING) { - uint64 this_frame_sample = frame->header.number.sample_number; - uint64 next_frame_sample = this_frame_sample + (uint64)frame->header.blocksize; - uint64 target_sample = file_decoder->private->target_sample; + 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; file_decoder->private->last_frame = *frame; /* save the frame in the private */ if(this_frame_sample <= target_sample && target_sample < next_frame_sample) { /* we hit our target frame */ @@ -449,11 +449,11 @@ FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decode /* shift out the samples before target_sample */ if(delta > 0) { unsigned channel; - const int32 *newbuffer[FLAC__MAX_CHANNELS]; + 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 += (uint64)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); } @@ -504,14 +504,14 @@ void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErro file_decoder->private->error_callback(file_decoder, status, file_decoder->private->client_data); } -bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, uint64 target_sample) +FLAC__bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, FLAC__uint64 target_sample) { long first_frame_offset, lower_bound, upper_bound, pos = -1, last_pos = -1; int i, lower_seek_point = -1, upper_seek_point = -1; unsigned approx_bytes_per_frame; - uint64 last_frame_sample = 0xffffffffffffffff; - bool needs_seek; - const bool is_variable_blocksize_stream = (decoder->private->stream_info.min_blocksize != decoder->private->stream_info.max_blocksize); + 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); /* we are just guessing here, but we want to guess high, not low */ if(decoder->private->stream_info.max_framesize > 0) { @@ -588,12 +588,12 @@ bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, uint64 pos = lower_bound; } else if(upper_seek_point >= 0) { - const uint64 target_offset = target_sample - decoder->private->seek_table->points[lower_seek_point].sample_number; - const 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 */ - pos = lower_bound + (long)((double)(int64)target_offset / (double)(int64)range_samples * (double)(range_bytes-1)) - approx_bytes_per_frame; + pos = lower_bound + (long)((double)(FLAC__int64)target_offset / (double)(FLAC__int64)range_samples * (double)(range_bytes-1)) - approx_bytes_per_frame; #else pos = lower_bound + (long)((double)target_offset / (double)range_samples * (double)(range_bytes-1)) - approx_bytes_per_frame; #endif @@ -603,7 +603,7 @@ bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, uint64 /* 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)(int64)target_sample / (double)(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; #endif @@ -637,7 +637,7 @@ bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, uint64 break; } else { /* we need to narrow the search */ - uint64 this_frame_sample = decoder->private->last_frame.header.number.sample_number; + FLAC__uint64 this_frame_sample = decoder->private->last_frame.header.number.sample_number; if(this_frame_sample == last_frame_sample) { /* our last move backwards wasn't big enough */ pos -= (last_pos - pos); diff --git a/src/libFLAC/fixed.c b/src/libFLAC/fixed.c index f7b423bb..79f77089 100644 --- a/src/libFLAC/fixed.c +++ b/src/libFLAC/fixed.c @@ -36,14 +36,14 @@ #endif #define local_abs(x) ((unsigned)((x)<0? -(x) : (x))) -unsigned FLAC__fixed_compute_best_predictor(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) { - int32 last_error_0 = data[-1]; - int32 last_error_1 = data[-1] - data[-2]; - int32 last_error_2 = last_error_1 - (data[-2] - data[-3]); - int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); - int32 error, save; - uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; + FLAC__int32 last_error_0 = data[-1]; + FLAC__int32 last_error_1 = data[-1] - data[-2]; + FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]); + FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); + FLAC__int32 error, save; + FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; unsigned i, order; for(i = 0; i < data_len; i++) { @@ -65,27 +65,27 @@ unsigned FLAC__fixed_compute_best_predictor(const int32 data[], unsigned data_le else order = 4; - residual_bits_per_sample[0] = (real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[1] = (real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[2] = (real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[3] = (real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[4] = (real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[0] = (FLAC__real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[1] = (FLAC__real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[2] = (FLAC__real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[3] = (FLAC__real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[4] = (FLAC__real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double) data_len) / M_LN2 : 0.0); return order; } -unsigned FLAC__fixed_compute_best_predictor_slow(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +unsigned FLAC__fixed_compute_best_predictor_slow(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) { - int32 last_error_0 = data[-1]; - int32 last_error_1 = data[-1] - data[-2]; - int32 last_error_2 = last_error_1 - (data[-2] - data[-3]); - int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); - int32 error, save; + FLAC__int32 last_error_0 = data[-1]; + FLAC__int32 last_error_1 = data[-1] - data[-2]; + FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]); + FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); + FLAC__int32 error, save; /* total_error_* are 64-bits to avoid overflow when encoding * erratic signals when the bits-per-sample and blocksize are * large. */ - uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; + FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; unsigned i, order; for(i = 0; i < data_len; i++) { @@ -112,23 +112,23 @@ unsigned FLAC__fixed_compute_best_predictor_slow(const int32 data[], unsigned da /* signal, so we use it directly to compute E(|x|) */ #ifdef _MSC_VER /* with VC++ you have to spoon feed it the casting */ - residual_bits_per_sample[0] = (real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)(int64)total_error_0 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[1] = (real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)(int64)total_error_1 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[2] = (real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (double)(int64)total_error_2 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[3] = (real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (double)(int64)total_error_3 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[4] = (real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (double)(int64)total_error_4 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[0] = (FLAC__real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_0 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[1] = (FLAC__real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_1 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[2] = (FLAC__real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_2 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[3] = (FLAC__real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_3 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[4] = (FLAC__real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_4 / (double) data_len) / M_LN2 : 0.0); #else - residual_bits_per_sample[0] = (real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[1] = (real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[2] = (real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[3] = (real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double) data_len) / M_LN2 : 0.0); - residual_bits_per_sample[4] = (real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[0] = (FLAC__real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[1] = (FLAC__real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[2] = (FLAC__real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[3] = (FLAC__real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double) data_len) / M_LN2 : 0.0); + residual_bits_per_sample[4] = (FLAC__real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double) data_len) / M_LN2 : 0.0); #endif return order; } -void FLAC__fixed_compute_residual(const int32 data[], unsigned data_len, unsigned order, int32 residual[]) +void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]) { int i, idata_len = (int)data_len; @@ -166,7 +166,7 @@ void FLAC__fixed_compute_residual(const int32 data[], unsigned data_len, unsigne } } -void FLAC__fixed_restore_signal(const int32 residual[], unsigned data_len, unsigned order, int32 data[]) +void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]) { int i, idata_len = (int)data_len; diff --git a/src/libFLAC/format.c b/src/libFLAC/format.c index 21675637..c4484fc7 100644 --- a/src/libFLAC/format.c +++ b/src/libFLAC/format.c @@ -20,7 +20,7 @@ #include #include "FLAC/format.h" -const byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' }; +const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' }; const unsigned FLAC__STREAM_SYNC = 0x664C6143; const unsigned FLAC__STREAM_SYNC_LEN = 32; /* bits */; @@ -42,7 +42,7 @@ const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits * const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */ const unsigned FLAC__STREAM_METADATA_SEEKPOINT_LEN = 18; /* bytes */ -const uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = 0xffffffffffffffff; +const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = 0xffffffffffffffff; const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */ const unsigned FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */ diff --git a/src/libFLAC/ia32/fixed_asm.nasm b/src/libFLAC/ia32/fixed_asm.nasm index 88b37fd5..ff92e6c5 100644 --- a/src/libFLAC/ia32/fixed_asm.nasm +++ b/src/libFLAC/ia32/fixed_asm.nasm @@ -26,14 +26,14 @@ cglobal FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov ; ********************************************************************** ; -; unsigned FLAC__fixed_compute_best_predictor(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +; unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) ; { -; int32 last_error_0 = data[-1]; -; int32 last_error_1 = data[-1] - data[-2]; -; int32 last_error_2 = last_error_1 - (data[-2] - data[-3]); -; int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); -; int32 error, save; -; uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; +; FLAC__int32 last_error_0 = data[-1]; +; FLAC__int32 last_error_1 = data[-1] - data[-2]; +; FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]); +; FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); +; FLAC__int32 error, save; +; FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; ; unsigned i, order; ; ; for(i = 0; i < data_len; i++) { @@ -55,11 +55,11 @@ cglobal FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov ; else ; order = 4; ; -; residual_bits_per_sample[0] = (real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (real)total_error_0 / (real) data_len) / M_LN2 : 0.0); -; residual_bits_per_sample[1] = (real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (real)total_error_1 / (real) data_len) / M_LN2 : 0.0); -; residual_bits_per_sample[2] = (real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (real)total_error_2 / (real) data_len) / M_LN2 : 0.0); -; residual_bits_per_sample[3] = (real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (real)total_error_3 / (real) data_len) / M_LN2 : 0.0); -; residual_bits_per_sample[4] = (real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (real)total_error_4 / (real) data_len) / M_LN2 : 0.0); +; residual_bits_per_sample[0] = (FLAC__real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); +; residual_bits_per_sample[1] = (FLAC__real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); +; residual_bits_per_sample[2] = (FLAC__real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); +; residual_bits_per_sample[3] = (FLAC__real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); +; residual_bits_per_sample[4] = (FLAC__real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); ; ; return order; ; } @@ -75,7 +75,7 @@ cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov push esi push edi sub esp, byte 16 - ; qword [esp] == temp space for loading uint64s to FPU regs + ; qword [esp] == temp space for loading FLAC__uint64s to FPU regs ; dword [esp] == last_error_0 ; dword [esp + 4] == last_error_1 ; dword [esp + 8] == last_error_2 @@ -230,11 +230,11 @@ cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov .not_order_3: mov ebp, 4 .got_order: - ; residual_bits_per_sample[0] = (real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (real)total_error_0 / (real) data_len) / M_LN2 : 0.0); - ; residual_bits_per_sample[1] = (real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (real)total_error_1 / (real) data_len) / M_LN2 : 0.0); - ; residual_bits_per_sample[2] = (real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (real)total_error_2 / (real) data_len) / M_LN2 : 0.0); - ; residual_bits_per_sample[3] = (real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (real)total_error_3 / (real) data_len) / M_LN2 : 0.0); - ; residual_bits_per_sample[4] = (real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (real)total_error_4 / (real) data_len) / M_LN2 : 0.0); + ; residual_bits_per_sample[0] = (FLAC__real)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); + ; residual_bits_per_sample[1] = (FLAC__real)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0); + ; residual_bits_per_sample[2] = (FLAC__real)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0); + ; residual_bits_per_sample[3] = (FLAC__real)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0); + ; residual_bits_per_sample[4] = (FLAC__real)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0); xor eax, eax cmp eax, [esp + 40] je near .data_len_is_0 @@ -244,7 +244,7 @@ cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov jz .total_error_0_is_0 fld1 ; ST = 1.0 data_len mov [esp], ebx - mov [esp + 4], eax ; [esp] = (uint64)total_error_0 + mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_0 mov ebx, [esp + 44] fild qword [esp] ; ST = total_error_0 1.0 data_len fdiv st2 ; ST = total_error_0/data_len 1.0 data_len @@ -261,7 +261,7 @@ cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov jz .total_error_1_is_0 fld1 ; ST = 1.0 data_len mov [esp], ecx - mov [esp + 4], eax ; [esp] = (uint64)total_error_1 + mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_1 fild qword [esp] ; ST = total_error_1 1.0 data_len fdiv st2 ; ST = total_error_1/data_len 1.0 data_len fldln2 ; ST = ln2 total_error_1/data_len 1.0 data_len @@ -276,7 +276,7 @@ cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov jz .total_error_2_is_0 fld1 ; ST = 1.0 data_len mov [esp], edx - mov [esp + 4], eax ; [esp] = (uint64)total_error_2 + mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_2 fild qword [esp] ; ST = total_error_2 1.0 data_len fdiv st2 ; ST = total_error_2/data_len 1.0 data_len fldln2 ; ST = ln2 total_error_2/data_len 1.0 data_len @@ -291,7 +291,7 @@ cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov jz .total_error_3_is_0 fld1 ; ST = 1.0 data_len mov [esp], esi - mov [esp + 4], eax ; [esp] = (uint64)total_error_3 + mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_3 fild qword [esp] ; ST = total_error_3 1.0 data_len fdiv st2 ; ST = total_error_3/data_len 1.0 data_len fldln2 ; ST = ln2 total_error_3/data_len 1.0 data_len @@ -306,7 +306,7 @@ cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov jz .total_error_4_is_0 fld1 ; ST = 1.0 data_len mov [esp], edi - mov [esp + 4], eax ; [esp] = (uint64)total_error_4 + mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_4 fild qword [esp] ; ST = total_error_4 1.0 data_len fdiv st2 ; ST = total_error_4/data_len 1.0 data_len fldln2 ; ST = ln2 total_error_4/data_len 1.0 data_len diff --git a/src/libFLAC/ia32/lpc_asm-unrolled.nasm b/src/libFLAC/ia32/lpc_asm-unrolled.nasm index cfc6ef2d..1bb15f11 100644 --- a/src/libFLAC/ia32/lpc_asm-unrolled.nasm +++ b/src/libFLAC/ia32/lpc_asm-unrolled.nasm @@ -28,9 +28,9 @@ cglobal FLAC__lpc_compute_autocorrelation_asm ; ********************************************************************** ; -; void FLAC__lpc_compute_autocorrelation_asm(const real data[], unsigned data_len, unsigned lag, real autoc[]) +; void FLAC__lpc_compute_autocorrelation_asm(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) ; { -; real d; +; FLAC__real d; ; unsigned sample, coeff; ; const unsigned limit = data_len - lag; ; diff --git a/src/libFLAC/ia32/lpc_asm.nasm b/src/libFLAC/ia32/lpc_asm.nasm index 6e5667c1..3352b1a5 100644 --- a/src/libFLAC/ia32/lpc_asm.nasm +++ b/src/libFLAC/ia32/lpc_asm.nasm @@ -33,9 +33,9 @@ cglobal FLAC__lpc_restore_signal_asm_ia32_mmx ; ********************************************************************** ; -; void FLAC__lpc_compute_autocorrelation_asm(const real data[], unsigned data_len, unsigned lag, real autoc[]) +; void FLAC__lpc_compute_autocorrelation_asm(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) ; { -; real d; +; FLAC__real d; ; unsigned sample, coeff; ; const unsigned limit = data_len - lag; ; @@ -592,7 +592,7 @@ cident FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12 .end: ret -;void FLAC__lpc_compute_residual_from_qlp_coefficients(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]) +;void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 data[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) ; ; for(i = 0; i < data_len; i++) { ; sum = 0; @@ -988,10 +988,10 @@ cident FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx ; ********************************************************************** ; -; void FLAC__lpc_restore_signal(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]) +; void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]) ; { ; unsigned i, j; -; int32 sum; +; FLAC__int32 sum; ; ; FLAC__ASSERT(order > 0); ; diff --git a/src/libFLAC/include/private/bitbuffer.h b/src/libFLAC/include/private/bitbuffer.h index 6c56deac..b06ff4e7 100644 --- a/src/libFLAC/include/private/bitbuffer.h +++ b/src/libFLAC/include/private/bitbuffer.h @@ -24,58 +24,58 @@ #include "FLAC/ordinals.h" typedef struct { - byte *buffer; + FLAC__byte *buffer; unsigned capacity; /* in bytes */ unsigned bytes, bits; unsigned total_bits; /* must always == 8*bytes+bits */ unsigned consumed_bytes, consumed_bits; unsigned total_consumed_bits; /* must always == 8*consumed_bytes+consumed_bits */ - uint16 read_crc16; + FLAC__uint16 read_crc16; } FLAC__BitBuffer; void FLAC__bitbuffer_init(FLAC__BitBuffer *bb); -bool FLAC__bitbuffer_init_from(FLAC__BitBuffer *bb, const byte buffer[], unsigned bytes); -void FLAC__bitbuffer_init_read_crc16(FLAC__BitBuffer *bb, uint16 seed); -bool FLAC__bitbuffer_concatenate_aligned(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src); +FLAC__bool FLAC__bitbuffer_init_from(FLAC__BitBuffer *bb, const FLAC__byte buffer[], unsigned bytes); +void FLAC__bitbuffer_init_read_crc16(FLAC__BitBuffer *bb, FLAC__uint16 seed); +FLAC__bool FLAC__bitbuffer_concatenate_aligned(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src); void FLAC__bitbuffer_free(FLAC__BitBuffer *bb); /* does not 'free(buffer)' */ -bool FLAC__bitbuffer_clear(FLAC__BitBuffer *bb); -bool FLAC__bitbuffer_clone(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src); -bool FLAC__bitbuffer_write_zeroes(FLAC__BitBuffer *bb, unsigned bits); -bool FLAC__bitbuffer_write_raw_uint32(FLAC__BitBuffer *bb, uint32 val, unsigned bits); -bool FLAC__bitbuffer_write_raw_int32(FLAC__BitBuffer *bb, int32 val, unsigned bits); -bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, uint64 val, unsigned bits); -bool FLAC__bitbuffer_write_raw_int64(FLAC__BitBuffer *bb, int64 val, unsigned bits); -bool FLAC__bitbuffer_write_unary_unsigned(FLAC__BitBuffer *bb, unsigned val); +FLAC__bool FLAC__bitbuffer_clear(FLAC__BitBuffer *bb); +FLAC__bool FLAC__bitbuffer_clone(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src); +FLAC__bool FLAC__bitbuffer_write_zeroes(FLAC__BitBuffer *bb, unsigned bits); +FLAC__bool FLAC__bitbuffer_write_raw_uint32(FLAC__BitBuffer *bb, FLAC__uint32 val, unsigned bits); +FLAC__bool FLAC__bitbuffer_write_raw_int32(FLAC__BitBuffer *bb, FLAC__int32 val, unsigned bits); +FLAC__bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, FLAC__uint64 val, unsigned bits); +FLAC__bool FLAC__bitbuffer_write_raw_int64(FLAC__BitBuffer *bb, FLAC__int64 val, unsigned bits); +FLAC__bool FLAC__bitbuffer_write_unary_unsigned(FLAC__BitBuffer *bb, unsigned val); unsigned FLAC__bitbuffer_rice_bits(int val, unsigned parameter); unsigned FLAC__bitbuffer_golomb_bits_signed(int val, unsigned parameter); unsigned FLAC__bitbuffer_golomb_bits_unsigned(unsigned val, unsigned parameter); -bool FLAC__bitbuffer_write_symmetric_rice_signed(FLAC__BitBuffer *bb, int val, unsigned parameter); -bool FLAC__bitbuffer_write_symmetric_rice_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, bool *overflow); -bool FLAC__bitbuffer_write_symmetric_rice_signed_escape(FLAC__BitBuffer *bb, int val, unsigned parameter); -bool FLAC__bitbuffer_write_rice_signed(FLAC__BitBuffer *bb, int val, unsigned parameter); -bool FLAC__bitbuffer_write_rice_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, bool *overflow); -bool FLAC__bitbuffer_write_golomb_signed(FLAC__BitBuffer *bb, int val, unsigned parameter); -bool FLAC__bitbuffer_write_golomb_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, bool *overflow); -bool FLAC__bitbuffer_write_golomb_unsigned(FLAC__BitBuffer *bb, unsigned val, unsigned parameter); -bool FLAC__bitbuffer_write_golomb_unsigned_guarded(FLAC__BitBuffer *bb, unsigned val, unsigned parameter, unsigned max_bits, bool *overflow); -bool FLAC__bitbuffer_write_utf8_uint32(FLAC__BitBuffer *bb, uint32 val); -bool FLAC__bitbuffer_write_utf8_uint64(FLAC__BitBuffer *bb, uint64 val); -bool FLAC__bitbuffer_zero_pad_to_byte_boundary(FLAC__BitBuffer *bb); -bool FLAC__bitbuffer_peek_bit(FLAC__BitBuffer *bb, unsigned *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_bit(FLAC__BitBuffer *bb, unsigned *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_bit_to_uint32(FLAC__BitBuffer *bb, uint32 *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_bit_to_uint64(FLAC__BitBuffer *bb, uint64 *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_raw_uint32(FLAC__BitBuffer *bb, uint32 *val, const unsigned bits, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_raw_int32(FLAC__BitBuffer *bb, int32 *val, const unsigned bits, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_raw_uint64(FLAC__BitBuffer *bb, uint64 *val, const unsigned bits, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_raw_int64(FLAC__BitBuffer *bb, int64 *val, const unsigned bits, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_unary_unsigned(FLAC__BitBuffer *bb, unsigned *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_symmetric_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_golomb_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_golomb_unsigned(FLAC__BitBuffer *bb, unsigned *val, unsigned parameter, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data); -bool FLAC__bitbuffer_read_utf8_uint32(FLAC__BitBuffer *bb, uint32 *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data, byte *raw, unsigned *rawlen); -bool FLAC__bitbuffer_read_utf8_uint64(FLAC__BitBuffer *bb, uint64 *val, bool (*read_callback)(byte buffer[], unsigned *bytes, void *client_data), void *client_data, byte *raw, unsigned *rawlen); +FLAC__bool FLAC__bitbuffer_write_symmetric_rice_signed(FLAC__BitBuffer *bb, int val, unsigned parameter); +FLAC__bool FLAC__bitbuffer_write_symmetric_rice_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, FLAC__bool *overflow); +FLAC__bool FLAC__bitbuffer_write_symmetric_rice_signed_escape(FLAC__BitBuffer *bb, int val, unsigned parameter); +FLAC__bool FLAC__bitbuffer_write_rice_signed(FLAC__BitBuffer *bb, int val, unsigned parameter); +FLAC__bool FLAC__bitbuffer_write_rice_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, FLAC__bool *overflow); +FLAC__bool FLAC__bitbuffer_write_golomb_signed(FLAC__BitBuffer *bb, int val, unsigned parameter); +FLAC__bool FLAC__bitbuffer_write_golomb_signed_guarded(FLAC__BitBuffer *bb, int val, unsigned parameter, unsigned max_bits, FLAC__bool *overflow); +FLAC__bool FLAC__bitbuffer_write_golomb_unsigned(FLAC__BitBuffer *bb, unsigned val, unsigned parameter); +FLAC__bool FLAC__bitbuffer_write_golomb_unsigned_guarded(FLAC__BitBuffer *bb, unsigned val, unsigned parameter, unsigned max_bits, FLAC__bool *overflow); +FLAC__bool FLAC__bitbuffer_write_utf8_uint32(FLAC__BitBuffer *bb, FLAC__uint32 val); +FLAC__bool FLAC__bitbuffer_write_utf8_uint64(FLAC__BitBuffer *bb, FLAC__uint64 val); +FLAC__bool FLAC__bitbuffer_zero_pad_to_byte_boundary(FLAC__BitBuffer *bb); +FLAC__bool FLAC__bitbuffer_peek_bit(FLAC__BitBuffer *bb, unsigned *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_bit(FLAC__BitBuffer *bb, unsigned *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_bit_to_uint32(FLAC__BitBuffer *bb, FLAC__uint32 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_bit_to_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_raw_uint32(FLAC__BitBuffer *bb, FLAC__uint32 *val, const unsigned bits, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_raw_int32(FLAC__BitBuffer *bb, FLAC__int32 *val, const unsigned bits, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_raw_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *val, const unsigned bits, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_raw_int64(FLAC__BitBuffer *bb, FLAC__int64 *val, const unsigned bits, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_unary_unsigned(FLAC__BitBuffer *bb, unsigned *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_symmetric_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_rice_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_golomb_signed(FLAC__BitBuffer *bb, int *val, unsigned parameter, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_golomb_unsigned(FLAC__BitBuffer *bb, unsigned *val, unsigned parameter, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data); +FLAC__bool FLAC__bitbuffer_read_utf8_uint32(FLAC__BitBuffer *bb, FLAC__uint32 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data, FLAC__byte *raw, unsigned *rawlen); +FLAC__bool FLAC__bitbuffer_read_utf8_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data, FLAC__byte *raw, unsigned *rawlen); void FLAC__bitbuffer_dump(const FLAC__BitBuffer *bb, FILE *out); #endif diff --git a/src/libFLAC/include/private/cpu.h b/src/libFLAC/include/private/cpu.h index 6e56361e..4e8e69c5 100644 --- a/src/libFLAC/include/private/cpu.h +++ b/src/libFLAC/include/private/cpu.h @@ -28,11 +28,11 @@ typedef enum { } FLAC__CPUInfo_Type; typedef struct { - bool cmov; - bool mmx; - bool fxsr; - bool sse; - bool sse2; + FLAC__bool cmov; + FLAC__bool mmx; + FLAC__bool fxsr; + FLAC__bool sse; + FLAC__bool sse2; } FLAC__CPUInfo_IA32; extern const unsigned FLAC__CPUINFO_IA32_CPUID_CMOV; extern const unsigned FLAC__CPUINFO_IA32_CPUID_MMX; @@ -41,7 +41,7 @@ extern const unsigned FLAC__CPUINFO_IA32_CPUID_SSE; extern const unsigned FLAC__CPUINFO_IA32_CPUID_SSE2; typedef struct { - bool use_asm; + FLAC__bool use_asm; FLAC__CPUInfo_Type type; union { FLAC__CPUInfo_IA32 ia32; diff --git a/src/libFLAC/include/private/crc.h b/src/libFLAC/include/private/crc.h index 16b3fe3c..b86d3cb3 100644 --- a/src/libFLAC/include/private/crc.h +++ b/src/libFLAC/include/private/crc.h @@ -26,20 +26,20 @@ ** polynomial = x^8 + x^2 + x^1 + x^0 ** init = 0 */ -extern byte const FLAC__crc8_table[256]; +extern FLAC__byte const FLAC__crc8_table[256]; #define FLAC__CRC8_UPDATE(data, crc) (crc) = FLAC__crc8_table[(crc) ^ (data)]; -void FLAC__crc8_update(const byte data, uint8 *crc); -void FLAC__crc8_update_block(const byte *data, unsigned len, uint8 *crc); -uint8 FLAC__crc8(const byte *data, unsigned len); +void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc); +void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc); +FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len); /* 16 bit CRC generator, MSB shifted first ** polynomial = x^16 + x^15 + x^2 + x^0 ** init = 0 */ -extern uint16 FLAC__crc16_table[256]; +extern FLAC__uint16 FLAC__crc16_table[256]; #define FLAC__CRC16_UPDATE(data, crc) (crc) = ((crc)<<8) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]; -void FLAC__crc16_update(const byte data, uint16 *crc); -void FLAC__crc16_update_block(const byte *data, unsigned len, uint16 *crc); -uint16 FLAC__crc16(const byte *data, unsigned len); +void FLAC__crc16_update(const FLAC__byte data, FLAC__uint16 *crc); +void FLAC__crc16_update_block(const FLAC__byte *data, unsigned len, FLAC__uint16 *crc); +FLAC__uint16 FLAC__crc16(const FLAC__byte *data, unsigned len); #endif diff --git a/src/libFLAC/include/private/fixed.h b/src/libFLAC/include/private/fixed.h index 55ccb696..25636064 100644 --- a/src/libFLAC/include/private/fixed.h +++ b/src/libFLAC/include/private/fixed.h @@ -34,15 +34,15 @@ * IN data_len * OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER] */ -unsigned FLAC__fixed_compute_best_predictor(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); #ifndef FLAC__NO_ASM #ifdef FLAC__CPU_IA32 #ifdef FLAC__HAS_NASM -unsigned FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +unsigned FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); #endif #endif #endif -unsigned FLAC__fixed_compute_best_predictor_slow(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +unsigned FLAC__fixed_compute_best_predictor_slow(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); /* * FLAC__fixed_compute_residual() @@ -55,7 +55,7 @@ unsigned FLAC__fixed_compute_best_predictor_slow(const int32 data[], unsigned da * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order * OUT residual[0,data_len-1] residual signal */ -void FLAC__fixed_compute_residual(const int32 data[], unsigned data_len, unsigned order, int32 residual[]); +void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]); /* * FLAC__fixed_restore_signal() @@ -70,6 +70,6 @@ void FLAC__fixed_compute_residual(const int32 data[], unsigned data_len, unsigne * IN data[-order,-1] previously-reconstructed historical samples * OUT data[0,data_len-1] original signal */ -void FLAC__fixed_restore_signal(const int32 residual[], unsigned data_len, unsigned order, int32 data[]); +void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]); #endif diff --git a/src/libFLAC/include/private/lpc.h b/src/libFLAC/include/private/lpc.h index c16f570f..358098ae 100644 --- a/src/libFLAC/include/private/lpc.h +++ b/src/libFLAC/include/private/lpc.h @@ -36,14 +36,14 @@ * IN 0 < lag <= data_len * OUT autoc[0,lag-1] */ -void FLAC__lpc_compute_autocorrelation(const real data[], unsigned data_len, unsigned lag, real autoc[]); +void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); #ifndef FLAC__NO_ASM #ifdef FLAC__CPU_IA32 #ifdef FLAC__HAS_NASM -void FLAC__lpc_compute_autocorrelation_asm_ia32(const real data[], unsigned data_len, unsigned lag, real autoc[]); -void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4(const real data[], unsigned data_len, unsigned lag, real autoc[]); -void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8(const real data[], unsigned data_len, unsigned lag, real autoc[]); -void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12(const real data[], unsigned data_len, unsigned lag, real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); #endif #endif #endif @@ -66,13 +66,13 @@ void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12(const real data[], un * in lp_coeff[8][0,8], the LP coefficients for order 8 will be * in lp_coeff[7][0,7], etc. */ -void FLAC__lpc_compute_lp_coefficients(const real autoc[], unsigned max_order, real lp_coeff[][FLAC__MAX_LPC_ORDER], real error[]); +void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__real error[]); /* * FLAC__lpc_quantize_coefficients() * -------------------------------------------------------------------- * Quantizes the LP coefficients. NOTE: precision + bits_per_sample - * must be less than 32 (sizeof(int32)*8). + * must be less than 32 (sizeof(FLAC__int32)*8). * * IN lp_coeff[0,order-1] LP coefficients * IN order LP order @@ -89,7 +89,7 @@ void FLAC__lpc_compute_lp_coefficients(const real autoc[], unsigned max_order, r * 2 => coefficients are all zero, which is bad. 'shift' is * unset. */ -int FLAC__lpc_quantize_coefficients(const real lp_coeff[], unsigned order, unsigned precision, unsigned bits_per_sample, int32 qlp_coeff[], int *shift); +int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, unsigned bits_per_sample, FLAC__int32 qlp_coeff[], int *shift); /* * FLAC__lpc_compute_residual_from_qlp_coefficients() @@ -104,12 +104,12 @@ int FLAC__lpc_quantize_coefficients(const real lp_coeff[], unsigned order, unsig * IN lp_quantization quantization of LP coefficients in bits * OUT residual[0,data_len-1] residual signal */ -void FLAC__lpc_compute_residual_from_qlp_coefficients(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 data[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); #ifndef FLAC__NO_ASM #ifdef FLAC__CPU_IA32 #ifdef FLAC__HAS_NASM -void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32(const FLAC__int32 data[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const FLAC__int32 data[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); #endif #endif #endif @@ -129,12 +129,12 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const int32 d * IN data[-order,-1] previously-reconstructed historical samples * OUT data[0,data_len-1] original signal */ -void FLAC__lpc_restore_signal(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]); +void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); #ifndef FLAC__NO_ASM #ifdef FLAC__CPU_IA32 #ifdef FLAC__HAS_NASM -void FLAC__lpc_restore_signal_asm_ia32(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]); -void FLAC__lpc_restore_signal_asm_ia32_mmx(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]); +void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); #endif #endif #endif @@ -149,8 +149,8 @@ void FLAC__lpc_restore_signal_asm_ia32_mmx(const int32 residual[], unsigned data * IN total_samples > 0 # of samples in residual signal * RETURN expected bits per sample */ -real FLAC__lpc_compute_expected_bits_per_residual_sample(real lpc_error, unsigned total_samples); -real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(real lpc_error, real error_scale); +FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__real lpc_error, unsigned total_samples); +FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__real lpc_error, FLAC__real error_scale); /* * FLAC__lpc_compute_best_order() @@ -164,6 +164,6 @@ real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(real l * IN bits_per_signal_sample # of bits per sample in the original signal * RETURN [1,max_order] best order */ -unsigned FLAC__lpc_compute_best_order(const real lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample); +unsigned FLAC__lpc_compute_best_order(const FLAC__real lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample); #endif diff --git a/src/libFLAC/include/private/md5.h b/src/libFLAC/include/private/md5.h index 70c016ea..96cb00f6 100644 --- a/src/libFLAC/include/private/md5.h +++ b/src/libFLAC/include/private/md5.h @@ -31,18 +31,18 @@ #include "FLAC/ordinals.h" struct MD5Context { - uint32 buf[4]; - uint32 bytes[2]; - uint32 in[16]; - byte *internal_buf; + FLAC__uint32 buf[4]; + FLAC__uint32 bytes[2]; + FLAC__uint32 in[16]; + FLAC__byte *internal_buf; unsigned capacity; }; void MD5Init(struct MD5Context *context); void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len); void MD5Final(md5byte digest[16], struct MD5Context *context); -void MD5Transform(uint32 buf[4], uint32 const in[16]); +void MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16]); -bool FLAC__MD5Accumulate(struct MD5Context *ctx, const int32 *signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample); +FLAC__bool FLAC__MD5Accumulate(struct MD5Context *ctx, const FLAC__int32 *signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample); #endif /* !MD5_H */ diff --git a/src/libFLAC/include/private/memory.h b/src/libFLAC/include/private/memory.h index 142f5bea..c6e0837c 100644 --- a/src/libFLAC/include/private/memory.h +++ b/src/libFLAC/include/private/memory.h @@ -22,15 +22,15 @@ #include /* for size_t */ -#include "FLAC/ordinals.h" /* for bool */ +#include "FLAC/ordinals.h" /* for FLAC__bool */ /* Returns the unaligned address returned by malloc. * Use free() on this address to deallocate. */ void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); -bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, int32 **unaligned_pointer, int32 **aligned_pointer); -bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, uint32 **unaligned_pointer, uint32 **aligned_pointer); -bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer); -bool FLAC__memory_alloc_aligned_real_array(unsigned elements, real **unaligned_pointer, real **aligned_pointer); +FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer); +FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer); +FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer); +FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); #endif diff --git a/src/libFLAC/include/private/stream_encoder_framing.h b/src/libFLAC/include/private/stream_encoder_framing.h index f3056d82..b623d3f0 100644 --- a/src/libFLAC/include/private/stream_encoder_framing.h +++ b/src/libFLAC/include/private/stream_encoder_framing.h @@ -23,11 +23,11 @@ #include "FLAC/format.h" #include "bitbuffer.h" -bool FLAC__add_metadata_block(const FLAC__StreamMetaData *metadata, FLAC__BitBuffer *bb); -bool FLAC__frame_add_header(const FLAC__FrameHeader *header, bool streamable_subset, bool is_last_block, FLAC__BitBuffer *bb); -bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb); -bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb); -bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb); -bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb); +FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetaData *metadata, FLAC__BitBuffer *bb); +FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__bool streamable_subset, FLAC__bool is_last_block, FLAC__BitBuffer *bb); +FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb); +FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb); +FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb); +FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb); #endif diff --git a/src/libFLAC/include/protected/file_decoder.h b/src/libFLAC/include/protected/file_decoder.h index 3d0b6bdb..3e9761a8 100644 --- a/src/libFLAC/include/protected/file_decoder.h +++ b/src/libFLAC/include/protected/file_decoder.h @@ -23,7 +23,7 @@ #include "FLAC/file_decoder.h" typedef struct FLAC__FileDecoderProtected { - bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the Encoding metadata block */ + FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the Encoding metadata block */ FLAC__FileDecoderState state; } FLAC__FileDecoderProtected; diff --git a/src/libFLAC/include/protected/stream_encoder.h b/src/libFLAC/include/protected/stream_encoder.h index ea11e175..951156f0 100644 --- a/src/libFLAC/include/protected/stream_encoder.h +++ b/src/libFLAC/include/protected/stream_encoder.h @@ -24,24 +24,24 @@ typedef struct FLAC__StreamEncoderProtected { FLAC__StreamEncoderState state; - bool streamable_subset; - bool do_mid_side_stereo; - bool loose_mid_side_stereo; + FLAC__bool streamable_subset; + FLAC__bool do_mid_side_stereo; + FLAC__bool loose_mid_side_stereo; unsigned channels; unsigned bits_per_sample; unsigned sample_rate; unsigned blocksize; unsigned max_lpc_order; unsigned qlp_coeff_precision; - bool do_qlp_coeff_prec_search; - bool do_exhaustive_model_search; + FLAC__bool do_qlp_coeff_prec_search; + FLAC__bool do_exhaustive_model_search; unsigned min_residual_partition_order; unsigned max_residual_partition_order; unsigned rice_parameter_search_dist; - uint64 total_samples_estimate; + FLAC__uint64 total_samples_estimate; const FLAC__StreamMetaData_SeekTable *seek_table; unsigned padding; - bool last_metadata_is_last; + FLAC__bool last_metadata_is_last; } FLAC__StreamEncoderProtected; #endif diff --git a/src/libFLAC/lpc.c b/src/libFLAC/lpc.c index 06d68088..73e449cd 100644 --- a/src/libFLAC/lpc.c +++ b/src/libFLAC/lpc.c @@ -30,11 +30,11 @@ #define LOCAL_FABS(x) ((x)<0.0? -(x):(x)) -void FLAC__lpc_compute_autocorrelation(const real data[], unsigned data_len, unsigned lag, real autoc[]) +void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) { /* a readable, but slower, version */ #if 0 - real d; + FLAC__real d; unsigned i; FLAC__ASSERT(lag > 0); @@ -51,7 +51,7 @@ void FLAC__lpc_compute_autocorrelation(const real data[], unsigned data_len, uns * this version tends to run faster because of better data locality * ('data_len' is usually much larger than 'lag') */ - real d; + FLAC__real d; unsigned sample, coeff; const unsigned limit = data_len - lag; @@ -72,10 +72,10 @@ void FLAC__lpc_compute_autocorrelation(const real data[], unsigned data_len, uns } } -void FLAC__lpc_compute_lp_coefficients(const real autoc[], unsigned max_order, real lp_coeff[][FLAC__MAX_LPC_ORDER], real error[]) +void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__real error[]) { unsigned i, j; - real r, err, ref[FLAC__MAX_LPC_ORDER], lpc[FLAC__MAX_LPC_ORDER]; + FLAC__real r, err, ref[FLAC__MAX_LPC_ORDER], lpc[FLAC__MAX_LPC_ORDER]; FLAC__ASSERT(0 < max_order); FLAC__ASSERT(max_order <= FLAC__MAX_LPC_ORDER); @@ -93,7 +93,7 @@ void FLAC__lpc_compute_lp_coefficients(const real autoc[], unsigned max_order, r /* Update LPC coefficients and total error. */ lpc[i]=r; for(j = 0; j < (i>>1); j++) { - real tmp = lpc[j]; + FLAC__real tmp = lpc[j]; lpc[j] += r * lpc[i-1-j]; lpc[i-1-j] += r * tmp; } @@ -109,16 +109,16 @@ void FLAC__lpc_compute_lp_coefficients(const real autoc[], unsigned max_order, r } } -int FLAC__lpc_quantize_coefficients(const real lp_coeff[], unsigned order, unsigned precision, unsigned bits_per_sample, int32 qlp_coeff[], int *shift) +int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, unsigned bits_per_sample, FLAC__int32 qlp_coeff[], int *shift) { unsigned i; - real d, cmax = -1e32; + FLAC__real d, cmax = -1e32; FLAC__ASSERT(bits_per_sample > 0); - FLAC__ASSERT(bits_per_sample <= sizeof(int32)*8); + FLAC__ASSERT(bits_per_sample <= sizeof(FLAC__int32)*8); FLAC__ASSERT(precision > 0); FLAC__ASSERT(precision >= FLAC__MIN_QLP_COEFF_PRECISION); - FLAC__ASSERT(precision + bits_per_sample < sizeof(int32)*8); + FLAC__ASSERT(precision + bits_per_sample < sizeof(FLAC__int32)*8); #ifdef NDEBUG (void)bits_per_sample; /* silence compiler warning about unused parameter */ #endif @@ -151,19 +151,19 @@ int FLAC__lpc_quantize_coefficients(const real lp_coeff[], unsigned order, unsig if(*shift != 0) { /* just to avoid wasting time... */ for(i = 0; i < order; i++) - qlp_coeff[i] = (int32)floor(lp_coeff[i] * (real)(1 << *shift)); + qlp_coeff[i] = (FLAC__int32)floor(lp_coeff[i] * (FLAC__real)(1 << *shift)); } return 0; } -void FLAC__lpc_compute_residual_from_qlp_coefficients(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]) +void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 data[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) { #ifdef FLAC__OVERFLOW_DETECT - int64 sumo; + FLAC__int64 sumo; #endif unsigned i, j; - int32 sum; - const int32 *history; + FLAC__int32 sum; + const FLAC__int32 *history; #ifdef FLAC__OVERFLOW_DETECT_VERBOSE fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); @@ -182,7 +182,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const int32 data[], unsign for(j = 0; j < order; j++) { sum += qlp_coeff[j] * (*(--history)); #ifdef FLAC__OVERFLOW_DETECT - sumo += (int64)qlp_coeff[j] * (int64)(*history); + sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history); if(sumo > 2147483647ll || sumo < -2147483648ll) { fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,sumo); } @@ -201,14 +201,14 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const int32 data[], unsign */ } -void FLAC__lpc_restore_signal(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]) +void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]) { #ifdef FLAC__OVERFLOW_DETECT - int64 sumo; + FLAC__int64 sumo; #endif unsigned i, j; - int32 sum; - const int32 *history; + FLAC__int32 sum; + const FLAC__int32 *history; #ifdef FLAC__OVERFLOW_DETECT_VERBOSE fprintf(stderr,"FLAC__lpc_restore_signal: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); @@ -227,7 +227,7 @@ void FLAC__lpc_restore_signal(const int32 residual[], unsigned data_len, const i for(j = 0; j < order; j++) { sum += qlp_coeff[j] * (*(--history)); #ifdef FLAC__OVERFLOW_DETECT - sumo += (int64)qlp_coeff[j] * (int64)(*history); + sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history); if(sumo > 2147483647ll || sumo < -2147483648ll) { fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,sumo); } @@ -246,16 +246,16 @@ void FLAC__lpc_restore_signal(const int32 residual[], unsigned data_len, const i */ } -real FLAC__lpc_compute_expected_bits_per_residual_sample(real lpc_error, unsigned total_samples) +FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__real lpc_error, unsigned total_samples) { - real error_scale; + FLAC__real error_scale; FLAC__ASSERT(total_samples > 0); - error_scale = 0.5 * M_LN2 * M_LN2 / (real)total_samples; + error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__real)total_samples; if(lpc_error > 0.0) { - real bps = 0.5 * log(error_scale * lpc_error) / M_LN2; + FLAC__real bps = 0.5 * log(error_scale * lpc_error) / M_LN2; if(bps >= 0.0) return bps; else @@ -269,10 +269,10 @@ real FLAC__lpc_compute_expected_bits_per_residual_sample(real lpc_error, unsigne } } -real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(real lpc_error, real error_scale) +FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__real lpc_error, FLAC__real error_scale) { if(lpc_error > 0.0) { - real bps = 0.5 * log(error_scale * lpc_error) / M_LN2; + FLAC__real bps = 0.5 * log(error_scale * lpc_error) / M_LN2; if(bps >= 0.0) return bps; else @@ -286,21 +286,21 @@ real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(real l } } -unsigned FLAC__lpc_compute_best_order(const real lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample) +unsigned FLAC__lpc_compute_best_order(const FLAC__real lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample) { unsigned order, best_order; - real best_bits, tmp_bits, error_scale; + FLAC__real best_bits, tmp_bits, error_scale; FLAC__ASSERT(max_order > 0); FLAC__ASSERT(total_samples > 0); - error_scale = 0.5 * M_LN2 * M_LN2 / (real)total_samples; + error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__real)total_samples; best_order = 0; - best_bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[0], error_scale) * (real)total_samples; + best_bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[0], error_scale) * (FLAC__real)total_samples; for(order = 1; order < max_order; order++) { - tmp_bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[order], error_scale) * (real)(total_samples - order) + (real)(order * bits_per_signal_sample); + tmp_bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[order], error_scale) * (FLAC__real)(total_samples - order) + (FLAC__real)(order * bits_per_signal_sample); if(tmp_bits < best_bits) { best_order = order; best_bits = tmp_bits; diff --git a/src/libFLAC/md5.c b/src/libFLAC/md5.c index 6bdda137..c4657287 100644 --- a/src/libFLAC/md5.c +++ b/src/libFLAC/md5.c @@ -28,17 +28,17 @@ #include "private/md5.h" -static bool is_big_endian_host_; +static FLAC__bool is_big_endian_host_; void -byteSwap(uint32 *buf, unsigned words) +byteSwap(FLAC__uint32 *buf, unsigned words) { md5byte *p = (md5byte *)buf; if(!is_big_endian_host_) return; do { - *buf++ = (uint32)((unsigned)p[3] << 8 | p[2]) << 16 | ((unsigned)p[1] << 8 | p[0]); + *buf++ = (FLAC__uint32)((unsigned)p[3] << 8 | p[2]) << 16 | ((unsigned)p[1] << 8 | p[0]); p += 4; } while (--words); } @@ -50,9 +50,9 @@ byteSwap(uint32 *buf, unsigned words) void MD5Init(struct MD5Context *ctx) { - uint32 test = 1; + FLAC__uint32 test = 1; - is_big_endian_host_ = (*((byte*)(&test)))? false : true; + is_big_endian_host_ = (*((FLAC__byte*)(&test)))? false : true; ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; @@ -73,7 +73,7 @@ MD5Init(struct MD5Context *ctx) void MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) { - uint32 t; + FLAC__uint32 t; /* Update byte count */ @@ -109,16 +109,16 @@ MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len) /* * Convert the incoming audio signal to a byte stream and MD5Update it. */ -bool -FLAC__MD5Accumulate(struct MD5Context *ctx, const int32 *signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample) +FLAC__bool +FLAC__MD5Accumulate(struct MD5Context *ctx, const FLAC__int32 *signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample) { unsigned channel, sample, a_byte; - int32 a_word; - byte *buf_; + FLAC__int32 a_word; + FLAC__byte *buf_; const unsigned bytes_needed = channels * samples * bytes_per_sample; if(ctx->capacity < bytes_needed) { - byte *tmp = realloc(ctx->internal_buf, bytes_needed); + FLAC__byte *tmp = realloc(ctx->internal_buf, bytes_needed); if(0 == tmp) { free(ctx->internal_buf); if(0 == (ctx->internal_buf = malloc(bytes_needed))) @@ -134,7 +134,7 @@ FLAC__MD5Accumulate(struct MD5Context *ctx, const int32 *signal[], unsigned chan for(channel = 0; channel < channels; channel++) { a_word = signal[channel][sample]; for(a_byte = 0; a_byte < bytes_per_sample; a_byte++) { - *buf_++ = (byte)(a_word & 0xff); + *buf_++ = (FLAC__byte)(a_word & 0xff); a_word >>= 8; } } @@ -206,9 +206,9 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx) * the data and converts bytes into longwords for this routine. */ void -MD5Transform(uint32 buf[4], uint32 const in[16]) +MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16]) { - register uint32 a, b, c, d; + register FLAC__uint32 a, b, c, d; a = buf[0]; b = buf[1]; diff --git a/src/libFLAC/memory.c b/src/libFLAC/memory.c index 92151042..e2088d0c 100644 --- a/src/libFLAC/memory.c +++ b/src/libFLAC/memory.c @@ -37,16 +37,16 @@ void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address) return x; } -bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, int32 **unaligned_pointer, int32 **aligned_pointer) +FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer) { - int32 *pa, *pu; /* aligned pointer, unaligned pointer */ + FLAC__int32 *pa, *pu; /* aligned pointer, unaligned pointer */ FLAC__ASSERT(elements > 0); FLAC__ASSERT(0 != unaligned_pointer); FLAC__ASSERT(0 != aligned_pointer); FLAC__ASSERT(unaligned_pointer != aligned_pointer); - pu = (int32*)FLAC__memory_alloc_aligned(sizeof(int32) * elements, (void*)&pa); + pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(FLAC__int32) * elements, (void*)&pa); if(0 == pu) { return false; } @@ -59,16 +59,16 @@ bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, int32 **unaligned } } -bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, uint32 **unaligned_pointer, uint32 **aligned_pointer) +FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer) { - uint32 *pa, *pu; /* aligned pointer, unaligned pointer */ + FLAC__uint32 *pa, *pu; /* aligned pointer, unaligned pointer */ FLAC__ASSERT(elements > 0); FLAC__ASSERT(0 != unaligned_pointer); FLAC__ASSERT(0 != aligned_pointer); FLAC__ASSERT(unaligned_pointer != aligned_pointer); - pu = (uint32*)FLAC__memory_alloc_aligned(sizeof(uint32) * elements, (void*)&pa); + pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(FLAC__uint32) * elements, (void*)&pa); if(0 == pu) { return false; } @@ -81,7 +81,7 @@ bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, uint32 **unalign } } -bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer) +FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer) { unsigned *pa, *pu; /* aligned pointer, unaligned pointer */ @@ -103,16 +103,16 @@ bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **una } } -bool FLAC__memory_alloc_aligned_real_array(unsigned elements, real **unaligned_pointer, real **aligned_pointer) +FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer) { - real *pa, *pu; /* aligned pointer, unaligned pointer */ + FLAC__real *pa, *pu; /* aligned pointer, unaligned pointer */ FLAC__ASSERT(elements > 0); FLAC__ASSERT(0 != unaligned_pointer); FLAC__ASSERT(0 != aligned_pointer); FLAC__ASSERT(unaligned_pointer != aligned_pointer); - pu = (real*)FLAC__memory_alloc_aligned(sizeof(real) * elements, (void*)&pa); + pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(FLAC__real) * elements, (void*)&pa); if(0 == pu) { return false; } diff --git a/src/libFLAC/seek_table.c b/src/libFLAC/seek_table.c index d76a942d..ea8fc592 100644 --- a/src/libFLAC/seek_table.c +++ b/src/libFLAC/seek_table.c @@ -19,11 +19,11 @@ #include "FLAC/seek_table.h" -bool FLAC__seek_table_is_valid(const FLAC__StreamMetaData_SeekTable *seek_table) +FLAC__bool FLAC__seek_table_is_valid(const FLAC__StreamMetaData_SeekTable *seek_table) { unsigned i; - uint64 last_sample_number = 0; - bool got_last = false; + FLAC__uint64 last_sample_number = 0; + FLAC__bool got_last = false; for(i = 0; i < seek_table->num_points; i++) { if(seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) { diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index 5933cb50..48d9137a 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -34,7 +34,7 @@ * ***********************************************************************/ -static byte ID3V2_TAG_[3] = { 'I', 'D', '3' }; +static FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' }; /*********************************************************************** * @@ -42,21 +42,21 @@ static byte ID3V2_TAG_[3] = { 'I', 'D', '3' }; * ***********************************************************************/ -static bool stream_decoder_allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels); -static bool stream_decoder_find_metadata_(FLAC__StreamDecoder *decoder); -static bool stream_decoder_read_metadata_(FLAC__StreamDecoder *decoder); -static bool stream_decoder_skip_id3v2_tag_(FLAC__StreamDecoder *decoder); -static bool stream_decoder_frame_sync_(FLAC__StreamDecoder *decoder); -static bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, bool *got_a_frame); -static bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder); -static bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps); -static bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps); -static bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order); -static bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order); -static bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps); -static bool stream_decoder_read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, int32 *residual); -static bool stream_decoder_read_zero_padding_(FLAC__StreamDecoder *decoder); -static bool read_callback_(byte buffer[], unsigned *bytes, void *client_data); +static FLAC__bool stream_decoder_allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels); +static FLAC__bool stream_decoder_find_metadata_(FLAC__StreamDecoder *decoder); +static FLAC__bool stream_decoder_read_metadata_(FLAC__StreamDecoder *decoder); +static FLAC__bool stream_decoder_skip_id3v2_tag_(FLAC__StreamDecoder *decoder); +static FLAC__bool stream_decoder_frame_sync_(FLAC__StreamDecoder *decoder); +static FLAC__bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame); +static FLAC__bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder); +static FLAC__bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps); +static FLAC__bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps); +static FLAC__bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order); +static FLAC__bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order); +static FLAC__bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps); +static FLAC__bool stream_decoder_read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__int32 *residual); +static FLAC__bool stream_decoder_read_zero_padding_(FLAC__StreamDecoder *decoder); +static FLAC__bool read_callback_(FLAC__byte buffer[], unsigned *bytes, void *client_data); /*********************************************************************** * @@ -65,27 +65,27 @@ static bool read_callback_(byte buffer[], unsigned *bytes, void *client_data); ***********************************************************************/ typedef struct FLAC__StreamDecoderPrivate { - FLAC__StreamDecoderReadStatus (*read_callback)(const FLAC__StreamDecoder *decoder, byte buffer[], unsigned *bytes, void *client_data); - FLAC__StreamDecoderWriteStatus (*write_callback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data); + FLAC__StreamDecoderReadStatus (*read_callback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data); + FLAC__StreamDecoderWriteStatus (*write_callback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data); void (*metadata_callback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data); void (*error_callback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); - void (*local_lpc_restore_signal)(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]); - void (*local_lpc_restore_signal_16bit)(const int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[]); + void (*local_lpc_restore_signal)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); + void (*local_lpc_restore_signal_16bit)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); void *client_data; FLAC__BitBuffer input; - int32 *output[FLAC__MAX_CHANNELS]; - int32 *residual[FLAC__MAX_CHANNELS]; + FLAC__int32 *output[FLAC__MAX_CHANNELS]; + FLAC__int32 *residual[FLAC__MAX_CHANNELS]; unsigned output_capacity, output_channels; - uint32 last_frame_number; - uint64 samples_decoded; - bool has_stream_info, has_seek_table; + FLAC__uint32 last_frame_number; + FLAC__uint64 samples_decoded; + FLAC__bool has_stream_info, has_seek_table; FLAC__StreamMetaData stream_info; FLAC__StreamMetaData seek_table; FLAC__Frame frame; - bool cached; /* true if there is a byte in lookahead */ + FLAC__bool cached; /* true if there is a byte in lookahead */ FLAC__CPUInfo cpuinfo; - byte header_warmup[2]; /* contains the sync code and reserved bits */ - byte lookahead; /* temp storage when we need to look ahead one byte in the stream */ + FLAC__byte header_warmup[2]; /* contains the sync code and reserved bits */ + FLAC__byte lookahead; /* temp storage when we need to look ahead one byte in the stream */ } FLAC__StreamDecoderPrivate; /*********************************************************************** @@ -261,7 +261,7 @@ void FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder) decoder->protected->state = FLAC__STREAM_DECODER_UNINITIALIZED; } -bool FLAC__stream_decoder_set_read_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderReadStatus (*value)(const FLAC__StreamDecoder *decoder, byte buffer[], unsigned *bytes, void *client_data)) +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) return false; @@ -269,7 +269,7 @@ bool FLAC__stream_decoder_set_read_callback(const FLAC__StreamDecoder *decoder, return true; } -bool FLAC__stream_decoder_set_write_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data)) +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) return false; @@ -277,7 +277,7 @@ bool FLAC__stream_decoder_set_write_callback(const FLAC__StreamDecoder *decoder, return true; } -bool FLAC__stream_decoder_set_metadata_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data)) +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) return false; @@ -285,7 +285,7 @@ bool FLAC__stream_decoder_set_metadata_callback(const FLAC__StreamDecoder *decod return true; } -bool FLAC__stream_decoder_set_error_callback(const FLAC__StreamDecoder *decoder, void (*value)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)) +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) return false; @@ -293,7 +293,7 @@ bool FLAC__stream_decoder_set_error_callback(const FLAC__StreamDecoder *decoder, return true; } -bool FLAC__stream_decoder_set_client_data(const FLAC__StreamDecoder *decoder, void *value) +FLAC__bool FLAC__stream_decoder_set_client_data(const FLAC__StreamDecoder *decoder, void *value) { if(decoder->protected->state != FLAC__STREAM_DECODER_UNINITIALIZED) return false; @@ -331,7 +331,7 @@ unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) return decoder->protected->blocksize; } -bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) +FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) { FLAC__ASSERT(decoder != 0); @@ -343,7 +343,7 @@ bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder) return true; } -bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) +FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) { FLAC__ASSERT(decoder != 0); @@ -358,9 +358,9 @@ bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder) return true; } -bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decoder) +FLAC__bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decoder) { - bool dummy; + FLAC__bool dummy; FLAC__ASSERT(decoder != 0); if(decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM) @@ -399,7 +399,7 @@ bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decoder) } } -bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder) +FLAC__bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder) { FLAC__ASSERT(decoder != 0); @@ -434,9 +434,9 @@ bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder) } } -bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder) +FLAC__bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder) { - bool got_a_frame; + FLAC__bool got_a_frame; FLAC__ASSERT(decoder != 0); if(decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM) @@ -464,9 +464,9 @@ bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder) } } -bool FLAC__stream_decoder_process_remaining_frames(FLAC__StreamDecoder *decoder) +FLAC__bool FLAC__stream_decoder_process_remaining_frames(FLAC__StreamDecoder *decoder) { - bool dummy; + FLAC__bool dummy; FLAC__ASSERT(decoder != 0); if(decoder->protected->state == FLAC__STREAM_DECODER_END_OF_STREAM) @@ -510,10 +510,10 @@ unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecod * ***********************************************************************/ -bool stream_decoder_allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels) +FLAC__bool stream_decoder_allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels) { unsigned i; - int32 *tmp; + FLAC__int32 *tmp; if(size <= decoder->private->output_capacity && channels <= decoder->private->output_channels) return true; @@ -532,14 +532,14 @@ bool stream_decoder_allocate_output_(FLAC__StreamDecoder *decoder, unsigned size } for(i = 0; i < channels; i++) { - tmp = (int32*)malloc(sizeof(int32)*size); + tmp = (FLAC__int32*)malloc(sizeof(FLAC__int32)*size); if(tmp == 0) { decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; return false; } decoder->private->output[i] = tmp; - tmp = (int32*)malloc(sizeof(int32)*size); + tmp = (FLAC__int32*)malloc(sizeof(FLAC__int32)*size); if(tmp == 0) { decoder->protected->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; return false; @@ -553,17 +553,17 @@ bool stream_decoder_allocate_output_(FLAC__StreamDecoder *decoder, unsigned size return true; } -bool stream_decoder_find_metadata_(FLAC__StreamDecoder *decoder) +FLAC__bool stream_decoder_find_metadata_(FLAC__StreamDecoder *decoder) { - uint32 x; + FLAC__uint32 x; unsigned i, id; - bool first = true; + FLAC__bool first = true; 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 = (uint32)decoder->private->lookahead; + x = (FLAC__uint32)decoder->private->lookahead; decoder->private->cached = false; } else { @@ -586,18 +586,18 @@ bool stream_decoder_find_metadata_(FLAC__StreamDecoder *decoder) continue; } if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */ - decoder->private->header_warmup[0] = (byte)x; + 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 = (byte)x; + 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] = (byte)x; + decoder->private->header_warmup[1] = (FLAC__byte)x; decoder->protected->state = FLAC__STREAM_DECODER_READ_FRAME; return true; } @@ -613,10 +613,10 @@ bool stream_decoder_find_metadata_(FLAC__StreamDecoder *decoder) return true; } -bool stream_decoder_read_metadata_(FLAC__StreamDecoder *decoder) +FLAC__bool stream_decoder_read_metadata_(FLAC__StreamDecoder *decoder) { - uint32 i, x, last_block, type, length; - uint64 xx; + 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 */ @@ -674,7 +674,7 @@ bool stream_decoder_read_metadata_(FLAC__StreamDecoder *decoder) for(i = 0; i < 16; i++) { 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] = (byte)x; + decoder->private->stream_info.data.stream_info.md5sum[i] = (FLAC__byte)x; } used_bits += i*8; @@ -737,9 +737,9 @@ bool stream_decoder_read_metadata_(FLAC__StreamDecoder *decoder) return true; } -bool stream_decoder_skip_id3v2_tag_(FLAC__StreamDecoder *decoder) +FLAC__bool stream_decoder_skip_id3v2_tag_(FLAC__StreamDecoder *decoder) { - uint32 x; + FLAC__uint32 x; unsigned i, skip; /* skip the version and flags bytes */ @@ -761,10 +761,10 @@ bool stream_decoder_skip_id3v2_tag_(FLAC__StreamDecoder *decoder) return true; } -bool stream_decoder_frame_sync_(FLAC__StreamDecoder *decoder) +FLAC__bool stream_decoder_frame_sync_(FLAC__StreamDecoder *decoder) { - uint32 x; - bool first = true; + FLAC__uint32 x; + FLAC__bool first = 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. */ @@ -783,7 +783,7 @@ bool stream_decoder_frame_sync_(FLAC__StreamDecoder *decoder) while(1) { if(decoder->private->cached) { - x = (uint32)decoder->private->lookahead; + x = (FLAC__uint32)decoder->private->lookahead; decoder->private->cached = false; } else { @@ -791,18 +791,18 @@ bool stream_decoder_frame_sync_(FLAC__StreamDecoder *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] = (byte)x; + 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 = (byte)x; + 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] = (byte)x; + decoder->private->header_warmup[1] = (FLAC__byte)x; decoder->protected->state = FLAC__STREAM_DECODER_READ_FRAME; return true; } @@ -816,13 +816,13 @@ bool stream_decoder_frame_sync_(FLAC__StreamDecoder *decoder) return true; } -bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, bool *got_a_frame) +FLAC__bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame) { unsigned channel; unsigned i; - int32 mid, side, left, right; - uint16 frame_crc; /* the one we calculate from the input stream */ - uint32 x; + FLAC__int32 mid, side, left, right; + FLAC__uint16 frame_crc; /* the one we calculate from the input stream */ + FLAC__uint32 x; *got_a_frame = false; @@ -884,7 +884,7 @@ bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, bool *got_a_frame) 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 == (uint16)x) { + if(frame_crc == (FLAC__uint16)x) { /* Undo any special channel coding */ switch(decoder->private->frame.header.channel_assignment) { case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: @@ -923,7 +923,7 @@ bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, bool *got_a_frame) /* 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(int32) * decoder->private->frame.header.blocksize); + memset(decoder->private->output[channel], 0, sizeof(FLAC__int32) * decoder->private->frame.header.blocksize); } } @@ -947,16 +947,16 @@ bool stream_decoder_read_frame_(FLAC__StreamDecoder *decoder, bool *got_a_frame) return true; } -bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder) +FLAC__bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder) { - uint32 x; - uint64 xx; + FLAC__uint32 x; + FLAC__uint64 xx; unsigned i, blocksize_hint = 0, sample_rate_hint = 0; - byte crc8, raw_header[16]; /* MAGIC NUMBER based on the maximum frame header size, including CRC */ + FLAC__byte crc8, raw_header[16]; /* MAGIC NUMBER based on the maximum frame header size, including CRC */ unsigned raw_header_len; - bool is_unparseable = false; - const 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 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__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); FLAC__ASSERT(decoder->private->input.consumed_bits == 0); /* make sure we're byte aligned */ @@ -986,13 +986,13 @@ bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *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 = (byte)x; + 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++] = (byte)x; + raw_header[raw_header_len++] = (FLAC__byte)x; } switch(x = raw_header[2] >> 4) { @@ -1163,7 +1163,7 @@ bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder) } decoder->private->last_frame_number = x; if(decoder->private->has_stream_info) { - decoder->private->frame.header.number.sample_number = (int64)decoder->private->stream_info.data.stream_info.min_blocksize * (int64)x; + 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; @@ -1173,12 +1173,12 @@ bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder) if(blocksize_hint) { 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++] = (byte)x; + raw_header[raw_header_len++] = (FLAC__byte)x; if(blocksize_hint == 7) { - uint32 _x; + FLAC__uint32 _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 */ - raw_header[raw_header_len++] = (byte)_x; + raw_header[raw_header_len++] = (FLAC__byte)_x; x = (x << 8) | _x; } decoder->private->frame.header.blocksize = x+1; @@ -1187,12 +1187,12 @@ bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder) if(sample_rate_hint) { 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++] = (byte)x; + raw_header[raw_header_len++] = (FLAC__byte)x; if(sample_rate_hint != 12) { - uint32 _x; + FLAC__uint32 _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 */ - raw_header[raw_header_len++] = (byte)_x; + raw_header[raw_header_len++] = (FLAC__byte)_x; x = (x << 8) | _x; } if(sample_rate_hint == 12) @@ -1206,7 +1206,7 @@ bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder) /* read the CRC-8 byte */ 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 = (byte)x; + 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); @@ -1222,10 +1222,10 @@ bool stream_decoder_read_frame_header_(FLAC__StreamDecoder *decoder) return true; } -bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps) +FLAC__bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps) { - uint32 x; - bool wasted_bits; + FLAC__uint32 x; + FLAC__bool wasted_bits; 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 */ @@ -1286,12 +1286,12 @@ bool stream_decoder_read_subframe_(FLAC__StreamDecoder *decoder, unsigned channe return true; } -bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps) +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; - int32 x; + FLAC__int32 x; unsigned i; - int32 *output = decoder->private->output[channel]; + FLAC__int32 *output = decoder->private->output[channel]; decoder->private->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; @@ -1307,11 +1307,11 @@ bool stream_decoder_read_subframe_constant_(FLAC__StreamDecoder *decoder, unsign return true; } -bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order) +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; - int32 i32; - uint32 u32; + FLAC__int32 i32; + FLAC__uint32 u32; unsigned u; decoder->private->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED; @@ -1352,17 +1352,17 @@ bool stream_decoder_read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned } /* decode the subframe */ - memcpy(decoder->private->output[channel], subframe->warmup, sizeof(int32) * 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; } -bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order) +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; - int32 i32; - uint32 u32; + FLAC__int32 i32; + FLAC__uint32 u32; unsigned u; decoder->private->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; @@ -1425,7 +1425,7 @@ bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned ch } /* decode the subframe */ - memcpy(decoder->private->output[channel], subframe->warmup, sizeof(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); else @@ -1434,10 +1434,10 @@ bool stream_decoder_read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned ch return true; } -bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps) +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; - int32 x, *residual = decoder->private->residual[channel]; + FLAC__int32 x, *residual = decoder->private->residual[channel]; unsigned i; decoder->private->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; @@ -1451,14 +1451,14 @@ bool stream_decoder_read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsign } /* decode the subframe */ - memcpy(decoder->private->output[channel], subframe->data, sizeof(int32) * decoder->private->frame.header.blocksize); + memcpy(decoder->private->output[channel], subframe->data, sizeof(FLAC__int32) * decoder->private->frame.header.blocksize); return true; } -bool stream_decoder_read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, int32 *residual) +FLAC__bool stream_decoder_read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__int32 *residual) { - uint32 rice_parameter; + FLAC__uint32 rice_parameter; int i; unsigned partition, sample, u; const unsigned partitions = 1u << partition_order; @@ -1494,10 +1494,10 @@ bool stream_decoder_read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder return true; } -bool stream_decoder_read_zero_padding_(FLAC__StreamDecoder *decoder) +FLAC__bool stream_decoder_read_zero_padding_(FLAC__StreamDecoder *decoder) { if(decoder->private->input.consumed_bits != 0) { - uint32 zero = 0; + FLAC__uint32 zero = 0; 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) { @@ -1508,7 +1508,7 @@ bool stream_decoder_read_zero_padding_(FLAC__StreamDecoder *decoder) return true; } -bool read_callback_(byte buffer[], unsigned *bytes, void *client_data) +FLAC__bool read_callback_(FLAC__byte buffer[], unsigned *bytes, void *client_data) { FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data; FLAC__StreamDecoderReadStatus status; diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index ba41d8f6..14ea34ee 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -49,21 +49,21 @@ * ***********************************************************************/ -static bool stream_encoder_resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_size); -static bool stream_encoder_process_frame_(FLAC__StreamEncoder *encoder, bool is_last_frame); -static bool stream_encoder_process_subframes_(FLAC__StreamEncoder *encoder, bool is_last_frame); -static bool stream_encoder_process_subframe_(FLAC__StreamEncoder *encoder, unsigned min_partition_order, unsigned max_partition_order, bool verbatim_only, const FLAC__FrameHeader *frame_header, unsigned subframe_bps, const int32 integer_signal[], const real real_signal[], FLAC__Subframe *subframe[2], int32 *residual[2], unsigned *best_subframe, unsigned *best_bits); -static bool stream_encoder_add_subframe_(FLAC__StreamEncoder *encoder, const FLAC__FrameHeader *frame_header, unsigned subframe_bps, const FLAC__Subframe *subframe, FLAC__BitBuffer *frame); -static unsigned stream_encoder_evaluate_constant_subframe_(const int32 signal, unsigned subframe_bps, FLAC__Subframe *subframe); -static unsigned stream_encoder_evaluate_fixed_subframe_(const int32 signal[], int32 residual[], uint32 abs_residual[], uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned blocksize, unsigned subframe_bps, unsigned order, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, FLAC__Subframe *subframe); -static unsigned stream_encoder_evaluate_lpc_subframe_(FLAC__StreamEncoder *encoder, const int32 signal[], int32 residual[], uint32 abs_residual[], uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], const real lp_coeff[], unsigned blocksize, unsigned subframe_bps, unsigned order, unsigned qlp_coeff_precision, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, FLAC__Subframe *subframe); -static unsigned stream_encoder_evaluate_verbatim_subframe_(const int32 signal[], unsigned blocksize, unsigned subframe_bps, FLAC__Subframe *subframe); -static unsigned stream_encoder_find_best_partition_order_(const int32 residual[], uint32 abs_residual[], uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned residual_samples, unsigned predictor_order, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, unsigned *best_partition_order, unsigned best_parameters[], unsigned best_raw_bits[]); +static FLAC__bool stream_encoder_resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_size); +static FLAC__bool stream_encoder_process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_frame); +static FLAC__bool stream_encoder_process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_frame); +static FLAC__bool stream_encoder_process_subframe_(FLAC__StreamEncoder *encoder, unsigned min_partition_order, unsigned max_partition_order, FLAC__bool verbatim_only, const FLAC__FrameHeader *frame_header, unsigned subframe_bps, const FLAC__int32 integer_signal[], const FLAC__real real_signal[], FLAC__Subframe *subframe[2], FLAC__int32 *residual[2], unsigned *best_subframe, unsigned *best_bits); +static FLAC__bool stream_encoder_add_subframe_(FLAC__StreamEncoder *encoder, const FLAC__FrameHeader *frame_header, unsigned subframe_bps, const FLAC__Subframe *subframe, FLAC__BitBuffer *frame); +static unsigned stream_encoder_evaluate_constant_subframe_(const FLAC__int32 signal, unsigned subframe_bps, FLAC__Subframe *subframe); +static unsigned stream_encoder_evaluate_fixed_subframe_(const FLAC__int32 signal[], FLAC__int32 residual[], FLAC__uint32 abs_residual[], FLAC__uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned blocksize, unsigned subframe_bps, unsigned order, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, FLAC__Subframe *subframe); +static unsigned stream_encoder_evaluate_lpc_subframe_(FLAC__StreamEncoder *encoder, const FLAC__int32 signal[], FLAC__int32 residual[], FLAC__uint32 abs_residual[], FLAC__uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], const FLAC__real lp_coeff[], unsigned blocksize, unsigned subframe_bps, unsigned order, unsigned qlp_coeff_precision, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, FLAC__Subframe *subframe); +static unsigned stream_encoder_evaluate_verbatim_subframe_(const FLAC__int32 signal[], unsigned blocksize, unsigned subframe_bps, FLAC__Subframe *subframe); +static unsigned stream_encoder_find_best_partition_order_(const FLAC__int32 residual[], FLAC__uint32 abs_residual[], FLAC__uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned residual_samples, unsigned predictor_order, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, unsigned *best_partition_order, unsigned best_parameters[], unsigned best_raw_bits[]); #if (defined FLAC__PRECOMPUTE_PARTITION_SUMS) || (defined FLAC__SEARCH_FOR_ESCAPES) -static unsigned stream_encoder_precompute_partition_info_(const int32 residual[], uint32 abs_residual[], uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order); +static unsigned stream_encoder_precompute_partition_info_(const FLAC__int32 residual[], FLAC__uint32 abs_residual[], FLAC__uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order); #endif -static bool stream_encoder_set_partitioned_rice_(const uint32 abs_residual[], const uint32 abs_residual_partition_sums[], const unsigned raw_bits_per_partition[], const unsigned residual_samples, const unsigned predictor_order, const unsigned suggested_rice_parameter, const unsigned rice_parameter_search_dist, const unsigned partition_order, unsigned parameters[], unsigned raw_bits[], unsigned *bits); -static unsigned stream_encoder_get_wasted_bits_(int32 signal[], unsigned samples); +static FLAC__bool stream_encoder_set_partitioned_rice_(const FLAC__uint32 abs_residual[], const FLAC__uint32 abs_residual_partition_sums[], const unsigned raw_bits_per_partition[], const unsigned residual_samples, const unsigned predictor_order, const unsigned suggested_rice_parameter, const unsigned rice_parameter_search_dist, const unsigned partition_order, unsigned parameters[], unsigned raw_bits[], unsigned *bits); +static unsigned stream_encoder_get_wasted_bits_(FLAC__int32 signal[], unsigned samples); /*********************************************************************** * @@ -73,14 +73,14 @@ static unsigned stream_encoder_get_wasted_bits_(int32 signal[], unsigned samples typedef struct FLAC__StreamEncoderPrivate { unsigned input_capacity; /* current size (in samples) of the signal and residual buffers */ - int32 *integer_signal[FLAC__MAX_CHANNELS]; /* the integer version of the input signal */ - int32 *integer_signal_mid_side[2]; /* the integer version of the mid-side input signal (stereo only) */ - real *real_signal[FLAC__MAX_CHANNELS]; /* the floating-point version of the input signal */ - real *real_signal_mid_side[2]; /* the floating-point version of the mid-side input signal (stereo only) */ + FLAC__int32 *integer_signal[FLAC__MAX_CHANNELS]; /* the integer version of the input signal */ + FLAC__int32 *integer_signal_mid_side[2]; /* the integer version of the mid-side input signal (stereo only) */ + FLAC__real *real_signal[FLAC__MAX_CHANNELS]; /* the floating-point version of the input signal */ + FLAC__real *real_signal_mid_side[2]; /* the floating-point version of the mid-side input signal (stereo only) */ unsigned subframe_bps[FLAC__MAX_CHANNELS]; /* the effective bits per sample of the input signal (stream bps - wasted bits) */ unsigned subframe_bps_mid_side[2]; /* the effective bits per sample of the mid-side input signal (stream bps - wasted bits + 0/1) */ - int32 *residual_workspace[FLAC__MAX_CHANNELS][2]; /* each channel has a candidate and best workspace where the subframe residual signals will be stored */ - int32 *residual_workspace_mid_side[2][2]; + FLAC__int32 *residual_workspace[FLAC__MAX_CHANNELS][2]; /* each channel has a candidate and best workspace where the subframe residual signals will be stored */ + FLAC__int32 *residual_workspace_mid_side[2][2]; FLAC__Subframe subframe_workspace[FLAC__MAX_CHANNELS][2]; FLAC__Subframe subframe_workspace_mid_side[2][2]; FLAC__Subframe *subframe_workspace_ptr[FLAC__MAX_CHANNELS][2]; @@ -89,8 +89,8 @@ typedef struct FLAC__StreamEncoderPrivate { unsigned best_subframe_mid_side[2]; unsigned best_subframe_bits[FLAC__MAX_CHANNELS]; /* size in bits of the best subframe for each channel */ unsigned best_subframe_bits_mid_side[2]; - uint32 *abs_residual; /* workspace where abs(candidate residual) is stored */ - uint32 *abs_residual_partition_sums; /* workspace where the sum of abs(candidate residual) for each partition is stored */ + FLAC__uint32 *abs_residual; /* workspace where abs(candidate residual) is stored */ + FLAC__uint32 *abs_residual_partition_sums; /* workspace where the sum of abs(candidate residual) for each partition is stored */ unsigned *raw_bits_per_partition; /* workspace where the sum of silog2(candidate residual) for each partition is stored */ FLAC__BitBuffer frame; /* the current frame being worked on */ double loose_mid_side_stereo_frames_exact; /* exact number of frames the encoder will use before trying both independent and mid/side frames again */ @@ -102,23 +102,23 @@ typedef struct FLAC__StreamEncoderPrivate { unsigned current_frame_number; struct MD5Context md5context; FLAC__CPUInfo cpuinfo; - unsigned (*local_fixed_compute_best_predictor)(const int32 data[], unsigned data_len, real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); - void (*local_lpc_compute_autocorrelation)(const real data[], unsigned data_len, unsigned lag, real autoc[]); - void (*local_lpc_compute_residual_from_qlp_coefficients)(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]); - void (*local_lpc_compute_residual_from_qlp_coefficients_16bit)(const int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[]); - bool use_slow; /* use slow 64-bit versions of some functions */ - FLAC__StreamEncoderWriteStatus (*write_callback)(const FLAC__StreamEncoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data); + unsigned (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); + void (*local_lpc_compute_autocorrelation)(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); + void (*local_lpc_compute_residual_from_qlp_coefficients)(const FLAC__int32 data[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); + void (*local_lpc_compute_residual_from_qlp_coefficients_16bit)(const FLAC__int32 data[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); + FLAC__bool use_slow; /* use slow 64-bit versions of some functions */ + FLAC__StreamEncoderWriteStatus (*write_callback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data); void (*metadata_callback)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data); void *client_data; /* unaligned (original) pointers to allocated data */ - int32 *integer_signal_unaligned[FLAC__MAX_CHANNELS]; - int32 *integer_signal_mid_side_unaligned[2]; - real *real_signal_unaligned[FLAC__MAX_CHANNELS]; - real *real_signal_mid_side_unaligned[2]; - int32 *residual_workspace_unaligned[FLAC__MAX_CHANNELS][2]; - int32 *residual_workspace_mid_side_unaligned[2][2]; - uint32 *abs_residual_unaligned; - uint32 *abs_residual_partition_sums_unaligned; + FLAC__int32 *integer_signal_unaligned[FLAC__MAX_CHANNELS]; + FLAC__int32 *integer_signal_mid_side_unaligned[2]; + FLAC__real *real_signal_unaligned[FLAC__MAX_CHANNELS]; + FLAC__real *real_signal_mid_side_unaligned[2]; + FLAC__int32 *residual_workspace_unaligned[FLAC__MAX_CHANNELS][2]; + FLAC__int32 *residual_workspace_mid_side_unaligned[2][2]; + FLAC__uint32 *abs_residual_unaligned; + FLAC__uint32 *abs_residual_partition_sums_unaligned; unsigned *raw_bits_per_partition_unaligned; } FLAC__StreamEncoderPrivate; @@ -289,10 +289,10 @@ FLAC__StreamEncoderState FLAC__stream_encoder_init(FLAC__StreamEncoder *encoder) encoder->protected->qlp_coeff_precision = 13; } else { - encoder->protected->qlp_coeff_precision = min(13, 8*sizeof(int32) - encoder->protected->bits_per_sample - 1); + encoder->protected->qlp_coeff_precision = min(13, 8*sizeof(FLAC__int32) - encoder->protected->bits_per_sample - 1); } } - else if(encoder->protected->qlp_coeff_precision < FLAC__MIN_QLP_COEFF_PRECISION || encoder->protected->qlp_coeff_precision + encoder->protected->bits_per_sample >= 8*sizeof(uint32) || encoder->protected->qlp_coeff_precision >= (1u<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<protected->state = FLAC__STREAM_ENCODER_INVALID_QLP_COEFF_PRECISION; if(encoder->protected->streamable_subset) { @@ -522,7 +522,7 @@ void FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder) encoder->protected->state = FLAC__STREAM_ENCODER_UNINITIALIZED; } -bool FLAC__stream_encoder_set_streamable_subset(const FLAC__StreamEncoder *encoder, bool value) +FLAC__bool FLAC__stream_encoder_set_streamable_subset(const FLAC__StreamEncoder *encoder, FLAC__bool value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -530,7 +530,7 @@ bool FLAC__stream_encoder_set_streamable_subset(const FLAC__StreamEncoder *encod return true; } -bool FLAC__stream_encoder_set_do_mid_side_stereo(const FLAC__StreamEncoder *encoder, bool value) +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) return false; @@ -538,7 +538,7 @@ bool FLAC__stream_encoder_set_do_mid_side_stereo(const FLAC__StreamEncoder *enco return true; } -bool FLAC__stream_encoder_set_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder, bool value) +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) return false; @@ -546,7 +546,7 @@ bool FLAC__stream_encoder_set_loose_mid_side_stereo(const FLAC__StreamEncoder *e return true; } -bool FLAC__stream_encoder_set_channels(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_channels(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -554,7 +554,7 @@ bool FLAC__stream_encoder_set_channels(const FLAC__StreamEncoder *encoder, unsig return true; } -bool FLAC__stream_encoder_set_bits_per_sample(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_bits_per_sample(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -562,7 +562,7 @@ bool FLAC__stream_encoder_set_bits_per_sample(const FLAC__StreamEncoder *encoder return true; } -bool FLAC__stream_encoder_set_sample_rate(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_sample_rate(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -570,7 +570,7 @@ bool FLAC__stream_encoder_set_sample_rate(const FLAC__StreamEncoder *encoder, un return true; } -bool FLAC__stream_encoder_set_blocksize(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_blocksize(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -578,7 +578,7 @@ bool FLAC__stream_encoder_set_blocksize(const FLAC__StreamEncoder *encoder, unsi return true; } -bool FLAC__stream_encoder_set_max_lpc_order(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_max_lpc_order(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -586,7 +586,7 @@ bool FLAC__stream_encoder_set_max_lpc_order(const FLAC__StreamEncoder *encoder, return true; } -bool FLAC__stream_encoder_set_qlp_coeff_precision(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -594,7 +594,7 @@ bool FLAC__stream_encoder_set_qlp_coeff_precision(const FLAC__StreamEncoder *enc return true; } -bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder, bool value) +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) return false; @@ -602,7 +602,7 @@ bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(const FLAC__StreamEncoder return true; } -bool FLAC__stream_encoder_set_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder, bool value) +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) return false; @@ -610,7 +610,7 @@ bool FLAC__stream_encoder_set_do_exhaustive_model_search(const FLAC__StreamEncod return true; } -bool FLAC__stream_encoder_set_min_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -618,7 +618,7 @@ bool FLAC__stream_encoder_set_min_residual_partition_order(const FLAC__StreamEnc return true; } -bool FLAC__stream_encoder_set_max_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -626,7 +626,7 @@ bool FLAC__stream_encoder_set_max_residual_partition_order(const FLAC__StreamEnc return true; } -bool FLAC__stream_encoder_set_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -634,7 +634,7 @@ bool FLAC__stream_encoder_set_rice_parameter_search_dist(const FLAC__StreamEncod return true; } -bool FLAC__stream_encoder_set_total_samples_estimate(const FLAC__StreamEncoder *encoder, uint64 value) +FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(const FLAC__StreamEncoder *encoder, FLAC__uint64 value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -642,7 +642,7 @@ bool FLAC__stream_encoder_set_total_samples_estimate(const FLAC__StreamEncoder * return true; } -bool FLAC__stream_encoder_set_seek_table(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData_SeekTable *value) +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) return false; @@ -650,7 +650,7 @@ bool FLAC__stream_encoder_set_seek_table(const FLAC__StreamEncoder *encoder, con return true; } -bool FLAC__stream_encoder_set_padding(const FLAC__StreamEncoder *encoder, unsigned value) +FLAC__bool FLAC__stream_encoder_set_padding(const FLAC__StreamEncoder *encoder, unsigned value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -658,7 +658,7 @@ bool FLAC__stream_encoder_set_padding(const FLAC__StreamEncoder *encoder, unsign return true; } -bool FLAC__stream_encoder_set_last_metadata_is_last(const FLAC__StreamEncoder *encoder, bool value) +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) return false; @@ -666,7 +666,7 @@ bool FLAC__stream_encoder_set_last_metadata_is_last(const FLAC__StreamEncoder *e return true; } -bool FLAC__stream_encoder_set_write_callback(const FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteStatus (*value)(const FLAC__StreamEncoder *encoder, const byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)) +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) return false; @@ -674,7 +674,7 @@ bool FLAC__stream_encoder_set_write_callback(const FLAC__StreamEncoder *encoder, return true; } -bool FLAC__stream_encoder_set_metadata_callback(const FLAC__StreamEncoder *encoder, void (*value)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetaData *metadata, void *client_data)) +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) return false; @@ -682,7 +682,7 @@ bool FLAC__stream_encoder_set_metadata_callback(const FLAC__StreamEncoder *encod return true; } -bool FLAC__stream_encoder_set_client_data(const FLAC__StreamEncoder *encoder, void *value) +FLAC__bool FLAC__stream_encoder_set_client_data(const FLAC__StreamEncoder *encoder, void *value) { if(encoder->protected->state != FLAC__STREAM_ENCODER_UNINITIALIZED) return false; @@ -695,17 +695,17 @@ FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncode return encoder->protected->state; } -bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder) +FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder) { return encoder->protected->streamable_subset; } -bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder) +FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder) { return encoder->protected->do_mid_side_stereo; } -bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder) +FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder) { return encoder->protected->loose_mid_side_stereo; } @@ -740,12 +740,12 @@ unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder return encoder->protected->qlp_coeff_precision; } -bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder) +FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder) { return encoder->protected->do_qlp_coeff_prec_search; } -bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder) +FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder) { return encoder->protected->do_exhaustive_model_search; } @@ -765,10 +765,10 @@ unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamE return encoder->protected->rice_parameter_search_dist; } -bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const int32 *buf[], unsigned samples) +FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 *buf[], unsigned samples) { unsigned i, j, channel; - int32 x, mid, side; + FLAC__int32 x, mid, side; const unsigned channels = encoder->protected->channels, blocksize = encoder->protected->blocksize; FLAC__ASSERT(encoder != 0); @@ -780,17 +780,17 @@ bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const int32 *buf 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] = (real)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] = (real)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] = (real)side; - encoder->private->real_signal_mid_side[0][i] = (real)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) { @@ -805,7 +805,7 @@ bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const int32 *buf for(channel = 0; channel < channels; channel++) { x = buf[channel][j]; encoder->private->integer_signal[channel][i] = x; - encoder->private->real_signal[channel][i] = (real)x; + encoder->private->real_signal[channel][i] = (FLAC__real)x; } encoder->private->current_sample_number++; } @@ -820,10 +820,10 @@ bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const int32 *buf } /* 'samples' is channel-wide samples, e.g. for 1 second at 44100Hz, 'samples' = 44100 regardless of the number of channels */ -bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const int32 buf[], unsigned samples) +FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buf[], unsigned samples) { unsigned i, j, k, channel; - int32 x, mid, side; + FLAC__int32 x, mid, side; const unsigned channels = encoder->protected->channels, blocksize = encoder->protected->blocksize; FLAC__ASSERT(encoder != 0); @@ -835,17 +835,17 @@ bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, cons 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] = (real)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] = (real)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] = (real)side; - encoder->private->real_signal_mid_side[0][i] = (real)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) { @@ -860,7 +860,7 @@ bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, cons for(channel = 0; channel < channels; channel++) { x = buf[k++]; encoder->private->integer_signal[channel][i] = x; - encoder->private->real_signal[channel][i] = (real)x; + encoder->private->real_signal[channel][i] = (FLAC__real)x; } encoder->private->current_sample_number++; } @@ -874,9 +874,9 @@ bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, cons return true; } -bool stream_encoder_resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_size) +FLAC__bool stream_encoder_resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_size) { - bool ok; + FLAC__bool ok; unsigned i, channel; FLAC__ASSERT(new_size > 0); @@ -928,7 +928,7 @@ bool stream_encoder_resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_s * ***********************************************************************/ -bool stream_encoder_process_frame_(FLAC__StreamEncoder *encoder, bool is_last_frame) +FLAC__bool stream_encoder_process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_last_frame) { FLAC__ASSERT(encoder->protected->state == FLAC__STREAM_ENCODER_OK); @@ -977,18 +977,18 @@ bool stream_encoder_process_frame_(FLAC__StreamEncoder *encoder, bool is_last_fr */ encoder->private->current_sample_number = 0; encoder->private->current_frame_number++; - encoder->private->metadata.data.stream_info.total_samples += (uint64)encoder->protected->blocksize; + 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; } -bool stream_encoder_process_subframes_(FLAC__StreamEncoder *encoder, bool is_last_frame) +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; - bool do_independent, do_mid_side; + FLAC__bool do_independent, do_mid_side; /* * Calculate the min,max Rice partition orders @@ -1203,13 +1203,13 @@ bool stream_encoder_process_subframes_(FLAC__StreamEncoder *encoder, bool is_las return true; } -bool stream_encoder_process_subframe_(FLAC__StreamEncoder *encoder, unsigned min_partition_order, unsigned max_partition_order, bool verbatim_only, const FLAC__FrameHeader *frame_header, unsigned subframe_bps, const int32 integer_signal[], const real real_signal[], FLAC__Subframe *subframe[2], int32 *residual[2], unsigned *best_subframe, unsigned *best_bits) +FLAC__bool stream_encoder_process_subframe_(FLAC__StreamEncoder *encoder, unsigned min_partition_order, unsigned max_partition_order, FLAC__bool verbatim_only, const FLAC__FrameHeader *frame_header, unsigned subframe_bps, const FLAC__int32 integer_signal[], const FLAC__real real_signal[], FLAC__Subframe *subframe[2], FLAC__int32 *residual[2], unsigned *best_subframe, unsigned *best_bits) { - real fixed_residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]; - real lpc_residual_bits_per_sample; - 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 */ - real lp_coeff[FLAC__MAX_LPC_ORDER][FLAC__MAX_LPC_ORDER]; - real lpc_error[FLAC__MAX_LPC_ORDER]; + 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 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; unsigned min_fixed_order, max_fixed_order, guess_fixed_order, fixed_order; unsigned min_qlp_coeff_precision, max_qlp_coeff_precision, qlp_coeff_precision; @@ -1254,7 +1254,7 @@ bool stream_encoder_process_subframe_(FLAC__StreamEncoder *encoder, unsigned min min_fixed_order = max_fixed_order = guess_fixed_order; } for(fixed_order = min_fixed_order; fixed_order <= max_fixed_order; fixed_order++) { - if(fixed_residual_bits_per_sample[fixed_order] >= (real)subframe_bps) + if(fixed_residual_bits_per_sample[fixed_order] >= (FLAC__real)subframe_bps) continue; /* don't even try */ rice_parameter = (fixed_residual_bits_per_sample[fixed_order] > 0.0)? (unsigned)(fixed_residual_bits_per_sample[fixed_order]+0.5) : 0; /* 0.5 is for rounding */ #ifndef FLAC__SYMMETRIC_RICE @@ -1296,7 +1296,7 @@ bool stream_encoder_process_subframe_(FLAC__StreamEncoder *encoder, unsigned min } 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); - if(lpc_residual_bits_per_sample >= (real)subframe_bps) + if(lpc_residual_bits_per_sample >= (FLAC__real)subframe_bps) continue; /* don't even try */ rice_parameter = (lpc_residual_bits_per_sample > 0.0)? (unsigned)(lpc_residual_bits_per_sample+0.5) : 0; /* 0.5 is for rounding */ #ifndef FLAC__SYMMETRIC_RICE @@ -1326,7 +1326,7 @@ bool stream_encoder_process_subframe_(FLAC__StreamEncoder *encoder, unsigned min return true; } -bool stream_encoder_add_subframe_(FLAC__StreamEncoder *encoder, const FLAC__FrameHeader *frame_header, unsigned subframe_bps, const FLAC__Subframe *subframe, FLAC__BitBuffer *frame) +FLAC__bool stream_encoder_add_subframe_(FLAC__StreamEncoder *encoder, const FLAC__FrameHeader *frame_header, unsigned subframe_bps, const FLAC__Subframe *subframe, FLAC__BitBuffer *frame) { switch(subframe->type) { case FLAC__SUBFRAME_TYPE_CONSTANT: @@ -1360,7 +1360,7 @@ bool stream_encoder_add_subframe_(FLAC__StreamEncoder *encoder, const FLAC__Fram return true; } -unsigned stream_encoder_evaluate_constant_subframe_(const int32 signal, unsigned subframe_bps, FLAC__Subframe *subframe) +unsigned stream_encoder_evaluate_constant_subframe_(const FLAC__int32 signal, unsigned subframe_bps, FLAC__Subframe *subframe) { subframe->type = FLAC__SUBFRAME_TYPE_CONSTANT; subframe->data.constant.value = signal; @@ -1368,7 +1368,7 @@ unsigned stream_encoder_evaluate_constant_subframe_(const int32 signal, unsigned return FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe_bps; } -unsigned stream_encoder_evaluate_fixed_subframe_(const int32 signal[], int32 residual[], uint32 abs_residual[], uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned blocksize, unsigned subframe_bps, unsigned order, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, FLAC__Subframe *subframe) +unsigned stream_encoder_evaluate_fixed_subframe_(const FLAC__int32 signal[], FLAC__int32 residual[], FLAC__uint32 abs_residual[], FLAC__uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned blocksize, unsigned subframe_bps, unsigned order, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, FLAC__Subframe *subframe) { unsigned i, residual_bits; const unsigned residual_samples = blocksize - order; @@ -1389,9 +1389,9 @@ unsigned stream_encoder_evaluate_fixed_subframe_(const int32 signal[], int32 res return FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + (order * subframe_bps) + residual_bits; } -unsigned stream_encoder_evaluate_lpc_subframe_(FLAC__StreamEncoder *encoder, const int32 signal[], int32 residual[], uint32 abs_residual[], uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], const real lp_coeff[], unsigned blocksize, unsigned subframe_bps, unsigned order, unsigned qlp_coeff_precision, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, FLAC__Subframe *subframe) +unsigned stream_encoder_evaluate_lpc_subframe_(FLAC__StreamEncoder *encoder, const FLAC__int32 signal[], FLAC__int32 residual[], FLAC__uint32 abs_residual[], FLAC__uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], const FLAC__real lp_coeff[], unsigned blocksize, unsigned subframe_bps, unsigned order, unsigned qlp_coeff_precision, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, FLAC__Subframe *subframe) { - int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; + FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; unsigned i, residual_bits; int quantization, ret; const unsigned residual_samples = blocksize - order; @@ -1415,14 +1415,14 @@ unsigned stream_encoder_evaluate_lpc_subframe_(FLAC__StreamEncoder *encoder, con subframe->data.lpc.order = order; subframe->data.lpc.qlp_coeff_precision = qlp_coeff_precision; subframe->data.lpc.quantization_level = quantization; - memcpy(subframe->data.lpc.qlp_coeff, qlp_coeff, sizeof(int32)*FLAC__MAX_LPC_ORDER); + memcpy(subframe->data.lpc.qlp_coeff, qlp_coeff, sizeof(FLAC__int32)*FLAC__MAX_LPC_ORDER); for(i = 0; i < order; i++) subframe->data.lpc.warmup[i] = signal[i]; return FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN + FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN + (order * (qlp_coeff_precision + subframe_bps)) + residual_bits; } -unsigned stream_encoder_evaluate_verbatim_subframe_(const int32 signal[], unsigned blocksize, unsigned subframe_bps, FLAC__Subframe *subframe) +unsigned stream_encoder_evaluate_verbatim_subframe_(const FLAC__int32 signal[], unsigned blocksize, unsigned subframe_bps, FLAC__Subframe *subframe) { subframe->type = FLAC__SUBFRAME_TYPE_VERBATIM; @@ -1431,9 +1431,9 @@ unsigned stream_encoder_evaluate_verbatim_subframe_(const int32 signal[], unsign return FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + (blocksize * subframe_bps); } -unsigned stream_encoder_find_best_partition_order_(const int32 residual[], uint32 abs_residual[], uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned residual_samples, unsigned predictor_order, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, unsigned *best_partition_order, unsigned best_parameters[], unsigned best_raw_bits[]) +unsigned stream_encoder_find_best_partition_order_(const FLAC__int32 residual[], FLAC__uint32 abs_residual[], FLAC__uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned residual_samples, unsigned predictor_order, unsigned rice_parameter, unsigned min_partition_order, unsigned max_partition_order, unsigned rice_parameter_search_dist, unsigned *best_partition_order, unsigned best_parameters[], unsigned best_raw_bits[]) { - int32 r; + FLAC__int32 r; #if (defined FLAC__PRECOMPUTE_PARTITION_SUMS) || (defined FLAC__SEARCH_FOR_ESCAPES) unsigned sum; int partition_order; @@ -1447,7 +1447,7 @@ unsigned stream_encoder_find_best_partition_order_(const int32 residual[], uint3 /* compute abs(residual) for use later */ for(residual_sample = 0; residual_sample < residual_samples; residual_sample++) { r = residual[residual_sample]; - abs_residual[residual_sample] = (uint32)(r<0? -r : r); + abs_residual[residual_sample] = (FLAC__uint32)(r<0? -r : r); } #if (defined FLAC__PRECOMPUTE_PARTITION_SUMS) || (defined FLAC__SEARCH_FOR_ESCAPES) @@ -1485,7 +1485,7 @@ unsigned stream_encoder_find_best_partition_order_(const int32 residual[], uint3 } #if (defined FLAC__PRECOMPUTE_PARTITION_SUMS) || (defined FLAC__SEARCH_FOR_ESCAPES) -unsigned stream_encoder_precompute_partition_info_(const int32 residual[], uint32 abs_residual[], uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order) +unsigned stream_encoder_precompute_partition_info_(const FLAC__int32 residual[], FLAC__uint32 abs_residual[], FLAC__uint32 abs_residual_partition_sums[], unsigned raw_bits_per_partition[], unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order) { int partition_order; unsigned from_partition, to_partition = 0; @@ -1494,13 +1494,13 @@ unsigned stream_encoder_precompute_partition_info_(const int32 residual[], uint3 /* first do max_partition_order */ for(partition_order = (int)max_partition_order; partition_order >= 0; partition_order--) { #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS - uint32 abs_residual_partition_sum; + FLAC__uint32 abs_residual_partition_sum; #endif #ifdef FLAC__SEARCH_FOR_ESCAPES - uint32 abs_residual_partition_max; + FLAC__uint32 abs_residual_partition_max; unsigned abs_residual_partition_max_index = 0; /* initialized to silence superfluous compiler warning */ #endif - uint32 abs_r; + FLAC__uint32 abs_r; unsigned partition, partition_sample, partition_samples, residual_sample; const unsigned partitions = 1u << partition_order; const unsigned default_partition_samples = blocksize >> partition_order; @@ -1551,7 +1551,7 @@ unsigned stream_encoder_precompute_partition_info_(const int32 residual[], uint3 /* now merge for lower orders */ for(from_partition = 0, --partition_order; partition_order >= (int)min_partition_order; partition_order--) { #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS - uint32 s; + FLAC__uint32 s; #endif #ifdef FLAC__SEARCH_FOR_ESCAPES unsigned m; @@ -1586,7 +1586,7 @@ unsigned stream_encoder_precompute_partition_info_(const int32 residual[], uint3 #endif #define VARIABLE_RICE_BITS(value, parameter) ((value) >> (parameter)) -bool stream_encoder_set_partitioned_rice_(const uint32 abs_residual[], const uint32 abs_residual_partition_sums[], const unsigned raw_bits_per_partition[], const unsigned residual_samples, const unsigned predictor_order, const unsigned suggested_rice_parameter, const unsigned rice_parameter_search_dist, const unsigned partition_order, unsigned parameters[], unsigned raw_bits[], unsigned *bits) +FLAC__bool stream_encoder_set_partitioned_rice_(const FLAC__uint32 abs_residual[], const FLAC__uint32 abs_residual_partition_sums[], const unsigned raw_bits_per_partition[], const unsigned residual_samples, const unsigned predictor_order, const unsigned suggested_rice_parameter, const unsigned rice_parameter_search_dist, const unsigned partition_order, unsigned parameters[], unsigned raw_bits[], unsigned *bits) { unsigned rice_parameter, partition_bits; #ifndef NO_RICE_SEARCH @@ -1765,10 +1765,10 @@ bool stream_encoder_set_partitioned_rice_(const uint32 abs_residual[], const uin return true; } -unsigned stream_encoder_get_wasted_bits_(int32 signal[], unsigned samples) +unsigned stream_encoder_get_wasted_bits_(FLAC__int32 signal[], unsigned samples) { unsigned i, shift; - int32 x = 0; + FLAC__int32 x = 0; for(i = 0; i < samples && !(x&1); i++) x |= signal[i]; diff --git a/src/libFLAC/stream_encoder_framing.c b/src/libFLAC/stream_encoder_framing.c index e463006a..036ffd2c 100644 --- a/src/libFLAC/stream_encoder_framing.c +++ b/src/libFLAC/stream_encoder_framing.c @@ -27,10 +27,10 @@ #endif #define max(x,y) ((x)>(y)?(x):(y)) -static bool subframe_add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__EntropyCodingMethod *method); -static bool subframe_add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order); +static FLAC__bool subframe_add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__EntropyCodingMethod *method); +static FLAC__bool subframe_add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order); -bool FLAC__add_metadata_block(const FLAC__StreamMetaData *metadata, FLAC__BitBuffer *bb) +FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetaData *metadata, FLAC__BitBuffer *bb) { unsigned i; @@ -112,10 +112,10 @@ bool FLAC__add_metadata_block(const FLAC__StreamMetaData *metadata, FLAC__BitBuf return true; } -bool FLAC__frame_add_header(const FLAC__FrameHeader *header, bool streamable_subset, bool is_last_block, FLAC__BitBuffer *bb) +FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__bool streamable_subset, FLAC__bool is_last_block, FLAC__BitBuffer *bb) { unsigned u, crc8_start, blocksize_hint, sample_rate_hint; - byte crc8; + FLAC__byte crc8; FLAC__ASSERT(bb->bits == 0); /* assert that we're byte-aligned before writing */ @@ -254,9 +254,9 @@ bool FLAC__frame_add_header(const FLAC__FrameHeader *header, bool streamable_sub return true; } -bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb) +FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb) { - bool ok; + FLAC__bool ok; ok = FLAC__bitbuffer_write_raw_uint32(bb, FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN) && @@ -267,7 +267,7 @@ bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsign return ok; } -bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb) +FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb) { unsigned i; @@ -295,7 +295,7 @@ bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned res return true; } -bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb) +FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb) { unsigned i; @@ -331,10 +331,10 @@ bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residua return true; } -bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb) +FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitBuffer *bb) { unsigned i; - const int32 *signal = subframe->data; + const FLAC__int32 *signal = subframe->data; if(!FLAC__bitbuffer_write_raw_uint32(bb, FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN)) return false; @@ -349,7 +349,7 @@ bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsign return true; } -bool subframe_add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__EntropyCodingMethod *method) +FLAC__bool subframe_add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__EntropyCodingMethod *method) { if(!FLAC__bitbuffer_write_raw_uint32(bb, method->type, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN)) return false; @@ -364,7 +364,7 @@ bool subframe_add_entropy_coding_method_(FLAC__BitBuffer *bb, const FLAC__Entrop return true; } -bool subframe_add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order) +FLAC__bool subframe_add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order) { if(partition_order == 0) { unsigned i; diff --git a/src/metaflac/main.c b/src/metaflac/main.c index adcfc8cb..ffedd3c2 100644 --- a/src/metaflac/main.c +++ b/src/metaflac/main.c @@ -39,15 +39,15 @@ static const char *metadata_type_string_[] = { /* DUPLICATE:FLAC__MetaDataTypeSt static const unsigned SEEKPOINT_LEN_ = 18; /* DUPLICATE:FLAC__STREAM_METADATA_SEEKPOINT_LEN */ static int usage(const char *message, ...); -static bool list(FILE *f, bool verbose); -static uint32 unpack_uint32(byte *b, unsigned bytes); -static uint64 unpack_uint64(byte *b, unsigned bytes); -static void hexdump(const byte *buf, unsigned bytes); +static FLAC__bool list(FILE *f, FLAC__bool verbose); +static FLAC__uint32 unpack_uint32(FLAC__byte *b, unsigned bytes); +static FLAC__uint64 unpack_uint64(FLAC__byte *b, unsigned bytes); +static void hexdump(const FLAC__byte *buf, unsigned bytes); int main(int argc, char *argv[]) { int i; - bool verbose = false, list_mode = true; + FLAC__bool verbose = false, list_mode = true; if(argc <= 1) return usage(0); @@ -126,10 +126,10 @@ int usage(const char *message, ...) return 1; } -bool list(FILE *f, bool verbose) +FLAC__bool list(FILE *f, FLAC__bool verbose) { - byte buf[65536]; - byte *b = buf; + FLAC__byte buf[65536]; + FLAC__byte *b = buf; FLAC__StreamMetaData metadata; unsigned blocknum = 0, byte_offset = 0, i; @@ -178,7 +178,7 @@ bool list(FILE *f, bool verbose) metadata.data.stream_info.sample_rate = (unpack_uint32(b, 2) << 4) | ((unsigned)(b[2] & 0xf0) >> 4); metadata.data.stream_info.channels = (unsigned)((b[2] & 0x0e) >> 1) + 1; metadata.data.stream_info.bits_per_sample = ((((unsigned)(b[2] & 0x01)) << 1) | (((unsigned)(b[3] & 0xf0)) >> 4)) + 1; - metadata.data.stream_info.total_samples = (((uint64)(b[3] & 0x0f)) << 32) | unpack_uint64(b+4, 4); + metadata.data.stream_info.total_samples = (((FLAC__uint64)(b[3] & 0x0f)) << 32) | unpack_uint64(b+4, 4); memcpy(metadata.data.stream_info.md5sum, b+8, 16); break; case FLAC__METADATA_TYPE_PADDING: @@ -251,32 +251,32 @@ bool list(FILE *f, bool verbose) return true; } -uint32 unpack_uint32(byte *b, unsigned bytes) +FLAC__uint32 unpack_uint32(FLAC__byte *b, unsigned bytes) { - uint32 ret = 0; + FLAC__uint32 ret = 0; unsigned i; for(i = 0; i < bytes; i++) - ret = (ret << 8) | (uint32)(*b++); + ret = (ret << 8) | (FLAC__uint32)(*b++); return ret; } -uint64 unpack_uint64(byte *b, unsigned bytes) +FLAC__uint64 unpack_uint64(FLAC__byte *b, unsigned bytes) { - uint64 ret = 0; + FLAC__uint64 ret = 0; unsigned i; for(i = 0; i < bytes; i++) - ret = (ret << 8) | (uint64)(*b++); + ret = (ret << 8) | (FLAC__uint64)(*b++); return ret; } -void hexdump(const byte *buf, unsigned bytes) +void hexdump(const FLAC__byte *buf, unsigned bytes) { unsigned i, left = bytes; - const byte *b = buf; + const FLAC__byte *b = buf; for(i = 0; i < bytes; i += 16) { printf("%08X: " diff --git a/src/plugin_winamp2/in_flac.c b/src/plugin_winamp2/in_flac.c index e4e8d92f..67f9ec62 100644 --- a/src/plugin_winamp2/in_flac.c +++ b/src/plugin_winamp2/in_flac.c @@ -33,7 +33,7 @@ BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lp #define WM_WA_MPEG_EOF WM_USER+2 typedef struct { - bool abort_flag; + FLAC__bool abort_flag; unsigned total_samples; unsigned bits_per_sample; unsigned channels; @@ -41,8 +41,8 @@ typedef struct { unsigned length_in_ms; } stream_info_struct; -static bool stream_init(const char *infilename); -static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data); +static FLAC__bool stream_init(const char *infilename); +static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data); static void metadata_callback(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data); static void error_callback(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); @@ -51,7 +51,7 @@ char lastfn[MAX_PATH]; /* currently playing file (used for getting info on the c int decode_pos_ms; /* current decoding position, in milliseconds */ int paused; /* are we paused? */ int seek_needed; /* if != -1, it is the point that the decode thread should seek to, in ms. */ -int16 reservoir[FLAC__MAX_BLOCK_SIZE * 2 * 2]; /* *2 for max channels, another *2 for overflow */ +FLAC__int16 reservoir[FLAC__MAX_BLOCK_SIZE * 2 * 2]; /* *2 for max channels, another *2 for overflow */ char sample_buffer[576 * 2 * (16/8) * 2]; /* 2 for max channels, (16/8) for max bytes per sample, and 2 for who knows what */ unsigned samples_in_reservoir; static stream_info_struct stream_info; @@ -251,7 +251,7 @@ DWORD WINAPI __stdcall DecodeThread(void *b) if (seek_needed != -1) { const double distance = (double)seek_needed / (double)getlength(); unsigned target_sample = (unsigned)(distance * (double)stream_info.total_samples); - if(FLAC__file_decoder_seek_absolute(decoder, (uint64)target_sample)) { + if(FLAC__file_decoder_seek_absolute(decoder, (FLAC__uint64)target_sample)) { decode_pos_ms = (int)(distance * (double)getlength()); seek_needed=-1; done=0; @@ -358,7 +358,7 @@ __declspec( dllexport ) In_Module * winampGetInModule2() /*********************************************************************** * local routines **********************************************************************/ -bool stream_init(const char *infilename) +FLAC__bool stream_init(const char *infilename) { FLAC__file_decoder_set_md5_checking(decoder, false); FLAC__file_decoder_set_filename(decoder, infilename); @@ -379,7 +379,7 @@ bool stream_init(const char *infilename) return true; } -FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data) +FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data) { stream_info_struct *stream_info = (stream_info_struct *)client_data; const unsigned bps = stream_info->bits_per_sample, channels = stream_info->channels, wide_samples = frame->header.blocksize; @@ -392,7 +392,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder, for(sample = samples_in_reservoir*channels, wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) - reservoir[sample] = (int16)buffer[channel][wide_sample]; + reservoir[sample] = (FLAC__int16)buffer[channel][wide_sample]; samples_in_reservoir += wide_samples; diff --git a/src/plugin_winamp3/in_flac.cpp b/src/plugin_winamp3/in_flac.cpp index 80ced211..c5eca0bf 100644 --- a/src/plugin_winamp3/in_flac.cpp +++ b/src/plugin_winamp3/in_flac.cpp @@ -22,7 +22,7 @@ #include "FLAC/all.h" typedef struct { - byte raw[128]; + FLAC__byte raw[128]; char title[31]; char artist[31]; char album[31]; @@ -34,9 +34,9 @@ typedef struct { } id3v1_struct; typedef struct { - bool abort_flag; - bool is_playing; - bool eof; + FLAC__bool abort_flag; + FLAC__bool is_playing; + FLAC__bool eof; unsigned total_samples; unsigned bits_per_sample; unsigned channels; @@ -44,9 +44,9 @@ typedef struct { unsigned length_in_msec; } file_info_struct; -static bool get_id3v1_tag_(const char *filename, id3v1_struct *tag); -static bool decoder_init_(const char *filename); -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data); +static FLAC__bool get_id3v1_tag_(const char *filename, id3v1_struct *tag); +static FLAC__bool decoder_init_(const char *filename); +static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data); static void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data); static void error_callback_(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); @@ -131,17 +131,17 @@ class FLAC_Source : public WInputSource private: id3v1_struct tag_; FLAC__FileDecoder *decoder_; - int16 reservoir_[FLAC__MAX_BLOCK_SIZE * 2 * 2]; /* *2 for max channels, another *2 for overflow */ + FLAC__int16 reservoir_[FLAC__MAX_BLOCK_SIZE * 2 * 2]; /* *2 for max channels, another *2 for overflow */ unsigned reservoir_samples_; file_info_struct file_info_; - bool audio_error_; + FLAC__bool audio_error_; public: FLAC_Source(); ~FLAC_Source(); inline char *GetDescription(void) { return plugin_description_; } inline int UsesOutputFilters(void) { return 1; } - int Open(char *url, bool *killswitch); - int GetSamples(char *sample_buffer, int bytes, int *bps, int *nch, int *srate, bool *killswitch); + int Open(char *url, FLAC__bool *killswitch); + int GetSamples(char *sample_buffer, int bytes, int *bps, int *nch, int *srate, FLAC__bool *killswitch); int SetPosition(int); // sets position in ms void GetTitle(char *buf, int maxlen); void GetInfoString(char *buf, int maxlen); @@ -174,7 +174,7 @@ void FLAC_Source::GetInfoString(char *buf, int maxlen) buf[maxlen-1] = 0; } -int FLAC_Source::Open(char *url, bool *killswitch) +int FLAC_Source::Open(char *url, FLAC__bool *killswitch) { const char *filename = url; /* @@@ right now we only handle files */ @@ -205,7 +205,7 @@ int FLAC_Source::Open(char *url, bool *killswitch) return 0; } -int FLAC_Source::GetSamples(char *sample_buffer, int bytes, int *bps, int *nch, int *srate, bool *killswitch) +int FLAC_Source::GetSamples(char *sample_buffer, int bytes, int *bps, int *nch, int *srate, FLAC__bool *killswitch) { int return_bytes = 0; @@ -228,7 +228,7 @@ if(bytes&0x3)fprintf(stderr,"@@@ Got odd buffer size request\n"); } if(reservoir_samples_ > 0) { unsigned i, n = min(reservoir_samples_, wide_samples), delta; - int16 output = (int16*)sample_buffer; + FLAC__int16 output = (FLAC__int16*)sample_buffer; for(i = 0; i < n*channels; i++) output[i] = reservoir_[i]; @@ -250,7 +250,7 @@ int FLAC_Source::SetPosition(int position) { const double distance = (double)position * 1000.0 / (double)file_info_.length_in_msec; unsigned target_sample = (unsigned)(distance * (double)file_info_.total_samples); - if(FLAC__file_decoder_seek_absolute(decoder_, (uint64)target_sample)) { + if(FLAC__file_decoder_seek_absolute(decoder_, (FLAC__uint64)target_sample)) { file_info_.eof = false; reservoir_samples_ = 0; return 0; @@ -277,7 +277,7 @@ void FLAC_Source::cleanup() * local routines **********************************************************************/ -bool get_id3v1_tag_(const char *filename, id3v1_struct *tag) +FLAC__bool get_id3v1_tag_(const char *filename, id3v1_struct *tag) { const char *temp; FILE *f = fopen(filename, "rb"); @@ -314,8 +314,8 @@ bool get_id3v1_tag_(const char *filename, id3v1_struct *tag) memcpy(tag->album, tag->raw+63, 30); memcpy(year_str, tag->raw+93, 4); year_str[4] = '\0'; tag->year = atoi(year_str); memcpy(tag->comment, tag->raw+97, 30); - tag->genre = (unsigned)((byte)tag->raw[127]); - tag->track = (unsigned)((byte)tag->raw[126]); + tag->genre = (unsigned)((FLAC__byte)tag->raw[127]); + tag->track = (unsigned)((FLAC__byte)tag->raw[126]); sprintf(tag->description, "%s - %s", tag->artist, tag->title); @@ -323,7 +323,7 @@ bool get_id3v1_tag_(const char *filename, id3v1_struct *tag) } } -bool decoder_init_(const char *filename) +FLAC__bool decoder_init_(const char *filename) { if(decoder_ == 0) return false; @@ -345,7 +345,7 @@ bool decoder_init_(const char *filename) return true; } -FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data) +FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data) { file_info_struct *file_info = (file_info_struct *)client_data; const unsigned bps = file_info->bits_per_sample, channels = file_info->channels, wide_samples = frame->header.blocksize; @@ -360,7 +360,7 @@ FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, for(sample = reservoir_samples_*channels, wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) - reservoir_[sample] = (int16)buffer[channel][wide_sample]; + reservoir_[sample] = (FLAC__int16)buffer[channel][wide_sample]; reservoir_samples_ += wide_samples; diff --git a/src/plugin_xmms/plugin.c b/src/plugin_xmms/plugin.c index 51e51b84..1dc2efb3 100644 --- a/src/plugin_xmms/plugin.c +++ b/src/plugin_xmms/plugin.c @@ -32,7 +32,7 @@ #define min(x,y) ((x)<(y)?(x):(y)) typedef struct { - byte raw[128]; + FLAC__byte raw[128]; char title[31]; char artist[31]; char album[31]; @@ -44,9 +44,9 @@ typedef struct { } id3v1_struct; typedef struct { - bool abort_flag; - bool is_playing; - bool eof; + FLAC__bool abort_flag; + FLAC__bool is_playing; + FLAC__bool eof; unsigned total_samples; unsigned bits_per_sample; unsigned channels; @@ -66,10 +66,10 @@ static int FLAC_XMMS__get_time(); static void FLAC_XMMS__cleanup(); static void FLAC_XMMS__get_song_info(char *filename, char **title, int *length); -static bool get_id3v1_tag_(const char *filename, id3v1_struct *tag); +static FLAC__bool get_id3v1_tag_(const char *filename, id3v1_struct *tag); static void *play_loop_(void *arg); -static bool decoder_init_(const char *filename); -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data); +static FLAC__bool decoder_init_(const char *filename); +static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data); static void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data); static void error_callback_(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); @@ -103,13 +103,13 @@ InputPlugin flac_ip = }; #define SAMPLES_PER_WRITE 512 -static byte reservoir_[FLAC__MAX_BLOCK_SIZE * 2 * 2 * 2]; /* *2 for max bytes-per-sample, *2 for max channels, another *2 for overflow */ -static byte output_[FLAC__MAX_BLOCK_SIZE * 2 * 2]; /* *2 for max bytes-per-sample, *2 for max channels */ +static FLAC__byte reservoir_[FLAC__MAX_BLOCK_SIZE * 2 * 2 * 2]; /* *2 for max bytes-per-sample, *2 for max channels, another *2 for overflow */ +static FLAC__byte output_[FLAC__MAX_BLOCK_SIZE * 2 * 2]; /* *2 for max bytes-per-sample, *2 for max channels */ static unsigned reservoir_samples_; static FLAC__FileDecoder *decoder_; static file_info_struct file_info_; static pthread_t decode_thread_; -static bool audio_error_ = false; +static FLAC__bool audio_error_ = false; InputPlugin *get_iplugin_info() { @@ -249,7 +249,7 @@ void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec) * local routines **********************************************************************/ -bool get_id3v1_tag_(const char *filename, id3v1_struct *tag) +FLAC__bool get_id3v1_tag_(const char *filename, id3v1_struct *tag) { const char *temp; FILE *f = fopen(filename, "rb"); @@ -286,8 +286,8 @@ bool get_id3v1_tag_(const char *filename, id3v1_struct *tag) memcpy(tag->album, tag->raw+63, 30); memcpy(year_str, tag->raw+93, 4); year_str[4] = '\0'; tag->year = atoi(year_str); memcpy(tag->comment, tag->raw+97, 30); - tag->genre = (unsigned)((byte)tag->raw[127]); - tag->track = (unsigned)((byte)tag->raw[126]); + tag->genre = (unsigned)((FLAC__byte)tag->raw[127]); + tag->track = (unsigned)((FLAC__byte)tag->raw[126]); sprintf(tag->description, "%s - %s", tag->artist, tag->title); @@ -339,7 +339,7 @@ void *play_loop_(void *arg) if (file_info_.seek_to_in_sec != -1) { const double distance = (double)file_info_.seek_to_in_sec * 1000.0 / (double)file_info_.length_in_msec; unsigned target_sample = (unsigned)(distance * (double)file_info_.total_samples); - if(FLAC__file_decoder_seek_absolute(decoder_, (uint64)target_sample)) { + if(FLAC__file_decoder_seek_absolute(decoder_, (FLAC__uint64)target_sample)) { flac_ip.output->flush(file_info_.seek_to_in_sec * 1000); file_info_.seek_to_in_sec = -1; file_info_.eof = false; @@ -359,7 +359,7 @@ void *play_loop_(void *arg) return 0; /* to silence the compiler warning about not returning a value */ } -bool decoder_init_(const char *filename) +FLAC__bool decoder_init_(const char *filename) { if(decoder_ == 0) return false; @@ -381,13 +381,13 @@ bool decoder_init_(const char *filename) return true; } -FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const int32 *buffer[], void *client_data) +FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data) { file_info_struct *file_info = (file_info_struct *)client_data; const unsigned bps = file_info->bits_per_sample, channels = file_info->channels, wide_samples = frame->header.blocksize; unsigned wide_sample, sample, channel; - int8 *scbuffer = (int8*)reservoir_; - int16 *ssbuffer = (int16*)reservoir_; + FLAC__int8 *scbuffer = (FLAC__int8*)reservoir_; + FLAC__int16 *ssbuffer = (FLAC__int16*)reservoir_; (void)decoder; @@ -397,12 +397,12 @@ FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, if(bps == 8) { for(sample = reservoir_samples_*channels, wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) - scbuffer[sample] = (int8)buffer[channel][wide_sample]; + scbuffer[sample] = (FLAC__int8)buffer[channel][wide_sample]; } else if(bps == 16) { for(sample = reservoir_samples_*channels, wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) - ssbuffer[sample] = (int16)buffer[channel][wide_sample]; + ssbuffer[sample] = (FLAC__int16)buffer[channel][wide_sample]; } else { file_info->abort_flag = true; diff --git a/src/test_streams/main.c b/src/test_streams/main.c index d16e01d7..02ac5a6e 100644 --- a/src/test_streams/main.c +++ b/src/test_streams/main.c @@ -29,9 +29,9 @@ static const char *mode = "w"; #endif -static bool is_big_endian_host; +static FLAC__bool is_big_endian_host; -static void swap16(int16 *i) +static void swap16(FLAC__int16 *i) { unsigned char *x = (unsigned char *)i, b; if(!is_big_endian_host) { @@ -41,7 +41,7 @@ static void swap16(int16 *i) } } -static void swap24(byte *x) +static void swap24(FLAC__byte *x) { if(is_big_endian_host) { x[0] = x[1]; @@ -49,17 +49,17 @@ static void swap24(byte *x) x[2] = x[3]; } else { - byte b = x[0]; + FLAC__byte b = x[0]; x[0] = x[2]; x[2] = b; } } /* a mono one-sample 16bps stream */ -static bool generate_01() +static FLAC__bool generate_01() { FILE *f; - int16 x = -32768; + FLAC__int16 x = -32768; if(0 == (f = fopen("test01.raw", mode))) return false; @@ -76,10 +76,10 @@ foo: } /* a stereo one-sample 16bps stream */ -static bool generate_02() +static FLAC__bool generate_02() { FILE *f; - int16 xl = -32768, xr = 32767; + FLAC__int16 xl = -32768, xr = 32767; if(0 == (f = fopen("test02.raw", mode))) return false; @@ -100,10 +100,10 @@ foo: } /* a mono five-sample 16bps stream */ -static bool generate_03() +static FLAC__bool generate_03() { FILE *f; - int16 x[] = { -25, 0, 25, 50, 100 }; + FLAC__int16 x[] = { -25, 0, 25, 50, 100 }; unsigned i; if(0 == (f = fopen("test03.raw", mode))) @@ -112,7 +112,7 @@ static bool generate_03() for(i = 0; i < 5; i++) swap16(x+i); - if(fwrite(&x, sizeof(int16), 5, f) < 5) + if(fwrite(&x, sizeof(FLAC__int16), 5, f) < 5) goto foo; fclose(f); @@ -123,10 +123,10 @@ foo: } /* a stereo five-sample 16bps stream */ -static bool generate_04() +static FLAC__bool generate_04() { FILE *f; - int16 x[] = { -25, 500, 0, 400, 25, 300, 50, 200, 100, 100 }; + FLAC__int16 x[] = { -25, 500, 0, 400, 25, 300, 50, 200, 100, 100 }; unsigned i; if(0 == (f = fopen("test04.raw", mode))) @@ -135,7 +135,7 @@ static bool generate_04() for(i = 0; i < 10; i++) swap16(x+i); - if(fwrite(&x, sizeof(int16), 10, f) < 10) + if(fwrite(&x, sizeof(FLAC__int16), 10, f) < 10) goto foo; fclose(f); @@ -146,7 +146,7 @@ foo: } /* a mono full-scale deflection 8bps stream */ -static bool generate_fsd8(const char *fn, const int pattern[], unsigned reps) +static FLAC__bool generate_fsd8(const char *fn, const int pattern[], unsigned reps) { FILE *f; unsigned rep, p; @@ -172,7 +172,7 @@ foo: } /* a mono full-scale deflection 16bps stream */ -static bool generate_fsd16(const char *fn, const int pattern[], unsigned reps) +static FLAC__bool generate_fsd16(const char *fn, const int pattern[], unsigned reps) { FILE *f; unsigned rep, p; @@ -184,7 +184,7 @@ static bool generate_fsd16(const char *fn, const int pattern[], unsigned reps) for(rep = 0; rep < reps; rep++) { for(p = 0; pattern[p]; p++) { - int16 x = pattern[p] > 0? 32767 : -32768; + FLAC__int16 x = pattern[p] > 0? 32767 : -32768; swap16(&x); if(fwrite(&x, sizeof(x), 1, f) < 1) goto foo; @@ -199,7 +199,7 @@ foo: } /* a stereo wasted-bits-per-sample 16bps stream */ -static bool generate_wbps16(const char *fn, unsigned samples) +static FLAC__bool generate_wbps16(const char *fn, unsigned samples) { FILE *f; unsigned sample; @@ -208,8 +208,8 @@ static bool generate_wbps16(const char *fn, unsigned samples) return false; for(sample = 0; sample < samples; sample++) { - int16 l = (sample % 2000) << 2; - int16 r = (sample % 1000) << 3; + FLAC__int16 l = (sample % 2000) << 2; + FLAC__int16 r = (sample % 1000) << 3; swap16(&l); swap16(&r); if(fwrite(&l, sizeof(l), 1, f) < 1) @@ -226,7 +226,7 @@ foo: } /* a mono full-scale deflection 24bps stream */ -static bool generate_fsd24(const char *fn, const int pattern[], unsigned reps) +static FLAC__bool generate_fsd24(const char *fn, const int pattern[], unsigned reps) { FILE *f; unsigned rep, p; @@ -238,8 +238,8 @@ static bool generate_fsd24(const char *fn, const int pattern[], unsigned reps) for(rep = 0; rep < reps; rep++) { for(p = 0; pattern[p]; p++) { - int32 x = pattern[p] > 0? 8388607 : -8388608; - byte *b = (byte*)(&x); + FLAC__int32 x = pattern[p] > 0? 8388607 : -8388608; + FLAC__byte *b = (FLAC__byte*)(&x); swap24(b); if(fwrite(b, 3, 1, f) < 1) goto foo; @@ -254,9 +254,9 @@ foo: } /* a mono sine-wave 16bps stream */ -static bool generate_sine16_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2) +static FLAC__bool generate_sine16_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2) { - const int16 full_scale = 32767; + const FLAC__int16 full_scale = 32767; const double delta1 = 2.0 * M_PI / ( sample_rate / f1); const double delta2 = 2.0 * M_PI / ( sample_rate / f2); FILE *f; @@ -268,7 +268,7 @@ static bool generate_sine16_1(const char *fn, const double sample_rate, const un for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - int16 v = (int16)(val + 0.5); + FLAC__int16 v = (FLAC__int16)(val + 0.5); swap16(&v); if(fwrite(&v, sizeof(v), 1, f) < 1) goto foo; @@ -282,9 +282,9 @@ foo: } /* a stereo sine-wave 16bps stream */ -static bool generate_sine16_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult) +static FLAC__bool generate_sine16_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult) { - const int16 full_scale = 32767; + const FLAC__int16 full_scale = 32767; const double delta1 = 2.0 * M_PI / ( sample_rate / f1); const double delta2 = 2.0 * M_PI / ( sample_rate / f2); FILE *f; @@ -296,12 +296,12 @@ static bool generate_sine16_2(const char *fn, const double sample_rate, const un for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - int16 v = (int16)(val + 0.5); + FLAC__int16 v = (FLAC__int16)(val + 0.5); swap16(&v); if(fwrite(&v, sizeof(v), 1, f) < 1) goto foo; val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale; - v = (int16)(val + 0.5); + v = (FLAC__int16)(val + 0.5); swap16(&v); if(fwrite(&v, sizeof(v), 1, f) < 1) goto foo; @@ -315,9 +315,9 @@ foo: } /* a mono sine-wave 24bps stream */ -static bool generate_sine24_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2) +static FLAC__bool generate_sine24_1(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2) { - const int32 full_scale = 0x7fffff; + const FLAC__int32 full_scale = 0x7fffff; const double delta1 = 2.0 * M_PI / ( sample_rate / f1); const double delta2 = 2.0 * M_PI / ( sample_rate / f2); FILE *f; @@ -329,8 +329,8 @@ static bool generate_sine24_1(const char *fn, const double sample_rate, const un for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - int32 v = (int32)(val + 0.5); - byte *b = (byte*)(&v); + FLAC__int32 v = (FLAC__int32)(val + 0.5); + FLAC__byte *b = (FLAC__byte*)(&v); swap24(b); if(fwrite(b, 3, 1, f) < 1) goto foo; @@ -344,9 +344,9 @@ foo: } /* a stereo sine-wave 24bps stream */ -static bool generate_sine24_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult) +static FLAC__bool generate_sine24_2(const char *fn, const double sample_rate, const unsigned samples, const double f1, const double a1, const double f2, const double a2, double fmult) { - const int32 full_scale = 0x7fffff; + const FLAC__int32 full_scale = 0x7fffff; const double delta1 = 2.0 * M_PI / ( sample_rate / f1); const double delta2 = 2.0 * M_PI / ( sample_rate / f2); FILE *f; @@ -358,13 +358,13 @@ static bool generate_sine24_2(const char *fn, const double sample_rate, const un for(i = 0, theta1 = theta2 = 0.0; i < samples; i++, theta1 += delta1, theta2 += delta2) { double val = (a1*sin(theta1) + a2*sin(theta2))*(double)full_scale; - int32 v = (int32)(val + 0.5); - byte *b = (byte*)(&v); + FLAC__int32 v = (FLAC__int32)(val + 0.5); + FLAC__byte *b = (FLAC__byte*)(&v); swap24(b); if(fwrite(b, 3, 1, f) < 1) goto foo; val = -(a1*sin(theta1*fmult) + a2*sin(theta2*fmult))*(double)full_scale; - v = (int32)(val + 0.5); + v = (FLAC__int32)(val + 0.5); swap24(b); if(fwrite(b, 3, 1, f) < 1) goto foo; @@ -377,7 +377,7 @@ foo: return false; } -static bool generate_noise(const char *fn, unsigned bytes) +static FLAC__bool generate_noise(const char *fn, unsigned bytes) { FILE *f; struct timeval tv; @@ -393,7 +393,7 @@ static bool generate_noise(const char *fn, unsigned bytes) return false; for(b = 0; b < bytes; b++) { - byte x = (byte)(((unsigned)random()) & 0xff); + FLAC__byte x = (FLAC__byte)(((unsigned)random()) & 0xff); if(fwrite(&x, sizeof(x), 1, f) < 1) goto foo; } @@ -405,10 +405,10 @@ foo: return false; } -static bool generate_wackywavs() +static FLAC__bool generate_wackywavs() { FILE *f; - byte wav[] = { + FLAC__byte wav[] = { 'R', 'I', 'F', 'F', 76, 0, 0, 0, 'W', 'A', 'V', 'E', 'f', 'a', 'c', 't', 4, 0, 0, 0 , 'b', 'l', 'a', 'h', @@ -444,7 +444,7 @@ foo: int main(int argc, char *argv[]) { - uint32 test = 1; + FLAC__uint32 test = 1; int pattern01[] = { 1, -1, 0 }; int pattern02[] = { 1, 1, -1, 0 }; @@ -456,7 +456,7 @@ int main(int argc, char *argv[]) (void)argc; (void)argv; - is_big_endian_host = (*((byte*)(&test)))? false : true; + is_big_endian_host = (*((FLAC__byte*)(&test)))? false : true; if(!generate_01()) return 1; if(!generate_02()) return 1; diff --git a/src/test_unit/bitbuffer.c b/src/test_unit/bitbuffer.c index 8df60dd1..8881bfcf 100644 --- a/src/test_unit/bitbuffer.c +++ b/src/test_unit/bitbuffer.c @@ -18,7 +18,7 @@ #include "private/bitbuffer.h" /* from the libFLAC private include area */ -static bool dummy_read_callback(byte buffer[], unsigned *bytes, void *client_data) +static FLAC__bool dummy_read_callback(FLAC__byte buffer[], unsigned *bytes, void *client_data) { (void)buffer, (void)bytes, (void)client_data; return true; @@ -27,9 +27,9 @@ static bool dummy_read_callback(byte buffer[], unsigned *bytes, void *client_dat int test_bitbuffer() { FLAC__BitBuffer bb, bb_zero, bb_one, bbcopy; - bool ok; + FLAC__bool ok; unsigned i, j; - static byte test_pattern1[19] = { 0xaa, 0xf0, 0xaa, 0xbe, 0xaa, 0xaa, 0xaa, 0xa8, 0x30, 0x0a, 0xaa, 0xaa, 0xaa, 0xad, 0xea, 0xdb, 0xee, 0xfa, 0xce }; + static FLAC__byte test_pattern1[19] = { 0xaa, 0xf0, 0xaa, 0xbe, 0xaa, 0xaa, 0xaa, 0xa8, 0x30, 0x0a, 0xaa, 0xaa, 0xaa, 0xad, 0xea, 0xdb, 0xee, 0xfa, 0xce }; printf("testing init... OK\n"); FLAC__bitbuffer_init(&bb); @@ -87,7 +87,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bb, stdout); return 1; } - if(memcmp(bb.buffer, test_pattern1, sizeof(byte)*sizeof(test_pattern1)) != 0) { + if(memcmp(bb.buffer, test_pattern1, sizeof(FLAC__byte)*sizeof(test_pattern1)) != 0) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); return 1; @@ -117,7 +117,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bb, stdout); return 1; } - if(memcmp(bb.buffer, test_pattern1, sizeof(byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes] != 0x3d) { + if(memcmp(bb.buffer, test_pattern1, sizeof(FLAC__byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes] != 0x3d) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); return 1; @@ -147,7 +147,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bb, stdout); return 1; } - if(memcmp(bb.buffer, test_pattern1, sizeof(byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes] != 0x3d) { + if(memcmp(bb.buffer, test_pattern1, sizeof(FLAC__byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes] != 0x3d) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); return 1; @@ -177,7 +177,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bb, stdout); return 1; } - if(memcmp(bb.buffer, test_pattern1, sizeof(byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes] != 0x7b) { + if(memcmp(bb.buffer, test_pattern1, sizeof(FLAC__byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes] != 0x7b) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); return 1; @@ -209,7 +209,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bb, stdout); return 1; } - if(memcmp(bb.buffer, test_pattern1, sizeof(byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes-1] != 0xf7) { + if(memcmp(bb.buffer, test_pattern1, sizeof(FLAC__byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes-1] != 0xf7) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); return 1; @@ -241,7 +241,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bb, stdout); return 1; } - if(memcmp(bb.buffer, test_pattern1, sizeof(byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes] != 0x08) { + if(memcmp(bb.buffer, test_pattern1, sizeof(FLAC__byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes] != 0x08) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); return 1; @@ -273,7 +273,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bb, stdout); return 1; } - if(memcmp(bb.buffer, test_pattern1, sizeof(byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes-1] != 0x8a || bb.buffer[bb.bytes] != 0x0a) { + if(memcmp(bb.buffer, test_pattern1, sizeof(FLAC__byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes-1] != 0x8a || bb.buffer[bb.bytes] != 0x0a) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); return 1; @@ -304,7 +304,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bb, stdout); return 1; } - if(memcmp(bb.buffer, test_pattern1, sizeof(byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes-3] != 0x8a || bb.buffer[bb.bytes-2] != 0xaa || bb.buffer[bb.bytes-1] != 0xaa || bb.buffer[bb.bytes] != 0x15) { + if(memcmp(bb.buffer, test_pattern1, sizeof(FLAC__byte)*sizeof(test_pattern1)) != 0 || bb.buffer[bb.bytes-3] != 0x8a || bb.buffer[bb.bytes-2] != 0xaa || bb.buffer[bb.bytes-1] != 0xaa || bb.buffer[bb.bytes] != 0x15) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); return 1; @@ -612,7 +612,7 @@ int test_bitbuffer() FLAC__bitbuffer_dump(&bbcopy, stdout); return 1; } - if(memcmp(bb.buffer, bbcopy.buffer, sizeof(byte)*bb.capacity) != 0) { + if(memcmp(bb.buffer, bbcopy.buffer, sizeof(FLAC__byte)*bb.capacity) != 0) { printf("FAILED pattern match\n"); FLAC__bitbuffer_dump(&bb, stdout); FLAC__bitbuffer_dump(&bbcopy, stdout);