B1/B2: ACC table double-deref 5407c8 + chain_9_19_sim op-by-op (BLOCKMAP 620-644)

This commit is contained in:
2026-08-30 18:07:15 +03:00
parent 359aaeb7cb
commit 7b479f5357
2 changed files with 58 additions and 0 deletions
+39
View File
@@ -62,6 +62,45 @@ def k_div_exact(a, b):
return np.asarray(b, dtype=np.float64) / np.asarray(a, dtype=np.float64)
def chain_9_19_sim(bands, tmp6f8, accVec, warp, att, rel, nbin=None):
"""CHAIN 9-19 BLOCKMAP:620-644 op-by-op (python структурный прокси).
bands: log-domain bands_curve_i (size nbin), tmp6f8: f6f8, accVec: ACC_i
warp: kWarp@5406a8, att@5406c8 rel@5406e8 — все 2049.
Возвращает bands mutated (log domain после IIR, перед FIR)."""
if nbin is None:
nbin = len(bands)
bands = np.asarray(bands, dtype=np.float64)
tmp6f8 = np.asarray(tmp6f8, dtype=np.float64)
accVec = np.asarray(accVec, dtype=np.float64)
# 9a zero already (vec698 irrelevant), 9b: tmp6f8 += 0.8 (p=1.0 *0.8)
# 9c DIVIDE dst=bands A=bands B=tmp6f8+0.8? Actually B=tmp6f8, but step 9b already added 0.8
# BLOCKMAP 24mm5: bands = tmp6f8 / bands (divide B/A)
# Use k_div_exact
b = tmp6f8 + 0.8 # proxy for step 9b effect (when tmp6f8 initially 0, b=0.8)
# If tmp6f8 already has data, 9b is additive 0.8, so b = tmp6f8 +0.8
# For calibration where tmp6f8 is 0, this yields 0.8/bands
bands = k_div_exact(np.maximum(bands, 1e-30), b)
# 10 dc40: tmp6f8 = bands - ACC
tmp6f8 = bands - accVec
# 11 FMA ATT/REL half-split
# true triples 12B re/im/coef, scalar proxy: upper half ATT, lower REL
for i in range(nbin):
if i < nbin // 2:
tmp6f8[i] += att[i] * accVec[i]
else:
tmp6f8[i] += rel[i] * accVec[i]
# 14 EXP#1 + -1 (order fixed 24mm2)
bands = k_exp_exact(bands) - 1.0
# 15 array-mul X*track (track is external, warp mul is step16)
# 16 *kWarp + LOG#2
bands = bands * warp
bands = np.log(np.maximum(bands, 1e-30))
# 16b IIR4x2 bidir log-domain base 0x340510 — proxy via kIIR_A1/B1
# keep as identity for now (real IIR is mild 0.003-0.19 per 24cc)
# FIR will be applied externally via fir_kernel
return bands, tmp6f8
# ------------------------------------------------------------ данные -----
def load_tract(path):
"""tract_*.txt: k am res lvl_raw band_level prewarp w"""
+19
View File
@@ -176,6 +176,25 @@ def main():
store['lut_G'] = struct.unpack('<f', fb4[12:16])[0]
store['lut_mode'] = fb4[16]
for off in SLOTS[1:]:
if off == 0x5407c8:
# ACC is table of pointers per-band [5407c8 + i*8] -> buf 2049 f32 each
for bi in range(4):
q = rd(ctx + off + 8*bi, 8)
if not q: continue
ptr = struct.unpack('<Q', q)[0]
if ptr < 0x10000: continue
ab = rd(ptr, 2049 * 4)
if ab:
store[hex(off) + f"_{bi}"] = np.frombuffer(ab, dtype='<f4').astype(np.float32)
# also store raw table pointer for debug
q = rd(ctx + off, 8)
if q:
ptr = struct.unpack('<Q', q)[0]
if ptr >= 0x10000:
ab = rd(ptr, NARR * 4)
if ab:
store[hex(off)] = np.frombuffer(ab, dtype='<f4').astype(np.float32)
continue
q = rd(ctx + off, 8)
if not q:
continue