Files
ZXCLI 0bfb926892 完成官方管线全量逆向与 demo3 v5 复刻,清理仓库
- 逆向:Ghidra/IDA 全量反编译 CoreSDKLib.dll/ThermalSDK.dll/libthermalSDK.so/
  libcoresdk.so(ARM64)/libmagcore.so,导出 analysis/ida/export/
- 解码官方渲染管线:DDT 校准表加载->快门端点选择->Q12 插值->ref(4x type1 帧
  均值)->NUC 查表->盲元补偿->窗口->LUT1024 重建->2x 升采样->调色板
- 逐像素验证:NUC+盲元 0/19200、插值 0 误差、2x 0/76800、窗口一致
- demo3 v5:完整复刻官方管线(含 DDT 解析、FFC 状态机、快门温度驱动),
  修复 load_ddt 表错位导致的零像素问题
- 鬼影根因分析写入 analysis/reverse_20260813_full.md
- 心跳/恢复机制:analysis/session_state.md + tools/resume_rev.ps1
- 新增 tsdk_pair3 增强采集工具;历史工具归档 csdk/tools/legacy/;
  根目录抓帧残留删除,历史文档归档 analysis/history/
- csdk/README.md 完整使用文档;.gitignore/.gitattributes 补 LFS 规则
2026-08-13 23:16:12 +08:00

60 lines
3.1 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MAG160C 逆向会话恢复脚本
# 用法: powershell -ExecutionPolicy Bypass -File tools\resume_rev.ps1
# 作用: 检查设备/进程/工具状态, 重新编译 demo3, 采集 demo3 帧数据,
# 并在必要时跑官方采集, 输出对比所需文件。中断恢复时直接运行。
$ErrorActionPreference = "Continue"
$proj = "C:\Project\MAG160C"
$art = "$proj\build-artifacts"
$pairsDir = "$proj\analysis\pairs_final_20260813"
Write-Host "=== 1. 环境检查 ==="
$dev = Get-CimInstance Win32_PnPEntity -ErrorAction SilentlyContinue | Where-Object { $_.DeviceID -match "VID_833C" }
if ($dev) { Write-Host "设备: $($dev.Name) OK" } else { Write-Host "!!! 设备未连接" }
Write-Host "=== 2. 清理冲突进程 ==="
Stop-Process -Name mag160c_demo3, tsdk_pair3, tsdk_pair2 -Force -ErrorAction SilentlyContinue
Start-Sleep 1
Write-Host "=== 3. 编译 demo3 v5 ==="
gcc -O2 -w -DMAG160C_STATIC -I"$proj\csdk\third_party\libusb\win64" -I"$proj\csdk\include" -I"$proj\csdk\src" -o "$art\mag160c_demo3.exe" "$proj\csdk\tools\mag160c_demo3.c" "$proj\csdk\src\mag160c_display.c" "$proj\csdk\src\mag160c_error.c" "$proj\csdk\third_party\libusb\win64\libusb-1.0.x64.a" -lgdi32 -luser32
if ($LASTEXITCODE -ne 0) { Write-Host "编译失败"; exit 1 }
Write-Host "编译 OK"
Write-Host "=== 4. 编译官方采集工具 ==="
gcc -O2 -w -o "$art\tsdk_pair3.exe" "$proj\csdk\tools\tsdk_pair3.c"
if ($LASTEXITCODE -ne 0) { Write-Host "tsdk_pair3 编译失败"; exit 1 }
Write-Host "编译 OK"
Write-Host "=== 5. 检查 DDT ==="
if (-not (Test-Path "$art\mag160c_official.ddt")) {
if (Test-Path "$env:TEMP\Core160043865") {
Copy-Item "$env:TEMP\Core160043865" "$art\mag160c_official.ddt" -Force
Write-Host "DDT 从 %TEMP% 复制"
} else { Write-Host "!!! DDT 缺失" }
} else { Write-Host "DDT OK" }
Write-Host "=== 6. 运行 demo3 采集(35s,捕获帧在 fcount=300/600/900==="
Remove-Item "$art\demo3_frame_capture.bin" -Force -ErrorAction SilentlyContinue
Remove-Item "$art\demo3_diag.txt" -Force -ErrorAction SilentlyContinue
Start-Process "$art\mag160c_demo3.exe" -WorkingDirectory $art
Start-Sleep 35
Stop-Process -Name mag160c_demo3 -Force -ErrorAction SilentlyContinue
if (Test-Path "$art\demo3_frame_capture.bin") {
Write-Host "捕获 OK: $((Get-Item "$art\demo3_frame_capture.bin").Length) 字节"
} else { Write-Host "!!! 无捕获文件, 检查 demo3_diag.txt" }
Write-Host "=== 7. 官方采集(同场景, 需保持镜头不动)==="
if (-not (Test-Path "$pairsDir\pair_000.raw")) {
New-Item -ItemType Directory -Path $pairsDir -Force | Out-Null
& "$art\tsdk_pair3.exe" $pairsDir 8 6000 > "$pairsDir\run.log" 2>&1
Move-Item "$proj\config.txt" "$pairsDir\config.txt" -Force -ErrorAction SilentlyContinue
Move-Item "$proj\pair_0*.meta", "$proj\pair_0*.win" $pairsDir -Force -ErrorAction SilentlyContinue
Write-Host "官方采集完成"
} else { Write-Host "官方数据已存在, 跳过" }
Write-Host "=== 8. 对比 ==="
python "C:\Users\ZXC\AppData\Local\Temp\opencode\compare_live.py"
Write-Host "=== 完成。下一步见 analysis\session_state.md ==="