flac icon indicating copy to clipboard operation
flac copied to clipboard

Bug in CHECK_ORDER_IS_VALID

Open neumatho opened this issue 2 years ago • 1 comments

Hi,

In src/libFLAC/fixed.c, you have defined the macro CHECK_ORDER_IS_VALID as this:

#ifndef FLAC__INTEGER_ONLY_LIBRARY
#define CHECK_ORDER_IS_VALID(macro_order)		\
if(order_##macro_order##_is_valid && total_error_##macro_order < smallest_error) { \
	order = macro_order;				\
	smallest_error = total_error_##macro_order ;	\
	residual_bits_per_sample[ macro_order ] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0); \
}							\
else							\
	residual_bits_per_sample[ macro_order ] = 34.0f;
#else
#define CHECK_ORDER_IS_VALID(macro_order)		\
if(order_##macro_order##_is_valid && total_error_##macro_order < smallest_error) { \
	order = macro_order;				\
	smallest_error = total_error_##macro_order ;	\
	residual_bits_per_sample[ macro_order ] = (total_error_##macro_order > 0) ? local__compute_rbps_wide_integerized(total_error_##macro_order, data_len) : 0; \
}							\
else							\
	residual_bits_per_sample[ macro_order ] = 34 * FLAC__FP_ONE;
#endif

If you look at the first version where residual_bits_per_sample is used, you use total_error_0. I guess this should be total_error##macro_order_, just like in the second version.

Regards Thomas

neumatho avatar Jul 09 '23 09:07 neumatho

Thanks!

ktmf01 avatar Jul 09 '23 20:07 ktmf01