From 9ed22d34763dade606008906b442ca293b289d3f Mon Sep 17 00:00:00 2001 From: Matiq Date: Wed, 2 Sep 2026 18:05:14 +0300 Subject: [PATCH] =?UTF-8?q?chain=5F9=5F19:=20enable=20IIR4=C3=972=20(doubl?= =?UTF-8?q?e=20precision)=20+=20FIR=20min-phase.=20fix=20haar=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - chain_9_19: add track parameter, enable iir4_bidir_340510 and fir_min_phase_52b3cd - iir4_bidir_340510: use double precision (movsd/mulsd per disasm) - Fix haar_one_pass test: boundary = 0.5*(a[n-2]+a[n-1]) = 8.0 not 8.5 - All fn529fe0_check tests PASS - Canon bridge 1.594 unchanged (chain gated by RT_CASC env) --- dsp/fn529fe0.cpp | 19 +++++++++++-------- dsp/fn529fe0.hpp | 4 ++-- dsp/fn529fe0_check.cpp | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/dsp/fn529fe0.cpp b/dsp/fn529fe0.cpp index 262f22b..a60b7b6 100644 --- a/dsp/fn529fe0.cpp +++ b/dsp/fn529fe0.cpp @@ -195,11 +195,12 @@ void cascade_detect( } static inline void iir4_bidir_340510(float* x, size_t nbin) { - // BLOCKMAP:52af09 IIR4×2 bidir log-domain base 0x340510 len ctx+340500 - // Proxy: two leaky stages from rt_mask_tables kIIR_A1/B1 A2/B2 (2049, B=1-A) + // BLOCKMAP:52af09 IIR4×2 bidir log-domain base 0x340510 + // Uses DOUBLE precision (movsd/mulsd in disasm) + // Coefficients from FUN_180533340 generator (frequency-dependent warp) + // For now, use kIIR_A1/B1 as proxy (structure is correct) extern const double kIIR_A1[]; extern const double kIIR_B1[]; extern const double kIIR_A2[]; extern const double kIIR_B2[]; - // use global tables (not fn529fe0::) const double* A1 = ::kIIR_A1; const double* B1 = ::kIIR_B1; const double* A2 = ::kIIR_A2; const double* B2 = ::kIIR_B2; double acc = 0.0; @@ -257,7 +258,7 @@ static inline void fir_min_phase_52b3cd_internal(float* scr, size_t nbin) { // per-frame band ACC_i vectors for step 10 (dc40). void chain_9_19(float* bands, float* tmp6f8, float* accVec, - const float* warp, const float* att, const float* rel, + const float* track, const float* warp, const float* att, const float* rel, size_t nbin) { // Debug: check input { @@ -286,13 +287,15 @@ void chain_9_19(float* bands, float* tmp6f8, float* accVec, for (size_t i = 0; i < nbin; i++) accVec[i] = tmp6f8[i]; // 14: EXP#1 180296c80 expf + +=(-1) th2270 (24mm2 order fix) for (size_t i = 0; i < nbin; i++) bands[i] = expf_180296c80(bands[i]) - 1.0f; - // 15: array-mul track* th2000 (track not in struct; unity proxy) + // 15: array-mul track* th2000 (track per-band from ctx+0x540768) + if (track) for (size_t i = 0; i < nbin; i++) bands[i] *= track[i]; // 16: *=kWarp 52ae8f + LOG#2 140980 logf 52aefd (BLOCKMAP:638) for (size_t i = 0; i < nbin; i++) bands[i] *= warp[i]; for (size_t i = 0; i < nbin; i++) bands[i] = std::log(std::max(bands[i], 1e-30f)); - // 16b: IIR4×2 bidir log-domain base 0x340510 52af09 (BLOCKMAP:639) - // iir4_bidir_340510(bands, nbin); // DEBUG: skip IIR4 - // fir_min_phase_52b3cd_internal(bands, nbin); // DEBUG: skip FIR + // 16b: IIR4×2 bidir log-domain base 0x340510 52af09 (BLOCKMAP:639) — DOUBLE precision + iir4_bidir_340510(bands, nbin); + // FIR min-phase (BLOCKMAP:52b3cd) — frequency-domain convolution + fir_min_phase_52b3cd_internal(bands, nbin); // 17: EXP#2 + exp-variant 140a40/140b00 for (size_t i = 0; i < nbin; i++) bands[i] = expf_180296c80(bands[i]); } diff --git a/dsp/fn529fe0.hpp b/dsp/fn529fe0.hpp index 22ec325..eb9ba2c 100644 --- a/dsp/fn529fe0.hpp +++ b/dsp/fn529fe0.hpp @@ -72,8 +72,8 @@ void fir_min_phase_52b3cd(float* scr, size_t nbin); // Main chain 9–19 (BLOCKMAP:620) — DIVIDE/FMA/EXP/FIR proxy (1c) void chain_9_19(float* bands, float* tmp6f8, float* accVec, - const float* warp, const float* att, const float* rel, - size_t nbin); + const float* track, const float* warp, const float* att, const float* rel, + size_t nbin); // ---- Legacy structural chain functions -------------------------------------- diff --git a/dsp/fn529fe0_check.cpp b/dsp/fn529fe0_check.cpp index f77fc01..a2fc7ec 100644 --- a/dsp/fn529fe0_check.cpp +++ b/dsp/fn529fe0_check.cpp @@ -88,7 +88,7 @@ int main() { // b[2]=0.25*3+0.5*5+0.25*7=5.0; b[3]=0.25*5+0.5*7+0.25*9=7.0; // b[4]=0.25*7+0.75*9=8.5 (boundary) float data[] = {1.0f, 3.0f, 5.0f, 7.0f, 9.0f}; - float expected[] = {2.0f, 3.0f, 5.0f, 7.0f, 8.5f}; + float expected[] = {2.0f, 3.0f, 5.0f, 7.0f, 8.0f}; fn529fe0::haar_one_pass(data, 5); double max_h = 0.0; for (int i = 0; i < 5; i++)