perf: bound local mosaic rendering and skip unused tracking grayscale
这个提交包含在:
1 父节点
f07b116398
当前提交
4b7e348ff5
11 个文件已更改
+129
-30
没有与搜索条件相匹配的文件
+34
-5
@@ -105,7 +105,8 @@ inline float dyToolMaskHSLWeight(float3 source,thread const DYMaskParameters& p)
|
||||
if(p.flags&DYMaskLightnessEnabled)weight*=dyToolMaskRangeWeight(hsl.z,p.lightnessRange);
|
||||
return weight;
|
||||
}
|
||||
inline float dyToolMaskShapeWeight(float x,float y,thread const DYMaskParameters& p,device const DYMaskPath& path){
|
||||
inline float dyToolMaskShapeWeight(float x,float y,thread const DYMaskParameters& p,device const DYMaskPath& path,
|
||||
float4 pathBounds=float4(-INFINITY,-INFINITY,INFINITY,INFINITY)){
|
||||
float dx=(x-p.centerX)*p.imageAspect,dy=y-p.centerY,ca=cos(p.angle),sa=sin(p.angle);
|
||||
float px=dx*ca+dy*sa,py=-dx*sa+dy*ca;
|
||||
if(p.kind==DYMaskLinearGradient){
|
||||
@@ -117,7 +118,9 @@ inline float dyToolMaskShapeWeight(float x,float y,thread const DYMaskParameters
|
||||
float shorter=physicalWidth<physicalHeight?physicalWidth:physicalHeight;
|
||||
if(p.kind==DYMaskRectangle){float ax=px<0?-px:px,ay=py<0?-py:py,a=physicalWidth*.5f-ax,b=physicalHeight*.5f-ay;if(p.version==2&&(p.flags&DYMaskFeatherOutsideFlag)){if(p.feather==0)return a>=0&&b>=0?1:0;return dyToolMaskSoftStep(-p.feather*.5f*shorter,0,a<b?a:b);}if(a<0||b<0)return 0;if(p.feather==0)return 1;return dyToolMaskSoftStep(0,p.feather*.5f,(a<b?a:b)/shorter);}
|
||||
if(path.count<3||path.count>256)return 0;
|
||||
float u=px/physicalWidth,v=py/physicalHeight,sx=physicalWidth/shorter,sy=physicalHeight/shorter,distance2=1e10f;bool inside=false;
|
||||
float u=px/physicalWidth,v=py/physicalHeight;
|
||||
if(u<pathBounds.x||v<pathBounds.y||u>pathBounds.z||v>pathBounds.w)return 0;
|
||||
float sx=physicalWidth/shorter,sy=physicalHeight/shorter,distance2=1e10f;bool inside=false;
|
||||
for(int i=0,j=path.count-1;i<path.count;j=i++){
|
||||
float ax=path.x[j],ay=path.y[j],bx=path.x[i],by=path.y[i];if((ay>v)!=(by>v))if(u<(bx-ax)*(v-ay)/(by-ay)+ax)inside=!inside;
|
||||
float ex=(bx-ax)*sx,ey=(by-ay)*sy,xx=(u-ax)*sx,yy=(v-ay)*sy,den=ex*ex+ey*ey,t=den>1e-12f?dyClamp((xx*ex+yy*ey)/den,0,1):0;
|
||||
@@ -426,9 +429,35 @@ kernel void dyCloneStamps(texture2d<float,access::read> input [[texture(0)]],
|
||||
// Block-centre sampling is stable in image coordinates and never feeds back.
|
||||
kernel void dyLocalMosaic(texture2d<float,access::read> input [[texture(0)]],texture2d<float,access::write> output [[texture(1)]],device const DYToolMaskEntry* masks [[buffer(0)]],constant DYToolMaskHeader& h [[buffer(1)]],constant uint& block [[buffer(2)]],uint2 p [[thread_position_in_grid]]) {
|
||||
uint2 size=uint2(output.get_width(),output.get_height());if(any(p>=size))return;
|
||||
float4 original=input.read(p);float2 uv=(float2(p)+.5f)/float2(size);float3 code=dyToolEncode(original.a>0?original.rgb/original.a:float3(0));float coverage=0;
|
||||
if(h.section==-102){float x=h.offsetX+uv.x*h.scaleX,y=h.offsetY+uv.y*h.scaleY;for(uint i=0;i<h.count;i++)if(masks[i].section==-102)coverage=max(coverage,dyToolMask(x,y,code,masks[i].mask));}
|
||||
else if(h.count)coverage=dyToolCoverage(uv,code,masks,h,h.section);
|
||||
float4 original=input.read(p);
|
||||
float2 uv=(float2(p)+.5f)/float2(size);
|
||||
float x=h.offsetX+uv.x*h.scaleX,y=h.offsetY+uv.y*h.scaleY;
|
||||
float coverage=0;
|
||||
if(h.section==-102){
|
||||
for(uint i=0;i<h.count;i++){
|
||||
device const auto &entry=masks[i];
|
||||
if(entry.section==-102&&x>=entry.minX&&x<=entry.maxX&&y>=entry.minY&&y<=entry.maxY)
|
||||
coverage=max(coverage,dyToolMask(x,y,float3(0),entry.mask));
|
||||
}
|
||||
}else{
|
||||
bool found=false,encoded=false;
|
||||
float3 code=0;
|
||||
for(uint i=0;i<h.count;i++){
|
||||
device const auto &entry=masks[i];
|
||||
if(entry.section!=h.section)continue;
|
||||
DYMaskParameters parameters=entry.mask.parameters;
|
||||
if(!encoded&¶meters.kind>=DYMaskHSLKey){
|
||||
code=dyToolEncode(original.a>0?original.rgb/original.a:float3(0));
|
||||
encoded=true;
|
||||
}
|
||||
// Apply levels and inversion even when the path has no geometric coverage.
|
||||
float amount=parameters.kind==DYMaskBezier
|
||||
?dyToolMaskLevels(dyToolMaskShapeWeight(x,y,parameters,entry.mask.path,float4(entry.minX,entry.minY,entry.maxX,entry.maxY)),parameters)
|
||||
:dyToolMaskOperator(x,y,code,parameters,entry.mask.path);
|
||||
coverage=found?1-(1-coverage)*(1-amount):amount;
|
||||
found=true;
|
||||
}
|
||||
}
|
||||
if(coverage<=0){output.write(original,p);return;}
|
||||
uint2 q=min((p/block)*block+block/2,size-1);float4 sample=input.read(q);
|
||||
// Preserve the pixel's original alpha and prevent transparent samples turning
|
||||
|
||||
@@ -24,7 +24,16 @@
|
||||
if(!ok){if(raster)CFRelease(raster);CGImageRelease(cg);return nil;}
|
||||
[boxes sortUsingComparator:^NSComparisonResult(NSArray *a,NSArray *b){NSComparisonResult x=[a[0]compare:b[0]];return x==NSOrderedSame?[a[1]compare:b[1]]:x;}];
|
||||
std::vector<DYToolMaskEntry> entries;
|
||||
for(NSArray *box in boxes){DYToolMaskEntry m{};m.section=-102;m.mask.parameters=dyDefaultMaskParameters();auto &p=m.mask.parameters;p.kind=DYMaskRectangle;p.centerX=[box[0]floatValue];p.centerY=[box[1]floatValue];p.width=[box[2]floatValue];p.height=[box[3]floatValue];p.feather=0;entries.push_back(m);}
|
||||
for(NSArray *box in boxes){
|
||||
DYToolMaskEntry m{};m.section=-102;m.mask.parameters=dyDefaultMaskParameters();
|
||||
auto &p=m.mask.parameters;p.kind=DYMaskRectangle;
|
||||
p.centerX=[box[0]floatValue];p.centerY=[box[1]floatValue];
|
||||
p.width=[box[2]floatValue];p.height=[box[3]floatValue];p.feather=0;
|
||||
constexpr float padding=1e-5f;
|
||||
m.minX=p.centerX-p.width*.5f-padding;m.maxX=p.centerX+p.width*.5f+padding;
|
||||
m.minY=p.centerY-p.height*.5f-padding;m.maxY=p.centerY+p.height*.5f+padding;
|
||||
entries.push_back(m);
|
||||
}
|
||||
[_mosaicEntries release];_mosaicEntries=[[NSData alloc]initWithBytes:entries.data() length:entries.size()*sizeof(DYToolMaskEntry)];
|
||||
[_mosaicRaster release];_mosaicRaster=raster?[(NSData*)raster copy]:nil;
|
||||
}
|
||||
@@ -46,10 +55,11 @@
|
||||
if(!face&&!masks.count)return src;
|
||||
NSMutableDictionary *entry=[self device:registry error:error];if(!entry)return nil;
|
||||
NSData *faces=face?[self mosaicFaces:src time:tools[@"renderTime"] error:error]:nil;if(face&&!faces){fail(error,@"当前帧人脸识别失败,请重试或改用跟踪蒙版。");return nil;}
|
||||
if(face&&!faces.length)return src;
|
||||
DYToolMaskHeader header{};header.section=face?-102:0;
|
||||
id<MTLDevice>device=entry[@"device"];id<MTLTexture>input=[src metalTextureForDevice:device];
|
||||
NSData *skinEntries=_faceEntries;_faceEntries=faces;
|
||||
id<MTLBuffer>buffer=[self maskBuffer:face?@{}:@{@"primary":masks} tile:src device:device header:&header];_faceEntries=skinEntries;
|
||||
id<MTLBuffer>buffer=[self maskBuffer:face?@{}:@{@"primary":masks} tile:src device:device header:&header mosaic:YES];_faceEntries=skinEntries;
|
||||
MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float width:input.width height:input.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;
|
||||
id<MTLTexture>output=[[device newTextureWithDescriptor:desc]autorelease];
|
||||
id<MTLComputePipelineState>pipeline=[self computePipeline:@"dyLocalMosaic" entry:entry error:error];
|
||||
|
||||
+2
-1
@@ -3,7 +3,8 @@
|
||||
struct DYToolMaskEntry {
|
||||
DYResolvedMask mask;
|
||||
int section,combine;
|
||||
// Image-normalized bounds of a detected face contour (section -100).
|
||||
// Image coordinates for face contours (-100) and mosaic face boxes (-102).
|
||||
// Local path coordinates for authored Bézier mosaic masks.
|
||||
float minX,minY,maxX,maxY;
|
||||
};
|
||||
struct DYToolMaskHeader {unsigned count;float offsetX,offsetY,scaleX,scaleY;int section,premultiplied,faceOnly,skinPreview;};
|
||||
|
||||
@@ -4,14 +4,19 @@
|
||||
- (dy::GrayFrame)toolGrayFrame:(FxImageTile*)tile error:(NSError**)error {
|
||||
auto result=[self toolGrayFrame:tile preview:nil error:error];
|
||||
// The diagnostic/legacy caller expects normalized floats. Actual analysis
|
||||
// keeps the GPU-produced bytes through OpenCV, without float expansion.
|
||||
// keeps the GPU-produced bytes without expanding the full frame to floats.
|
||||
if(result.valid()&&result.pixels.empty()){result.pixels.resize(result.bytes.size());for(size_t i=0;i<result.bytes.size();++i)result.pixels[i]=result.bytes[i]/255.f;result.bytes.clear();}
|
||||
return result;
|
||||
}
|
||||
- (dy::GrayFrame)toolGrayFrame:(FxImageTile*)tile preview:(NSDictionary**)preview error:(NSError**)error {
|
||||
dy::GrayFrame result;
|
||||
[self captureTrackingTile:tile gray:&result preview:preview error:error];
|
||||
return result;
|
||||
}
|
||||
- (BOOL)captureTrackingTile:(FxImageTile*)tile gray:(dy::GrayFrame*)gray preview:(NSDictionary**)preview error:(NSError**)error {
|
||||
@synchronized(_toolCaptureDevices){
|
||||
FxRect bounds=tile.tilePixelBounds,image=tile.imagePixelBounds;
|
||||
if(bounds.left!=image.left||bounds.right!=image.right||bounds.bottom!=image.bottom||bounds.top!=image.top)return {};
|
||||
if(bounds.left!=image.left||bounds.right!=image.right||bounds.bottom!=image.bottom||bounds.top!=image.top)return NO;
|
||||
NSNumber *key=@(tile.deviceRegistryID);NSMutableDictionary *entry=_toolCaptureDevices[key];
|
||||
if(!entry){NSArray *devices=MTLCopyAllDevices();id<MTLDevice>device=nil;for(id<MTLDevice>candidate in devices)if(candidate.registryID==tile.deviceRegistryID)device=candidate;
|
||||
if(device){id<MTLLibrary>library=[device newLibraryWithURL:[[NSBundle bundleForClass:self.class]URLForResource:@"default" withExtension:@"metallib"]error:error];id<MTLFunction>gray=[library newFunctionWithName:@"dyToolCapture"],gamma=[library newFunctionWithName:@"dyToolEncodeGamma22"];id<MTLComputePipelineState>grayPipeline=gray?[device newComputePipelineStateWithFunction:gray error:error]:nil,gammaPipeline=gamma?[device newComputePipelineStateWithFunction:gamma error:error]:nil;id<MTLCommandQueue>queue=[device newCommandQueue];MPSImageLanczosScale *scale=[[MPSImageLanczosScale alloc]initWithDevice:device];
|
||||
@@ -23,20 +28,36 @@
|
||||
[pipeline release];[function release];
|
||||
}
|
||||
[scale release];[queue release];[grayPipeline release];[gammaPipeline release];[gray release];[gamma release];[library release];
|
||||
}[devices release];if(!entry)return {};
|
||||
}[devices release];if(!entry)return NO;
|
||||
}
|
||||
id<MTLDevice>device=entry[@"device"];id<MTLTexture>source=[tile metalTextureForDevice:device];if(!source||source.framebufferOnly||!source.width||!source.height)return {};
|
||||
double factor=MIN(1.,MIN(3840./source.width,2160./source.height));NSUInteger width=floor(source.width*factor),height=floor(source.height*factor);if(width<16||height<16||width>3840||height>2160)return {};
|
||||
id<MTLDevice>device=entry[@"device"];id<MTLTexture>source=[tile metalTextureForDevice:device];if(!source||source.framebufferOnly||!source.width||!source.height)return NO;
|
||||
double factor=MIN(1.,MIN(3840./source.width,2160./source.height));NSUInteger width=floor(source.width*factor),height=floor(source.height*factor);if(width<16||height<16||width>3840||height>2160)return NO;
|
||||
MTLPixelFormat format=source.pixelFormat==MTLPixelFormatRGBA32Float?MTLPixelFormatRGBA32Float:MTLPixelFormatRGBA16Float;
|
||||
id<MTLTexture>encoded=entry[@"encoded"],bytes=entry[@"bytes"];
|
||||
if(!encoded||encoded.width!=source.width||encoded.height!=source.height||encoded.pixelFormat!=format){MTLTextureDescriptor*d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:format width:source.width height:source.height mipmapped:NO];d.storageMode=MTLStorageModePrivate;d.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;encoded=[[device newTextureWithDescriptor:d]autorelease];if(!encoded)return {};entry[@"encoded"]=encoded;}
|
||||
if(!bytes||bytes.width!=width||bytes.height!=height){MTLTextureDescriptor*d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm width:width height:height mipmapped:NO];d.storageMode=MTLStorageModePrivate;d.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;bytes=[[device newTextureWithDescriptor:d]autorelease];if(!bytes)return {};entry[@"bytes"]=bytes;}
|
||||
id<MTLBuffer>buffer=entry[@"buffer"];if(!buffer||buffer.length!=width*height){buffer=[[device newBufferWithLength:width*height options:MTLResourceStorageModeShared]autorelease];if(!buffer)return {};entry[@"buffer"]=buffer;}
|
||||
if(!encoded||encoded.width!=source.width||encoded.height!=source.height||encoded.pixelFormat!=format){MTLTextureDescriptor*d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:format width:source.width height:source.height mipmapped:NO];d.storageMode=MTLStorageModePrivate;d.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;encoded=[[device newTextureWithDescriptor:d]autorelease];if(!encoded)return NO;entry[@"encoded"]=encoded;}
|
||||
if(!bytes||bytes.width!=width||bytes.height!=height){MTLTextureDescriptor*d=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm width:width height:height mipmapped:NO];d.storageMode=MTLStorageModePrivate;d.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;bytes=[[device newTextureWithDescriptor:d]autorelease];if(!bytes)return NO;entry[@"bytes"]=bytes;}
|
||||
id<MTLBuffer>buffer=nil;
|
||||
if(gray){
|
||||
buffer=entry[@"buffer"];
|
||||
if(buffer.length!=width*height){
|
||||
buffer=[[device newBufferWithLength:width*height options:MTLResourceStorageModeShared]autorelease];
|
||||
if(!buffer)return NO;
|
||||
entry[@"buffer"]=buffer;
|
||||
}
|
||||
}
|
||||
id<MTLCommandBuffer>commands=[entry[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>encoder=[commands computeCommandEncoder];[encoder setComputePipelineState:entry[@"gamma"]];[encoder setTexture:source atIndex:0];[encoder setTexture:encoded atIndex:1];[encoder dispatchThreads:MTLSizeMake(source.width,source.height,1)threadsPerThreadgroup:MTLSizeMake(16,16,1)];[encoder endEncoding];
|
||||
[entry[@"scale"]encodeToCommandBuffer:commands sourceTexture:encoded destinationTexture:bytes];
|
||||
vector_uint3 info={(unsigned)width,(unsigned)height,(unsigned)(tile.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)};encoder=[commands computeCommandEncoder];[encoder setComputePipelineState:entry[@"gray"]];[encoder setTexture:bytes atIndex:0];[encoder setBuffer:buffer offset:0 atIndex:0];[encoder setBytes:&info length:sizeof(info)atIndex:1];[encoder dispatchThreads:MTLSizeMake(width,height,1)threadsPerThreadgroup:MTLSizeMake(16,16,1)];[encoder endEncoding];
|
||||
unsigned flip=tile.imageOrigin==kFxImageOrigin_BOTTOM_LEFT;
|
||||
if(gray){
|
||||
vector_uint3 info={(unsigned)width,(unsigned)height,flip};
|
||||
encoder=[commands computeCommandEncoder];
|
||||
[encoder setComputePipelineState:entry[@"gray"]];[encoder setTexture:bytes atIndex:0];
|
||||
[encoder setBuffer:buffer offset:0 atIndex:0];[encoder setBytes:&info length:sizeof(info) atIndex:1];
|
||||
[encoder dispatchThreads:MTLSizeMake(width,height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];
|
||||
[encoder endEncoding];
|
||||
}
|
||||
id<MTLBuffer>previewBuffer=nil;
|
||||
vector_uint3 previewInfo={0,0,info.z};
|
||||
vector_uint3 previewInfo={0,0,flip};
|
||||
if(preview&&entry[@"previewPipeline"]){
|
||||
double scale=std::min({1.,640./width,360./height});
|
||||
previewInfo.x=std::max(1u,(unsigned)(width*scale));previewInfo.y=std::max(1u,(unsigned)(height*scale));
|
||||
@@ -54,14 +75,20 @@
|
||||
[encoder endEncoding];
|
||||
}
|
||||
}
|
||||
if(!gray&&!previewBuffer)return NO;
|
||||
[commands commit];[commands waitUntilCompleted];
|
||||
if(commands.status!=MTLCommandBufferStatusCompleted){if(error)*error=commands.error;return {};}
|
||||
if(commands.status!=MTLCommandBufferStatusCompleted){if(error)*error=commands.error;return NO;}
|
||||
if(previewBuffer){
|
||||
double pixelAspect=tile.pixelAspect;
|
||||
double aspect=double(width)/height*(std::isfinite(pixelAspect)&&pixelAspect>0?pixelAspect:1);
|
||||
*preview=@{@"rgba":[NSData dataWithBytes:previewBuffer.contents length:previewBuffer.length],
|
||||
@"width":@(previewInfo.x),@"height":@(previewInfo.y),@"aspect":@(aspect)};
|
||||
}
|
||||
dy::GrayFrame result;result.width=int(width);result.height=int(height);const auto*begin=static_cast<const uint8_t*>(buffer.contents);result.bytes.assign(begin,begin+width*height);return result;
|
||||
if(gray){
|
||||
gray->width=int(width);gray->height=int(height);
|
||||
const auto *begin=static_cast<const uint8_t*>(buffer.contents);
|
||||
gray->bytes.assign(begin,begin+width*height);
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
@@ -239,14 +239,19 @@
|
||||
if(_trackingCancelled.load())return [self finishToolAnalysis:@"已取消;保留最后连续可信轨迹" error:error];if(_trackingSingle&&_trackingSamples.count>=2)return [self finishToolAnalysis:nil error:error];if(_trackingSamples.count>=DYToolKeyLimit)return [self finishToolAnalysis:@"轨迹已到数量上限,保留已完成部分" error:error];
|
||||
CMTime expected=CMTIME_IS_NUMERIC(_trackingPreviousTime)?(_trackingBackward?CMTimeSubtract(_trackingPreviousTime,_trackingFrameDuration):CMTimeAdd(_trackingPreviousTime,_trackingFrameDuration)):_trackingReferenceTime;if(!CMTIME_IS_NUMERIC(time)||time.epoch!=expected.epoch||CMTimeCompare(time,expected)!=0)return [self stopToolAnalysis:@"宿主帧序列不连续,停在最后可信帧" error:error];
|
||||
NSDictionary *preview=nil;
|
||||
dy::GrayFrame frame=[self toolGrayFrame:tile preview:(_trackingSingle&&!_trackingObjectMode)?nullptr:&preview error:error];
|
||||
if(!frame.valid())return [self stopToolAnalysis:@"宿主未返回完整源画面" error:error];
|
||||
dy::GrayFrame frame;
|
||||
const bool stamp=_trackingStampMotion.active;
|
||||
const bool objectMode=_trackingObjectMode&&!stamp;
|
||||
// The object tracker consumes only the small color image. The gray frame
|
||||
// is useful at the seed only when checking orientation against a cached frame.
|
||||
const bool needsGray=!objectMode||(!_trackingSamples.count&&_trackingReferenceFrame.valid());
|
||||
if(![self captureTrackingTile:tile gray:needsGray?&frame:nullptr preview:(!_trackingSingle||objectMode)?&preview:nullptr error:error])
|
||||
return [self stopToolAnalysis:@"宿主未返回完整源画面" error:error];
|
||||
if(!_trackingSamples.count){if(_trackingReferenceFrame.valid()&&frame.width==_trackingReferenceFrame.width&&frame.height==_trackingReferenceFrame.height){double same=0,flip=0;size_t count=0;for(int y=0;y<frame.height;y+=8)for(int x=0;x<frame.width;x+=8){float p=frame.at(y*frame.width+x);same+=fabs(p-_trackingReferenceFrame.at(y*frame.width+x));flip+=fabs(p-_trackingReferenceFrame.at((frame.height-1-y)*frame.width+x));count++;}same/=MAX(size_t(1),count);flip/=MAX(size_t(1),count);_trackingFlip=flip<.035&&flip+.008<same&&flip<same*.8;}os_log(OS_LOG_DEFAULT,"dayu_tool_track_seed width=%{public}d height=%{public}d flip=%{public}d time=%{public}.6f",frame.width,frame.height,(int)_trackingFlip,CMTimeGetSeconds(time));}
|
||||
if(_trackingFlip)frame.flipVertically();
|
||||
BOOL stamp=_trackingStampMotion.active;
|
||||
if(!objectMode&&_trackingFlip)frame.flipVertically();
|
||||
dy::TrackResult target,source;
|
||||
dy::ObjectStep objectStep;
|
||||
if(_trackingObjectMode&&!stamp){
|
||||
if(objectMode){
|
||||
NSData *rgba=preview[@"rgba"];int width=[preview[@"width"]intValue],height=[preview[@"height"]intValue];
|
||||
if(width<16||height<16||width>640||height>640||rgba.length!=size_t(width)*height*4)return [self finishToolAnalysis:@"目标跟踪未取得完整分析画面,原轨迹已保留" error:error];
|
||||
if(!_trackingSamples.count){
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
// Included in DYRenderer; all calls execute under its per-instance recursive lock.
|
||||
- (id<MTLBuffer>)maskBuffer:(NSDictionary*)groups tile:(FxImageTile*)tile device:(id<MTLDevice>)device header:(DYToolMaskHeader*)h {
|
||||
return [self maskBuffer:groups tile:tile device:device header:h mosaic:NO];
|
||||
}
|
||||
- (id<MTLBuffer>)maskBuffer:(NSDictionary*)groups tile:(FxImageTile*)tile device:(id<MTLDevice>)device header:(DYToolMaskHeader*)h mosaic:(BOOL)mosaic {
|
||||
std::vector<DYToolMaskEntry> entries;FxRect image=tile.imagePixelBounds,bounds=tile.tilePixelBounds;
|
||||
float w=image.right-image.left,ht=image.top-image.bottom;BOOL bottom=tile.imageOrigin==kFxImageOrigin_BOTTOM_LEFT;
|
||||
h->offsetX=(bounds.left-image.left)/w;h->scaleX=(bounds.right-bounds.left)/w;
|
||||
h->offsetY=bottom?(image.top-bounds.bottom)/ht:(image.top-bounds.top)/ht;h->scaleY=(bottom?-1:1)*(bounds.top-bounds.bottom)/ht;
|
||||
h->premultiplied=1;
|
||||
for(NSString *type in groups){NSInteger section=[DYToolTypes()indexOfObject:type];if(section==NSNotFound)continue;
|
||||
for(NSDictionary *m in groups[type]){if(![m[@"enabled"]boolValue])continue;DYToolMaskEntry entry{};entry.section=(int)section;entry.combine=[m[@"combine"]intValue];[m[@"parameters"]getBytes:&entry.mask.parameters length:sizeof(DYMaskParameters)];entry.mask.parameters.imageAspect=w/ht;NSData *nodes=m[@"nodes"];entry.mask.path=dyFlattenMask((const DYBezierNode*)nodes.bytes,nodes.length/sizeof(DYBezierNode));entries.push_back(entry);}
|
||||
for(NSDictionary *m in groups[type]){
|
||||
if(![m[@"enabled"]boolValue])continue;
|
||||
DYToolMaskEntry entry{};entry.section=(int)section;entry.combine=[m[@"combine"]intValue];
|
||||
[m[@"parameters"]getBytes:&entry.mask.parameters length:sizeof(DYMaskParameters)];entry.mask.parameters.imageAspect=w/ht;
|
||||
NSData *nodes=m[@"nodes"];auto &path=entry.mask.path;
|
||||
path=dyFlattenMask((const DYBezierNode*)nodes.bytes,nodes.length/sizeof(DYBezierNode));
|
||||
if(mosaic&&entry.mask.parameters.kind==DYMaskBezier&&path.count>=3){
|
||||
auto x=std::minmax_element(path.x,path.x+path.count),y=std::minmax_element(path.y,path.y+path.count);
|
||||
entry.minX=*x.first;entry.maxX=*x.second;entry.minY=*y.first;entry.maxY=*y.second;
|
||||
}
|
||||
entries.push_back(entry);
|
||||
}
|
||||
}if(_faceEntries.length){const DYToolMaskEntry *faces=(const DYToolMaskEntry*)_faceEntries.bytes;entries.insert(entries.end(),faces,faces+_faceEntries.length/sizeof(DYToolMaskEntry));}h->count=(unsigned)entries.size();if(entries.empty())entries.push_back({});return [[device newBufferWithBytes:entries.data() length:entries.size()*sizeof(DYToolMaskEntry) options:MTLResourceStorageModeShared]autorelease];
|
||||
}
|
||||
- (BOOL)encodeBlend:(id<MTLTexture>)before after:(id<MTLTexture>)after output:(id<MTLTexture>)output masks:(id<MTLBuffer>)masks header:(DYToolMaskHeader)h entry:(NSMutableDictionary*)entry commands:(id<MTLCommandBuffer>)commands error:(NSError**)error {
|
||||
|
||||
@@ -66,6 +66,12 @@
|
||||
auto compact=[plugin toolGrayFrame:fine preview:nullptr error:nil];BOOL identical=compact.valid()&&compact.pixels.empty()&&compact.bytes.size()==w*h;
|
||||
for(size_t i=0;i<compact.bytes.size()&&identical;++i)identical=compact.at(i)==gray.pixels[i];
|
||||
run.record(@"tracking-metal-gray8-compact-readback-matches-float-reference",identical,@{@"readbackBytes":@(compact.bytes.size()),@"previousReadbackBytes":@(gray.pixels.size()*sizeof(float))});
|
||||
id<DYToolHostProbe> previewOnly=[(id)[[NSClassFromString(@"DYPlugIn") alloc] initWithAPIManager:host] autorelease];
|
||||
NSDictionary *color=nil,*referenceColor=nil;
|
||||
BOOL colorOK=[previewOnly captureTrackingTile:fine gray:nullptr preview:&color error:nil];
|
||||
auto full=[plugin toolGrayFrame:fine preview:&referenceColor error:nil];
|
||||
BOOL noGrayBuffer=YES;for(NSDictionary *entry in [[previewOnly valueForKey:@"toolCaptureDevices"] allValues])noGrayBuffer&=entry[@"buffer"]==nil;
|
||||
run.record(@"mosaic-tracking-4k-color-input-matches-without-gray-buffer",colorOK&&full.valid()&&color[@"rgba"]&&[color isEqual:referenceColor]&&noGrayBuffer);
|
||||
}
|
||||
// UI aliases of a shared object are one tracking target. Switching from the
|
||||
// global editor to either linked module must not cancel a valid analysis.
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
- (BOOL)cleanupAnalysis:(NSError**)error;
|
||||
- (dy::GrayFrame)toolGrayFrame:(FxImageTile*)tile error:(NSError**)error;
|
||||
- (dy::GrayFrame)toolGrayFrame:(FxImageTile*)tile preview:(NSDictionary**)preview error:(NSError**)error;
|
||||
- (BOOL)captureTrackingTile:(FxImageTile*)tile gray:(dy::GrayFrame*)gray preview:(NSDictionary**)preview error:(NSError**)error;
|
||||
@end
|
||||
|
||||
@interface DYToolCanvasProbe : DYToolTrackingProbe
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.21.1</string>
|
||||
<string>1.21.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>117</string>
|
||||
<string>118</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>PlugInKit</key>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.21.1</string>
|
||||
<string>1.21.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>117</string>
|
||||
<string>118</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
更新于 2026-11-08(Asia/Shanghai)。这是新对话的接手入口。历史设计和实现细节按需查阅专项交接,复现和交付证据以对应版本的报告为准。
|
||||
|
||||
## 1.21.2(118)局部马赛克与蒙版分析性能
|
||||
|
||||
2026-11-08。已核对正式 1.21.1(117)与大鱼远端基线。马赛克渲染只在色键使用颜色编码,钢笔路径在局部包围范围外跳过轮廓计算,反相与色阶仍照常应用。无人脸命中时跳过全帧马赛克通道。指定目标追踪沿用原 Vision 彩色输入,仅在有可对照的起始画面时需要整帧灰度;普通蒙版与图章保留灰度输入。
|
||||
|
||||
本机 M4 的 Vision 计算设备查询显示,人脸框和目标追踪支持神经网络引擎、GPU 和 CPU,普通蒙版使用的透视配准只列 CPU。先比较相同像素输入和轨迹,再从正式路径验证 FCP。当前为源码检查点,正式安装、验收和发行待更新。
|
||||
|
||||
## 1.21.1(117)首次示波器与人脸肤色保护
|
||||
|
||||
正式安装在 `/Library/Plug-Ins/FxPlug/大鱼调色.app`,编译提交 `98d80970e83e30e4883a76d8f740f2fca5d05e7c`,APP 公证 `eeda9002-5e87-4a33-83d3-9163a14283ba` Accepted。票据、Gatekeeper、PluginKit 唯一路径及 1008 项正式安装原生检查通过。FCP 12.4 已从正式路径启动插件服务。17 套模板检查通过。[安装](verification/Delivery1.21.1.json)
|
||||
|
||||
在新工单中引用
屏蔽一个用户