diff --git a/README.md b/README.md index e695d3b..aa020a6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 原生 FxPlug 4 调色器,当前正式安装的公测版本 **1.7.4(52)**。唯一安装位置为 `/Library/Plug-Ins/FxPlug/大鱼调色.app`;Final Cut Pro 中从“效果 → 大鱼调色”添加。 -2026-11-03完成BASIS、Colour Space Transform和Color Finale的只读色彩管理调查,含原版GPU曝光/映射及当前一级颜色内核的有限检查。宿主边界、重复映射、工具工作域和旧工程迁移的改进方案见[研究报告与实施方案](research/cms-audit-20261103/report.md)。1.8.0(54)候选已按方案接入新版 CMS,正式交付状态以 verification/Delivery.json 为准。 +2026-11-03完成BASIS、Colour Space Transform和Color Finale的只读色彩管理调查,含原版GPU曝光/映射及当前一级颜色内核的有限检查。宿主边界、重复映射、工具工作域和旧工程迁移的改进方案见[研究报告与实施方案](research/cms-audit-20261103/report.md)。1.8.0(55)候选已按方案接入新版 CMS,正式交付状态以 verification/Delivery.json 为准。 ## 1.8.0 色彩管理 diff --git a/大鱼调色/Plugin/DYManagedColorPanel.mm b/大鱼调色/Plugin/DYManagedColorPanel.mm index 3f06a3a..f8c20ef 100644 --- a/大鱼调色/Plugin/DYManagedColorPanel.mm +++ b/大鱼调色/Plugin/DYManagedColorPanel.mm @@ -3,10 +3,13 @@ #import "DYModel.h" #import "DYRenderer.h" #import "DYTheme.h" +@protocol DYManagedAssetTarget +- (NSProgress*)setAssetPath:(NSString*)path forKey:(NSString*)key completion:(void(^)(NSError*))completion; +@end @implementation DYManagedColorPanel { id _manager;id _assetTarget;DYRenderer *_renderer; NSPopUpButton *_mode,*_input,*_output;NSButton *_gamut,*_lut;NSTextField *_inputLabel,*_outputLabel,*_help,*_context; - NSDictionary *_state;BOOL _refreshing; + NSDictionary *_state;NSString *_inputLUTPath;NSUInteger _selectionGeneration;BOOL _refreshing; } - (BOOL)isFlipped{return YES;} - (CGFloat)contentHeight{NSInteger m=[_state[@"mode"]integerValue];return m==0?112:m==1?190:302;} @@ -23,7 +26,7 @@ static NSTextField *cmsLabel(NSString*s){NSTextField*l=[NSTextField wrappingLabe for(NSView*v in @[_mode,_inputLabel,_input,_outputLabel,_output,_gamut,_lut,_help,_context])[self addSubview:v];[self refreshWithState:nil context:nil]; }return self; } -- (void)dealloc{[_renderer release];[_state release];for(id v in @[_mode,_input,_output,_gamut,_lut,_inputLabel,_outputLabel,_help,_context])[v release];[super dealloc];} +- (void)dealloc{[_renderer release];[_state release];[_inputLUTPath release];for(id v in @[_mode,_input,_output,_gamut,_lut,_inputLabel,_outputLabel,_help,_context])[v release];[super dealloc];} - (void)layout{[super layout];CGFloat w=self.bounds.size.width;_mode.frame=NSMakeRect(0,3,w,26);_inputLabel.frame=NSMakeRect(2,36,70,22);_input.frame=NSMakeRect(72,32,w-72,26);_outputLabel.frame=NSMakeRect(2,67,70,22);_output.frame=NSMakeRect(72,63,w-72,26);_gamut.frame=NSMakeRect(0,94,w,22);_lut.frame=NSMakeRect(0,120,w,25);_help.frame=NSMakeRect(2,152,w-4,96);_context.frame=NSMakeRect(2,252,w-4,47);if([_state[@"mode"]integerValue]<2){_help.frame=NSMakeRect(2,36,w-4,90);_context.frame=NSMakeRect(2,132,w-4,54);}} - (void)refreshWithState:(NSDictionary*)s context:(NSDictionary*)context { _refreshing=YES;NSDictionary *saved=[s copy];[_state release];_state=saved;NSInteger mode=s.count?[s[@"mode"]integerValue]:0;[_mode selectItemAtIndex:mode]; @@ -32,12 +35,17 @@ static NSTextField *cmsLabel(NSString*s){NSTextField*l=[NSTextField wrappingLabe _help.stringValue=mode==0?@"保留当前工程的原有颜色。选择新版后,一级层在 ACEScct 中调色,印片位于输出之前;可撤销或切回兼容方式。":mode==1?@"按宿主实际空间处理,不重复还原或映射。顺序:一级层 → 印片 → SDR 修饰。Rec.2020 宿主暂限一级与印片。":mode==2?@"按所选相机编码解释兼容码值。请确认上游未还原、未自动符合;选择准确输入与输出目标。PQ/HLG 仅支持一级与印片,其他工具用于 SDR。":@"使用输入 LUT,并按“LUT 输出”解释其结果;再进入 ACEScct 和所选输出变换。"; _context.stringValue=context.count?[NSString stringWithFormat:@"%@ → ACEScct → %@",context[@"source"]?:@"未知",context[@"destination"]?:@"未知"]:@"宿主颜色信息将在渲染后显示。";_refreshing=NO;[self setNeedsLayout:YES]; } -- (void)setInputLUTPath:(NSString*)path{_lut.title=path.length?path.lastPathComponent:@"选择输入 LUT…";_lut.toolTip=path.length?path:@"选择 LUT,并准确指定其输出编码";_lut.accessibilityLabel=path.length?[@"输入 LUT:" stringByAppendingString:path.lastPathComponent]:@"选择输入 LUT";} +- (void)setInputLUTPath:(NSString*)path{NSString *saved=[path copy];[_inputLUTPath release];_inputLUTPath=saved;_lut.title=path.length?path.lastPathComponent:@"选择输入 LUT…";_lut.toolTip=path.length?path:@"选择 LUT,并准确指定其输出编码";_lut.accessibilityLabel=path.length?[@"输入 LUT:" stringByAppendingString:path.lastPathComponent]:@"选择输入 LUT";} - (void)refreshContext{[self refreshWithState:_state context:[_renderer colorContext]];} - (void)writeState:(NSDictionary*)state { if(state&&!DYManagedColorValid(state,nil))return;ida=[_manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{idundo=[_manager apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"更改色彩管理方式"];DYAssetState*assets=[[DYReadAssets(_manager,a.currentTime)copy]autorelease];assets.colorManagement=state;DYWriteAssets(_manager,assets,a.currentTime);[undo endUndoGroup];}@finally{[a endAction:self];}[_renderer invalidatePreview];[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:_manager]; } -- (void)modeChanged:(id)sender {if(_refreshing)return;NSInteger mode=_mode.indexOfSelectedItem;if(!mode){[self writeState:nil];return;}NSMutableDictionary *s=[[_state?:DYManagedColorDefaults() mutableCopy]autorelease];s[@"mode"]=@(mode);[self writeState:s];} +- (void)modeChanged:(id)sender {if(_refreshing)return;NSInteger mode=_mode.indexOfSelectedItem;_selectionGeneration++;if(mode==3&&(!_inputLUTPath.length||![NSFileManager.defaultManager fileExistsAtPath:_inputLUTPath])){[self refreshWithState:_state context:[_renderer colorContext]];[self selectInputLUTAndEnable:YES];return;}if(!mode){[self writeState:nil];return;}NSMutableDictionary *s=[[_state?:DYManagedColorDefaults() mutableCopy]autorelease];s[@"mode"]=@(mode);[self writeState:s];} - (void)settingsChanged:(id)sender {if(_refreshing||!_state)return;NSMutableDictionary*s=[[_state mutableCopy]autorelease];s[@"input"]=_input.selectedItem.representedObject;s[@"output"]=_output.selectedItem.representedObject;s[@"gamutCompression"]=@(_gamut.state==NSControlStateValueOn);[self writeState:s];} -- (void)chooseLUT:(id)sender {[_assetTarget performSelector:@selector(chooseFileForKey:) withObject:@"input"];} +- (void)selectInputLUTAndEnable:(BOOL)enable { + NSUInteger generation=_selectionGeneration;NSOpenPanel *panel=[NSOpenPanel openPanel];panel.allowedFileTypes=@[@"cube"];panel.allowsMultipleSelection=NO;panel.canChooseDirectories=NO;panel.message=@"选择输入 LUT,再指定 LUT 的输出编码"; + if([panel runModal]!=NSModalResponseOK||!self.window)return; + [(id)_assetTarget setAssetPath:panel.URL.path forKey:@"input" completion:^(NSError *error){if(error||!enable||!self.window||generation!=_selectionGeneration)return;NSMutableDictionary *s=[[(_state?:DYManagedColorDefaults())mutableCopy]autorelease];s[@"mode"]=@3;[self writeState:s];}]; +} +- (void)chooseLUT:(id)sender {[self selectInputLUTAndEnable:NO];} @end diff --git a/大鱼调色/Plugin/DYManagedDiagnostics.inc.h b/大鱼调色/Plugin/DYManagedDiagnostics.inc.h index 0286435..6771b6d 100644 --- a/大鱼调色/Plugin/DYManagedDiagnostics.inc.h +++ b/大鱼调色/Plugin/DYManagedDiagnostics.inc.h @@ -33,7 +33,7 @@ for(NSDictionary *inputSpace in DYManagedInputSpaces()){@autoreleasepool{state[@"input"]=inputSpace[@"id"];Pixels gpuFrame=managed(state,u,empty.document,[NSString stringWithFormat:@"cms-input-%@-render",inputSpace[@"id"]]);Difference delta=difference(gpuFrame,cpuOutput(cpuInput(),1));run.record([NSString stringWithFormat:@"cms-input-%@-cpu-parity",inputSpace[@"id"]],delta.nonfinite==0&&delta.maximum<.01,measure(delta));}}state[@"input"]=@109; // Identity input LUT must be the same declared-input path, not an extra DRT. NSString *identityPath=[runtime stringByAppendingPathComponent:@"cms-identity-input.cube"];NSMutableString *identity=[NSMutableString stringWithString:@"LUT_3D_SIZE 2\n"];for(int z=0;z<2;z++)for(int y=0;y<2;y++)for(int x=0;x<2;x++)[identity appendFormat:@"%d %d %d\n",x,y,z];[identity writeToFile:identityPath atomically:YES encoding:NSUTF8StringEncoding error:&error]; - state[@"output"]=@1;Pixels camera=managed(state,u,empty.document,@"cms-camera-identity-LUT-reference");state[@"mode"]=@3;error=nil;BOOL lutOK=[cmsRenderer renderSource:source destination:destination uniforms:u paths:@{@"input":identityPath} spider:nil tools:empty.document colorManagement:state hostPrimaries:kFxColorPrimaries_Rec709 error:&error];Difference lutDelta=difference(camera,read(destination,gpu));run.record(@"cms-input-LUT-same-single-input-and-ODT-chain",lutOK&&lutDelta.maximum<.001&&lutDelta.nonfinite==0,measure(lutDelta));error=nil;BOOL missingLUT=[cmsRenderer renderSource:source destination:destination uniforms:u paths:@{} spider:nil tools:empty.document colorManagement:state hostPrimaries:kFxColorPrimaries_Rec709 error:&error];run.record(@"cms-input-LUT-missing-resource-fails-explicitly",!missingLUT&&error!=nil);state[@"mode"]=@2; + state[@"output"]=@1;Pixels camera=managed(state,u,empty.document,@"cms-camera-identity-LUT-reference");state[@"mode"]=@3;error=nil;BOOL lutOK=[cmsRenderer renderSource:source destination:destination uniforms:u paths:@{@"input":identityPath} spider:nil tools:empty.document colorManagement:state hostPrimaries:kFxColorPrimaries_Rec709 error:&error];Difference lutDelta=difference(camera,read(destination,gpu));run.record(@"cms-input-LUT-same-single-input-and-ODT-chain",lutOK&&lutDelta.maximum<.001&&lutDelta.nonfinite==0,measure(lutDelta));error=nil;BOOL missingLUT=[cmsRenderer renderSource:source destination:destination uniforms:u paths:@{} spider:nil tools:empty.document colorManagement:state hostPrimaries:kFxColorPrimaries_Rec709 error:&error];run.record(@"cms-input-LUT-missing-resource-fails-explicitly",!missingLUT&&[error.domain isEqual:@"com.dayu.color"]&&error.localizedDescription.length>0);state[@"mode"]=@2; state[@"output"]=@3;DYUniforms print=u;print.filmPrint.x=1;print.filmPrint.y=.6;print.film.mix=.8;Pixels base=managed(state,u,empty.document,@"cms-print-baseline-p3"),printed=managed(state,print,empty.document,@"cms-print-before-p3-output"); NSMutableDictionary *printDoc=DYMutablePlist(empty.document),*printNode=(id)DYInsertTool(printDoc,@"film",@"base:film");printNode[@"values"][@"filmPrintLook"]=@1;printNode[@"values"][@"filmPrintStrength"]=@.6;printNode[@"values"][@"filmMix"]=@.8;Pixels extraPrint=managed(state,u,printDoc,@"cms-independent-print-before-output");run.record(@"cms-root-and-extra-print-same-pre-output-result",difference(printed,extraPrint).maximum==0&&difference(printed,base).different>20); // A CPU tetrahedral lookup in AP1/ACEScct, mixed in AP1 linear, then ODT. @@ -42,7 +42,7 @@ if(readLook)for(auto &pixel:scene){if(!(pixel.a>0))continue;float c[3]={pixel.r/pixel.a,pixel.g/pixel.a,pixel.b/pixel.a},f[3];int cell[3],axis[3]={0,1,2};for(int k=0;k<3;k++){float x=fmaxf(0,fminf(1,c[k]))*(lookSide-1);cell[k]=MIN((int)floorf(x),(int)lookSide-2);f[k]=x-cell[k];}std::sort(axis,axis+3,[&](int x,int y){return f[x]>f[y];}); float weights[4]={1-f[axis[0]],f[axis[0]]-f[axis[1]],f[axis[1]]-f[axis[2]],f[axis[2]]},value[3]={};for(int j=0;j<4;j++){size_t offset=((cell[2]*lookSide+cell[1])*lookSide+cell[0])*4;for(int k=0;k<3;k++)value[k]+=look[offset+k]*weights[j];if(j<3)cell[axis[j]]++;}float out[3];for(int k=0;k<3;k++)out[k]=dyPrintCCTEncode(dyPrintCCTDecode(c[k])*.52f+dyPrintCCTDecode(value[k])*.48f)*pixel.a;pixel.r=out[0];pixel.g=out[1];pixel.b=out[2];} Difference printDelta=difference(printed,cpuOutput(scene,3));run.record(@"cms-print-cpu-reference-before-ODT-linear-mix",readLook&&printDelta.maximum<.01&&printDelta.nonfinite==0,measure(printDelta)); - state[@"output"]=@6;DYUniforms bounded=u;bounded.hslHueA.x=20;NSError *blocked=nil;BOOL hdr=[cmsRenderer renderSource:source destination:destination uniforms:bounded paths:@{} spider:nil tools:empty.document colorManagement:state hostPrimaries:kFxColorPrimaries_Rec709 error:&blocked];run.record(@"cms-hdr-refuses-unvalidated-bounded-finishing",!hdr&&blocked!=nil); + state[@"output"]=@6;DYUniforms bounded=u;bounded.hslHueA.x=20;NSError *blocked=nil;BOOL hdr=[cmsRenderer renderSource:source destination:destination uniforms:bounded paths:@{} spider:nil tools:empty.document colorManagement:state hostPrimaries:kFxColorPrimaries_Rec709 error:&blocked];run.record(@"cms-hdr-refuses-unvalidated-bounded-finishing",!hdr&&[blocked.domain isEqual:@"com.dayu.color"]&&blocked.localizedDescription.length>0); state[@"output"]=@1;NSURL *cube=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"cms-v2.cube"]];error=nil;BOOL exportOK=[cmsRenderer exportLUT:cube uniforms:u paths:@{} spider:nil tools:empty.document colorManagement:state error:&error];std::vectortable;NSUInteger size=0;BOOL parse=exportOK&&DYLUTReadCube(cube.path,table,size,&error);run.record(@"cms-v2-cube-65-declared-output-contract",parse&&size==65,@{@"error":reason(error),@"size":@(size)}); // Static Cube interpolation at off-grid values must match the complete path. Pixels direct=managed(state,u,empty.document,@"cms-cube-off-grid-direct-reference");double cubeError=0; diff --git a/大鱼调色/Plugin/DYManagedRender.inc.h b/大鱼调色/Plugin/DYManagedRender.inc.h index 3ff1d0b..bc920e8 100644 --- a/大鱼调色/Plugin/DYManagedRender.inc.h +++ b/大鱼调色/Plugin/DYManagedRender.inc.h @@ -24,7 +24,7 @@ - (BOOL)managedProfile:(DYColorProfile*)profile input:(id)input output:(id)output entry:(NSMutableDictionary*)entry error:(NSError**)error { if(!profile)return NO;NSMutableDictionary*cache=entry[@"managedProfiles"];if(!cache){cache=[NSMutableDictionary dictionary];entry[@"managedProfiles"]=cache;}DYColorProfileGPU*p=cache[profile.key];if(!p){p=[[[DYColorProfileGPU alloc]initWithDevice:entry[@"device"] profile:profile error:error]autorelease];if(!p)return NO;if(cache.count>=16)[cache removeAllObjects];cache[profile.key]=p;}return [p renderInput:input output:output alpha:dycm::Alpha::Premultiplied workspaceBudget:2ull*1024*1024*1024 cancelled:nullptr error:error]; } -- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools colorManagement:(NSDictionary*)state hostPrimaries:(NSInteger)primaries error:(NSError**)error {@synchronized(self){@autoreleasepool{ +- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools colorManagement:(NSDictionary*)state hostPrimaries:(NSInteger)primaries error:(NSError**)error {@synchronized(self){return DYRenderWithPool(error,[&]()->BOOL{ if(state&&![state isKindOfClass:NSDictionary.class])return fail(error,@"色彩管理状态无效。"); NSDictionary*context=DYHostColorContext(src,dst,primaries);@synchronized(_previewLock){[_colorContext release];_colorContext=[context copy];} if(!state.count)return [self renderSource:src destination:dst uniforms:u paths:paths spider:spider tools:tools error:error]; @@ -66,5 +66,5 @@ DYColorProfile*returnProfile=[[[DYColorProfile alloc]initWithSource:linear709 target:dstSpace error:error]autorelease];if(!profile(returnProfile))return NO; _managedFinishing=YES;@try{return [self copyTile:tile(current) to:dst entry:entry error:error];}@finally{_managedFinishing=NO;} }catch(const std::exception&e){return fail(error,@(e.what()));}}@finally{if(srcSpace)CGColorSpaceRelease(srcSpace);if(dstSpace)CGColorSpaceRelease(dstSpace);if(aces)CGColorSpaceRelease(aces);if(linear709)CGColorSpaceRelease(linear709);} -}}} +});}} - (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools colorManagement:(NSDictionary*)state error:(NSError**)error {@synchronized(self){if(state&&![state isKindOfClass:NSDictionary.class])return fail(error,@"色彩管理状态无效。");if(state.count&&!DYManagedColorValid(state,error))return NO;if(state.count&&[state[@"mode"]integerValue]!=1&&[@[@6,@7]containsObject:state[@"output"]])return fail(error,@"PQ/HLG 交付需要明确的亮度与范围,请保存完整预设;当前静态 Cube 输出为 sRGB。");if(state.count){auto spatial=[](DYUniforms v){return v.baseSectionEnabled>.5&&((v.textureEnabled>.5&&v.texture!=0)||(v.clarityEnabled>.5&&v.clarity!=0)||(v.dehazeEnabled>.5&&v.dehaze!=0));};BOOL unsupported=spatial(u);for(NSDictionary *node in tools[@"layers"])unsupported|=spatial(DYToolUniforms(node));if(unsupported)return fail(error,@"纹理、清晰度或去朦胧依赖画面内容,不能完整保存到 Cube;请保存完整预设。");}_exportManagedState=state.count?state:nil;@try{return [self exportLUT:url uniforms:u paths:paths spider:spider tools:tools error:error];}@finally{_exportManagedState=nil;}}} diff --git a/大鱼调色/Plugin/DYRenderer.mm b/大鱼调色/Plugin/DYRenderer.mm index 7d6acd5..54a2ed9 100644 --- a/大鱼调色/Plugin/DYRenderer.mm +++ b/大鱼调色/Plugin/DYRenderer.mm @@ -18,6 +18,13 @@ #include #include static BOOL fail(NSError**e,NSString*m){if(e)*e=[NSError errorWithDomain:@"com.dayu.color" code:1 userInfo:@{NSLocalizedDescriptionKey:m?:@"Metal 调色失败"}];return NO;} +// MRC NSError out-parameters must outlive every nested render pool. Preserve +// the same pointer across nested closures, then autorelease in the caller pool. +template static BOOL DYRenderWithPool(NSError **error,F body){ + if(error)*error=nil;NSError *held=nil;BOOL ok=NO; + @autoreleasepool{@try{ok=body();}@catch(NSException *exception){ok=fail(error,exception.reason?:@"渲染异常");}if(!ok&&error)held=[*error retain];} + if(error)*error=[held autorelease];return ok; +} static NSArray *inputFiles(){return @[@"",@"apple_log_to_rec709",@"arri_logc3_to_rec709",@"arri_logc4_to_rec709",@"blackmagic_film_gen5_to_rec709",@"canon_clog_bt709_to_rec709",@"canon_clog2_cinema_gamut_to_rec709",@"canon_clog3_cinema_gamut_to_rec709",@"dji_dlog_to_rec709",@"dji_dlog_m_to_rec709",@"fujifilm_flog_to_rec709",@"fujifilm_flog2_to_rec709",@"nikon_nlog_to_rec709",@"panasonic_vlog_vgamut_to_rec709",@"red_log3g10_rwg_to_rec709",@"sony_slog2_sgamut_to_rec709",@"sony_slog3_sgamut3cine_to_rec709",@"sony_hlg_bt2020_to_rec709"];} static id texture3D(idd,const float*values,NSUInteger n){MTLTextureDescriptor*t=[MTLTextureDescriptor new];t.textureType=MTLTextureType3D;t.pixelFormat=MTLPixelFormatRGBA32Float;t.width=n;t.height=n;t.depth=n;t.storageMode=MTLStorageModeShared;t.usage=MTLTextureUsageShaderRead;idx=[d newTextureWithDescriptor:t];[t release];if(x)[x replaceRegion:MTLRegionMake3D(0,0,0,n,n,n) mipmapLevel:0 slice:0 withBytes:values bytesPerRow:n*16 bytesPerImage:n*n*16];return [x autorelease];} // A synthetic texture lattice uses exactly the production render path for Cube export. @@ -160,7 +167,7 @@ static NSArray *DYManagedActiveFinishing(DYUniforms u,NSDictionary *paths,NSData - (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{return [self renderSource:src destination:dst uniforms:u paths:paths spider:nil error:err];} - (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider error:(NSError**)err{return [self renderSource:src destination:dst uniforms:u paths:paths spider:spider tools:nil error:err];} - (BOOL)renderLegacy:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider masks:(NSDictionary*)masks error:(NSError**)err{return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:masks stageFirst:-1 stageLast:-1 skinReference:nil originalReference:nil captureOriginal:nullptr suppressBlackWhite:NO error:err];} -- (BOOL)renderLegacy:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider masks:(NSDictionary*)masks stageFirst:(NSInteger)stageFirst stageLast:(NSInteger)stageLast skinReference:(FxImageTile*)skinReference originalReference:(FxImageTile*)originalReference captureOriginal:(DYExportTile**)captureOriginal suppressBlackWhite:(BOOL)suppressBlackWhite error:(NSError**)err{@synchronized(self){@autoreleasepool{ +- (BOOL)renderLegacy:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider masks:(NSDictionary*)masks stageFirst:(NSInteger)stageFirst stageLast:(NSInteger)stageLast skinReference:(FxImageTile*)skinReference originalReference:(FxImageTile*)originalReference captureOriginal:(DYExportTile**)captureOriginal suppressBlackWhite:(BOOL)suppressBlackWhite error:(NSError**)err{@synchronized(self){return DYRenderWithPool(err,[&]()->BOOL{ BOOL segmented=stageFirst>=0;if(segmented&&(stageFirst>stageLast||stageLast>11))return fail(err,@"原生工具分段范围无效"); if(spider.length&&!DYSpiderMeshIsValid(spider))return fail(err,@"蜘蛛盘数据无效"); if(u.primarySectionEnabled<.5){u.inputSectionEnabled=0;u.cm.basisEnabled=0;u.cm.outputEnabled=0;} @@ -216,7 +223,7 @@ static NSArray *DYManagedActiveFinishing(DYUniforms u,NSDictionary *paths,NSData _lastPreview=CACurrentMediaTime();dispatch_async(dispatch_get_main_queue(),^{[[NSNotificationCenter defaultCenter]postNotificationName:@"DYPreviewDidChange" object:self];}); }} if(!ok)fail(err,cb.error.localizedDescription);[pb release];[straight release];[scene release];return ok; - }}} + });}} - (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{return [self exportLUT:url uniforms:u paths:paths spider:nil error:err];} - (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider error:(NSError**)err{@synchronized(self){ if(DYFilmToolActive(u)&&DYFilmSpatialActive(u.film))return fail(err,@"胶片空间和颗粒处理不能保存到静态 Cube,请保存完整预设。"); diff --git a/大鱼调色/Plugin/DYToolRender.inc.h b/大鱼调色/Plugin/DYToolRender.inc.h index 70651f8..fe49c77 100644 --- a/大鱼调色/Plugin/DYToolRender.inc.h +++ b/大鱼调色/Plugin/DYToolRender.inc.h @@ -40,7 +40,7 @@ DYToolMaskHeader h{};h.section=3;idbuffer=[self maskBuffer:@{type:node[@"masks"]} tile:source device:d header:&h];cb=[entry[@"queue"]commandBuffer];[self encodeBlend:before after:after output:blend masks:buffer header:h entry:entry commands:cb];[cb commit];[cb waitUntilCompleted];BOOL ok=cb.status==MTLCommandBufferStatusCompleted; DYExportTile *blended=[[DYExportTile alloc]initWithTexture:blend registry:d.registryID];[blended setBounds:source.tilePixelBounds origin:source.imageOrigin];[blended setPixelAspect:source.pixelAspect];[blend release];if(ok)ok=[self copyTile:blended to:destination entry:entry error:error];else fail(error,cb.error.localizedDescription);[blended release];return ok; } -- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){@autoreleasepool{ +- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){return DYRenderWithPool(error,[&]()->BOOL{ if(!tools)tools=@{@"schema":@1,@"layers":@[],@"baseMasks":@{}};if(!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程"); DYApplyRemovedBaseTools(&u,tools);paths=DYVisibleBaseToolPaths(paths,tools);if(DYBaseToolRemoved(tools,@"spider"))spider=nil; NSArray *layers=tools[@"layers"];BOOL active=NO,anchored=NO;for(NSDictionary *node in layers)if(!DYToolIsNeutral(node)){active=YES;anchored|=![DYToolRootAnchor(tools,node[@"id"])isEqual:@"tail"];} @@ -51,7 +51,7 @@ DYExportTile *tile=nil,*skinReference=nil,*originalReference=nil;NSArray *order=DYToolDisplayOrder(tools);NSMutableDictionary *groups=[NSMutableDictionary dictionary];for(NSString *ID in order){NSDictionary *node=DYToolWithID(tools,ID);if(!node||DYToolIsNeutral(node))continue;NSString *root=DYToolRootAnchor(tools,ID);if(!groups[root])groups[root]=[NSMutableArray array];[groups[root]addObject:node];} auto makeTile=[&](){idtexture=[d newTextureWithDescriptor:desc];if(!texture)return (DYExportTile*)nil;DYExportTile *result=[[DYExportTile alloc]initWithTexture:texture registry:d.registryID];[result setBounds:src.tilePixelBounds origin:src.imageOrigin];[result setPixelAspect:src.pixelAspect];[texture release];return result;}; auto replace=[&](DYExportTile *next){[tile release];tile=next;}; - auto apply=[&](NSString *anchor){for(NSDictionary *node in groups[anchor]){@autoreleasepool{DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配新增工具缓冲区");BOOL ok=[self renderExtraTool:node source:tile original:src destination:next entry:entry error:error];if(!ok){[next release];return NO;}replace(next);}}return YES;}; + auto apply=[&](NSString *anchor){for(NSDictionary *node in groups[anchor]){if(!DYRenderWithPool(error,[&]()->BOOL{DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配新增工具缓冲区");BOOL ok=[self renderExtraTool:node source:tile original:src destination:next entry:entry error:error];if(!ok){[next release];return NO;}replace(next);return YES;}))return NO;}return YES;}; @try{ if(!anchored){DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配工具图层缓冲区");BOOL ok=[self renderLegacy:src destination:next uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error];if(!ok){[next release];return NO;}replace(next);} else { @@ -61,13 +61,13 @@ NSArray *anchors=@[@"base:primary",@"base:primaries",@"",@"base:curve",@"base:levels",@"base:balance",@"base:hsl",@"base:grading",@"base:base",@"base:blackwhite",@"base:look",@"base:skin"]; float bwMix=fmaxf(0,fminf(1,u.cm.blackWhiteMix));BOOL splitBW=u.blackWhiteSectionEnabled>.5&&bwMix>0&&bwMix<1&&([groups[@"base:blackwhite"]count]||[groups[@"base:look"]count]); NSInteger first=0; - for(NSInteger last=0;last<(splitBW?9:12);last++)if(last==5||last==(splitBW?8:11)||[groups[anchors[last]]count]){@autoreleasepool{ + for(NSInteger last=0;last<(splitBW?9:12);last++)if(last==5||last==(splitBW?8:11)||[groups[anchors[last]]count]){if(!DYRenderWithPool(error,[&]()->BOOL{ DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配原生工具分段缓冲区");DYUniforms segment=u; BOOL ok=[self renderLegacy:tile?:src destination:next uniforms:segment paths:paths spider:nil masks:tools[@"baseMasks"] stageFirst:first stageLast:last skinReference:skinReference originalReference:originalReference captureOriginal:first==0?&originalReference:nullptr suppressBlackWhite:NO error:error];if(!ok){[next release];return NO;}replace(next); if(!apply(anchors[last]))return NO; // Skin protects the native pre-HSL result, including tools inserted before it. - if(last==5){[skinReference release];skinReference=[tile retain];}first=last+1; - }} + if(last==5){[skinReference release];skinReference=[tile retain];}first=last+1;return YES; + }))return NO;} if(splitBW){ // Native partial B&W mixes two complete color branches after native skin, // before Spider. Keep that fork if a B&W/Look insertion splits stages 9-11. @@ -76,9 +76,9 @@ @try{ for(int branch=0;branch<2;branch++){ if(branch==1)replace([prefix retain]);DYUniforms branchUniforms=u;branchUniforms.cm.blackWhiteMix=1;NSInteger begin=9; - for(NSInteger end=9;end<12;end++)if(end==11||[groups[anchors[end]]count]){@autoreleasepool{ - DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配黑白混合分支缓冲区");BOOL ok=[self renderLegacy:tile destination:next uniforms:branchUniforms paths:paths spider:nil masks:tools[@"baseMasks"] stageFirst:begin stageLast:end skinReference:skinReference originalReference:originalReference captureOriginal:nullptr suppressBlackWhite:branch==1 error:error];if(!ok){[next release];return NO;}replace(next);if(end<11&&!apply(anchors[end]))return NO;begin=end+1; - }} + for(NSInteger end=9;end<12;end++)if(end==11||[groups[anchors[end]]count]){if(!DYRenderWithPool(error,[&]()->BOOL{ + DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配黑白混合分支缓冲区");BOOL ok=[self renderLegacy:tile destination:next uniforms:branchUniforms paths:paths spider:nil masks:tools[@"baseMasks"] stageFirst:begin stageLast:end skinReference:skinReference originalReference:originalReference captureOriginal:nullptr suppressBlackWhite:branch==1 error:error];if(!ok){[next release];return NO;}replace(next);if(end<11&&!apply(anchors[end]))return NO;begin=end+1;return YES; + }))return NO;} if(branch==0)bwTile=[tile retain]; } DYExportTile *mixed=makeTile();if(!mixed)return fail(error,@"无法分配黑白混合缓冲区");DYToolMaskEntry constant{};constant.section=0;constant.combine=0;constant.mask.parameters=dyDefaultMaskParameters();constant.mask.parameters.kind=DYMaskRectangle;constant.mask.parameters.width=constant.mask.parameters.height=4000;constant.mask.parameters.feather=0;constant.mask.parameters.outputBlack=constant.mask.parameters.outputWhite=1;constant.mask.parameters.strength=bwMix; @@ -96,7 +96,7 @@ // their old end-of-chain order. Saving does not silently migrate old looks. if(!apply(@"tail"))return NO;return [self copyTile:tile to:dst entry:entry error:error]; }@finally{[originalReference release];[skinReference release];[tile release];} - }}} + });}} - (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){ if(tools&&!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程");DYApplyRemovedBaseTools(&u,tools);paths=DYVisibleBaseToolPaths(paths,tools);if(DYBaseToolRemoved(tools,@"spider"))spider=nil; if(DYFilmToolActive(u)&&DYFilmSpatialActive(u.film))return fail(error,@"当前胶片含晕光、辉光、颗粒或暗角,无法完整保存到静态 Cube。请保存完整预设,或关闭这些处理后再导出。");for(NSDictionary *node in tools[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"film"]&&DYFilmToolActive(layer)&&DYFilmSpatialActive(layer.film))return fail(error,@"新增胶片层含空间或时间处理,无法完整保存到静态 Cube。请保存完整预设。");} diff --git a/大鱼调色/Plugin/Info.plist b/大鱼调色/Plugin/Info.plist index 1b32d15..f6616ea 100644 --- a/大鱼调色/Plugin/Info.plist +++ b/大鱼调色/Plugin/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.8.0 CFBundleVersion - 54 + 55 NSHumanReadableCopyright PlugInKit diff --git a/大鱼调色/Wrapper Application/Info.plist b/大鱼调色/Wrapper Application/Info.plist index 5a3e64d..ec1862b 100644 --- a/大鱼调色/Wrapper Application/Info.plist +++ b/大鱼调色/Wrapper Application/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.8.0 CFBundleVersion - 54 + 55 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright