Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

fix: reset temporal history on moderate-luma scene changes

Veyra Goal Agent3fc3e2246ccc
diff --git a/docs/REVIEW_SCENE_BOUNDARIES_2026-09-08.md b/docs/REVIEW_SCENE_BOUNDARIES_2026-09-08.md
new file mode 100644
index 00000000..b78bd320
--- /dev/null
+++ b/docs/REVIEW_SCENE_BOUNDARIES_2026-09-08.md
@@ -0,0 +1,17 @@
+# Independent scene-boundary review — cycles 71–73
+
+Reviewer `review_scene_boundaries`, fresh context and read-only. Base `fb11585`. **Scoped PASS**, no introduced P0/P1/P2. Full optimization Goal remains in progress.
+
+Independent preflight 71 checks and phase7 75 checks exit 0. Delivery evidence: `logs/delivery/55725c1cd58846c59342d5e624562773/result.json`, 41.568 seconds. Initial environment-only preflight failure is retained; setting the WindowsPowerShell child PSModulePath resolved unavailable Get-FileHash. No gate or control changes.
+
+Fresh evidence root: `logs/optimization-goal-20260908/review-scene-fc558d881d0b404fbe51e5f6f2ebd6e0/`.
+
+- `scene.log`: 14 checks passed.
+- `motion_validation.log`: both axes, cost16/31/32/255, bounds and fractional vectors passed; debug errors 0. Legacy256 rejected/768 retained, validated512 rejected/344 retained/168 attenuated.
+- `quality.json` / `quality.log`: actual RTX Feature18 Create result0x1, non-null handle, SEH0; NR600/NVOF594, failures/debug errors0. Boundary frames150/300/301/302/450.
+- `fg.log`: actual app2X export600source/594generated/6holds/1200output, success.
+- `decode-check.json`: independently decoded1200frames. Five boundary holds match previous real frame, maximum mean Y difference.048694/255; difference from current frames25.29–106.70/255.
+
+Reviewer confirmed reset clears previous validity before NVOF, SR/NR receive reset, and FG suppresses cross-boundary candidates. Export integrity code unchanged. Fixture transposes geometry, vector components and expectations correctly. Tracked diff fingerprint before/after `4343fa50af201ad1393b6bec4228e3c18fb4447d`, unchanged; no runtime/SDK/log/capture tracked.
+
+Limits: five candidates are three authored cuts plus two flash boundaries. Natural exposure transitions and equal-histogram cuts remain heuristic limits. Other four clips' zero-boundary evidence was cross-checked, not independently rerun. Periodic guidance samples do not prove perceptual improvement. No full Goal, physical capture, natural quality, long stability or distribution approval.
diff --git a/docs/SCENE_MOTION_CORPUS_2026-09-08.md b/docs/SCENE_MOTION_CORPUS_2026-09-08.md
new file mode 100644
index 00000000..fe76df8c
--- /dev/null
+++ b/docs/SCENE_MOTION_CORPUS_2026-09-08.md
@@ -0,0 +1,26 @@
+# Motion corpus and scene-boundary repair
+
+Phase 7 optimization remains in progress. Cycles 71–73 are a scoped correction, not full Q6/Q7 completion. Export integrity checks are unchanged.
+
+## Findings and change
+
+The original 600-frame cut/flash/duplicate clip contains scene transitions at zero-based frames 150, 300 and 450, plus a white flash at 301. The previous two reported cuts were actually flash appearance/return at 301/302. All three scene transitions were missed: their normalized SAD was .1041/.2118/.2142, below the mandatory .3 threshold, despite histogram distance .9449/1/1.
+
+The shared scene analyzer now additionally resets on SAD > .08 AND histogram L1/2 distance > .9. The existing .3/.5 path remains. Logs identify the frame, PTS, scores and candidate reason. This is a conservative temporal-discontinuity heuristic; a counter includes exposure transitions and is not a count of semantically proven cuts. Equal-histogram scene changes can still be missed, and large exposure changes can reset. No future frame, model, new pixel readback or export verification was added.
+
+Cycle 71 independently extends the known-vector GPU fixture to vertical motion, top/bottom boundaries and cost 16/31/32/255. Both axes pass: legacy 256 rejected/768 retained, validation 512 rejected/344 retained/168 attenuated, debug errors 0. Product shader unchanged in this cycle. Scene unit tests now contain 14 checks including moderate-luma replacement and negative controls.
+
+## Actual execution
+
+All paths below are under `logs/optimization-goal-20260908/`. Each GPU child has a 275-second watchdog; observed corpus children took 8.3–9.6 seconds. Build: `powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/build.ps1 -Root "$PWD" -Preset x64-release`, log `build-cycle73.log`, exit 0.
+
+- Before scene fix: `motion-corpus-17987af4f4a540daba704b7dd0d4db29/`, five 600-frame 1080p clips, same EXE validated vs `--legacy-motion`. Each child exit 0, NR 600, debug errors 0. These are NR/NVOF runs, not FG runs. The initial runner `motion-corpus-cb15c7b16c3f45f1a518011e497ae722` failed because its process ExitCode was unavailable; a retained Handle fixed the runner, and the complete matrix was rerun.
+- Diagnostic statistics are 64×36 samples every 60 frames, 23,040 samples per clip, **not final-frame statistics**. The original summary's `Final` property names were wrong; raw records are retained. Translation nonzero samples stay 23,040; occlusion falls 20,216→19,554, particles 16,327→16,254, UI 12,053→12,040. This proves changed gating, not improved perceived quality. Mixed GPU command-list timing is not isolated shader time.
+- Source Y-plane diagnostic `scene-source-*.json`, generated by `inspect-scene.py`, reproduces exact product sampling, identifies the missed cuts, and predicts zero new candidates in the other four clips.
+- After scene fix: `motion-corpus-4f1a465d927b4194b7386a74e56f900c/`, five validated 600-frame runs, exit 0/debug errors 0. Four clips: 0 boundaries, NR 600/NVOF 599. Cut/flash: exactly 150/300/301/302/450, NR 600/NVOF 594. Counts are five reset candidates: three authored cuts and two flash boundaries. All frames processed.
+- Actual app D3D12 NVENC 2X export: `fg-scene-b1e15c6c88b64b00aee2b6af5f8c4990/`, command recorded in `run-fg-scene.ps1`: `veyra.exe <cut clip> --export-out <unique output.mp4> --max-frames 600 --fg --fg-multiplier 2`. Exit 0; source 600, generated 594, holds 6 (five boundaries plus tail), output 1200. This is native 1080p, not native 4K evidence. Source has no audio.
+- Independent FFmpeg decode of that export: 1200 frames, 1920×1080 H.264 at 120 fps. Five boundary holds at output indices 299/599/601/603/899 differ from previous real frames by mean Y error ≤ .049/255, versus current frames by 25.3–106.7/255 (`decode-check.json`). Lossy encode explains nonzero hold differences. No cross-boundary generated image was substituted at these positions. This development decode did not change product export checks.
+
+## Remaining scope
+
+Synthetic motion gating and boundary correctness do not prove natural temporal quality, FG interpolation quality on occlusions, or SR reconstruction benefit. Bidirectional A/B flow cost/benefit, RTX Video SR/depth candidates and natural comparisons remain pending. Physical capture/audio/latency, long stability and redistribution remain separate. Gate and independent review are recorded in WORKLOG/EVIDENCE after execution.
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 99dfa073..23e2c76c 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1213,3 +1213,9 @@ review_motion_validation scopedPASS, no introducedP0/P1/P2. Independent prefligh
AppD14DFB94A933E1BE85B9972CADB628BC58E320C26D53B4887F2102BFA2E48D46; quality21A265B0645BD8FA5556E527776155FD26AB7F65DF2EBAC9E523CF653D0988F1; motiontestC5F3AE03B74EB56B106C070FD275095811DE0CE18599411B564C1F2B85C25428. Reviewer trackedfingerprinte3db68bd6d230d63b0752d9f5d6fa84be6837252 unchanged. Product export integrity remains unchanged.
Limits: encoded-luma.03/.15 heuristic cannot detect isoluminant mismatch or repetitive wrong matches; shortened/zero motion does not prove safe model history exclusion. Unit matrix currently horizontalpositive/negative/fractional only; next atomic task extends nonzerovertical/top-bottom/cost31-32/intermediateconfidence, then actual occlusion/cut/FG comparisons and A/B bidirectional cost/benefit. Natural footage/Q7/physical acceptance remain pending. Phase7/Goalin_progress; scopedpass only.
+
+## Cycles71-73 scoped scene repair candidate
+See docs/SCENE_MOTION_CORPUS_2026-09-08.md. Motion vertical/cost GPU checks and scene14 checks PASS. Fixed all3 authored cuts missed by old .3 SAD threshold; actual shared graph logs150/300/301/302/450,600NR/594NVOF/debug0. Four other600frameclips zero new boundaries. Actual1080p2X export fg-scene-b1e15c6c88b64b00aee2b6af5f8c4990 exit0:600source/594generated/6hold/1200output; full diagnosticdecode1200,5boundaryholds matchpreviousYmean<=.049/255. Buildcycle73exit0. No exportintegrity change, no naturalquality conclusion. Frozen gate/review pending.
+
+## Cycles71-73 independent scoped PASS
+review_scene_boundaries no introducedP0/P1/P2; docs/REVIEW_SCENE_BOUNDARIES_2026-09-08.md. Independentpreflight71/phase7delivery55725c1cd58846c59342d5e62456277341.568s75PASS. Freshreview-scene-fc558d881d0b404fbe51e5f6f2ebd6e0:scene14/motionbothaxesdebug0;RTXNR600NVOF594/Create0x1SEH0;actualFG600source594generated6holds1200output andindependentfull1200decode. BoundarypreviousYerror<=.048694/255. Trackedfingerprint4343fa50af201ad1393b6bec4228e3c18fb4447dunchanged. Q6/Q7/natural/physical/long-term/distribution not passed.
diff --git a/include/veyra/core/SceneCadenceAnalyzer.h b/include/veyra/core/SceneCadenceAnalyzer.h
index 27815ed9..6adcc866 100644
--- a/include/veyra/core/SceneCadenceAnalyzer.h
+++ b/include/veyra/core/SceneCadenceAnalyzer.h
@@ -11,7 +11,7 @@
namespace veyra::core {
struct SceneAnalysisResult {
- bool isSceneCut = false; // hard cut detected
+ bool isSceneCut = false; // reset candidate; also includes abrupt exposure transitions
bool isFlash = false; // bright flash (not a cut)
bool isDuplicate = false; // duplicate of previous frame
bool isCadenceBreak = false; // PTS irregularity
@@ -27,6 +27,10 @@ public:
struct Config {
double sceneCutHistogramThreshold = 0.5; // L1 distance for hard cut
double sceneCutSadThreshold = 0.3; // normalized SAD for hard cut
+ // Similar average brightness does not imply temporal continuity. Require
+ // nearly disjoint histograms before accepting the lower SAD threshold.
+ double replacementHistogramThreshold = 0.9;
+ double replacementSadThreshold = 0.08;
double flashHistogramThreshold = 0.1; // flash: high SAD, low hist distance
double flashSadThreshold = 0.5; // flash: SAD above this
double duplicateSadThreshold = 0.001; // near-zero SAD = duplicate
diff --git a/loop/EVIDENCE.md b/loop/EVIDENCE.md
index 3d38ba8b..89ea2b1c 100644
--- a/loop/EVIDENCE.md
+++ b/loop/EVIDENCE.md
@@ -516,3 +516,9 @@ review_motion_validation scopedPASS, no introducedP0/P1/P2. Independent prefligh
AppD14DFB94A933E1BE85B9972CADB628BC58E320C26D53B4887F2102BFA2E48D46; quality21A265B0645BD8FA5556E527776155FD26AB7F65DF2EBAC9E523CF653D0988F1; motiontestC5F3AE03B74EB56B106C070FD275095811DE0CE18599411B564C1F2B85C25428. Reviewer trackedfingerprinte3db68bd6d230d63b0752d9f5d6fa84be6837252 unchanged. Product export integrity remains unchanged.
Limits: encoded-luma.03/.15 heuristic cannot detect isoluminant mismatch or repetitive wrong matches; shortened/zero motion does not prove safe model history exclusion. Unit matrix currently horizontalpositive/negative/fractional only; next atomic task extends nonzerovertical/top-bottom/cost31-32/intermediateconfidence, then actual occlusion/cut/FG comparisons and A/B bidirectional cost/benefit. Natural footage/Q7/physical acceptance remain pending. Phase7/Goalin_progress; scopedpass only.
+
+## Cycles71-73 scoped scene repair candidate
+See docs/SCENE_MOTION_CORPUS_2026-09-08.md. Motion vertical/cost GPU checks and scene14 checks PASS. Fixed all3 authored cuts missed by old .3 SAD threshold; actual shared graph logs150/300/301/302/450,600NR/594NVOF/debug0. Four other600frameclips zero new boundaries. Actual1080p2X export fg-scene-b1e15c6c88b64b00aee2b6af5f8c4990 exit0:600source/594generated/6hold/1200output; full diagnosticdecode1200,5boundaryholds matchpreviousYmean<=.049/255. Buildcycle73exit0. No exportintegrity change, no naturalquality conclusion. Frozen gate/review pending.
+
+## Cycles71-73 independent scoped PASS
+review_scene_boundaries no introducedP0/P1/P2; docs/REVIEW_SCENE_BOUNDARIES_2026-09-08.md. Independentpreflight71/phase7delivery55725c1cd58846c59342d5e62456277341.568s75PASS. Freshreview-scene-fc558d881d0b404fbe51e5f6f2ebd6e0:scene14/motionbothaxesdebug0;RTXNR600NVOF594/Create0x1SEH0;actualFG600source594generated6holds1200output andindependentfull1200decode. BoundarypreviousYerror<=.048694/255. Trackedfingerprint4343fa50af201ad1393b6bec4228e3c18fb4447dunchanged. Q6/Q7/natural/physical/long-term/distribution not passed.
diff --git a/loop/JOURNAL.md b/loop/JOURNAL.md
index cb50bec3..9a7ac378 100644
--- a/loop/JOURNAL.md
+++ b/loop/JOURNAL.md
@@ -1524,3 +1524,21 @@ review_motion_validation scopedPASS, no introducedP0/P1/P2. Independent prefligh
AppD14DFB94A933E1BE85B9972CADB628BC58E320C26D53B4887F2102BFA2E48D46; quality21A265B0645BD8FA5556E527776155FD26AB7F65DF2EBAC9E523CF653D0988F1; motiontestC5F3AE03B74EB56B106C070FD275095811DE0CE18599411B564C1F2B85C25428. Reviewer trackedfingerprinte3db68bd6d230d63b0752d9f5d6fa84be6837252 unchanged. Product export integrity remains unchanged.
Limits: encoded-luma.03/.15 heuristic cannot detect isoluminant mismatch or repetitive wrong matches; shortened/zero motion does not prove safe model history exclusion. Unit matrix currently horizontalpositive/negative/fractional only; next atomic task extends nonzerovertical/top-bottom/cost31-32/intermediateconfidence, then actual occlusion/cut/FG comparisons and A/B bidirectional cost/benefit. Natural footage/Q7/physical acceptance remain pending. Phase7/Goalin_progress; scopedpass only.
+
+## Cycle71 - motion validation boundary completion
+Previous turn progress fb11585 fused motion validation, independently reviewed. Clean HEAD/noSTOP. Extend shader fixture to transposed vertical motion/top-bottom bounds and cost16/31/32/255; unchanged product logic. Run real GPU test then frozen gate, retain per-test <=300s.
+
+Cycle71 GPU horizontal/vertical costboundary tests PASS debug0; gate75PASS.
+## Cycle72 - actual motion corpus A/B evidence
+Run existing pinned1080p corpus through current shared NR/NVOF,600framesperclip toinclude allcuts/flash/duplicate. SameEXE legacyflag0 vsvalidation3, report periodic samples; no invented fulltrajectory metric. Eachchild275secondwatchdog. No product edits during experiment.
+Cycle72 correction: quality motion/confidence statistics aggregate 64x36 samples every60frames (23040 samples), not final-frame-only. Ten600frame NR/NVOF runs exit0/debug0; source diagnostic shows ALL THREE actual cuts150/300/450 missed; prior count2 corresponds to flash301/302. No scene-quality PASS. Initial runner nullExitCode retained; cached process Handle and fresh complete matrix exit0.
+## Cycle73 - moderate-luma hard discontinuity repair
+Before edits: source-exact64x36 Y-plane diagnostics for all five600frame corpus clips find strong histogram replacement with SAD.104/.212/.214 at actual cuts. Add conservative alternate threshold SAD>.08 AND histogram L1/2>.9, retaining old high-SAD branch. Five affected boundaries include flash appearance/return; without future-frame classification these are reset candidates, not five semantic cuts. Four other synthetic clips produce no candidate resets. Add regression tests and actual boundary logs, then NR/FG corpus, gate and independent review. This heuristic cannot guarantee detection of equal-histogram cuts or eliminate exposure false positives; no new model/readback/lookahead.
+
+## Cycles71-73 scoped scene repair candidate
+See docs/SCENE_MOTION_CORPUS_2026-09-08.md. Motion vertical/cost GPU checks and scene14 checks PASS. Fixed all3 authored cuts missed by old .3 SAD threshold; actual shared graph logs150/300/301/302/450,600NR/594NVOF/debug0. Four other600frameclips zero new boundaries. Actual1080p2X export fg-scene-b1e15c6c88b64b00aee2b6af5f8c4990 exit0:600source/594generated/6hold/1200output; full diagnosticdecode1200,5boundaryholds matchpreviousYmean<=.049/255. Buildcycle73exit0. No exportintegrity change, no naturalquality conclusion. Frozen gate/review pending.
+
+Cycle73 gate initial wrapper FAIL: phase.state needs_review is not accepted by the protected state schema; delivery body exit0 and no project mutation. Restored phase.state=in_progress; currentTask explicitly remains needs independent review. No gate/control change. Retain gate-cycle73.log and rerun frozen wrapper.
+
+## Cycles71-73 independent scoped PASS
+review_scene_boundaries no introducedP0/P1/P2; docs/REVIEW_SCENE_BOUNDARIES_2026-09-08.md. Independentpreflight71/phase7delivery55725c1cd58846c59342d5e62456277341.568s75PASS. Freshreview-scene-fc558d881d0b404fbe51e5f6f2ebd6e0:scene14/motionbothaxesdebug0;RTXNR600NVOF594/Create0x1SEH0;actualFG600source594generated6holds1200output andindependentfull1200decode. BoundarypreviousYerror<=.048694/255. Trackedfingerprint4343fa50af201ad1393b6bec4228e3c18fb4447dunchanged. Q6/Q7/natural/physical/long-term/distribution not passed.
diff --git a/loop/STATE.json b/loop/STATE.json
index 4f35c427..d90b2c57 100644
--- a/loop/STATE.json
+++ b/loop/STATE.json
@@ -76,19 +76,19 @@
}
],
"cycle": {
- "completed": 70,
+ "completed": 73,
"maximum": 120,
"sameFailureAttempts": 0,
"maximumSameFailureAttempts": 3,
"noProgressCycles": 0,
"maximumNoProgressCycles": 5
},
- "currentTask": "Fused motion bounds/photometric checks and residual harness repair independently reviewed PASS; Q6 quality evaluation ongoing",
+ "currentTask": "Cycles71-73 moderate-luma scene reset and motion boundaries independently reviewed PASS; remaining Q6/Q7 optimization ongoing",
"lastGate": {
"name": "phase7",
"status": "passed",
"exitCode": 0,
- "evidence": "logs/delivery/240031138e804d7f84a42a57a2069759/result.json 41.996s;75checks"
+ "evidence": "logs/delivery/55725c1cd58846c59342d5e624562773/result.json 41.568s;75checks"
},
"lastFailureFingerprint": "",
"failureLedger": [
@@ -107,8 +107,8 @@
"Current USB2 1080p50 physical throughput passed; user perceived latency/audio/actual FG display cadence still need confirmation.",
"Public proprietary runtime distribution rights unresolved; local delivery only."
],
- "nextAction": "Extend motion GPU matrix to vertical/top-bottom/cost31-32/intermediate confidence; then occlusion/cut/FG corpus and bidirectional A/B ROI, followed by Q7 candidates/natural reconstruction",
- "updatedAt": "2026-09-08T11:08:10.377584+00:00",
+ "nextAction": "Q6 A/B bidirectional flow cost/benefit and FG occlusion quality; Q7 controlled depth response before model investment, RTX Video SR SDK dependency and natural SR reconstruction",
+ "updatedAt": "2026-09-08T11:32:50.944787+00:00",
"deliveryPlan": "docs/ACTIVE_DELIVERY_PLAN.md",
"captureAcceptance": "throughput_short_test_passed_user_latency_audio_pending",
"testInvocationLimitSeconds": 300,
@@ -129,7 +129,8 @@
"docs/REVIEW_NR_PROTECTION_2026-09-08.md: scopedPASS afterP2syncfix; GPU/presets andactualUI dirty/master-off independently verified",
"Cycle66 independent scoped PASS: image-e8c7b9377cd94f68bd50fb189bd8b49c 21.916s; feather2/32, disjoint, central tile seams. No product changes.",
"Cycles67-68 independent scoped PASS: temporal image6508c7cc PASS; optional R8d5f8d738/RGBAd9974360 reproduce expected-contract FAIL, no product integration.",
- "Cycles69-70 independentPASS: motionshader/debug0; repairedresidual24constants; image29e690f3 andSR60A/B GBV0. Natural/FGquality still open."
+ "Cycles69-70 independentPASS: motionshader/debug0; repairedresidual24constants; image29e690f3 andSR60A/B GBV0. Natural/FGquality still open.",
+ "Cycles71-73 independent scopedPASS: scene14/motionverticalcostboundary; NR600NVOF594; actualFG600source594generated6hold1200output independentlydecoded, docs/REVIEW_SCENE_BOUNDARIES_2026-09-08.md"
],
"reviewBaseCommit": "6f0ebaa687e3966d989bf138c86b6882380f20fb",
"localDelivery": "capture_fix_candidate_needs_review",
@@ -267,9 +268,11 @@
"testInvocationLimitSeconds": 300,
"productModified": true,
"consecutiveBlockedGoalTurns": 0,
- "previousGoalTurnClassification": "progress: d2921d2 temporal protection/private resource decision",
- "currentGoalTurnClassification": "progress: fixed residual harness P2; fused motion bounds/photometric validation implemented and independently tested",
+ "previousGoalTurnClassification": "progress: fixed residual harness P2; fused motion bounds/photometric validation implemented and independently tested",
+ "currentGoalTurnClassification": "progress: motion corpus found all3authoredcuts missed; repaired moderate-luma scene reset and independently verified actual2Xboundaryholds",
"controlSynchronizationAuthorization": "2026-09-08 user: 确认,给你全部权限; applies to previously proposed exact two-hash synchronization",
- "diagnosticFindings": []
+ "diagnosticFindings": [
+ "Q7 read-only dependency check: RTXVideoSDK not present in third_party_local; official1.1download redirects NVIDIA login. Localdepthfile vitl is Large, not permitted Small; no verified Small ONNX/provider. No dependency integrated or performance claimed."
+ ]
}
}
diff --git a/src/core/SceneCadenceAnalyzer.cpp b/src/core/SceneCadenceAnalyzer.cpp
index e8d6aa6c..7b094dbe 100644
--- a/src/core/SceneCadenceAnalyzer.cpp
+++ b/src/core/SceneCadenceAnalyzer.cpp
@@ -51,9 +51,14 @@ SceneAnalysisResult SceneCadenceAnalyzer::analyze(uint64_t frameId,
++flashCount_;
// Flash is NOT a cut don't reset.
}
- // Hard cut: high SAD AND high histogram distance.
- else if (sad > config_.sceneCutSadThreshold &&
- result.histogramDistance > config_.sceneCutHistogramThreshold) {
+ // Hard discontinuity: either large per-pixel change, or almost complete
+ // histogram replacement with moderate change. The latter catches cuts with
+ // similar brightness. A flash can also trigger this conservative reset;
+ // without future frames this is not a semantic scene classification.
+ else if ((sad > config_.sceneCutSadThreshold &&
+ result.histogramDistance > config_.sceneCutHistogramThreshold) ||
+ (sad > config_.replacementSadThreshold &&
+ result.histogramDistance > config_.replacementHistogramThreshold)) {
result.isSceneCut = true;
++sceneCutCount_;
}
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index a436b6ea..215623bc 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -666,7 +666,11 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
if(cadence_.conflicts(desc_.contentRate)&&realFrameIndex_%60==0)veyra::log::warn("cadence","requested content-rate identification conflicts with observed motion; preserving source timestamps");
out.contentDuplicate=desc_.contentRate!=engine::ContentRate::Transport&&previousLuma_.size()==sample.size()&&sad<0.0001;
const auto analysis=scene_.analyze(realFrameIndex_,hist,sad,static_cast<uint64_t>(std::max(0.0,ptsMs)*1000));
- if(analysis.isSceneCut||analysis.isCadenceBreak){reset=true;prevValid_=false;if(analysis.isSceneCut)++metrics_.sceneCutCount;}
+ if(analysis.isSceneCut||analysis.isCadenceBreak){
+ reset=true;prevValid_=false;if(analysis.isSceneCut)++metrics_.sceneCutCount;
+ veyra::log::info("scene",std::format("history boundary frame={} ptsMs={} cutCandidate={} cadenceBreak={} sad={} histogramDistance={}",
+ realFrameIndex_,ptsMs,analysis.isSceneCut,analysis.isCadenceBreak,analysis.sadScore,analysis.histogramDistance));
+ }
previousLuma_=std::move(sample);
};
diff --git a/tests/integration/MotionValidationTests.cpp b/tests/integration/MotionValidationTests.cpp
index 5a4b3f13..21aa3c05 100644
--- a/tests/integration/MotionValidationTests.cpp
+++ b/tests/integration/MotionValidationTests.cpp
@@ -8,7 +8,7 @@
#include <iostream>
using namespace veyra;using namespace veyra::pipeline;
float half(uint16_t v){int e=(v>>10)&31;float n=e?std::ldexp(1.f+(v&1023)/1024.f,e-15):std::ldexp(float(v&1023),-24);return v&32768?-n:n;}
-int main(){
+int run(bool vertical){
gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status st;gfx::DeviceContextDesc dd;dd.enableDebugLayer=true;
if(!ctx.initialize(dd,st)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,st))return 2;
auto flow=makeTexture(ctx.device(),8,8,DXGI_FORMAT_R16G16_SINT,false),cost=makeTexture(ctx.device(),8,8,DXGI_FORMAT_R8_UINT,false);
@@ -21,9 +21,9 @@ int main(){
memset(ptr,0,pitch*h);for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x)fill(static_cast<uint8_t*>(ptr)+y*pitch+x*bpp,x,y);data->Unmap(0,nullptr);
states.transition(list,tex,D3D12_RESOURCE_STATE_COPY_DEST);D3D12_TEXTURE_COPY_LOCATION a{},b{};a.pResource=tex;a.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;b.pResource=data.Get();b.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;b.PlacedFootprint.Footprint={tex->GetDesc().Format,w,h,1,pitch};list->CopyTextureRegion(&a,0,0,0,&b,nullptr);states.transition(list,tex,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);uploads.push_back(data);return true;
};
- if(!upload(flow.Get(),8,8,4,[](uint8_t* p,unsigned,unsigned y){int16_t v[2]={int16_t(y>=6?-80:y>=4?80:64),0};memcpy(p,v,4);})||!upload(cost.Get(),8,8,1,[](uint8_t* p,unsigned x,unsigned){*p=x==3?255:0;})||
- !upload(previous.Get(),32,32,16,[](uint8_t* p,unsigned x,unsigned){float v[4]={x/40.f,x/40.f,x/40.f,1};memcpy(p,v,16);})||
- !upload(current.Get(),32,32,16,[](uint8_t* p,unsigned x,unsigned y){float shift=y>=24?-2.5f:y>=16?2.5f:2.f;float c=(x+shift)/40.f+(y>=8&&y<16?.3f:y>=16&&y<24?.08f:0);float v[4]={c,c,c,1};memcpy(p,v,16);}))return 2;
+ if(!upload(flow.Get(),8,8,4,[&](uint8_t* p,unsigned x,unsigned y){if(vertical)std::swap(x,y);int16_t v[2]={0,0};v[vertical?1:0]=int16_t(y>=6?-80:y>=4?80:64);memcpy(p,v,4);})||!upload(cost.Get(),8,8,1,[&](uint8_t* p,unsigned x,unsigned y){if(vertical)std::swap(x,y);*p=x==3?255:x==5?31:x==6?32:x==7?16:0;})||
+ !upload(previous.Get(),32,32,16,[&](uint8_t* p,unsigned x,unsigned y){if(vertical)std::swap(x,y);float v[4]={x/40.f,x/40.f,x/40.f,1};memcpy(p,v,16);})||
+ !upload(current.Get(),32,32,16,[&](uint8_t* p,unsigned x,unsigned y){if(vertical)std::swap(x,y);float shift=y>=24?-2.5f:y>=16?2.5f:2.f;float c=(x+shift)/40.f+(y>=8&&y<16?.3f:y>=16&&y<24?.08f:0);float v[4]={c,c,c,1};memcpy(p,v,16);}))return 2;
if(!ring.submitAndSignal(slot)||!ring.waitIdle())return 2;
ComputePass pass;std::vector<uint8_t> shader;if(!pass.loadShader("NvofDensify.dxil",shader)||!pass.create(ctx.device(),shader,6,4,2))return 2;
unsigned index=0;for(auto* r:{flow.Get(),cost.Get(),previous.Get(),current.Get()})makeSrv(ctx.device(),r,r->GetDesc().Format,cpuHandleOf(pass,index++));
@@ -37,16 +37,20 @@ int main(){
if(!ring.submitAndSignal(slot)||!ring.waitIdle())return 2;void* ptr=nullptr;D3D12_RANGE read{0,16384};if(FAILED(readback->Map(0,&read,&ptr)))return 2;
unsigned rejected=0,retained=0,attenuated=0;bool passOk=true;
for(unsigned y=0;y<32;++y)for(unsigned x=0;x<32;++x){auto* p=static_cast<uint8_t*>(ptr);auto* v=reinterpret_cast<uint16_t*>(p+y*256+x*4);float vx=half(v[0]),vy=half(v[1]);unsigned conf=p[8192+y*256+x];
- float expected=y>=24?-2.5f:y>=16?2.5f:2.f;bool outside=x+expected<0||x+expected>31;
- bool reject=(x>=12&&x<16)||(flags&&(outside||(y>=8&&y<16)));bool attenuate=flags&&!reject&&y>=16&&y<24;
+ unsigned sx=vertical?y:x,sy=vertical?x:y;if(vertical)std::swap(vx,vy);
+ float expected=sy>=24?-2.5f:sy>=16?2.5f:2.f;bool outside=sx+expected<0||sx+expected>31;
+ unsigned expectedCost=sx/4==3?255:sx/4==5?31:sx/4==6?32:sx/4==7?16:0;
+ bool reject=expectedCost>=32||(flags&&(outside||(sy>=8&&sy<16)));bool attenuate=flags&&!reject&&sy>=16&&sy<24;
if(reject){++rejected;passOk=passOk&&vx==0&&vy==0&&conf==0;}
- else if(attenuate){++attenuated;passOk=passOk&&vx>0&&vx<expected&&vy==0&&conf>0&&conf<255;}
- else{++retained;passOk=passOk&&vx==expected&&vy==0&&conf==255;}
+ else if(attenuate){++attenuated;passOk=passOk&&vx>0&&vx<expected&&vy==0&&conf>0&&conf<255-expectedCost;}
+ else{++retained;passOk=passOk&&vx==expected&&vy==0&&conf==255-expectedCost;}
}
D3D12_RANGE written{0,0};readback->Unmap(0,&written);ok=ok&&passOk&&retained>100&&rejected>100&&(!flags||attenuated>100);
- std::cout<<"MOTION_VALIDATION flags="<<flags<<" rejected="<<rejected<<" retained="<<retained<<" attenuated="<<attenuated<<" pass="<<passOk<<std::endl;
+ std::cout<<"MOTION_VALIDATION vertical="<<vertical<<" flags="<<flags<<" rejected="<<rejected<<" retained="<<retained<<" attenuated="<<attenuated<<" pass="<<passOk<<std::endl;
}
ring.drainQueue();ComPtr<ID3D12InfoQueue> iq;unsigned errors=0;if(FAILED(ctx.device()->QueryInterface(IID_PPV_ARGS(&iq))))return 2;
for(UINT64 i=0;i<iq->GetNumStoredMessages();++i){SIZE_T n=0;iq->GetMessage(i,nullptr,&n);std::vector<uint8_t> b(n);auto* m=reinterpret_cast<D3D12_MESSAGE*>(b.data());if(FAILED(iq->GetMessage(i,m,&n)))return 2;if(m->Severity<=D3D12_MESSAGE_SEVERITY_ERROR){++errors;std::cerr<<m->pDescription<<std::endl;}}
std::cout<<"MOTION_DEBUG errors="<<errors<<" pass="<<(ok&&!errors)<<std::endl;return ok&&!errors?0:1;
}
+
+int main(){int result=run(false);return result?result:run(true);}
diff --git a/tests/unit/SceneCadenceTests.cpp b/tests/unit/SceneCadenceTests.cpp
index 31913bdf..2399940a 100644
--- a/tests/unit/SceneCadenceTests.cpp
+++ b/tests/unit/SceneCadenceTests.cpp
@@ -48,6 +48,26 @@ int main() {
check("scene:cut-counted", a.sceneCutCount() == 1, "count=1");
}
+ // Moderate-luma cuts were previously missed by the mandatory SAD > .3.
+ // Disjoint point histograms are deliberately independent of the generator.
+ {
+ std::vector<double> dark(256,0), nearby(256,0), partial(256,0);
+ dark[100]=1; nearby[130]=1; partial[100]=.2;partial[130]=.8;
+ SceneCadenceAnalyzer a;
+ (void)a.analyze(0,dark,0,0);
+ auto r=a.analyze(1,nearby,30.0/255,16667);
+ check("scene:moderate-luma-cut",r.isSceneCut,"histogram replacement and SAD below old .3 threshold");
+ a.reset();(void)a.analyze(0,dark,0,0);
+ r=a.analyze(1,nearby,.079,16667);
+ check("scene:small-change-not-cut",!r.isSceneCut,"disjoint histogram alone is insufficient");
+ a.reset();(void)a.analyze(0,dark,0,0);
+ r=a.analyze(1,partial,.15,16667);
+ check("scene:partial-replacement-not-cut",!r.isSceneCut,"moderate SAD needs near-total replacement");
+ a.reset();(void)a.analyze(0,dark,0,0);
+ r=a.analyze(1,dark,.25,16667);
+ check("scene:moving-texture-not-cut",!r.isSceneCut,"high motion with stable distribution is not a cut");
+ }
+
// Same scene: similar histogram + low SAD.
{
SceneCadenceAnalyzer a;