FLAC__ize all the #defines

This commit is contained in:
Josh Coalson
2001-04-24 22:54:07 +00:00
parent f4035ba7f5
commit bb6712e9e4
7 changed files with 45 additions and 45 deletions

View File

@@ -4,7 +4,7 @@
lib_LTLIBRARIES = libFLAC.la lib_LTLIBRARIES = libFLAC.la
if DEBUG if DEBUG
CFLAGS += @CFLAGS@ -DFLAC_OVERFLOW_DETECT CFLAGS += @CFLAGS@ -DFLAC__OVERFLOW_DETECT
else else
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
endif endif

View File

@@ -4,7 +4,7 @@
LIB_NAME = libFLAC LIB_NAME = libFLAC
INCLUDES = -I./include -I../../include INCLUDES = -I./include -I../../include
DEBUG_CFLAGS = -DFLAC_OVERFLOW_DETECT DEBUG_CFLAGS = -DFLAC__OVERFLOW_DETECT
OBJS = \ OBJS = \
bitbuffer.o \ bitbuffer.o \

View File

@@ -2,7 +2,7 @@
!IFDEF DEBUG !IFDEF DEBUG
.c.obj: .c.obj:
$(cc) /D FLAC_OVERFLOW_DETECT /GX $(cdebug) $(cflags) /I "..\..\include" /I ".\include" -DSTRICT -YX /Od /D "_DEBUG" $< $(cc) /D FLAC__OVERFLOW_DETECT /GX $(cdebug) $(cflags) /I "..\..\include" /I ".\include" -DSTRICT -YX /Od /D "_DEBUG" $<
!else !else
.c.obj: .c.obj:
$(cc) /O2 $(crelease) $(cflags) /I "..\..\include" /I ".\include" -DSTRICT -YX -DNODEBUG $< $(cc) /O2 $(crelease) $(cflags) /I "..\..\include" /I ".\include" -DSTRICT -YX -DNODEBUG $<

View File

@@ -88,7 +88,7 @@ static unsigned encoder_evaluate_fixed_subframe_(const int32 signal[], int32 res
static unsigned encoder_evaluate_lpc_subframe_(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 max_partition_order, FLAC__Subframe *subframe); static unsigned encoder_evaluate_lpc_subframe_(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 max_partition_order, FLAC__Subframe *subframe);
static unsigned encoder_evaluate_verbatim_subframe_(const int32 signal[], unsigned blocksize, unsigned subframe_bps, FLAC__Subframe *subframe); static unsigned encoder_evaluate_verbatim_subframe_(const int32 signal[], unsigned blocksize, unsigned subframe_bps, FLAC__Subframe *subframe);
static unsigned 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 max_partition_order, unsigned *best_partition_order, unsigned best_parameters[], unsigned best_raw_bits[]); static unsigned 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 max_partition_order, unsigned *best_partition_order, unsigned best_parameters[], unsigned best_raw_bits[]);
#if (defined PRECOMPUTE_PARTITION_SUMS) || (defined SEARCH_FOR_ESCAPES) #if (defined FLAC__PRECOMPUTE_PARTITION_SUMS) || (defined FLAC__SEARCH_FOR_ESCAPES)
static unsigned 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 max_partition_order); static unsigned 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 max_partition_order);
#endif #endif
static bool 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, unsigned rice_parameter, const unsigned partition_order, unsigned parameters[], unsigned raw_bits[], unsigned *bits); static bool 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, unsigned rice_parameter, const unsigned partition_order, unsigned parameters[], unsigned raw_bits[], unsigned *bits);
@@ -233,7 +233,7 @@ bool encoder_resize_buffers_(FLAC__Encoder *encoder, unsigned new_size)
free(encoder->guts->abs_residual); free(encoder->guts->abs_residual);
encoder->guts->abs_residual = abs_residual; encoder->guts->abs_residual = abs_residual;
} }
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
abs_residual = (uint32*)malloc(sizeof(uint32) * (new_size * 2)); abs_residual = (uint32*)malloc(sizeof(uint32) * (new_size * 2));
if(0 == abs_residual) { if(0 == abs_residual) {
encoder->state = FLAC__ENCODER_MEMORY_ALLOCATION_ERROR; encoder->state = FLAC__ENCODER_MEMORY_ALLOCATION_ERROR;
@@ -245,7 +245,7 @@ bool encoder_resize_buffers_(FLAC__Encoder *encoder, unsigned new_size)
encoder->guts->abs_residual_partition_sums = abs_residual; encoder->guts->abs_residual_partition_sums = abs_residual;
} }
#endif #endif
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
raw_bits_per_partition = (unsigned*)malloc(sizeof(unsigned) * (new_size * 2)); raw_bits_per_partition = (unsigned*)malloc(sizeof(unsigned) * (new_size * 2));
if(0 == raw_bits_per_partition) { if(0 == raw_bits_per_partition) {
encoder->state = FLAC__ENCODER_MEMORY_ALLOCATION_ERROR; encoder->state = FLAC__ENCODER_MEMORY_ALLOCATION_ERROR;
@@ -963,7 +963,7 @@ bool encoder_process_subframe_(FLAC__Encoder *encoder, unsigned max_partition_or
if(fixed_residual_bits_per_sample[fixed_order] >= (real)subframe_bps) if(fixed_residual_bits_per_sample[fixed_order] >= (real)subframe_bps)
continue; /* don't even try */ 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 */ 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 SYMMETRIC_RICE #ifndef FLAC__SYMMETRIC_RICE
rice_parameter++; /* to account for the signed->unsigned conversion during rice coding */ rice_parameter++; /* to account for the signed->unsigned conversion during rice coding */
#endif #endif
if(rice_parameter >= (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)) if(rice_parameter >= (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN))
@@ -1005,7 +1005,7 @@ bool encoder_process_subframe_(FLAC__Encoder *encoder, unsigned max_partition_or
if(lpc_residual_bits_per_sample >= (real)subframe_bps) if(lpc_residual_bits_per_sample >= (real)subframe_bps)
continue; /* don't even try */ 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 */ rice_parameter = (lpc_residual_bits_per_sample > 0.0)? (unsigned)(lpc_residual_bits_per_sample+0.5) : 0; /* 0.5 is for rounding */
#ifndef SYMMETRIC_RICE #ifndef FLAC__SYMMETRIC_RICE
rice_parameter++; /* to account for the signed->unsigned conversion during rice coding */ rice_parameter++; /* to account for the signed->unsigned conversion during rice coding */
#endif #endif
if(rice_parameter >= (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)) if(rice_parameter >= (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN))
@@ -1137,7 +1137,7 @@ unsigned encoder_evaluate_verbatim_subframe_(const int32 signal[], unsigned bloc
unsigned 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 max_partition_order, unsigned *best_partition_order, unsigned best_parameters[], unsigned best_raw_bits[]) unsigned 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 max_partition_order, unsigned *best_partition_order, unsigned best_parameters[], unsigned best_raw_bits[])
{ {
int32 r; int32 r;
#if (defined PRECOMPUTE_PARTITION_SUMS) || (defined SEARCH_FOR_ESCAPES) #if (defined FLAC__PRECOMPUTE_PARTITION_SUMS) || (defined FLAC__SEARCH_FOR_ESCAPES)
unsigned sum; unsigned sum;
int partition_order; int partition_order;
#else #else
@@ -1153,7 +1153,7 @@ unsigned encoder_find_best_partition_order_(const int32 residual[], uint32 abs_r
abs_residual[residual_sample] = (uint32)(r<0? -r : r); abs_residual[residual_sample] = (uint32)(r<0? -r : r);
} }
#if (defined PRECOMPUTE_PARTITION_SUMS) || (defined SEARCH_FOR_ESCAPES) #if (defined FLAC__PRECOMPUTE_PARTITION_SUMS) || (defined FLAC__SEARCH_FOR_ESCAPES)
max_partition_order = encoder_precompute_partition_info_(residual, abs_residual, abs_residual_partition_sums, raw_bits_per_partition, residual_samples, predictor_order, max_partition_order); max_partition_order = encoder_precompute_partition_info_(residual, abs_residual, abs_residual_partition_sums, raw_bits_per_partition, residual_samples, predictor_order, max_partition_order);
for(partition_order = (int)max_partition_order, sum = 0; partition_order >= 0; partition_order--) { for(partition_order = (int)max_partition_order, sum = 0; partition_order >= 0; partition_order--) {
@@ -1186,7 +1186,7 @@ unsigned encoder_find_best_partition_order_(const int32 residual[], uint32 abs_r
return best_residual_bits; return best_residual_bits;
} }
#if (defined PRECOMPUTE_PARTITION_SUMS) || (defined SEARCH_FOR_ESCAPES) #if (defined FLAC__PRECOMPUTE_PARTITION_SUMS) || (defined FLAC__SEARCH_FOR_ESCAPES)
unsigned 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 max_partition_order) unsigned 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 max_partition_order)
{ {
int partition_order; int partition_order;
@@ -1195,10 +1195,10 @@ unsigned encoder_precompute_partition_info_(const int32 residual[], uint32 abs_r
/* first do max_partition_order */ /* first do max_partition_order */
for(partition_order = (int)max_partition_order; partition_order >= 0; partition_order--) { for(partition_order = (int)max_partition_order; partition_order >= 0; partition_order--) {
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
uint32 abs_residual_partition_sum; uint32 abs_residual_partition_sum;
#endif #endif
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
uint32 abs_residual_partition_max; uint32 abs_residual_partition_max;
unsigned abs_residual_partition_max_index = 0; /* initialized to silence superfluous compiler warning */ unsigned abs_residual_partition_max_index = 0; /* initialized to silence superfluous compiler warning */
#endif #endif
@@ -1216,18 +1216,18 @@ unsigned encoder_precompute_partition_info_(const int32 residual[], uint32 abs_r
partition_samples = default_partition_samples; partition_samples = default_partition_samples;
if(partition == 0) if(partition == 0)
partition_samples -= predictor_order; partition_samples -= predictor_order;
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
abs_residual_partition_sum = 0; abs_residual_partition_sum = 0;
#endif #endif
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
abs_residual_partition_max = 0; abs_residual_partition_max = 0;
#endif #endif
for(partition_sample = 0; partition_sample < partition_samples; partition_sample++) { for(partition_sample = 0; partition_sample < partition_samples; partition_sample++) {
abs_r = abs_residual[residual_sample]; abs_r = abs_residual[residual_sample];
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
abs_residual_partition_sum += abs_r; /* @@@ this can overflow with small max_partition_order and (large blocksizes or bits-per-sample), FIX! */ abs_residual_partition_sum += abs_r; /* @@@ this can overflow with small max_partition_order and (large blocksizes or bits-per-sample), FIX! */
#endif #endif
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
if(abs_r > abs_residual_partition_max) { if(abs_r > abs_residual_partition_max) {
abs_residual_partition_max = abs_r; abs_residual_partition_max = abs_r;
abs_residual_partition_max_index = residual_sample; abs_residual_partition_max_index = residual_sample;
@@ -1235,10 +1235,10 @@ unsigned encoder_precompute_partition_info_(const int32 residual[], uint32 abs_r
#endif #endif
residual_sample++; residual_sample++;
} }
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
abs_residual_partition_sums[partition] = abs_residual_partition_sum; abs_residual_partition_sums[partition] = abs_residual_partition_sum;
#endif #endif
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
if(abs_residual_partition_max > 0) if(abs_residual_partition_max > 0)
raw_bits_per_partition[partition] = FLAC__bitmath_silog2(residual[abs_residual_partition_max_index]); raw_bits_per_partition[partition] = FLAC__bitmath_silog2(residual[abs_residual_partition_max_index]);
else else
@@ -1252,26 +1252,26 @@ unsigned encoder_precompute_partition_info_(const int32 residual[], uint32 abs_r
/* now merge for lower orders */ /* now merge for lower orders */
for(from_partition = 0; partition_order >= 0; partition_order--) { for(from_partition = 0; partition_order >= 0; partition_order--) {
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
uint32 s; uint32 s;
#endif #endif
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
unsigned m; unsigned m;
#endif #endif
unsigned i; unsigned i;
const unsigned partitions = 1u << partition_order; const unsigned partitions = 1u << partition_order;
for(i = 0; i < partitions; i++) { for(i = 0; i < partitions; i++) {
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
s = abs_residual_partition_sums[from_partition]; s = abs_residual_partition_sums[from_partition];
#endif #endif
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
m = raw_bits_per_partition[from_partition]; m = raw_bits_per_partition[from_partition];
#endif #endif
from_partition++; from_partition++;
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
abs_residual_partition_sums[to_partition] = s + abs_residual_partition_sums[from_partition]; abs_residual_partition_sums[to_partition] = s + abs_residual_partition_sums[from_partition];
#endif #endif
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
raw_bits_per_partition[to_partition] = max(m, raw_bits_per_partition[from_partition]); raw_bits_per_partition[to_partition] = max(m, raw_bits_per_partition[from_partition]);
#endif #endif
from_partition++; from_partition++;
@@ -1291,7 +1291,7 @@ unsigned encoder_precompute_partition_info_(const int32 residual[], uint32 abs_r
bool 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, unsigned rice_parameter, const unsigned partition_order, unsigned parameters[], unsigned raw_bits[], unsigned *bits) bool 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, unsigned rice_parameter, const unsigned partition_order, unsigned parameters[], unsigned raw_bits[], unsigned *bits)
{ {
unsigned partition_bits; unsigned partition_bits;
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
unsigned flat_bits; unsigned flat_bits;
#endif #endif
unsigned bits_ = FLAC__ENTROPY_CODING_METHOD_TYPE_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; unsigned bits_ = FLAC__ENTROPY_CODING_METHOD_TYPE_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN;
@@ -1306,7 +1306,7 @@ bool encoder_set_partitioned_rice_(const uint32 abs_residual[], const uint32 abs
{ {
#ifdef VARIABLE_RICE_BITS #ifdef VARIABLE_RICE_BITS
#ifdef SYMMETRIC_RICE #ifdef FLAC__SYMMETRIC_RICE
partition_bits += (2+rice_parameter) * residual_samples; partition_bits += (2+rice_parameter) * residual_samples;
#else #else
const unsigned rice_parameter_estimate = rice_parameter-1; const unsigned rice_parameter_estimate = rice_parameter-1;
@@ -1317,7 +1317,7 @@ bool encoder_set_partitioned_rice_(const uint32 abs_residual[], const uint32 abs
partition_bits += FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; partition_bits += FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
for(i = 0; i < residual_samples; i++) { for(i = 0; i < residual_samples; i++) {
#ifdef VARIABLE_RICE_BITS #ifdef VARIABLE_RICE_BITS
#ifdef SYMMETRIC_RICE #ifdef FLAC__SYMMETRIC_RICE
partition_bits += VARIABLE_RICE_BITS(abs_residual[i], rice_parameter); partition_bits += VARIABLE_RICE_BITS(abs_residual[i], rice_parameter);
#else #else
partition_bits += VARIABLE_RICE_BITS(abs_residual[i], rice_parameter_estimate); partition_bits += VARIABLE_RICE_BITS(abs_residual[i], rice_parameter_estimate);
@@ -1326,7 +1326,7 @@ bool encoder_set_partitioned_rice_(const uint32 abs_residual[], const uint32 abs
partition_bits += FLAC__bitbuffer_rice_bits(residual[i], rice_parameter); /* NOTE: we will need to pass in residual[] instead of abs_residual[] */ partition_bits += FLAC__bitbuffer_rice_bits(residual[i], rice_parameter); /* NOTE: we will need to pass in residual[] instead of abs_residual[] */
#endif #endif
} }
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
flat_bits = raw_bits_per_partition[0] * residual_samples; flat_bits = raw_bits_per_partition[0] * residual_samples;
if(flat_bits < partition_bits) { if(flat_bits < partition_bits) {
parameters[0] = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; parameters[0] = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
@@ -1352,7 +1352,7 @@ bool encoder_set_partitioned_rice_(const uint32 abs_residual[], const uint32 abs
partition_samples -= predictor_order; partition_samples -= predictor_order;
} }
mean = partition_samples >> 1; mean = partition_samples >> 1;
#ifdef PRECOMPUTE_PARTITION_SUMS #ifdef FLAC__PRECOMPUTE_PARTITION_SUMS
mean += abs_residual_partition_sums[i]; mean += abs_residual_partition_sums[i];
#else #else
for(k = 0; k < partition_samples; j++, k++) for(k = 0; k < partition_samples; j++, k++)
@@ -1360,7 +1360,7 @@ bool encoder_set_partitioned_rice_(const uint32 abs_residual[], const uint32 abs
j -= k; j -= k;
#endif #endif
mean /= partition_samples; mean /= partition_samples;
#ifdef SYMMETRIC_RICE #ifdef FLAC__SYMMETRIC_RICE
/* calc parameter = floor(log2(mean)) */ /* calc parameter = floor(log2(mean)) */
parameter = 0; parameter = 0;
mean>>=1; mean>>=1;
@@ -1383,7 +1383,7 @@ mean>>=1;
parameters[i] = parameter; parameters[i] = parameter;
partition_bits += FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; partition_bits += FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
#ifdef VARIABLE_RICE_BITS #ifdef VARIABLE_RICE_BITS
#ifdef SYMMETRIC_RICE #ifdef FLAC__SYMMETRIC_RICE
partition_bits += (2+parameter) * partition_samples; partition_bits += (2+parameter) * partition_samples;
#else #else
partition_bits += (1+parameter) * partition_samples; partition_bits += (1+parameter) * partition_samples;
@@ -1392,7 +1392,7 @@ mean>>=1;
#endif #endif
for(k = 0; k < partition_samples; j++, k++) { for(k = 0; k < partition_samples; j++, k++) {
#ifdef VARIABLE_RICE_BITS #ifdef VARIABLE_RICE_BITS
#ifdef SYMMETRIC_RICE #ifdef FLAC__SYMMETRIC_RICE
partition_bits += VARIABLE_RICE_BITS(abs_residual[j], parameter); partition_bits += VARIABLE_RICE_BITS(abs_residual[j], parameter);
#else #else
partition_bits += VARIABLE_RICE_BITS(abs_residual[j], parameter); partition_bits += VARIABLE_RICE_BITS(abs_residual[j], parameter);
@@ -1401,7 +1401,7 @@ mean>>=1;
partition_bits += FLAC__bitbuffer_rice_bits(residual[j], parameter); /* NOTE: we will need to pass in residual[] instead of abs_residual[] */ partition_bits += FLAC__bitbuffer_rice_bits(residual[j], parameter); /* NOTE: we will need to pass in residual[] instead of abs_residual[] */
#endif #endif
} }
#ifdef SEARCH_FOR_ESCAPES #ifdef FLAC__SEARCH_FOR_ESCAPES
flat_bits = raw_bits_per_partition[i] * partition_samples; flat_bits = raw_bits_per_partition[i] * partition_samples;
if(flat_bits < partition_bits) { if(flat_bits < partition_bits) {
parameters[i] = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; parameters[i] = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;

View File

@@ -359,7 +359,7 @@ bool subframe_add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const int32 re
return false; return false;
if(rice_parameters[0] < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) { if(rice_parameters[0] < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) {
for(i = 0; i < residual_samples; i++) { for(i = 0; i < residual_samples; i++) {
#ifdef SYMMETRIC_RICE #ifdef FLAC__SYMMETRIC_RICE
if(!FLAC__bitbuffer_write_symmetric_rice_signed(bb, residual[i], rice_parameters[0])) if(!FLAC__bitbuffer_write_symmetric_rice_signed(bb, residual[i], rice_parameters[0]))
return false; return false;
#else #else
@@ -391,7 +391,7 @@ bool subframe_add_residual_partitioned_rice_(FLAC__BitBuffer *bb, const int32 re
k += partition_samples; k += partition_samples;
if(rice_parameters[i] < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) { if(rice_parameters[i] < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) {
for(j = k_last; j < k; j++) { for(j = k_last; j < k; j++) {
#ifdef SYMMETRIC_RICE #ifdef FLAC__SYMMETRIC_RICE
if(!FLAC__bitbuffer_write_symmetric_rice_signed(bb, residual[j], rice_parameters[i])) if(!FLAC__bitbuffer_write_symmetric_rice_signed(bb, residual[j], rice_parameters[i]))
return false; return false;
#else #else

View File

@@ -129,14 +129,14 @@ int FLAC__lpc_quantize_coefficients(const real lp_coeff[], unsigned order, unsig
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 int32 data[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 residual[])
{ {
#ifdef FLAC_OVERFLOW_DETECT #ifdef FLAC__OVERFLOW_DETECT
int64 sumo; int64 sumo;
#endif #endif
unsigned i, j; unsigned i, j;
int32 sum; int32 sum;
const int32 *history; const int32 *history;
#ifdef FLAC_OVERFLOW_DETECT_VERBOSE #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); fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
for(i=0;i<order;i++) for(i=0;i<order;i++)
fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]); fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
@@ -145,14 +145,14 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const int32 data[], unsign
assert(order > 0); assert(order > 0);
for(i = 0; i < data_len; i++) { for(i = 0; i < data_len; i++) {
#ifdef FLAC_OVERFLOW_DETECT #ifdef FLAC__OVERFLOW_DETECT
sumo = 0; sumo = 0;
#endif #endif
sum = 0; sum = 0;
history = data; history = data;
for(j = 0; j < order; j++) { for(j = 0; j < order; j++) {
sum += qlp_coeff[j] * (*(--history)); sum += qlp_coeff[j] * (*(--history));
#ifdef FLAC_OVERFLOW_DETECT #ifdef FLAC__OVERFLOW_DETECT
sumo += (int64)qlp_coeff[j] * (int64)(*history); sumo += (int64)qlp_coeff[j] * (int64)(*history);
if(sumo > 2147483647ll || sumo < -2147483648ll) { 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); 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);
@@ -174,14 +174,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 int32 residual[], unsigned data_len, const int32 qlp_coeff[], unsigned order, int lp_quantization, int32 data[])
{ {
#ifdef FLAC_OVERFLOW_DETECT #ifdef FLAC__OVERFLOW_DETECT
int64 sumo; int64 sumo;
#endif #endif
unsigned i, j; unsigned i, j;
int32 sum; int32 sum;
const int32 *history; const int32 *history;
#ifdef FLAC_OVERFLOW_DETECT_VERBOSE #ifdef FLAC__OVERFLOW_DETECT_VERBOSE
fprintf(stderr,"FLAC__lpc_restore_signal: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization); fprintf(stderr,"FLAC__lpc_restore_signal: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
for(i=0;i<order;i++) for(i=0;i<order;i++)
fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]); fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
@@ -190,14 +190,14 @@ void FLAC__lpc_restore_signal(const int32 residual[], unsigned data_len, const i
assert(order > 0); assert(order > 0);
for(i = 0; i < data_len; i++) { for(i = 0; i < data_len; i++) {
#ifdef FLAC_OVERFLOW_DETECT #ifdef FLAC__OVERFLOW_DETECT
sumo = 0; sumo = 0;
#endif #endif
sum = 0; sum = 0;
history = data; history = data;
for(j = 0; j < order; j++) { for(j = 0; j < order; j++) {
sum += qlp_coeff[j] * (*(--history)); sum += qlp_coeff[j] * (*(--history));
#ifdef FLAC_OVERFLOW_DETECT #ifdef FLAC__OVERFLOW_DETECT
sumo += (int64)qlp_coeff[j] * (int64)(*history); sumo += (int64)qlp_coeff[j] * (int64)(*history);
if(sumo > 2147483647ll || sumo < -2147483648ll) { 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); 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);

View File

@@ -1312,7 +1312,7 @@ bool stream_decoder_read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder
return false; /* the read_callback_ sets the state for us */ return false; /* the read_callback_ sets the state for us */
if(rice_parameter < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) { if(rice_parameter < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) {
for(u = (partition_order == 0 || partition > 0)? 0 : predictor_order; u < partition_samples; u++, sample++) { for(u = (partition_order == 0 || partition > 0)? 0 : predictor_order; u < partition_samples; u++, sample++) {
#ifdef SYMMETRIC_RICE #ifdef FLAC__SYMMETRIC_RICE
if(!FLAC__bitbuffer_read_symmetric_rice_signed(&decoder->guts->input, &i, rice_parameter, read_callback_, decoder)) if(!FLAC__bitbuffer_read_symmetric_rice_signed(&decoder->guts->input, &i, rice_parameter, read_callback_, decoder))
return false; /* the read_callback_ sets the state for us */ return false; /* the read_callback_ sets the state for us */
#else #else