From 98d80970e83e30e4883a76d8f740f2fca5d05e7c Mon Sep 17 00:00:00 2001 From: mac Date: Sun, 8 Nov 2026 16:57:15 +0800 Subject: [PATCH] fix: replay the last presented scope frame at the clip out point --- 大鱼调色/Plugin/DYColorWorkspace.mm | 9 ++++++--- 大鱼调色/Plugin/DYPlugIn.mm | 6 ------ 大鱼调色/Plugin/DYRenderer.h | 3 +-- 大鱼调色/Plugin/DYRenderer.mm | 3 ++- 大鱼调色/Plugin/DYScopeCapture.inc.h | 15 ++++++--------- 大鱼调色/Plugin/DYScopeDisplayTime.h | 14 ++++++++++---- 大鱼调色/Plugin/DYWorkspaceDiagnostics.inc.h | 12 +++++++----- 大鱼调色/Plugin/Info.plist | 2 +- 大鱼调色/Wrapper Application/Info.plist | 2 +- 开发交接.md | 6 +++--- 10 files changed, 37 insertions(+), 35 deletions(-) diff --git a/大鱼调色/Plugin/DYColorWorkspace.mm b/大鱼调色/Plugin/DYColorWorkspace.mm index 34d23f9..f18ffbe 100644 --- a/大鱼调色/Plugin/DYColorWorkspace.mm +++ b/大鱼调色/Plugin/DYColorWorkspace.mm @@ -214,10 +214,13 @@ static BOOL DYWorkspaceEnabled(DYUniforms u,NSString *type){if([type isEqual:@"b } - (void)pageChanged:(id)sender{ if(_editorMode==2)[self bindLUTTarget];_scopePane.hidden=NO;_lutPane.hidden=_editorMode!=2;_lutExplanation.hidden=YES;_toolEditor.hidden=_editorMode!=0;_maskPane.hidden=_editorMode!=1;_selectionTitle.hidden=_editorMode==2; - CMTime displayTime=_toolTime,frameDuration=kCMTimeInvalid;idaction=[self actionAPI];if(_visible&&!_renderer.scopeEnabled&&action){[action startAction:self];@try{ - displayTime=DYHostDisplayedFrameTime([self rootHost],action.currentTime,&frameDuration); + CMTime currentTime=_toolTime,frameDuration=kCMTimeInvalid;BOOL exclusiveEnd=NO; + idaction=[self actionAPI];if(_visible&&!_renderer.scopeEnabled&&action){[action startAction:self];@try{ + currentTime=action.currentTime; + CMTime displayTime=DYHostDisplayedFrameTime([self rootHost],currentTime,&frameDuration); + exclusiveEnd=CMTIME_IS_NUMERIC(currentTime)&&CMTimeCompare(displayTime,currentTime)<0; }@finally{[action endAction:self];}} - [_renderer setScopeEnabled:_visible atTime:displayTime frameDuration:frameDuration];if(_editorMode==2)[self ensureBrowser];[self scopeChanged:nil];[self layoutWorkspace]; + [_renderer setScopeEnabled:_visible atTime:currentTime frameDuration:frameDuration exclusiveEnd:exclusiveEnd];if(_editorMode==2)[self ensureBrowser];[self scopeChanged:nil];[self layoutWorkspace]; } - (void)toggleHostScopes:(id)sender{ id action=[self actionAPI];NSError *error=nil;BOOL done=NO;if(action){[action startAction:self];@try{id commands=[_manager apiForProtocol:@protocol(FxCommandAPI)];done=[commands performCommand:kFxCommand_ToggleWaveforms error:&error];}@finally{[action endAction:self];}} diff --git a/大鱼调色/Plugin/DYPlugIn.mm b/大鱼调色/Plugin/DYPlugIn.mm index fe47655..2873ba2 100644 --- a/大鱼调色/Plugin/DYPlugIn.mm +++ b/大鱼调色/Plugin/DYPlugIn.mm @@ -36,12 +36,6 @@ - (NSView*)createViewForParameterID:(UInt32)pid { [self scheduleToolCanvasRegistration]; if(pid!=DYInspectorParameterID)return [[NSView alloc]initWithFrame:NSZeroRect]; - id timing=[_apiManager apiForProtocol:@protocol(FxTimingAPI_v4)]; - if([timing respondsToSelector:@selector(timelineFpsNumeratorForEffect:)]&&[timing respondsToSelector:@selector(timelineFpsDenominatorForEffect:)]){ - NSUInteger numerator=[timing timelineFpsNumeratorForEffect:self],denominator=[timing timelineFpsDenominatorForEffect:self]; - if(numerator>0&&numerator<=INT32_MAX&&denominator>0&&denominator<=INT64_MAX) - [_renderer setScopeProjectFrameDuration:CMTimeMake(denominator,(int32_t)numerator)]; - } return [[DYInspector alloc]initWithAPIManager:_apiManager renderer:_renderer]; } - (BOOL)parameterChanged:(UInt32)pid atTime:(CMTime)t error:(NSError**)e{if(pid==DYToolsParameterID)[self adoptToolCanvasDocument:DYReadTools(_apiManager,t).document];if(pid==DYToolsParameterID||pid==2013||pid==2014||(pid>=2236&&pid<2400)||pid==DYAssetsParameterID)[_renderer invalidatePreview];// Many parameter callbacks arrive in one host transaction. Refresh the native diff --git a/大鱼调色/Plugin/DYRenderer.h b/大鱼调色/Plugin/DYRenderer.h index ce9b9f9..fc8f7be 100644 --- a/大鱼调色/Plugin/DYRenderer.h +++ b/大鱼调色/Plugin/DYRenderer.h @@ -31,9 +31,8 @@ /// Conversion/statistics run while visible; retain one small final-output /// sample per instance so opening a paused workspace needs no parameter edit. - (BOOL)scopeEnabled; -- (void)setScopeProjectFrameDuration:(CMTime)duration; - (void)setScopeEnabled:(BOOL)enabled; -- (void)setScopeEnabled:(BOOL)enabled atTime:(CMTime)time frameDuration:(CMTime)frameDuration; +- (void)setScopeEnabled:(BOOL)enabled atTime:(CMTime)time frameDuration:(CMTime)frameDuration exclusiveEnd:(BOOL)exclusiveEnd; /// Call after the final destination render succeeds, while the tile is valid. /// Only the small GPU readback waits here; conversion/statistics are coalesced /// on a worker. No main-queue wait or host API is performed by this method. diff --git a/大鱼调色/Plugin/DYRenderer.mm b/大鱼调色/Plugin/DYRenderer.mm index 528de75..f33005c 100644 --- a/大鱼调色/Plugin/DYRenderer.mm +++ b/大鱼调色/Plugin/DYRenderer.mm @@ -150,7 +150,8 @@ struct DYScopeReadback { uint64_t _spiderScopeSerial; NSUInteger _scopeGeneration; DYScopeSample *_scopePending,*_scopeLatest; - uint64_t _scopeCaptureSerial,_scopeLatestSerial;CMTime _scopeRequestedTime,_scopeRequestedFrameDuration,_scopeProjectFrameDuration; + uint64_t _scopeCaptureSerial,_scopeLatestSerial;CMTime _scopeRequestedTime,_scopeRequestedFrameDuration; + BOOL _scopeRequestedExclusiveEnd; FxImageTile *_scopeDestination; // borrowed for one locked host render CMTime _scopeRenderTime; BOOL _scopeCaptured; diff --git a/大鱼调色/Plugin/DYScopeCapture.inc.h b/大鱼调色/Plugin/DYScopeCapture.inc.h index 78dcfe0..2887531 100644 --- a/大鱼调色/Plugin/DYScopeCapture.inc.h +++ b/大鱼调色/Plugin/DYScopeCapture.inc.h @@ -1,17 +1,14 @@ // Included in DYRenderer's implementation; final destination sampling is kept // separate from the earlier input-analysis thumbnail used by auto-grade/LUTs. -- (void)setScopeProjectFrameDuration:(CMTime)duration{@synchronized(_previewLock){_scopeProjectFrameDuration=duration;}} - (BOOL)scopeEnabled{@synchronized(_previewLock){return _scopeEnabled;}} -- (void)setScopeEnabled:(BOOL)enabled{[self setScopeEnabled:enabled atTime:kCMTimeInvalid frameDuration:kCMTimeInvalid];} -- (void)setScopeEnabled:(BOOL)enabled atTime:(CMTime)time frameDuration:(CMTime)frameDuration{ +- (void)setScopeEnabled:(BOOL)enabled{[self setScopeEnabled:enabled atTime:kCMTimeInvalid frameDuration:kCMTimeInvalid exclusiveEnd:NO];} +- (void)setScopeEnabled:(BOOL)enabled atTime:(CMTime)time frameDuration:(CMTime)frameDuration exclusiveEnd:(BOOL)exclusiveEnd{ BOOL start=NO;@synchronized(_previewLock){if(_scopeEnabled==enabled)return;_scopeEnabled=enabled;_scopeGeneration++;[_scopePending release];_scopePending=nil; if(enabled){ - // Viewer output advances at project cadence even when the source is 60p. - if(CMTIME_IS_NUMERIC(_scopeProjectFrameDuration)&&_scopeProjectFrameDuration.value>0)frameDuration=_scopeProjectFrameDuration; - _scopeRequestedTime=time;_scopeRequestedFrameDuration=frameDuration;[_scopePreview release];_scopePreview=nil;[_scopeMetadata release];_scopeMetadata=nil; + _scopeRequestedTime=time;_scopeRequestedFrameDuration=frameDuration;_scopeRequestedExclusiveEnd=exclusiveEnd;[_scopePreview release];_scopePreview=nil;[_scopeMetadata release];_scopeMetadata=nil; CMTime cached=_scopeLatest?CMTimeMakeWithEpoch([_scopeLatest.metadata[@"timeValue"]longLongValue],[_scopeLatest.metadata[@"timeScale"]intValue],[_scopeLatest.metadata[@"timeEpoch"]longLongValue]):kCMTimeInvalid; - BOOL replay=_scopeLatest&&(!CMTIME_IS_NUMERIC(time)||DYScopeFrameContainsTime(cached,time,frameDuration)); - os_log(OS_LOG_DEFAULT,"dayu_scope_open requested=%{public}.9f cached=%{public}.9f frame=%{public}.9f replay=%{public}d",CMTimeGetSeconds(time),CMTimeGetSeconds(cached),CMTimeGetSeconds(frameDuration),replay); + BOOL replay=_scopeLatest&&(!CMTIME_IS_NUMERIC(time)||DYScopeFrameContainsTime(cached,time,frameDuration,exclusiveEnd)); + os_log(OS_LOG_DEFAULT,"dayu_scope_open requested=%{public}.9f cached=%{public}.9f frame=%{public}.9f out=%{public}d replay=%{public}d",CMTimeGetSeconds(time),CMTimeGetSeconds(cached),CMTimeGetSeconds(frameDuration),exclusiveEnd,replay); // Reuse this instance's final output when the host is still on that frame. if(replay){DYScopeSample *sample=[DYScopeSample new];sample.pixels=_scopeLatest.pixels;sample.space=_scopeLatest.space;sample.metadata=_scopeLatest.metadata;sample.generation=_scopeGeneration;_scopePending=sample;if(!_scopeWorkerRunning){_scopeWorkerRunning=YES;start=YES;}} } @@ -123,7 +120,7 @@ [_scopeLatest release];_scopeLatest=[sample retain];_scopeLatestSerial=readback.serial; if(_outputObserved&&!_outputNotificationPending){_outputNotificationPending=YES;notifyOutput=YES;} } - if(_scopeEnabled&&readback.serial==_scopeLatestSerial&&(readback.generation==_scopeGeneration||!CMTIME_IS_NUMERIC(_scopeRequestedTime)||DYScopeFrameContainsTime(time,_scopeRequestedTime,_scopeRequestedFrameDuration))){ + if(_scopeEnabled&&readback.serial==_scopeLatestSerial&&(readback.generation==_scopeGeneration||!CMTIME_IS_NUMERIC(_scopeRequestedTime)||DYScopeFrameContainsTime(time,_scopeRequestedTime,_scopeRequestedFrameDuration,_scopeRequestedExclusiveEnd))){ sample.generation=_scopeGeneration;[_scopePending release];_scopePending=[sample retain]; if(!_scopeWorkerRunning){_scopeWorkerRunning=YES;start=YES;} } diff --git a/大鱼调色/Plugin/DYScopeDisplayTime.h b/大鱼调色/Plugin/DYScopeDisplayTime.h index 989e213..2020368 100644 --- a/大鱼调色/Plugin/DYScopeDisplayTime.h +++ b/大鱼调色/Plugin/DYScopeDisplayTime.h @@ -10,12 +10,18 @@ static inline CMTime DYScopeDisplayTime(CMTime requested,CMTime start,CMTime dur // Custom-view time can land between rendered input frames. A cached frame // covers its own interval only; the next frame boundary must get a fresh sample. -static inline bool DYScopeFrameContainsTime(CMTime captured,CMTime requested,CMTime frame){ +static inline bool DYScopeFrameContainsTime(CMTime captured,CMTime requested,CMTime frame,bool exclusiveEnd){ if(!CMTIME_IS_NUMERIC(captured)||!CMTIME_IS_NUMERIC(requested)||captured.epoch!=requested.epoch)return false; int comparison=CMTimeCompare(captured,requested); - if(comparison==0)return true; - return comparison<0&&CMTIME_IS_NUMERIC(frame)&&frame.value>0&&!frame.epoch&& - CMTimeCompare(CMTimeSubtract(requested,captured),frame)<0; + if(comparison==0)return !exclusiveEnd; + if(comparison>0||!CMTIME_IS_NUMERIC(frame)||frame.value<=0||frame.epoch)return false; + CMTime delta=CMTimeSubtract(requested,captured); + if(exclusiveEnd){ + // FCP holds its last presented project frame at the exclusive clip end. + // Allow a final project frame as slow as 23.976 even for faster source media. + return CMTimeCompare(delta,CMTimeMaximum(frame,CMTimeMake(1001,24000)))<=0; + } + return CMTimeCompare(delta,frame)<0; } #import diff --git a/大鱼调色/Plugin/DYWorkspaceDiagnostics.inc.h b/大鱼调色/Plugin/DYWorkspaceDiagnostics.inc.h index ee0d04c..d23ec7c 100644 --- a/大鱼调色/Plugin/DYWorkspaceDiagnostics.inc.h +++ b/大鱼调色/Plugin/DYWorkspaceDiagnostics.inc.h @@ -2,6 +2,9 @@ CMTime end=CMTimeMake(4,1),start=kCMTimeZero,duration=CMTimeMake(100,25),frame=CMTimeMake(1,25); run.record(@"scope-exclusive-clip-end-aligns-to-last-visible-frame",CMTimeCompare(DYScopeDisplayTime(end,start,duration,frame),CMTimeMake(99,25))==0); run.record(@"scope-interior-time-is-never-replaced-by-previous-frame",CMTimeCompare(DYScopeDisplayTime(CMTimeMake(50,25),start,duration,frame),CMTimeMake(50,25))==0); + run.record(@"scope-exclusive-end-rejects-older-or-beyond-end-output", + !DYScopeFrameContainsTime(CMTimeMake(283,25),CMTimeMake(285,25),CMTimeMake(1,60),true)&& + !DYScopeFrameContainsTime(CMTimeMake(285,25),CMTimeMake(285,25),CMTimeMake(1,60),true)); run.record(@"scope-after-end-is-not-silently-clamped",CMTimeCompare(DYScopeDisplayTime(CMTimeMake(101,25),start,duration,frame),CMTimeMake(101,25))==0); run.record(@"scope-end-alignment-requires-valid-positive-host-frame",CMTimeCompare(DYScopeDisplayTime(end,start,duration,kCMTimeInvalid),end)==0&&CMTimeCompare(DYScopeDisplayTime(end,start,duration,kCMTimeZero),end)==0); run.record(@"scope-trimmed-input-end-preserves-native-time-origin",CMTimeCompare(DYScopeDisplayTime(CMTimeMake(6,1),CMTimeMake(2,1),duration,frame),CMTimeMake(149,25))==0); @@ -111,12 +114,11 @@ run.record(@"workspace-final-output-worker-publishes-real-scope-rasters",[scopeData[@"waveform"]length]==320*256*4&&[scopeData[@"parade"]length]==3*320*256*4&&[scopeData[@"histogram"]length]==4*256*4&&[scopeData[@"vectorscope"]length]==256*256*4&&[scopeData[@"wholeImage"]boolValue]); [scopeRenderer setScopeEnabled:NO];[scopeRenderer captureScopeTile:finalTile atTime:CMTimeMake(8,24)];workspaceDrain();DYScopeSample *hiddenSample=[scopeRenderer valueForKey:@"scopeLatest"]; run.record(@"workspace-hidden-scope-retains-only-one-small-final-sample-without-processing",[scopeRenderer.scopeMetadata isEqual:scopeData]&&hiddenSample.pixels.length==320*180*16&&[hiddenSample.metadata[@"timeValue"]longLongValue]==8&&![scopeRenderer valueForKey:@"scopePending"]); - [scopeRenderer setScopeProjectFrameDuration:CMTimeMake(1,25)]; - [scopeRenderer setScopeEnabled:YES atTime:CMTimeAdd(CMTimeMake(8,24),CMTimeMake(7,300)) frameDuration:CMTimeMake(1,60)];scopeDeadline=NSProcessInfo.processInfo.systemUptime+5;while(!scopeRenderer.scopeMetadata&&NSProcessInfo.processInfo.systemUptimeCFBundleShortVersionString 1.21.1 CFBundleVersion - 116 + 117 NSHumanReadableCopyright PlugInKit diff --git a/大鱼调色/Wrapper Application/Info.plist b/大鱼调色/Wrapper Application/Info.plist index dc36d0e..aaf24a3 100644 --- a/大鱼调色/Wrapper Application/Info.plist +++ b/大鱼调色/Wrapper Application/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.21.1 CFBundleVersion - 116 + 117 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright diff --git a/开发交接.md b/开发交接.md index d5b3203..d366fdd 100644 --- a/开发交接.md +++ b/开发交接.md @@ -2,13 +2,13 @@ 更新于 2026-11-08(Asia/Shanghai)。这是新对话的接手入口。历史设计和实现细节按需查阅专项交接,复现和交付证据以对应版本的报告为准。 -## 1.21.1(116)首次示波器与人脸肤色保护 +## 1.21.1(117)首次示波器与人脸肤色保护 -用户反馈首次打开控制面板没有波形、人脸相关预览卡顿。控制面板从宿主动作读取当前时间,并优先按项目帧长验证本效果实例最后一次最终输出。缓存时间相同或播放头仍在该帧区间时立即送测量队列,下一帧边界等待对应渲染。参数写入与蜘蛛盘仍用原时间规则。 +用户反馈首次打开控制面板没有波形、人脸相关预览卡顿。控制面板从宿主动作读取当前时间,并按宿主时间验证本效果实例最后一次最终输出。缓存时间相同或播放头仍在该帧区间时立即送测量队列,下一帧边界等待对应渲染。参数写入与蜘蛛盘仍用原时间规则。 Skin 的 Vision 轮廓、眼眉嘴排除及强度沿用原算法。Metal 先检查实际轮廓外接范围,外部跳过多边形计算,无覆盖时跳过五官权重;按需读取设备端路径。人脸马赛克仍独立检测每个不同画面的矩形。4K 活跃人脸肤色保护旧版中位 1176.07 ms,其中取样及 Vision 平均 10.73 ms,主要耗时在逐像素轮廓。M4 同一公开人像的 12 帧中位数降至 21.78 ms,1080p 从 308.08 降至 10.07 ms;六组末帧 SHA-256 完全一致。以上是渲染器耗时。 -候选 115 已公证并在 FCP 12.4 实测。片尾请求 11.383333333 秒,实际输出 11.360000000 秒。素材 60p 帧长 16.667 ms 导致仍拒绝缓存,因此候选未发布。116 改用 25p 项目帧长并等待同位置复测,再打包和发布。既有项目文件的 Security 引用排序未纳入本轮。 +候选 115 已公证并在 FCP 12.4 实测。片尾请求 11.383333333 秒,实际输出 11.360000000 秒。素材 60p 帧长 16.667 ms 导致仍拒绝缓存,因此候选未发布。116 在实际自定视图回调仍收到 60p,亦未发布。117 对已确认的排他出点匹配最后一张实际输出,普通位置仍限制在一帧内。等待同位置复测、打包和发布。既有项目文件的 Security 引用排序未纳入本轮。 ## 1.21.0(114)流畅性优化