mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
first pass at making an integer-only flavor of the libraries. move FLAC__real out of ordinals.h to src/libFLAC/include/private/float.h, add FLAC__double and FLAC__float and use these everywhere instead of double and float, and don't typedef FLAC__real/float/double when building in integer-only mode. still need to provide integer substitutes in several places.
This commit is contained in:
@@ -58,7 +58,6 @@ typedef uint64_t FLAC__uint64;
|
|||||||
typedef int FLAC__bool;
|
typedef int FLAC__bool;
|
||||||
|
|
||||||
typedef FLAC__uint8 FLAC__byte;
|
typedef FLAC__uint8 FLAC__byte;
|
||||||
typedef float FLAC__real;
|
|
||||||
|
|
||||||
#ifdef true
|
#ifdef true
|
||||||
#undef true
|
#undef true
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#define local_abs(x) ((unsigned)((x)<0? -(x) : (x)))
|
#define local_abs(x) ((unsigned)((x)<0? -(x) : (x)))
|
||||||
|
|
||||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||||
{
|
{
|
||||||
FLAC__int32 last_error_0 = data[-1];
|
FLAC__int32 last_error_0 = data[-1];
|
||||||
FLAC__int32 last_error_1 = data[-1] - data[-2];
|
FLAC__int32 last_error_1 = data[-1] - data[-2];
|
||||||
@@ -85,16 +85,16 @@ unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned d
|
|||||||
FLAC__ASSERT(data_len > 0 || total_error_2 == 0);
|
FLAC__ASSERT(data_len > 0 || total_error_2 == 0);
|
||||||
FLAC__ASSERT(data_len > 0 || total_error_3 == 0);
|
FLAC__ASSERT(data_len > 0 || total_error_3 == 0);
|
||||||
FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
|
FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
|
||||||
residual_bits_per_sample[0] = (FLAC__real)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[1] = (FLAC__real)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[2] = (FLAC__real)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[3] = (FLAC__real)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[4] = (FLAC__real)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
|
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||||
{
|
{
|
||||||
FLAC__int32 last_error_0 = data[-1];
|
FLAC__int32 last_error_0 = data[-1];
|
||||||
FLAC__int32 last_error_1 = data[-1] - data[-2];
|
FLAC__int32 last_error_1 = data[-1] - data[-2];
|
||||||
@@ -137,17 +137,17 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig
|
|||||||
FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
|
FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
|
||||||
#if defined _MSC_VER || defined __MINGW32__
|
#if defined _MSC_VER || defined __MINGW32__
|
||||||
/* with VC++ you have to spoon feed it the casting */
|
/* with VC++ you have to spoon feed it the casting */
|
||||||
residual_bits_per_sample[0] = (FLAC__real)((total_error_0 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_0 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[1] = (FLAC__real)((total_error_1 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_1 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[2] = (FLAC__real)((total_error_2 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_2 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[3] = (FLAC__real)((total_error_3 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_3 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[4] = (FLAC__real)((total_error_4 > 0) ? log(M_LN2 * (double)(FLAC__int64)total_error_4 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
#else
|
#else
|
||||||
residual_bits_per_sample[0] = (FLAC__real)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[1] = (FLAC__real)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[2] = (FLAC__real)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[3] = (FLAC__real)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
residual_bits_per_sample[4] = (FLAC__real)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0);
|
residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return order;
|
return order;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ cglobal FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov
|
|||||||
|
|
||||||
; **********************************************************************
|
; **********************************************************************
|
||||||
;
|
;
|
||||||
; unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
; unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||||
; {
|
; {
|
||||||
; FLAC__int32 last_error_0 = data[-1];
|
; FLAC__int32 last_error_0 = data[-1];
|
||||||
; FLAC__int32 last_error_1 = data[-1] - data[-2];
|
; FLAC__int32 last_error_1 = data[-1] - data[-2];
|
||||||
@@ -67,11 +67,11 @@ cglobal FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov
|
|||||||
; else
|
; else
|
||||||
; order = 4;
|
; order = 4;
|
||||||
;
|
;
|
||||||
; 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[0] = (FLAC__float)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__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[1] = (FLAC__float)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__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[2] = (FLAC__float)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__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[3] = (FLAC__float)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__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);
|
; residual_bits_per_sample[4] = (FLAC__float)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
;
|
;
|
||||||
; return order;
|
; return order;
|
||||||
; }
|
; }
|
||||||
@@ -196,11 +196,11 @@ cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov
|
|||||||
movd ebx, mm0 ; ebx = total_error_0
|
movd ebx, mm0 ; ebx = total_error_0
|
||||||
emms
|
emms
|
||||||
|
|
||||||
; 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[0] = (FLAC__float)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__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[1] = (FLAC__float)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__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[2] = (FLAC__float)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__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[3] = (FLAC__float)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__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);
|
; residual_bits_per_sample[4] = (FLAC__float)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
fild dword [esp + 40] ; ST = data_len (NOTE: assumes data_len is <2gigs)
|
fild dword [esp + 40] ; ST = data_len (NOTE: assumes data_len is <2gigs)
|
||||||
.rbps_0:
|
.rbps_0:
|
||||||
|
|||||||
@@ -32,12 +32,13 @@
|
|||||||
#ifndef FLAC__PRIVATE__FIXED_H
|
#ifndef FLAC__PRIVATE__FIXED_H
|
||||||
#define FLAC__PRIVATE__FIXED_H
|
#define FLAC__PRIVATE__FIXED_H
|
||||||
|
|
||||||
#include "FLAC/format.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "private/float.h"
|
||||||
|
#include "FLAC/format.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLAC__fixed_compute_best_predictor()
|
* FLAC__fixed_compute_best_predictor()
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
@@ -50,15 +51,15 @@
|
|||||||
* IN data_len
|
* IN data_len
|
||||||
* OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER]
|
* OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER]
|
||||||
*/
|
*/
|
||||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||||
#ifndef FLAC__NO_ASM
|
#ifndef FLAC__NO_ASM
|
||||||
#ifdef FLAC__CPU_IA32
|
#ifdef FLAC__CPU_IA32
|
||||||
#ifdef FLAC__HAS_NASM
|
#ifdef FLAC__HAS_NASM
|
||||||
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]);
|
unsigned FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLAC__fixed_compute_residual()
|
* FLAC__fixed_compute_residual()
|
||||||
|
|||||||
@@ -32,12 +32,13 @@
|
|||||||
#ifndef FLAC__PRIVATE__LPC_H
|
#ifndef FLAC__PRIVATE__LPC_H
|
||||||
#define FLAC__PRIVATE__LPC_H
|
#define FLAC__PRIVATE__LPC_H
|
||||||
|
|
||||||
#include "FLAC/format.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "private/float.h"
|
||||||
|
#include "FLAC/format.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLAC__lpc_compute_autocorrelation()
|
* FLAC__lpc_compute_autocorrelation()
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
@@ -81,7 +82,7 @@ void FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow(const FLAC__real data[], u
|
|||||||
* in lp_coeff[8][0,8], the LP coefficients for order 8 will be
|
* in lp_coeff[8][0,8], the LP coefficients for order 8 will be
|
||||||
* in lp_coeff[7][0,7], etc.
|
* in lp_coeff[7][0,7], etc.
|
||||||
*/
|
*/
|
||||||
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__real error[]);
|
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLAC__lpc_quantize_coefficients()
|
* FLAC__lpc_quantize_coefficients()
|
||||||
@@ -168,8 +169,8 @@ void FLAC__lpc_restore_signal_asm_ppc_altivec_16_order8(const FLAC__int32 residu
|
|||||||
* IN total_samples > 0 # of samples in residual signal
|
* IN total_samples > 0 # of samples in residual signal
|
||||||
* RETURN expected bits per sample
|
* RETURN expected bits per sample
|
||||||
*/
|
*/
|
||||||
FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__real lpc_error, unsigned total_samples);
|
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples);
|
||||||
FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__real lpc_error, double error_scale);
|
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FLAC__lpc_compute_best_order()
|
* FLAC__lpc_compute_best_order()
|
||||||
@@ -183,6 +184,6 @@ FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(
|
|||||||
* IN bits_per_signal_sample # of bits per sample in the original signal
|
* IN bits_per_signal_sample # of bits per sample in the original signal
|
||||||
* RETURN [1,max_order] best order
|
* RETURN [1,max_order] best order
|
||||||
*/
|
*/
|
||||||
unsigned FLAC__lpc_compute_best_order(const FLAC__real lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample);
|
unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,8 +32,13 @@
|
|||||||
#ifndef FLAC__PRIVATE__MEMORY_H
|
#ifndef FLAC__PRIVATE__MEMORY_H
|
||||||
#define FLAC__PRIVATE__MEMORY_H
|
#define FLAC__PRIVATE__MEMORY_H
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h> /* for size_t */
|
#include <stdlib.h> /* for size_t */
|
||||||
|
|
||||||
|
#include "private/float.h"
|
||||||
#include "FLAC/ordinals.h" /* for FLAC__bool */
|
#include "FLAC/ordinals.h" /* for FLAC__bool */
|
||||||
|
|
||||||
/* Returns the unaligned address returned by malloc.
|
/* Returns the unaligned address returned by malloc.
|
||||||
|
|||||||
@@ -85,10 +85,10 @@ void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_le
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__real error[])
|
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[])
|
||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
double r, err, ref[FLAC__MAX_LPC_ORDER], lpc[FLAC__MAX_LPC_ORDER];
|
FLAC__double r, err, ref[FLAC__MAX_LPC_ORDER], lpc[FLAC__MAX_LPC_ORDER];
|
||||||
|
|
||||||
FLAC__ASSERT(0 < max_order);
|
FLAC__ASSERT(0 < max_order);
|
||||||
FLAC__ASSERT(max_order <= FLAC__MAX_LPC_ORDER);
|
FLAC__ASSERT(max_order <= FLAC__MAX_LPC_ORDER);
|
||||||
@@ -106,7 +106,7 @@ void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_or
|
|||||||
/* Update LPC coefficients and total error. */
|
/* Update LPC coefficients and total error. */
|
||||||
lpc[i]=r;
|
lpc[i]=r;
|
||||||
for(j = 0; j < (i>>1); j++) {
|
for(j = 0; j < (i>>1); j++) {
|
||||||
double tmp = lpc[j];
|
FLAC__double tmp = lpc[j];
|
||||||
lpc[j] += r * lpc[i-1-j];
|
lpc[j] += r * lpc[i-1-j];
|
||||||
lpc[i-1-j] += r * tmp;
|
lpc[i-1-j] += r * tmp;
|
||||||
}
|
}
|
||||||
@@ -118,14 +118,14 @@ void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned max_or
|
|||||||
/* save this order */
|
/* save this order */
|
||||||
for(j = 0; j <= i; j++)
|
for(j = 0; j <= i; j++)
|
||||||
lp_coeff[i][j] = (FLAC__real)(-lpc[j]); /* negate FIR filter coeff to get predictor coeff */
|
lp_coeff[i][j] = (FLAC__real)(-lpc[j]); /* negate FIR filter coeff to get predictor coeff */
|
||||||
error[i] = (FLAC__real)err;
|
error[i] = err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift)
|
int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
double d, cmax = -1e32;
|
FLAC__double d, cmax = -1e32;
|
||||||
FLAC__int32 qmax, qmin;
|
FLAC__int32 qmax, qmin;
|
||||||
const int max_shiftlimit = (1 << (FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN-1)) - 1;
|
const int max_shiftlimit = (1 << (FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN-1)) - 1;
|
||||||
const int min_shiftlimit = -max_shiftlimit - 1;
|
const int min_shiftlimit = -max_shiftlimit - 1;
|
||||||
@@ -171,12 +171,12 @@ redo_it:
|
|||||||
|
|
||||||
if(*shift >= 0) {
|
if(*shift >= 0) {
|
||||||
for(i = 0; i < order; i++) {
|
for(i = 0; i < order; i++) {
|
||||||
qlp_coeff[i] = (FLAC__int32)floor((double)lp_coeff[i] * (double)(1 << *shift));
|
qlp_coeff[i] = (FLAC__int32)floor((FLAC__double)lp_coeff[i] * (FLAC__double)(1 << *shift));
|
||||||
|
|
||||||
/* double-check the result */
|
/* double-check the result */
|
||||||
if(qlp_coeff[i] > qmax || qlp_coeff[i] < qmin) {
|
if(qlp_coeff[i] > qmax || qlp_coeff[i] < qmin) {
|
||||||
#ifdef FLAC__OVERFLOW_DETECT
|
#ifdef FLAC__OVERFLOW_DETECT
|
||||||
fprintf(stderr,"FLAC__lpc_quantize_coefficients: compensating for overflow, qlp_coeff[%u]=%d, lp_coeff[%u]=%f, cmax=%f, precision=%u, shift=%d, q=%f, f(q)=%f\n", i, qlp_coeff[i], i, lp_coeff[i], cmax, precision, *shift, (double)lp_coeff[i] * (double)(1 << *shift), floor((double)lp_coeff[i] * (double)(1 << *shift)));
|
fprintf(stderr,"FLAC__lpc_quantize_coefficients: compensating for overflow, qlp_coeff[%u]=%d, lp_coeff[%u]=%f, cmax=%f, precision=%u, shift=%d, q=%f, f(q)=%f\n", i, qlp_coeff[i], i, lp_coeff[i], cmax, precision, *shift, (FLAC__double)lp_coeff[i] * (FLAC__double)(1 << *shift), floor((FLAC__double)lp_coeff[i] * (FLAC__double)(1 << *shift)));
|
||||||
#endif
|
#endif
|
||||||
cmax *= 2.0;
|
cmax *= 2.0;
|
||||||
goto redo_it;
|
goto redo_it;
|
||||||
@@ -189,12 +189,12 @@ redo_it:
|
|||||||
fprintf(stderr,"FLAC__lpc_quantize_coefficients: negative shift = %d\n", *shift);
|
fprintf(stderr,"FLAC__lpc_quantize_coefficients: negative shift = %d\n", *shift);
|
||||||
#endif
|
#endif
|
||||||
for(i = 0; i < order; i++) {
|
for(i = 0; i < order; i++) {
|
||||||
qlp_coeff[i] = (FLAC__int32)floor((double)lp_coeff[i] / (double)(1 << nshift));
|
qlp_coeff[i] = (FLAC__int32)floor((FLAC__double)lp_coeff[i] / (FLAC__double)(1 << nshift));
|
||||||
|
|
||||||
/* double-check the result */
|
/* double-check the result */
|
||||||
if(qlp_coeff[i] > qmax || qlp_coeff[i] < qmin) {
|
if(qlp_coeff[i] > qmax || qlp_coeff[i] < qmin) {
|
||||||
#ifdef FLAC__OVERFLOW_DETECT
|
#ifdef FLAC__OVERFLOW_DETECT
|
||||||
fprintf(stderr,"FLAC__lpc_quantize_coefficients: compensating for overflow, qlp_coeff[%u]=%d, lp_coeff[%u]=%f, cmax=%f, precision=%u, shift=%d, q=%f, f(q)=%f\n", i, qlp_coeff[i], i, lp_coeff[i], cmax, precision, *shift, (double)lp_coeff[i] / (double)(1 << nshift), floor((double)lp_coeff[i] / (double)(1 << nshift)));
|
fprintf(stderr,"FLAC__lpc_quantize_coefficients: compensating for overflow, qlp_coeff[%u]=%d, lp_coeff[%u]=%f, cmax=%f, precision=%u, shift=%d, q=%f, f(q)=%f\n", i, qlp_coeff[i], i, lp_coeff[i], cmax, precision, *shift, (FLAC__double)lp_coeff[i] / (FLAC__double)(1 << nshift), floor((FLAC__double)lp_coeff[i] / (FLAC__double)(1 << nshift)));
|
||||||
#endif
|
#endif
|
||||||
cmax *= 2.0;
|
cmax *= 2.0;
|
||||||
goto redo_it;
|
goto redo_it;
|
||||||
@@ -369,50 +369,49 @@ void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__real lpc_error, unsigned total_samples)
|
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples)
|
||||||
{
|
{
|
||||||
double error_scale;
|
FLAC__double error_scale;
|
||||||
|
|
||||||
FLAC__ASSERT(total_samples > 0);
|
FLAC__ASSERT(total_samples > 0);
|
||||||
|
|
||||||
error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__real)total_samples;
|
error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__double)total_samples;
|
||||||
|
|
||||||
return FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error, error_scale);
|
return FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error, error_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC__real FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__real lpc_error, double error_scale)
|
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale)
|
||||||
{
|
{
|
||||||
if(lpc_error > 0.0) {
|
if(lpc_error > 0.0) {
|
||||||
FLAC__real bps = (FLAC__real)((double)0.5 * log(error_scale * lpc_error) / M_LN2);
|
FLAC__double bps = (FLAC__double)0.5 * log(error_scale * lpc_error) / M_LN2;
|
||||||
if(bps >= 0.0)
|
if(bps >= 0.0)
|
||||||
return bps;
|
return bps;
|
||||||
else
|
else
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
else if(lpc_error < 0.0) { /* error should not be negative but can happen due to inadequate float resolution */
|
else if(lpc_error < 0.0) { /* error should not be negative but can happen due to inadequate floating-point resolution */
|
||||||
return (FLAC__real)1e32;
|
return 1e32;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned FLAC__lpc_compute_best_order(const FLAC__real lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample)
|
unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned bits_per_signal_sample)
|
||||||
{
|
{
|
||||||
unsigned order, best_order;
|
unsigned order, best_order;
|
||||||
FLAC__real best_bits, tmp_bits;
|
FLAC__double best_bits, tmp_bits, error_scale;
|
||||||
double error_scale;
|
|
||||||
|
|
||||||
FLAC__ASSERT(max_order > 0);
|
FLAC__ASSERT(max_order > 0);
|
||||||
FLAC__ASSERT(total_samples > 0);
|
FLAC__ASSERT(total_samples > 0);
|
||||||
|
|
||||||
error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__real)total_samples;
|
error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__double)total_samples;
|
||||||
|
|
||||||
best_order = 0;
|
best_order = 0;
|
||||||
best_bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[0], error_scale) * (FLAC__real)total_samples;
|
best_bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[0], error_scale) * (FLAC__double)total_samples;
|
||||||
|
|
||||||
for(order = 1; order < max_order; order++) {
|
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) * (FLAC__real)(total_samples - order) + (FLAC__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__double)(total_samples - order) + (FLAC__double)(order * bits_per_signal_sample);
|
||||||
if(tmp_bits < best_bits) {
|
if(tmp_bits < best_bits) {
|
||||||
best_order = order;
|
best_order = order;
|
||||||
best_bits = tmp_bits;
|
best_bits = tmp_bits;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "FLAC/assert.h"
|
#include "FLAC/assert.h"
|
||||||
#include "protected/seekable_stream_decoder.h"
|
#include "protected/seekable_stream_decoder.h"
|
||||||
#include "protected/stream_decoder.h"
|
#include "protected/stream_decoder.h"
|
||||||
|
#include "private/float.h" /* for FLAC__double */
|
||||||
#include "private/md5.h"
|
#include "private/md5.h"
|
||||||
|
|
||||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||||
@@ -951,9 +952,9 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__
|
|||||||
const FLAC__uint64 range_bytes = upper_bound - lower_bound;
|
const FLAC__uint64 range_bytes = upper_bound - lower_bound;
|
||||||
#if defined _MSC_VER || defined __MINGW32__
|
#if defined _MSC_VER || defined __MINGW32__
|
||||||
/* with VC++ you have to spoon feed it the casting */
|
/* with VC++ you have to spoon feed it the casting */
|
||||||
pos = (FLAC__int64)lower_bound + (FLAC__int64)((double)(FLAC__int64)target_offset / (double)(FLAC__int64)range_samples * (double)(FLAC__int64)(range_bytes-1)) - approx_bytes_per_frame;
|
pos = (FLAC__int64)lower_bound + (FLAC__int64)((FLAC__double)(FLAC__int64)target_offset / (FLAC__double)(FLAC__int64)range_samples * (FLAC__double)(FLAC__int64)(range_bytes-1)) - approx_bytes_per_frame;
|
||||||
#else
|
#else
|
||||||
pos = (FLAC__int64)lower_bound + (FLAC__int64)((double)target_offset / (double)range_samples * (double)(range_bytes-1)) - approx_bytes_per_frame;
|
pos = (FLAC__int64)lower_bound + (FLAC__int64)((FLAC__double)target_offset / (FLAC__double)range_samples * (FLAC__double)(range_bytes-1)) - approx_bytes_per_frame;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -966,9 +967,9 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__
|
|||||||
if(pos < 0 && total_samples > 0) {
|
if(pos < 0 && total_samples > 0) {
|
||||||
#if defined _MSC_VER || defined __MINGW32__
|
#if defined _MSC_VER || defined __MINGW32__
|
||||||
/* with VC++ you have to spoon feed it the casting */
|
/* with VC++ you have to spoon feed it the casting */
|
||||||
pos = (FLAC__int64)first_frame_offset + (FLAC__int64)((double)(FLAC__int64)target_sample / (double)(FLAC__int64)total_samples * (double)(FLAC__int64)(stream_length-first_frame_offset-1)) - approx_bytes_per_frame;
|
pos = (FLAC__int64)first_frame_offset + (FLAC__int64)((FLAC__double)(FLAC__int64)target_sample / (FLAC__double)(FLAC__int64)total_samples * (FLAC__double)(FLAC__int64)(stream_length-first_frame_offset-1)) - approx_bytes_per_frame;
|
||||||
#else
|
#else
|
||||||
pos = (FLAC__int64)first_frame_offset + (FLAC__int64)((double)target_sample / (double)total_samples * (double)(stream_length-first_frame_offset-1)) - approx_bytes_per_frame;
|
pos = (FLAC__int64)first_frame_offset + (FLAC__int64)((FLAC__double)target_sample / (FLAC__double)total_samples * (FLAC__double)(stream_length-first_frame_offset-1)) - approx_bytes_per_frame;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ typedef struct FLAC__StreamEncoderPrivate {
|
|||||||
FLAC__uint64 *abs_residual_partition_sums; /* workspace where the sum of abs(candidate residual) for each partition is stored */
|
FLAC__uint64 *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 */
|
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 */
|
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 */
|
FLAC__double loose_mid_side_stereo_frames_exact; /* exact number of frames the encoder will use before trying both independent and mid/side frames again */
|
||||||
unsigned loose_mid_side_stereo_frames; /* rounded number of frames the encoder will use before trying both independent and mid/side frames again */
|
unsigned loose_mid_side_stereo_frames; /* rounded number of frames the encoder will use before trying both independent and mid/side frames again */
|
||||||
unsigned loose_mid_side_stereo_frame_count; /* number of frames using the current channel assignment */
|
unsigned loose_mid_side_stereo_frame_count; /* number of frames using the current channel assignment */
|
||||||
FLAC__ChannelAssignment last_channel_assignment;
|
FLAC__ChannelAssignment last_channel_assignment;
|
||||||
@@ -346,7 +346,7 @@ typedef struct FLAC__StreamEncoderPrivate {
|
|||||||
unsigned current_frame_number;
|
unsigned current_frame_number;
|
||||||
struct FLAC__MD5Context md5context;
|
struct FLAC__MD5Context md5context;
|
||||||
FLAC__CPUInfo cpuinfo;
|
FLAC__CPUInfo cpuinfo;
|
||||||
unsigned (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], unsigned data_len, FLAC__real residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
unsigned (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], unsigned data_len, FLAC__float 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_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)(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_64bit)(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_64bit)(const FLAC__int32 data[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||||
@@ -717,7 +717,7 @@ FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_init(FLAC__StreamEncoder
|
|||||||
encoder->private_->abs_residual_unaligned = encoder->private_->abs_residual = 0;
|
encoder->private_->abs_residual_unaligned = encoder->private_->abs_residual = 0;
|
||||||
encoder->private_->abs_residual_partition_sums_unaligned = encoder->private_->abs_residual_partition_sums = 0;
|
encoder->private_->abs_residual_partition_sums_unaligned = encoder->private_->abs_residual_partition_sums = 0;
|
||||||
encoder->private_->raw_bits_per_partition_unaligned = encoder->private_->raw_bits_per_partition = 0;
|
encoder->private_->raw_bits_per_partition_unaligned = encoder->private_->raw_bits_per_partition = 0;
|
||||||
encoder->private_->loose_mid_side_stereo_frames_exact = (double)encoder->protected_->sample_rate * 0.4 / (double)encoder->protected_->blocksize;
|
encoder->private_->loose_mid_side_stereo_frames_exact = (FLAC__double)encoder->protected_->sample_rate * 0.4 / (FLAC__double)encoder->protected_->blocksize;
|
||||||
encoder->private_->loose_mid_side_stereo_frames = (unsigned)(encoder->private_->loose_mid_side_stereo_frames_exact + 0.5);
|
encoder->private_->loose_mid_side_stereo_frames = (unsigned)(encoder->private_->loose_mid_side_stereo_frames_exact + 0.5);
|
||||||
if(encoder->private_->loose_mid_side_stereo_frames == 0)
|
if(encoder->private_->loose_mid_side_stereo_frames == 0)
|
||||||
encoder->private_->loose_mid_side_stereo_frames = 1;
|
encoder->private_->loose_mid_side_stereo_frames = 1;
|
||||||
@@ -1966,10 +1966,10 @@ FLAC__bool process_subframe_(
|
|||||||
unsigned *best_bits
|
unsigned *best_bits
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
FLAC__real fixed_residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1];
|
FLAC__float fixed_residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1];
|
||||||
FLAC__real lpc_residual_bits_per_sample;
|
FLAC__double lpc_residual_bits_per_sample;
|
||||||
FLAC__real autoc[FLAC__MAX_LPC_ORDER+1]; /* WATCHOUT: the size is important even though encoder->protected_->max_lpc_order might be less; some asm routines need all the space */
|
FLAC__real autoc[FLAC__MAX_LPC_ORDER+1]; /* WATCHOUT: the size is important even though encoder->protected_->max_lpc_order might be less; some asm routines need all the space */
|
||||||
FLAC__real lpc_error[FLAC__MAX_LPC_ORDER];
|
FLAC__double lpc_error[FLAC__MAX_LPC_ORDER];
|
||||||
unsigned min_lpc_order, max_lpc_order, 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_fixed_order, max_fixed_order, guess_fixed_order, fixed_order;
|
||||||
unsigned min_qlp_coeff_precision, max_qlp_coeff_precision, qlp_coeff_precision;
|
unsigned min_qlp_coeff_precision, max_qlp_coeff_precision, qlp_coeff_precision;
|
||||||
@@ -2017,7 +2017,7 @@ FLAC__bool process_subframe_(
|
|||||||
min_fixed_order = max_fixed_order = guess_fixed_order;
|
min_fixed_order = max_fixed_order = guess_fixed_order;
|
||||||
}
|
}
|
||||||
for(fixed_order = min_fixed_order; fixed_order <= max_fixed_order; fixed_order++) {
|
for(fixed_order = min_fixed_order; fixed_order <= max_fixed_order; fixed_order++) {
|
||||||
if(fixed_residual_bits_per_sample[fixed_order] >= (FLAC__real)subframe_bps)
|
if(fixed_residual_bits_per_sample[fixed_order] >= (FLAC__float)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 FLAC__SYMMETRIC_RICE
|
#ifndef FLAC__SYMMETRIC_RICE
|
||||||
@@ -2076,7 +2076,7 @@ FLAC__bool process_subframe_(
|
|||||||
}
|
}
|
||||||
for(lpc_order = min_lpc_order; lpc_order <= max_lpc_order; lpc_order++) {
|
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);
|
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 >= (FLAC__real)subframe_bps)
|
if(lpc_residual_bits_per_sample >= (FLAC__double)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 FLAC__SYMMETRIC_RICE
|
#ifndef FLAC__SYMMETRIC_RICE
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "FLAC/assert.h"
|
#include "FLAC/assert.h"
|
||||||
#include "protected/seekable_stream_decoder.h"
|
#include "protected/seekable_stream_decoder.h"
|
||||||
#include "protected/stream_decoder.h"
|
#include "protected/stream_decoder.h"
|
||||||
|
#include "../libFLAC/include/private/float.h" /* @@@ ugly hack, but how else to do? we need to reuse the float formats but don't want to expose it */
|
||||||
#include "../libFLAC/include/private/md5.h" /* @@@ ugly hack, but how else to do? we need to reuse the md5 code but don't want to expose it */
|
#include "../libFLAC/include/private/md5.h" /* @@@ ugly hack, but how else to do? we need to reuse the md5 code but don't want to expose it */
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
@@ -864,9 +865,9 @@ FLAC__bool seek_to_absolute_sample_(OggFLAC__SeekableStreamDecoder *decoder, FLA
|
|||||||
else {
|
else {
|
||||||
#if defined _MSC_VER || defined __MINGW32__
|
#if defined _MSC_VER || defined __MINGW32__
|
||||||
/* with MSVC you have to spoon feed it the casting */
|
/* with MSVC you have to spoon feed it the casting */
|
||||||
pos = (FLAC__uint64)((double)(FLAC__int64)(target_sample - left_sample) / (double)(FLAC__int64)(right_sample - left_sample) * (double)(FLAC__int64)(right_pos - left_pos));
|
pos = (FLAC__uint64)((FLAC__double)(FLAC__int64)(target_sample - left_sample) / (FLAC__double)(FLAC__int64)(right_sample - left_sample) * (FLAC__double)(FLAC__int64)(right_pos - left_pos));
|
||||||
#else
|
#else
|
||||||
pos = (FLAC__uint64)((double)(target_sample - left_sample) / (double)(right_sample - left_sample) * (double)(right_pos - left_pos));
|
pos = (FLAC__uint64)((FLAC__double)(target_sample - left_sample) / (FLAC__double)(right_sample - left_sample) * (FLAC__double)(right_pos - left_pos));
|
||||||
#endif
|
#endif
|
||||||
/* @@@ TODO: might want to limit pos to some distance
|
/* @@@ TODO: might want to limit pos to some distance
|
||||||
* before EOF, to make sure we land before the last frame,
|
* before EOF, to make sure we land before the last frame,
|
||||||
|
|||||||
Reference in New Issue
Block a user