diff --git a/template/sources/RegisteredParameters.json b/template/sources/RegisteredParameters.json index 413ec6b..8bfcf7f 100644 --- a/template/sources/RegisteredParameters.json +++ b/template/sources/RegisteredParameters.json @@ -3639,7 +3639,7 @@ "大鱼调色/Plugin/DYFilmMath.h": "945b7036c6aa6d27941a3bf96c4d70dec65a14b1747fba618e650738fa7108f0", "大鱼调色/Plugin/DYFilmTypes.h": "c35a43b5b93988e8517e5db8f281da0dfd1e02f5b0e7bfb62e7345cec444a36d", "大鱼调色/Plugin/DYManagedColor.h": "616c7919bf0889f767ebb68d4b37b775183451b213b8d2d979eeb293be69010c", - "大鱼调色/Plugin/DYManagedColor.mm": "7e7fc5633d88d2c626f2561fc9f02440da464a7b9531b8c2d635745077548d0a", + "大鱼调色/Plugin/DYManagedColor.mm": "8c9276003ea75c21c8e631122fe9a910bac26b12db69c76e626ec2100a6cbfd1", "大鱼调色/Plugin/DYModel.h": "a28652bd53aa9e1d085af1108c344b5d673c5e1b3731531e1bb2982efeb8708c", "大鱼调色/Plugin/DYModel.mm": "29fea6064d3131119933401f554cc04e48cadf07d0c62f25b8d66795201396f8", "大鱼调色/Plugin/DYSpiderState.h": "0c80747e41e8fc97762e301b011bd08c18865a825eaafde086ed79ace37b22f9", diff --git a/tools/create_cms_host_fixture.py b/tools/create_cms_host_fixture.py new file mode 100644 index 0000000..7d500a2 --- /dev/null +++ b/tools/create_cms_host_fixture.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +"""Create isolated synthetic timelines for CMS migration; no library edits.""" +from pathlib import Path +import uuid +import xml.etree.ElementTree as E + +qa = Path.home() / 'Library/Caches/CodexBuilds/com.dayu.color/fcp-qa' +chart = qa / '大鱼调色验收图.png' +assert chart.is_file(), 'Generate the existing synthetic chart fixture first.' +root = E.Element('fcpxml', version='1.12') +resources = E.SubElement(root, 'resources') +E.SubElement(resources, 'format', id='f1', width='1920', height='1080', + frameDuration='1/25s', colorSpace='1-1-1 (Rec. 709)') +E.SubElement(resources, 'format', id='f2', width='1920', height='1080', + name='FFVideoFormatRateUndefined') +asset = E.SubElement(resources, 'asset', id='a1', name='色彩管理验收图', start='0s', + duration='0s', format='f2', hasVideo='1', videoSources='1') +E.SubElement(asset, 'media-rep', kind='original-media', src=chart.as_uri()) +template = Path.home() / 'Movies/Motion Templates.localized/Effects.localized/大鱼调色/大鱼调色/大鱼调色.moef' +E.SubElement(resources, 'effect', id='fx', name='大鱼调色', + uid='~/Effects.localized/大鱼调色/大鱼调色/大鱼调色.moef', src=template.as_uri()) +event = E.SubElement(E.SubElement(root, 'library'), 'event', + name='大鱼调色_1.8_新版CMS验收', uid=str(uuid.uuid4()).upper()) +for title in ['大鱼调色_1.8_旧版兼容', '大鱼调色_1.8_跟随FCP', '大鱼调色_1.8_相机ACES']: + project = E.SubElement(event, 'project', name=title, uid=str(uuid.uuid4()).upper()) + sequence = E.SubElement(project, 'sequence', format='f1', duration='4s', + tcStart='0s', tcFormat='NDF', audioLayout='stereo', audioRate='48k') + clip = E.SubElement(E.SubElement(sequence, 'spine'), 'video', ref='a1', + name=title, offset='0s', start='0s', duration='4s') + E.SubElement(clip, 'filter-video', ref='fx', name='大鱼调色', enabled='1') +E.indent(root) +output = qa / '大鱼调色_1.8_新版CMS验收.fcpxml' +output.write_text('\n\n' + + E.tostring(root, encoding='unicode') + '\n') +print(output) diff --git a/大鱼调色/Plugin/DYInspector.mm b/大鱼调色/Plugin/DYInspector.mm index 9e7ac8e..bc8a722 100644 --- a/大鱼调色/Plugin/DYInspector.mm +++ b/大鱼调色/Plugin/DYInspector.mm @@ -810,7 +810,7 @@ static NSImage *DYWheelImage(void) { [(DYMaskCountBadge*)card[@"maskBadge"]setCount:count];NSString *hint=count?[NSString stringWithFormat:@"已有 %lu 个蒙版;点击添加独立蒙版",(unsigned long)count]:@"添加本工具的独立蒙版"; [card[@"maskButton"]setToolTip:hint];[card[@"maskButton"]setAccessibilityHelp:hint]; } - DYAssetState *assets=DYReadAssets(_manager,t);_tabs[@"managedColor"]=@((_embedded?DYReadAssets([(DYToolManager*)_manager host],t).colorManagement:assets.colorManagement).count>0);[_managedPanel refreshWithState:assets.colorManagement context:[_renderer colorContext]];for(NSDictionary *r in _controls.allValues)if([r[@"descriptor"][@"key"]isEqual:@"cmmix"])[r[@"label"]setStringValue:[_tabs[@"managedColor"]boolValue]?@"调色混合":@"CST 混合"]; + DYAssetState *assets=DYReadAssets(_manager,t);_tabs[@"managedColor"]=@((_embedded?DYReadAssets([(DYToolManager*)_manager host],t).colorManagement:assets.colorManagement).count>0);[_managedPanel refreshWithState:assets.colorManagement context:[_renderer colorContext]];[_managedPanel setInputLUTPath:assets.paths[@"input"]];for(NSDictionary *r in _controls.allValues)if([r[@"descriptor"][@"key"]isEqual:@"cmmix"])[r[@"label"]setStringValue:[_tabs[@"managedColor"]boolValue]?@"调色混合":@"CST 混合"]; if([_tabs[@"managedColor"]boolValue])for(NSDictionary *c in _cards)if([c[@"section"][@"key"]isEqual:@"primary"]){[c[@"enabled"]setToolTip:@"启停此层一级调色;全局色彩管理保持当前方式"];[c[@"enabled"]setAccessibilityHelp:[c[@"enabled"]toolTip]];} [_spiderPanel setMesh:assets.spiderMesh linked:assets.spiderLinked]; double profile=0,configured=0;[get getFloatValue:&profile fromParameter:2013 atTime:t];[get getFloatValue:&configured fromParameter:2236 atTime:t]; diff --git a/大鱼调色/Plugin/DYManagedColor.mm b/大鱼调色/Plugin/DYManagedColor.mm index 366943d..234ac04 100644 --- a/大鱼调色/Plugin/DYManagedColor.mm +++ b/大鱼调色/Plugin/DYManagedColor.mm @@ -18,5 +18,12 @@ CGColorSpaceRef DYManagedTileSpace(FxImageTile *tile,NSInteger primaries){ if(primaries==kFxColorPrimaries_Rec2020)return CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearITUR_2020); return nil; } +static NSString *profileLabel(CGColorSpaceRef space){ + if(!space)return @"未知空间";NSString *name=[(id)CGColorSpaceCopyName(space)autorelease]; + if([name containsString:@"LinearSRGB"])return @"线性 Rec.709"; + if([name containsString:@"LinearITUR_2020"])return @"线性 Rec.2020"; + if([name containsString:@"ACESCGLinear"])return @"线性 ACEScg"; + return name.length?[name stringByReplacingOccurrencesOfString:@"kCGColorSpace" withString:@""]:@"自定义 RGB 配置"; +} static NSString *profileKey(CGColorSpaceRef space){if(!space)return @"unknown";CFPropertyListRef p=CGColorSpaceCopyPropertyList(space);NSData *d=p?[NSPropertyListSerialization dataWithPropertyList:(id)p format:NSPropertyListBinaryFormat_v1_0 options:0 error:nil]:nil;if(p)CFRelease(p);if(!d)return @"unknown";unsigned char hash[CC_SHA256_DIGEST_LENGTH];CC_SHA256(d.bytes,(CC_LONG)d.length,hash);NSMutableString*s=[NSMutableString string];for(auto c:hash)[s appendFormat:@"%02x",c];return s;} -NSDictionary *DYHostColorContext(FxImageTile *source,FxImageTile *destination,NSInteger primaries){CGColorSpaceRef a=DYManagedTileSpace(source,primaries),b=DYManagedTileSpace(destination,primaries);NSString *an=a?[(id)CGColorSpaceCopyName(a)autorelease]:nil,*bn=b?[(id)CGColorSpaceCopyName(b)autorelease]:nil;NSDictionary *d=@{@"primaries":@(primaries),@"source":an?:(a?@"自定义 RGB 配置":@"未知空间"),@"destination":bn?:(b?@"自定义 RGB 配置":@"未知空间"),@"sourceKey":profileKey(a),@"destinationKey":profileKey(b),@"processing":@"RGB Linear",@"alpha":@"premultiplied"};if(a)CGColorSpaceRelease(a);if(b)CGColorSpaceRelease(b);return d;} +NSDictionary *DYHostColorContext(FxImageTile *source,FxImageTile *destination,NSInteger primaries){CGColorSpaceRef a=DYManagedTileSpace(source,primaries),b=DYManagedTileSpace(destination,primaries);NSString *an=profileLabel(a),*bn=profileLabel(b);NSDictionary *d=@{@"primaries":@(primaries),@"source":an?:(a?@"自定义 RGB 配置":@"未知空间"),@"destination":bn?:(b?@"自定义 RGB 配置":@"未知空间"),@"sourceKey":profileKey(a),@"destinationKey":profileKey(b),@"processing":@"RGB Linear",@"alpha":@"premultiplied"};if(a)CGColorSpaceRelease(a);if(b)CGColorSpaceRelease(b);return d;} diff --git a/大鱼调色/Plugin/DYManagedColorPanel.h b/大鱼调色/Plugin/DYManagedColorPanel.h index 715c7e1..b2246d2 100644 --- a/大鱼调色/Plugin/DYManagedColorPanel.h +++ b/大鱼调色/Plugin/DYManagedColorPanel.h @@ -5,6 +5,7 @@ @interface DYManagedColorPanel : NSView - (instancetype)initWithManager:(id)manager renderer:(DYRenderer*)renderer assetTarget:(id)target; - (void)refreshContext; +- (void)setInputLUTPath:(NSString*)path; - (void)refreshWithState:(NSDictionary*)state context:(NSDictionary*)context; - (CGFloat)contentHeight; @end diff --git a/大鱼调色/Plugin/DYManagedColorPanel.mm b/大鱼调色/Plugin/DYManagedColorPanel.mm index 17d1435..3f06a3a 100644 --- a/大鱼调色/Plugin/DYManagedColorPanel.mm +++ b/大鱼调色/Plugin/DYManagedColorPanel.mm @@ -32,6 +32,7 @@ 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)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]; diff --git a/大鱼调色/Plugin/DYManagedDiagnostics.inc.h b/大鱼调色/Plugin/DYManagedDiagnostics.inc.h index 6659d54..0286435 100644 --- a/大鱼调色/Plugin/DYManagedDiagnostics.inc.h +++ b/大鱼调色/Plugin/DYManagedDiagnostics.inc.h @@ -31,6 +31,9 @@ for(int output=1;output<=10;output++){@autoreleasepool{state[@"output"]=@(output);Pixels gpuFrame=managed(state,u,empty.document,[NSString stringWithFormat:@"cms-output-%d-render",output]);Pixels ref=cpuOutput(cpuInput(),output);Difference d=difference(ref,gpuFrame);run.record([NSString stringWithFormat:@"cms-output-%d-single-ODT-cpu-parity",output],d.maximum<.02&&d.nonfinite==0,measure(d));}} state[@"output"]=@1; 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"]=@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. diff --git a/大鱼调色/Plugin/Info.plist b/大鱼调色/Plugin/Info.plist index 1c1434a..1b32d15 100644 --- a/大鱼调色/Plugin/Info.plist +++ b/大鱼调色/Plugin/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.8.0 CFBundleVersion - 53 + 54 NSHumanReadableCopyright PlugInKit diff --git a/大鱼调色/Wrapper Application/Info.plist b/大鱼调色/Wrapper Application/Info.plist index 51ec4ba..5a3e64d 100644 --- a/大鱼调色/Wrapper Application/Info.plist +++ b/大鱼调色/Wrapper Application/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.8.0 CFBundleVersion - 53 + 54 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright