fix: reject mask tracking when the host has no valid reference frame
这个提交包含在:
1 父节点
4b7e348ff5
当前提交
6a979f16a8
6 个文件已更改
+574
-5
没有与搜索条件相匹配的文件
@@ -155,7 +155,9 @@
|
||||
NSInteger direction=[notification.userInfo[@"direction"]integerValue];if(direction==9){_trackingCancelled.store(true);return;}@synchronized(self){if(_toolDrawingPen||_toolDrawingShape||_toolCanvasCommitPending){[self postToolCanvasStatus:@"请先完成或取消蒙版绘制,再开始跟踪。"];return;}}if(_trackingActive.load()){[self toolStatus:@"请先取消当前跟踪"];return;}
|
||||
id<FxCustomParameterActionAPI_v4>a=[_apiManager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{
|
||||
id<FxAnalysisAPI>analysis=[_apiManager apiForProtocol:@protocol(FxAnalysisAPI)];FxAnalysisState state=[analysis analysisStateForEffect];if(!analysis||state==kFxAnalysisState_AnalysisRequested||state==kFxAnalysisState_AnalysisStarted){[self toolStatus:@"宿主未就绪,请等待当前分析结束"];return;}
|
||||
CMTime time=a.currentTime;NSDictionary *doc=DYReadTools(_apiManager,time).document;NSString *node=DYSharedMaskWithID(doc,notification.userInfo[@"mask"])?@"shared":notification.userInfo[@"node"];NSDictionary *mask=[self toolMask:notification.userInfo[@"mask"] node:node document:doc];if(!mask||![mask[@"enabled"]boolValue]){[self toolStatus:@"请先选择当前工具的启用蒙版"];return;}DYMaskParameters seed=DYMaskAtTime(mask,time);if(seed.kind>DYMaskBezier||(seed.kind==DYMaskBezier&&[mask[@"nodes"]length]<3*sizeof(DYBezierNode))){[self toolStatus:@"跟踪需要矩形、椭圆或闭合钢笔区域"];return;}
|
||||
CMTime time=a.currentTime;
|
||||
if(!CMTIME_IS_NUMERIC(time)){[self toolStatus:@"请在时间线定位到有效画面后再开始跟踪"];return;}
|
||||
NSDictionary *doc=DYReadTools(_apiManager,time).document;NSString *node=DYSharedMaskWithID(doc,notification.userInfo[@"mask"])?@"shared":notification.userInfo[@"node"];NSDictionary *mask=[self toolMask:notification.userInfo[@"mask"] node:node document:doc];if(!mask||![mask[@"enabled"]boolValue]){[self toolStatus:@"请先选择当前工具的启用蒙版"];return;}DYMaskParameters seed=DYMaskAtTime(mask,time);if(seed.kind>DYMaskBezier||(seed.kind==DYMaskBezier&&[mask[@"nodes"]length]<3*sizeof(DYBezierNode))){[self toolStatus:@"跟踪需要矩形、椭圆或闭合钢笔区域"];return;}
|
||||
// The host may reuse an already rendered frame without calling our renderer.
|
||||
// Analyzer input is authoritative; a matching preview is only an optional
|
||||
// orientation check, never a prerequisite for starting at the playhead.
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
auto drain=[&](){double end=NSProcessInfo.processInfo.systemUptime+.15;while(NSProcessInfo.processInfo.systemUptime<end)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.005]];};CMTimeRange inputRange=CMTimeRangeMake(kCMTimeZero,CMTimeMake(6*1001,24000)),desired;
|
||||
NSMutableArray *updates=[NSMutableArray array];
|
||||
id observer=[NSNotificationCenter.defaultCenter addObserverForName:@"DYToolTrackingStatus" object:host queue:nil usingBlock:^(NSNotification *note){if(note.userInfo[@"tracking"])[updates addObject:note.userInfo];}];
|
||||
host->_time=kCMTimeInvalid;request(1);
|
||||
run.record(@"tracking-invalid-host-time-does-not-start-analysis",host->_forwardStarts==0&&host->_state==kFxAnalysisState_NotAnalyzing);
|
||||
run.need(@"tracking-renders-valid-source-before-analysis",capture(0));run.record(@"inactive-tracking-avoids-full-frame-motion-readback",[[plugin valueForKey:@"toolCaptureDevices"]count]==0);int undoBefore=base->_undoStarts;request(1);BOOL callbacks=[plugin desiredAnalysisTimeRange:&desired forInputWithTimeRange:inputRange error:&error]&&[plugin setupAnalysisForTimeRange:desired frameDuration:timeAt(1) error:&error];
|
||||
for(int i=0;i<6&&callbacks;i++){setFrame(i);callbacks&=[plugin analyzeFrame:frame atTime:timeAt(i) error:&error];}host->_state=kFxAnalysisState_AnalysisCompleted;[plugin cleanupAnalysis:nil];drain();NSDictionary *tracked=DYReadTools(base,kCMTimeZero).document[@"baseMasks"][@"hsl"][0];DYMaskParameters end=DYMaskAtTime(tracked,timeAt(5));run.record(@"host-callback-vision-tracking-six-exact-frames",callbacks&&[tracked[@"keys"]count]==6&&fabs(end.centerX-(.5+10./tw))<.004&&fabs(end.centerY-(.5+5./th))<.004,@{@"keyCount":@([tracked[@"keys"]count]),@"centerX":@(end.centerX),@"centerY":@(end.centerY),@"error":reason(error)});
|
||||
NSDictionary *lastPreview=updates.count>=2?updates[updates.count-2]:nil;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.21.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>118</string>
|
||||
<string>119</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>PlugInKit</key>
|
||||
|
||||
在新工单中引用
屏蔽一个用户