原汁原味补全官方管线细节:0x8c CDF 中心、temporal 移植、uniform 分支、状态标志
- 抓取官方会话控制字段确认实际启用路径:0x109c0→0x11ee0→0x19740; temporal(0x41fe0=1)/帧差(0x230=0)/隔行平滑(0x41fe8=0)/0x30=0 全关 - 实现 0x8c=1 分支:CDF 中心=max(均值bin, 累计75%bin),lres 545→631 (官方 633,跨帧差 2 bin);用官方 cdf 离线验证 LUT 差异降至 123/1024 (集中在灰度过渡区,跨帧异步所致) - 移植 temporal filter(0x18001e920,0x41fe0>1 启用,默认关=官方) - 补 uniform 帧分支(0x109c0:fmin==fmax 时 LUT/gray 置中灰) - 补官方标志维护(0x4203c/0x42038/0x42004) - 实机确认:ref=15502(type1)、d=-2390、win/stats 正常
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
dev24=5 dev48=0 dev4c=0 dev54=31821 dev58=31321 dev5c=31970 dev60=31470
|
||||
11c=12 41340=1 41344=0 41348=1 4134c=C:\Users\ZXC\AppData\Local\Temp\Core160043865
|
||||
41558=6 41554=3 4155c=1024 41560=0 47944=8 47948=-50000 4794c=3 47950=0 47954=0 47938=19200
|
||||
T: 8304 18390 28495 33637 38730 47664
|
||||
B: 7804 17890 27995 33137 38230 47164
|
||||
C: 7987 9245 10566 11309 11944 13468
|
||||
D(blind cnt): 32 32 32 32 32
|
||||
loaded: 0 0 1 1 0 0
|
||||
offsets(41708): 128 308352 616576 924800 1233024 1541248
|
||||
thr_off(41758): 0 308224 616448 924672 1232896 1541120
|
||||
blind_off(417a8): 1849472 1850752 1852032 1853312 1854592 0
|
||||
blind_off2(417f4): 0 1280 2560 3840 5120 0
|
||||
bases: 416a0=00000232952d6040 416a8=000002329512ddc0 416b0=0000023294b8c820
|
||||
41840=2 41848=000002329536c840 41850=00000232953b7c40 41858=000002329512ddc0 41860=000002329537f840 41868=00000232953cac40 41870=0000023295140dc0 41878=0000023294b8d220
|
||||
41f0c=1 41f3c=1 41fdc=1 41fe0=1 41fe4=5 41fe8=0
|
||||
2d47=0 2d86=0 2d78=0 2d88=0 2d8c=0 2d90=0 2d94=0 2d98=0 2d9c=0
|
||||
47940=3840 44c50=0 44c60=0 44c64=0 44c68=0 42010=10825 42014=9036
|
||||
ctrl: 28=0 30=0 44=0 88=0 8c=1 90=0 230=0 234=1
|
||||
temporal: 41f40+30=0 +34=0 +38=0 +3c=0 41f68=0000000000000000 41f70=0 41f74=0 41f7c=0
|
||||
smo2: 41f90+30=160 +38=320 +3c=240 41fa8=00000232950e2c90 41fb0=0 41fb4=19200 41fbc=1
|
||||
flags: 4203c=1 42038=0 42040=0 42044=0 42004=1 41ffc=0 41fdc=1
|
||||
bufs: 270=0000023294ce15f0 278=0000000000000000 280=0000023294d16140 288=0000023294ceac00 290=0000023294cf4210 2a0=0000023294cfea20 2b0=0000023294b8b910 2c8=0000000500000000
|
||||
win: 42018=9998 4201c=227 44c48=76608 44c64=0 44c68=0
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -127,12 +127,20 @@ LUT 填充公式:在正确 center 下 834/1024 精确,其余 ±1~±58 为
|
||||
|
||||
1. 1024-bin 直方图:bin = ((nuc-lo) * 0xffc00000/(hi-lo)) >> 22(u32 算术)
|
||||
2. 3-tap 就地平滑(bin 0..1022)
|
||||
3. 双向 CDF(从 mean-bin 向两侧累积):
|
||||
3. **0x8c 分支(live=1)**:找平滑后直方图累计 >= 总计数×3/4 的第一个 bin,
|
||||
CDF 中心 = max(均值bin, 该bin)(实测 545 → 631,官方 633,跨帧差 2)
|
||||
4. 双向 CDF(从中心向两侧累积):
|
||||
- 向下:每累积 u21(=total>>12) 个计数 +0x100
|
||||
- 向上:<8*u21 时每 u21 个 +0x100,>=8*u21 时每 bin +0x200
|
||||
4. 对比度曲线 curve[k] = max(1, (0x300000 + k*0x800)>>13)
|
||||
5. 中心值二分搜索(fmin/fmax 对应 LUT 端约束)
|
||||
6. center 时域平滑 + 重填
|
||||
5. 对比度曲线 curve[k] = max(1, (0x300000 + k*0x800)>>13)
|
||||
6. 中心值二分搜索(fmin/fmax 对应 LUT 端约束)
|
||||
7. center 时域平滑 + 重填
|
||||
|
||||
验证:用官方同帧 cdf + 中心搜索,LUT 123/1024 差异,全部集中在 lres 上方
|
||||
灰度过渡区(±1-7 级),来源是官方 SDK 抓帧的跨帧异步(cdf/lut 不同帧),
|
||||
非算法差异。官方会话实测启用路径 = 0x109c0 → 0x11ee0 → 0x19740,
|
||||
temporal(0x41fe0=1)/帧差(0x230=0)/隔行平滑(0x41fe8=0)/0x30 gray 路径(0x30=0)
|
||||
全部关闭,demo3 默认一致,temporal 已移植作备用开关。
|
||||
|
||||
## 6. 2x 升采样(0x180019740,逐像素验证)
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -105,6 +105,7 @@ static int g_dev24 = 5; /* window base */
|
||||
static int g_dev4c_shift = 3; /* 0x4794c */
|
||||
static int g_dev48; /* contrast -100..100 */
|
||||
static int g_dev4c; /* window scale -100..100 */
|
||||
static int g_dev8c = 1; /* 0x8c: CDF pivot at 75% cumulative (live=1) */
|
||||
static int g_shift; /* 0x11c = 12 */
|
||||
static int g_ep_temps[64]; /* T[] */
|
||||
static int g_blind_cnt[64];
|
||||
@@ -133,6 +134,9 @@ static int g_f20[NPIX];
|
||||
static int g_fcount;
|
||||
static int g_manual_ffc;
|
||||
static int g_startup_ffc_done;
|
||||
static int g_flag4203c; /* official 0x4203c: auto-gray-path marker */
|
||||
static int g_flag42038; /* official 0x42038: temporal ran this frame */
|
||||
static int g_flag42004; /* official 0x42004: NUC output valid this frame */
|
||||
|
||||
/* ---- render state ---- */
|
||||
static unsigned short g_nuc[NPIX];
|
||||
@@ -358,6 +362,16 @@ static void official_stats_window(const unsigned short *nuc) {
|
||||
double var = (double)s2sum / NPIX - dmean * dmean;
|
||||
g_stat_std = (int)sqrt(var > 0 ? var : 0);
|
||||
(void)mi; (void)xi;
|
||||
/* official 0x109c0 uniform-frame branch: fmin==fmax -> window pinned,
|
||||
* LUT/gray reset to mid level, flag 0x4203c set (auto path marker). */
|
||||
if (mn == mx) {
|
||||
g_win_lo = g_win_hi = (int)mn;
|
||||
memset(g_lut, 0x80, sizeof(g_lut));
|
||||
memset(g_gray160, 0x80, sizeof(g_gray160));
|
||||
g_flag4203c = 1;
|
||||
return;
|
||||
}
|
||||
g_flag4203c = 0;
|
||||
/* window half (FUN_1800108a0): base = max(0x80, dev24*1000>>shift) */
|
||||
int base = (g_dev24 * 1000) >> g_dev4c_shift;
|
||||
if (base < 0x80) base = 0x80;
|
||||
@@ -408,6 +422,19 @@ static void lut_rebuild(const unsigned short *nuc) {
|
||||
int lres = ((g_stat_mean - g_win_lo) * 0x3ff) / span;
|
||||
if (lres < 0) lres = 0;
|
||||
if (lres > 1023) lres = 1023;
|
||||
/* official 0x8c=1 (live): CDF center = max(mean-bin, first bin whose
|
||||
* cumulative count reaches total*3/4). This moves the equalization
|
||||
* pivot to the 75% accumulation point (FUN_180011ee0). */
|
||||
if (g_dev8c) {
|
||||
unsigned acc = 0;
|
||||
int k = 0;
|
||||
while (k < 1024) {
|
||||
acc += g_hist1024[k];
|
||||
if (acc >= (total * 3 >> 2)) break;
|
||||
k++;
|
||||
}
|
||||
if (k < 1024 && k > lres) lres = k;
|
||||
}
|
||||
|
||||
/* 3. CDF: down from lres, up from lres+1 */
|
||||
unsigned u11 = 0, u13 = 0;
|
||||
@@ -511,6 +538,40 @@ static void lut_rebuild(const unsigned short *nuc) {
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------- temporal filter (FUN_18001e920) ---------------- */
|
||||
/* Official object at dev+0x41f40: +0x10 history (u16), +0x28 ring write
|
||||
* pointer, +0x30 counter, +0x34 pixel count, +0x38 period(mode), +0x3c
|
||||
* enabled. Active when dev+0x41fe0 > 1; live session = 1 (off).
|
||||
* period==1: out[i] = in[i] - ((in[i]-prev[i])>>1) when |d|<=thr (EMA). */
|
||||
static unsigned short g_tmp_hist[NPIX];
|
||||
static unsigned short *g_tmp_ring = g_tmp_hist;
|
||||
static int g_tmp_cnt;
|
||||
static int g_tmp_period = 1; /* dev+0x41f40+0x38 */
|
||||
static int g_tmp_enabled; /* dev+0x41f40+0x3c */
|
||||
static int g_tmp_mode = 1; /* dev+0x41fe0 */
|
||||
|
||||
static void temporal_apply(unsigned short *buf, int thr) {
|
||||
if (!g_tmp_enabled) return;
|
||||
g_tmp_cnt++;
|
||||
if (g_tmp_period < g_tmp_cnt) {
|
||||
if (g_tmp_period != 1) return;
|
||||
for (int i = 0; i < NPIX; ++i) {
|
||||
unsigned prev = g_tmp_hist[i];
|
||||
g_tmp_hist[i] = buf[i];
|
||||
int d = (int)buf[i] - (int)prev;
|
||||
if (d <= thr && -d <= thr && d != 0)
|
||||
buf[i] = (unsigned short)(buf[i] - (d >> 1));
|
||||
}
|
||||
} else {
|
||||
memcpy(g_tmp_ring, buf, NPIX * 2);
|
||||
}
|
||||
if (g_tmp_cnt % g_tmp_period != 0) {
|
||||
g_tmp_ring += NPIX;
|
||||
return;
|
||||
}
|
||||
g_tmp_ring = g_tmp_hist;
|
||||
}
|
||||
|
||||
/* ---------------- gray + 2x upscale (FUN_180019740) ---------------- */
|
||||
|
||||
static void gray_map(const unsigned short *nuc) {
|
||||
@@ -964,10 +1025,19 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show) {
|
||||
if (dbg) { fprintf(dbg, "RENDER f=%u has_ref=%d tables=%d\n", g_fcount, g_has_ref, g_tables_ready); fflush(dbg); }
|
||||
if (g_has_ref && g_tables_ready) {
|
||||
official_nuc_and_blind(g_live, g_nuc);
|
||||
/* official 0xca30: temporal filter when 0x41fe0 > 1 (live=1, off) */
|
||||
g_flag42038 = 0;
|
||||
if (g_tmp_mode > 1) {
|
||||
int thr = (g_dev24 * 1000 >> 1) >> g_dev4c_shift; /* 0x15680 static */
|
||||
if (thr > 0xffff) thr = 0xffff;
|
||||
temporal_apply(g_nuc, thr);
|
||||
g_flag42038 = 1;
|
||||
}
|
||||
official_stats_window(g_nuc);
|
||||
lut_rebuild(g_nuc);
|
||||
gray_map(g_nuc);
|
||||
upscale2x();
|
||||
g_flag42004 = 1;
|
||||
} else {
|
||||
memset(g_nuc, 0, sizeof(g_nuc));
|
||||
memset(g_gray160, 0, sizeof(g_gray160));
|
||||
|
||||
@@ -167,6 +167,30 @@ int main(int argc, char **argv) {
|
||||
*(int *)(dev + 0x47940), *(int *)(dev + 0x44c50), *(int *)(dev + 0x44c60),
|
||||
*(int *)(dev + 0x44c64), *(int *)(dev + 0x44c68),
|
||||
*(int *)(dev + 0x42010), *(int *)(dev + 0x42014));
|
||||
fprintf(cfg, "ctrl: 28=%d 30=%d 44=%d 88=%d 8c=%d 90=%d 230=%d 234=%d\n",
|
||||
*(int *)(dev + 0x28), *(int *)(dev + 0x30), *(int *)(dev + 0x44),
|
||||
*(int *)(dev + 0x88), *(int *)(dev + 0x8c), *(int *)(dev + 0x90),
|
||||
*(int *)(dev + 0x230), *(int *)(dev + 0x234));
|
||||
fprintf(cfg, "temporal: 41f40+30=%d +34=%d +38=%d +3c=%d 41f68=%p 41f70=%d 41f74=%d 41f7c=%d\n",
|
||||
*(int *)(dev + 0x41f40 + 0x30), *(int *)(dev + 0x41f40 + 0x34),
|
||||
*(int *)(dev + 0x41f40 + 0x38), *(int *)(dev + 0x41f40 + 0x3c),
|
||||
*(void **)(dev + 0x41f68), *(int *)(dev + 0x41f70), *(int *)(dev + 0x41f74),
|
||||
*(int *)(dev + 0x41f7c));
|
||||
fprintf(cfg, "smo2: 41f90+30=%d +38=%d +3c=%d 41fa8=%p 41fb0=%d 41fb4=%d 41fbc=%d\n",
|
||||
*(int *)(dev + 0x41f90 + 0x30), *(int *)(dev + 0x41f90 + 0x38),
|
||||
*(int *)(dev + 0x41f90 + 0x3c), *(void **)(dev + 0x41fa8),
|
||||
*(int *)(dev + 0x41fb0), *(int *)(dev + 0x41fb4), *(int *)(dev + 0x41fbc));
|
||||
fprintf(cfg, "flags: 4203c=%d 42038=%d 42040=%d 42044=%d 42004=%d 41ffc=%d 41fdc=%d\n",
|
||||
*(int *)(dev + 0x4203c), *(int *)(dev + 0x42038), *(int *)(dev + 0x42040),
|
||||
*(int *)(dev + 0x42044), *(int *)(dev + 0x42004), *(int *)(dev + 0x41ffc),
|
||||
*(int *)(dev + 0x41fdc));
|
||||
fprintf(cfg, "bufs: 270=%p 278=%p 280=%p 288=%p 290=%p 2a0=%p 2b0=%p 2c8=%p\n",
|
||||
*(void **)(dev + 0x270), *(void **)(dev + 0x278), *(void **)(dev + 0x280),
|
||||
*(void **)(dev + 0x288), *(void **)(dev + 0x290), *(void **)(dev + 0x2a0),
|
||||
*(void **)(dev + 0x2b0), *(void **)(dev + 0x2c8));
|
||||
fprintf(cfg, "win: 42018=%d 4201c=%d 44c48=%d 44c64=%d 44c68=%d\n",
|
||||
*(int *)(dev + 0x42018), *(int *)(dev + 0x4201c), *(int *)(dev + 0x44c48),
|
||||
*(int *)(dev + 0x44c64), *(int *)(dev + 0x44c68));
|
||||
fclose(cfg);
|
||||
}
|
||||
/* copy the DDT file */
|
||||
|
||||
Reference in New Issue
Block a user