fix(cw): repair FFT pipeline (NaN twiddle table + dead cond_22 path)

The waterfall showed mirrored/upside-down garbage because the FFT
never produced a valid spectrum:
1. g3.c.f() (high-precision sin) had its quadrant-0 case mangled by
   jadx into a nested-if that returned NaN for small angles - the
   twiddle factor table ended up with 329/1024 NaN entries.
   Restored the smali switch: case0->g(), case1->c(), case2->-g(),
   case3->-c().
2. i3.d.k() routed the runtime FFT (a5==0, single-thread path) into
   the else of if(a5!=1) instead of if(a5!=0), so the FFT never ran
   and the output stayed in the time domain (peak at bin 357 for a
   669Hz tone instead of bin 86).

Verified with a JVM harness (static-block tables + pure-tone inputs):
200Hz->bin26, 400Hz->bin51, 669Hz->bin86, 1000Hz->bin128, all exact.
Twiddle table NaN count: 329 -> 0.
This commit is contained in:
mckero committed 2026-08-04 06:55:03 +00:00
1 parent 3c5486cc5c
commit f731775346
2 files changed
+16 -14

No files matched your search

+14 -12
View File
@@ -455,21 +455,23 @@ public abstract class c {
if (z3) {
i4 ^= 2;
}
// smali 证实: f() = sin(象限 switch!):
// case 0 -> g(d5,0)(sin(0-π/2))
// case 1 -> c(d5,0)(sin(π/2-π) = cos(余角))
// case 2 -> -g(d5,0)(sin(π-3π/2) = -sin(余角))
// case 3 -> -c(d5,0)(sin(3π/2-2π) = -cos(余角))
// jadx 畸形嵌套 if 把 case 0 还原成 return NaN(小角度全 NaN!),
// 且 case 1/2/3 全走 g() —— 旋转因子表 329 个 NaN + 频谱错乱的根源!
if (i4 == 0) {
if (i4 != 1) {
if (i4 != 2) {
if (i4 != 3) {
return Double.NaN;
}
g4 = c(d5, d7);
} else {
g4 = g(d5, d7);
}
return -g4;
}
return g(d5, d7);
}
if (i4 == 1) {
return c(d5, d7);
}
return g(d5, d7);
if (i4 == 2) {
return -g(d5, d7);
}
return -c(d5, d7);
}
d7 = d6;
// jadx 还原不完整(smali 650 行, jadx 只还原 63 行); f() 未被任何代码调用(死代码),
+2 -2
View File
@@ -1211,7 +1211,8 @@ public final class d {
throw null;
}
}
} else {
}
} else {
// smali cond_22(a5==0, k=1 时运行时路径!): 单线程 FFT + 后处理
// jadx 原把这段错塞进 if(i8!=1) 的 else(死代码), a5==0 的 else 是幻觉(throw null)
int i26 = this.f11700a;
@@ -1264,4 +1265,3 @@ public final class d {
}
}
}
}