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(capture): filter persistent driver discontinuity flags; record playback audit
Veyra Goal Agented00218e69ee
diff --git a/docs/CAPTURE_STICKY_DISCONTINUITY_2026-09-20.md b/docs/CAPTURE_STICKY_DISCONTINUITY_2026-09-20.mdnew file mode 100644index 00000000..f671963d--- /dev/null+++ b/docs/CAPTURE_STICKY_DISCONTINUITY_2026-09-20.md@@ -0,0 +1,35 @@+# Capture persistent discontinuity repair++User log: `C:/Users/123/Desktop/veyra-app.log`, 2026-09-20.+RTX 5070 Ti Laptop, native YUY2 1920x1080 at 60.0002 fps.+Audio endpoint is Hagibis; the log does not establish the video card model.++All 92 rate-limited capture-discontinuity records report driverFlag=true,+clockBreak=false. The last counter is source=10560,count=10560. There are+10559 frame-flow records with resetReason=10. With FG enabled the graph+continually reports fgWarmup=1, fgReadyValid=0 and generatedPresented=0.+This establishes repeated input-history resets, not insufficient GPU compute.+The native sink does not manufacture the sample discontinuity flag.++Repair: filter a persistent driver flag only for native, independently+decodable frames. Require three consecutive flagged timestamp pairs, complete+positive sample times, PTS delta 0.5--1.5 nominal intervals and positive arrival+delta no larger than 2.5 intervals. Preserve the first/isolated flag. Restart+evidence gathering after any unflagged sample, invalid timing or cadence break.+Close clears the detector. Compressed inputs retain all driver flags.+Existing clock, mailbox, drop and graph reset policies remain in force.+Rate-limited diagnostics report suppressed flags. No extra buffering or waits.++Limit: a genuine discontinuity that has perfectly continuous timestamps and+arrival cadence cannot be distinguished from this already-stuck flag alone.+The filter is limited to raw frames to avoid hiding compressed reference loss.+This is not a guarantee that every capture device's timing metadata is correct.++Checkpoint: `checkpoint/pre-capture-sticky-discontinuity-20260920`.+Build and regression evidence: `E:/项目/Veyra/logs/capture-timeline-20260920/`.+LivePresentationTimingTests cover sustained flags (10000 samples), isolated+flags, backwards PTS, missing frames, arrival stalls, missing timestamps,+compressed input, reconnect and preservation of an unconsumed mailbox reset.+Initial callback deltas from the user log are included as regression data.+Application build and timing regressions pass; affected-device FG recovery+still needs user verification. No new release or portable package produced.diff --git a/docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.md b/docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.mdnew file mode 100644index 00000000..d9c44b1d--- /dev/null+++ b/docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.md@@ -0,0 +1,199 @@+# Playback, subtitles, HDR and NR: investigation and proposed work++Date: 2026-09-20. Status: proposal only; no implementation authorized in this request.++## Evidence and limits++- Veyra baseline: be3e2e6, branch codex/capture-color-144beta-20260920.+ Existing uncommitted capture discontinuity repair is preserved.+- Read-only inspection of C:/Users/123/Desktop/033. No package executable,+ installer, injection script, addon or runtime was executed or loaded.+- Magpie experimental source: https://github.com/SAOG0721/Magpie/tree/3841698348bfb246623d4acf791984c8b68a577b+ Download: E:/项目/Veyra/downloads/magpie-six-issue-audit-20260920.+ GPLv3 source reuse is permitted subject to attribution, fixed revision,+ modifications and corresponding source notices. No source port performed.+- No projector, affected MKV cue, controlled XeSS image comparison or physical+ HDR output measurement was available for this investigation. Code mechanisms+ below are distinguished from unverified explanations of user observations.++## 1. Independent output frame-rate limit++Current settings offer FG multipliers 1/2/3/4/6, not a custom final output cap.+Capture input limits are a different control. The existing frame-pacing plan+excluded an extra limiter to avoid competing clocks; this is a new proposal.++A 60 Hz projector cannot display 120 distinct complete frames each second.+Submitting 120 FPS may affect latency, tearing, frame selection or device+processing, but is not equivalent to 120 Hz output and is not always smoother.+VSync at 60 Hz also cannot promise 120 visible complete frames.++Proposed UI: output limit Off / Follow display / Custom numeric FPS, independent+of VSync. Preserve existing default behavior (Off), allow fractional rates such+as 59.94/119.88, persist settings and expose requested versus effective rates.+Do not silently change the requested FG multiplier or media/audio playback speed.++Integrate the cap into the existing presentation owner, not a second Sleep loop+on source/processing threads. DLSS self-presentation and XeSS provider-owned+pacing require separate integration checks; verify the provider's actual cap+capability before promising identical behavior. Bound queued work and avoid+generating work that cannot be presented where the provider contract permits.+Do not add a fixed latency cushion. A cap still necessarily schedules frames+against target time slots; it cannot be described as zero waiting.++Selecting 120 frames out of 144 generated temporal samples does not yield+uniform content phases automatically. Evenly spacing Present calls alone does+not fix that discrepancy. Keep frame selection and actual interpolation phase+quality as distinct acceptance criteria; do not falsify timestamps to hide it.++Acceptance: 23.976/24/25/30/60 input, 59.94/60/120 Hz displays, FG off/DLSS/XeSS,+VSync on/off, seek, cap changes and cross-monitor movement. Measure generated,+submitted and displayed rates separately, interval distribution, queue residence+and audio continuity. Physical latency requires separate instrumentation.++## 2. Subtitle size changes++Confirmed mechanism: apps/veyra/ui/SubtitleOverlay.cpp:128-134 shrinks text by+10 percent per attempt to fit targetLines; another fit step shrinks stacked+subtitles to available height. Default targetLines is two. This explains a+possible one-line/two-line size change, but the exact user's cue was not tested.+ASS-authored font differences and bitmap subtitles must be distinguished.++Proposal: preserve selected/authored font size by default, respect explicit line+breaks and grow the block upward. Treat preferred line count as a layout setting,+not implicit permission to shrink. Offer explicit Fit-to-area mode separately.+Handle long cues, bilingual overlap and safe-area overflow without clipping;+do not apply text font rules to PGS/VobSub bitmap scaling.++Acceptance: SRT/ASS embedded cues with one/two/three lines, narrow/wide windows,+DPI changes, bilingual text, styled/positioned ASS and bitmap subtitles.++## 3. Fullscreen lock and HDR color changes++Confirmed: AppShell.cpp pointerActivity reveals the controls on mouse motion;+there is no fullscreen lock. No direct HDR toggle was found in that handler.+The video viewport remains fullscreen while separate control windows are shown.+EngineController periodically checks display HDR state and may rebuild the graph+when output state changes; PresentSink manages the swapchain color space.++Hypothesis requiring measurement: an overlapping SDR control window changes+DWM composition/independent-flip/MPO behavior, affecting HDR appearance. Do not+report this as a confirmed RTX HDR disable/enable cycle.++Proposal: a lock icon in fullscreen controls; locking hides controls and ignores+incidental mouse motion. Provide explicit unlock action/shortcut; Esc/F11 must+always allow exit, without requiring a hidden control. Default session unlocked.+Log control visibility, display HDR state, swapchain format/color space, TrueHDR+active state and graph revision together. If overlay composition is responsible,+integrate HDR-aware UI composition after FG with a controlled UI white level.+Showing controls must not itself recreate the enhancement graph or toggle HDR.+The lock improves usability but does not replace fixing a confirmed color defect.++Acceptance: SDR/HDR displays, HDR input and SDR+TrueHDR, controls shown/hidden,+locked playback, keyboard escape, subtitles and cross-monitor transitions.++## 4. Dolby Vision compatibility++RTX Video HDR converts SDR to HDR; it is not a Dolby Vision decoder or converter.+Existing include/veyra/source/DolbyVision.h and MediaFileSource.cpp already route+compatible base layers: P7 to HDR10; P8/P10 compatibility 1 to HDR10, 2 to SDR,+4 to HLG. Unsupported profiles, absent base layers and incompatible color+descriptions are rejected. RPU/enhancement layers are not applied.++For a compatible HDR10 base layer, use that HDR directly. Do not round-trip+HDR through SDR and TrueHDR and call it Dolby Vision compatibility.++P5 and other non-compatible sources need a separate implementation project:+evaluate FFmpeg metadata extraction and libplacebo Dolby Vision color/reshape+support, then map to the shared linear processing/output contract. Reference:+https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/colorspace.h+(research reference only; pin and audit a revision before reuse).+Verify D3D12 interoperability, GPU-only processing cost and dependency licensing.+Do not claim full P7 FEL reconstruction, original dynamic metadata preservation+or licensed native DV output. Acceptance requires real profile-specific samples+and a reference renderer, not merely successful playback initialization.++## 5. XeSS 4x jelly compared with Magpie++The sharpening explanation is unproven. Magpie's XeSS marker shader is a point+copy, not an independent sharpening pass. Its defaults select AMD optical flow,+whereas Veyra defaults to NVOF. Magpie also exposes duplicate-frame filtering.+Both provide estimated motion and simplified depth; exact settings/runtime and+source content must match before comparing algorithms.++References in pinned upstream: src/Effects/XeSSFG/XeSS_FrameGeneration.hlsl and+src/Magpie.Core/XeSSFGPresenter.cpp. Veyra: src/gfx/XessPresenter.cpp. Veyra's+FSR SR sharpening is disabled in the inspected dispatch; DLSS SR has a sharpness+parameter, which does not establish the user's actual runtime setting.++Proposal: first compare identical clips/crops/resolution with NR and SR off,+same XeSS runtime/multiplier and input cadence. Then isolate optical-flow choice,+NR, SR and sharpening individually. Check current/previous frame identity,+motion direction/units/scaling, occlusion rejection, duplicate detection and+history resets. Zero motion is a diagnostic control, not a quality solution.+Measure warping/occlusion artifacts and repeated/uneven frames as well as FPS.+Port a demonstrated improvement only after the controlled comparison; do not+globally soften the image or disable effects to hide the symptom.++## 6. NR controls, styles and temporal stabilization++NR here is neural rendering/enhancement, not simply a conventional denoiser.+Veyra already sends NGX style IDs 0/1/2 plus intensity, tone, structure and skin+parameters. SettingsWindow currently labels style buttons 0/1/2. Magpie names+those IDs Default/Natural/Cinematic; they are not three newly discovered models.+Veyra clamps intensity/tone/structure to 0..1; inspected Magpie allows 0..2.+Range expansion needs tests against each supported NR runtime and consistent+UI/config validation. Categorical style IDs are not arbitrary user-trained styles.++Useful open-source implementation: Magpie DLSSNRTemporalShader.h and+DLSSNRTemporal.cpp stabilize the NR residual (Raw minus Base), with motion+reprojection, history validity, neighborhood clamping and rejection. A low-+frequency mode stabilizes broad residual changes while retaining current detail.+This is substantially different from blurring the entire image. It uses history,+not an additional future frame, but adds GPU work and can introduce ghosting.+Upstream also has 1..3 NR passes; multipass increases cost and should not be+bundled into the initial stabilization proposal.++033 inspection limits:+- Core NR implementation is a binary engine DLL; no matching core C++ source+ was found. No binary was loaded, extracted into Veyra or modified.+- Configuration exposes style, intensity, structure, tone, skin, sharpen,+ pregrade and stabilization-related fields. Values such as 200 have unknown+ exact runtime mapping without core source. Inspected seeds use sharpen=0.+- Readable DLSS5_Feed.fx prepares optical-flow/depth guidance and validity+ rejection. Game-injected depth access is not available for normal video input.+- notices/InsaneShaders033/SOURCE.md describes CC0 BilateralComic-derived+ log-luma/chroma color quantization and bounded HDR/skin handling, explicitly+ without bilateral smoothing or temporal filtering. Natural/cinematic recipes+ are described as numeric color recipes. These are not evidence of new trained+ NR models. The notice's source-inclusion statement was not confirmed by the+ inspected files. Preserve this distinction before reuse.+- Package NR runtime differs from Veyra's approved runtime identity. This audit+ grants no replacement or redistribution approval and did not verify its hash.++Proposal: name/explain the existing three styles; add named user NR presets for+model parameters and optional residual/temporal settings. Keep color presets+explicitly distinguishable from model styles. If reproducing pre-NR color recipes,+design their exact processing stage and HDR contract rather than blindly using+post-processing values. Evaluate an optional, default-off port of Magpie's+temporal residual stabilization into the shared D3D12 graph with full provenance.+Exact 033 core reproduction requires corresponding source and license evidence;+do not add ReShade injection to the product.++Acceptance: fixed scenes, motion, faces, dark gradients, HDR highlights, cuts,+seek, pause/resume, resize and provider switching; compare NR-off/base/temporal+variants for detail, trails/flicker and GPU time. Persist presets without breaking+old configurations. Reject a port that merely trades all flicker for ghosting.++## Proposed order and delivery gates++1. Fixed-size subtitle layout and fullscreen lock; instrument HDR control changes.+2. Independent output cap, with provider feasibility and cadence checks first.+3. Controlled XeSS/flow comparison; implement only evidence-backed differences.+4. Named NR presets and optional temporal residual stabilization, separately gated.+5. Non-HDR10-compatible Dolby Vision processing as a distinct larger project.++Each implementation step requires a reversible checkpoint, scoped changes,+build and relevant regression results. No automatic FG downshift, fixed latency+cushion, NR multipass default, runtime substitution or global color adjustment is+part of this proposal. User hardware acceptance remains separate from local tests.+This audit performed no application build or functional acceptance test.diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 2bb0bb7c..e1f7d7c4 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,45 @@# Veyra 工作记录+## 2026-09-20 Six playback/NR requests: investigation only++User requested investigation and proposals, explicitly no implementation.+Recorded evidence, uncertainties, proposed changes and acceptance criteria in+`docs/PLAYBACK_SIX_ISSUE_AUDIT_PLAN_2026-09-20.md`: output FPS cap, subtitle+size changes, fullscreen lock/HDR overlays, Dolby Vision compatibility, XeSS+warping comparison and NR styles/temporal stabilization.++Read-only source/config inspection of `C:/Users/123/Desktop/033`; no package+executable, injection script, addon or runtime loaded. Inspected Magpie GPLv3+experimental revision `3841698348bfb246623d4acf791984c8b68a577b`, downloaded to+`E:/项目/Veyra/downloads/magpie-six-issue-audit-20260920`. Commands included+git clone/revision inspection, rg/Get-Content source searches and an upstream+libplacebo colorspace header read. No source port, application build, package,+hardware test or release. Only this plan and WORKLOG changed for this request;+pre-existing capture discontinuity changes remain untouched. Validation:+`git diff --check` and `git status --short`/diff inspection for documentation.++## 2026-09-20 Native capture persistent discontinuity++User confirmed the previous MK.2 HDR repair now has correct colors on the+affected setup. This is user device feedback, not universal device validation.++New user log `C:/Users/123/Desktop/veyra-app.log` shows continuous native YUY2+timestamps but a discontinuity flag on every sample; FG stays in warmup.+Checkpoint `checkpoint/pre-capture-sticky-discontinuity-20260920` at be3e2e6.+Added a narrowly scoped persistent-flag filter in CaptureTiming.h, integrated+callback/close in CaptureCardSource.cpp, and expanded LivePresentationTimingTests.+Details and limitations: `docs/CAPTURE_STICKY_DISCONTINUITY_2026-09-20.md`.++Validation: `scripts/build-isolated.ps1 -Root . -BuildDirectory+E:/项目/Veyra/build/color-mixer-hue-20260920 -DependencyCache+E:/项目/Veyra/build/frame-pacing-20260918/CMakeCache.txt -TempDirectory+E:/项目/Veyra/tmp/capture-timeline-20260920 -Targets veyra,veyra_live_timing_tests+-DisplayVersion 1.4.4beta`; application and regression executable build passed.+Ran `veyra_live_timing_tests.exe`, exit 0; `git diff --check` passed.+Logs: `E:/项目/Veyra/logs/capture-timeline-20260920/{build,timing-tests}.txt`.+Build has existing compiler warnings. No affected capture hardware test, no+package, no upload; SDK/runtime identities unchanged and none added to Git.+## 2026-09-20 Elgato MK.2 vendor HDR controlInvestigated user log veyra-app(30).log and Nitlink; official Elgato supportdiff --git a/include/veyra/source/CaptureTiming.h b/include/veyra/source/CaptureTiming.hindex 2a994992..59e3a54a 100644--- a/include/veyra/source/CaptureTiming.h+++ b/include/veyra/source/CaptureTiming.h@@ -1,7 +1,26 @@#pragma once#include "veyra/pipeline/FramePacket.h"#include <limits>+#include <cmath>namespace veyra::source {+class CaptureDriverDiscontinuity {+ unsigned continuousFlags_=0;+public:+ void reset(){continuousFlags_=0;}+ bool observe(bool flagged,bool native,bool completeTime,bool havePrevious,+ double ptsDelta,double arrivalDelta,double nominalFps){+ // Some raw-video drivers leave the flag set on every sample. Only+ // discount a sustained flag when both clocks demonstrate normal cadence.+ const double interval=nominalFps>0?1.0/nominalFps:0;+ const bool continuous=native&&completeTime&&havePrevious&&interval>0&&+ std::isfinite(ptsDelta)&&std::isfinite(arrivalDelta)&&+ ptsDelta>=interval*.5&&ptsDelta<=interval*1.5&&+ arrivalDelta>0&&arrivalDelta<=interval*2.5;+ if(!flagged||!continuous){reset();return flagged;}+ if(continuousFlags_<3)++continuousFlags_;+ return continuousFlags_<3;+ }+};inline bool captureDiscontinuity(bool pending,bool retained,bool driver,bool havePrevious,double previous,double current,double nominalFps){const double maxGap=nominalFps>0?2.5/nominalFps:0.1;diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cppindex 0ab2a247..03cf39b6 100644--- a/src/source/CaptureCardSource.cpp+++ b/src/source/CaptureCardSource.cpp@@ -231,6 +231,8 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {int64_t nominalDuration100ns=0;pipeline::Rational pendingDuration=pipeline::Rational::unknown();uint64_t received=0,dropped=0,lastDrop=0,sequence=0;uint64_t discontinuitySamples=0;+ CaptureDriverDiscontinuity driverDiscontinuity;+ uint64_t suppressedDriverDiscontinuities=0;Clock::time_point pendingArrival{},readArrival{},firstArrival{},latestArrival{};std::deque<Clock::time_point> recentArrivals;ComPtr<IGraphBuilder> graph;ComPtr<ICaptureGraphBuilder2> builder;ComPtr<IBaseFilter> device,grabFilter,nullFilter,audioFilter;ComPtr<IAMStreamConfig> config;ComPtr<ISampleGrabber> grab;ComPtr<IMediaControl> control;ComPtr<IMediaEvent> events;@@ -398,7 +400,14 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {else {const double previous=compressedPath?lastCallbackTime:pendingTime;if(received){arrivalDeltaMs=std::chrono::duration<double,std::milli>(arrival-latestArrival).count();ptsDeltaMs=(time-previous)*1000;}- const bool driverBreak=sample->IsDiscontinuity()==S_OK;+ const bool driverFlag=sample->IsDiscontinuity()==S_OK;+ const bool driverBreak=driverDiscontinuity.observe(driverFlag,!compressedPath,+ sampleTime&&sampleEnd>sampleStart,received>0,time-previous,arrivalDeltaMs/1000,info.averageFps);+ if(driverFlag&&!driverBreak){+ ++suppressedDriverDiscontinuities;+ if(suppressedDriverDiscontinuities==1||suppressedDriverDiscontinuities%600==0)+ log::warn("capture-driver-flag",std::format("suppressed={} persistent raw-video discontinuity flag with continuous timestamps; ptsDeltaMs={:.4f} arrivalDeltaMs={:.4f}",suppressedDriverDiscontinuities,ptsDeltaMs,arrivalDeltaMs));+ }// Interframe packet PTS may move backwards in decode order.// Apply cadence checks to decoded output, not B-frame packets.const bool clockBreak=received&&(!compressedPath||codec==CaptureCodec::Mjpeg)&&@@ -1242,5 +1251,6 @@ void CaptureCardSource::close()noexcept{p.info={};p.sequence=p.received=p.dropped=p.lastDrop=0;p.pending=p.callbackError=p.configured=p.forceDiscontinuity=false;p.lastPts=p.readAgeMs=0;p.recentArrivals.clear();+ p.driverDiscontinuity.reset();p.suppressedDriverDiscontinuities=p.discontinuitySamples=0;}}diff --git a/tests/unit/LivePresentationTimingTests.cpp b/tests/unit/LivePresentationTimingTests.cppindex db82dd43..6834077c 100644--- a/tests/unit/LivePresentationTimingTests.cpp+++ b/tests/unit/LivePresentationTimingTests.cpp@@ -32,6 +32,29 @@ int main(){check(rate.rate(10000000)==1000,"completion rate has no 60 or 120fps cap");using veyra::source::captureDuration;using veyra::engine::liveSourceInterval100ns;using veyra::source::captureDiscontinuity;+ veyra::source::CaptureDriverDiscontinuity driverFlag;+ auto flag=[&](bool flagged=true,bool native=true,bool timed=true,double pts=1.0/60,double arrival=1.0/60){+ return driverFlag.observe(flagged,native,timed,true,pts,arrival,60);+ };+ check(flag()&&flag()&&!flag(),"persistent native flag requires three continuous timestamp pairs");+ bool stable=true;for(int i=0;i<10000;++i)stable&=!flag();+ check(stable,"persistent flag cannot keep frame generation in warmup");+ check(flag(true,true,true,-.01),"backward time preserves flagged reset");+ check(flag()&&flag()&&!flag(),"clock break requires new continuity evidence");+ check(flag(true,true,true,.1),"missing source frames preserve flagged reset");+ check(flag(true,true,true,1.0/60,.2),"arrival stall preserves flagged reset even with smooth PTS");+ check(flag(true,true,false),"missing sample timestamps preserve driver reset");+ stable=true;for(int i=0;i<20;++i)stable&=flag(true,false);+ check(stable,"compressed reference chains never suppress driver discontinuity");+ check(!flag(false)&&flag(),"isolated flag after unflagged sample always resets");+ driverFlag.reset();check(flag(),"reconnect clears persistent flag evidence");+ driverFlag.reset();+ check(driverFlag.observe(true,true,true,false,0,0,60),"first sample keeps its discontinuity");+ check(flag(true,true,true,.0164827,.0164222)&&+ flag(true,true,true,.0171206,.0172319)&&+ !flag(true,true,true,.0165042,.0164009),"user log initial callback cadence exits repeated reset");+ check(captureDiscontinuity(true,true,flag(),true,1,1+1.0/60,60),"filter cannot erase an unconsumed mailbox boundary");+ check(!captureDiscontinuity(false,true,flag(),true,1,1+1.0/60,60),"after boundary delivery continuous flagged frames can form a pair");check(!captureDiscontinuity(true,false,false,true,1,1+1.0/60,60),"continuous callbacks remain continuous while mailbox is overwritten");check(captureDiscontinuity(true,true,false,true,1,1+1.0/60,60),"driver discontinuity survives mailbox overwrite");check(!captureDiscontinuity(false,true,false,true,1,1+1.0/60,60),"consumed driver discontinuity does not leak to next packet");