P4-prep: eval_lut_bin uses float logf/expf (matches decomp FUN_180563440 logf/expf, not double std::log/exp)

This commit is contained in:
2026-08-20 09:26:38 +03:00
parent 8fad2bbfd9
commit 5a4554a9a3
+4 -7
View File
@@ -61,22 +61,19 @@ static float eval_lut_bin(float x, const BandConfig* band) {
float result; float result;
if (band->flag == 0) { if (band->flag == 0) {
// Linear path (0x563595): t = x^(1/γ) if γ!=1 && x>0; val = A + (B-A)*t // Linear path (0x563595): t = x^(1/γ) if γ!=1 && x>0; val = A + (B-A)*t
// decomp: fVar16 = expf(logf(x)/gamma) (FLOAT log/exp)
float t = x; float t = x;
if (gamma != ONE && x > ZERO) { if (gamma != ONE && x > ZERO) {
double d = static_cast<double>(fabsf(x)); t = expf(logf(x) / gamma);
d = std::log(d) / static_cast<double>(gamma);
t = static_cast<float>(std::exp(d));
} }
result = band->A + (band->B - band->A) * t; result = band->A + (band->B - band->A) * t;
} else { } else {
// Power-law path (0x5635cd): t = 2x-1; if γ!=1 && t!=0: t = sign(t)·|t|^(1/γ) // Power-law path (0x5635cd): t = 2x-1; if γ!=1 && t!=0: t = sign(t)·|t|^(1/γ)
// val = A + (B-A)·0.5·(1+t) // val = A + (B-A)·0.5·(1+t); decomp: sign·expf(logf(|t|)/gamma)
float t = TWO * x - ONE; float t = TWO * x - ONE;
if (gamma != ONE && t != ZERO) { if (gamma != ONE && t != ZERO) {
float sign = (t < ZERO) ? NEG1 : ONE; float sign = (t < ZERO) ? NEG1 : ONE;
double d = static_cast<double>(fabsf(t)); t = expf(logf(fabsf(t)) / gamma) * sign;
d = std::log(d) / static_cast<double>(gamma);
t = static_cast<float>(std::exp(d)) * sign;
} }
result = band->A + (band->B - band->A) * HALF * (ONE + t); result = band->A + (band->B - band->A) * HALF * (ONE + t);
} }