Add ACES CMS regression coverage and 1.8.0 Release candidate; 527 native checks passed
这个提交包含在:
1 父节点
bb5ede7be4
当前提交
54e68b4810
21 个文件已更改
+143
-51
没有与搜索条件相匹配的文件
@@ -3,6 +3,8 @@
|
||||
#import "DYDiagnostics.h"
|
||||
#import "DYModel.h"
|
||||
#import "DYRenderer.h"
|
||||
#import "DYManagedColor.h"
|
||||
#import "../../ColorManagement/Sources/DYColorProfile.h"
|
||||
#import "DYAutoGrade.h"
|
||||
#import "DYLUTLibrary.h"
|
||||
#import "DYLUTBrowser.h"
|
||||
@@ -93,9 +95,11 @@
|
||||
FxRect _bounds;
|
||||
uint64_t _registry;
|
||||
FxImageOrigin _diagnosticOrigin;
|
||||
CGColorSpaceRef _diagnosticSpace;
|
||||
}
|
||||
- (instancetype)initWithDevice:(id<MTLDevice>)device width:(NSUInteger)width height:(NSUInteger)height;
|
||||
- (void)setDiagnosticImageOrigin:(FxImageOrigin)origin;
|
||||
- (void)setDiagnosticColorSpace:(CGColorSpaceRef)space;
|
||||
@end
|
||||
@implementation DYDiagnosticTile
|
||||
- (instancetype)initWithDevice:(id<MTLDevice>)device width:(NSUInteger)width height:(NSUInteger)height {
|
||||
@@ -111,12 +115,14 @@
|
||||
if(!_surface||!_texture){[self release];return nil;}
|
||||
}return self;
|
||||
}
|
||||
- (void)dealloc {[_texture release];if(_surface)CFRelease(_surface);[super dealloc];}
|
||||
- (void)dealloc {if(_diagnosticSpace)CGColorSpaceRelease(_diagnosticSpace);[_texture release];if(_surface)CFRelease(_surface);[super dealloc];}
|
||||
- (id<MTLTexture>)metalTextureForDevice:(id<MTLDevice>)device {return device.registryID==_registry?_texture:nil;}
|
||||
- (IOSurface *)ioSurface {return (IOSurface *)_surface;}
|
||||
- (FxRect)tilePixelBounds {return _bounds;}
|
||||
- (FxRect)imagePixelBounds {return _bounds;}
|
||||
- (uint64_t)deviceRegistryID {return _registry;}
|
||||
- (CGColorSpaceRef)colorSpace{return _diagnosticSpace;}
|
||||
- (void)setDiagnosticColorSpace:(CGColorSpaceRef)s{if(_diagnosticSpace)CGColorSpaceRelease(_diagnosticSpace);_diagnosticSpace=s?CGColorSpaceRetain(s):nil;}
|
||||
- (FxImageOrigin)imageOrigin {return _diagnosticOrigin;}
|
||||
- (double)pixelAspect{return 1;}
|
||||
- (void)setDiagnosticImageOrigin:(FxImageOrigin)origin {_diagnosticOrigin=origin;}
|
||||
@@ -282,7 +288,7 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
run.record(@"spider-single-drag-spoke-following-and-pin",dragged.x[0]>initialMesh.x[0]&&dragged.x[1]>initialMesh.x[1]&&dragged.x[3]>initialMesh.x[3]&&dragged.x[4]==initialMesh.x[4]&&dragged.x[5]==initialMesh.x[5]&&dragged.pins[2]);
|
||||
run.record(@"spider-drag-one-host-undo-group",uiHost->_undoStarts==starts+1&&uiHost->_undoEnds==ends+1&&!uiHost->_undoActive);
|
||||
error=nil;NSData *spiderArchive=[NSKeyedArchiver archivedDataWithRootObject:spiderSaved requiringSecureCoding:YES error:&error];DYAssetState *decodedSpider=[NSKeyedUnarchiver unarchivedObjectOfClass:DYAssetState.class fromData:spiderArchive error:&error];run.record(@"spider-archive-retains-mesh-pins-and-lut-paths",decodedSpider&&[decodedSpider isEqual:spiderSaved],@{@"error":reason(error)});
|
||||
NSDictionary *snapshot=[inspector performSelector:@selector(presetSnapshot)];NSData *presetJSON=[NSJSONSerialization dataWithJSONObject:snapshot options:0 error:&error];NSDictionary *decodedPreset=[NSJSONSerialization JSONObjectWithData:presetJSON options:0 error:&error];run.record(@"complete-version-six-preset-includes-mesh",[decodedPreset[@"version"]isEqual:@6]&&[DYSpiderFromJSON(decodedPreset[@"spider"])isEqual:spiderSaved.spiderMesh]);
|
||||
NSDictionary *snapshot=[inspector performSelector:@selector(presetSnapshot)];NSData *presetJSON=[NSJSONSerialization dataWithJSONObject:snapshot options:0 error:&error];NSDictionary *decodedPreset=[NSJSONSerialization JSONObjectWithData:presetJSON options:0 error:&error];run.record(@"complete-version-seven-preset-includes-mesh",[decodedPreset[@"version"]isEqual:@7]&&[DYSpiderFromJSON(decodedPreset[@"spider"])isEqual:spiderSaved.spiderMesh]);
|
||||
NSDictionary *portable=DYSpiderJSON(spiderSaved.spiderMesh,spiderSaved.spiderLinked);NSData *decodedPortable=DYSpiderFromJSON(portable);run.record(@"spider-json-preset-exact-roundtrip",[decodedPortable isEqual:spiderSaved.spiderMesh]);
|
||||
NSMutableDictionary *badJSON=[[portable mutableCopy]autorelease];badJSON[@"hues"]=@7;run.record(@"spider-json-rejects-unsupported-topology",!DYSpiderFromJSON(badJSON));auto corrupt=dragged;corrupt.x[0]=NAN;run.record(@"spider-archive-rejects-nonfinite-coordinates",!DYSpiderMeshIsValid([NSData dataWithBytes:&corrupt length:sizeof(corrupt)]));
|
||||
[disc changeHueCount:12 saturationCount:8];spiderSaved=DYReadAssets(uiHost,kCMTimeZero);auto dense=DYSpiderMesh(spiderSaved.spiderMesh);run.record(@"spider-independent-resolution-and-resample",dense.hues==12&&dense.rings==7&&fabs(dy::meshDelta(dense,0,.6).x)>0);
|
||||
@@ -493,6 +499,7 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
#include "DYToolCanvasDiagnostics.inc.h"
|
||||
#include "DYToolPenDiagnostics.inc.h"
|
||||
#include "DYMaskPanelDiagnostics.inc.h"
|
||||
#include "DYManagedDiagnostics.inc.h"
|
||||
[gpu release];
|
||||
} @catch(NSException *exception) {
|
||||
run.record(@"diagnostic-exception",false,@{@"exception":exception.name?:@"unknown",@"message":exception.reason?:@"unknown"});
|
||||
|
||||
@@ -417,6 +417,7 @@ static NSImage *DYWheelImage(void) {
|
||||
id<PROAPIAccessing> _manager;
|
||||
NSScrollView *_scroll;
|
||||
DYFlippedView *_document;
|
||||
DYManagedColorPanel *_managedPanel;
|
||||
NSTextField *_brand;
|
||||
NSTextField *_subtitle;
|
||||
NSButton *_resetAll, *_save, *_load, *_export, *_websiteLink;
|
||||
@@ -490,6 +491,7 @@ static NSImage *DYWheelImage(void) {
|
||||
_document=[[DYFlippedView alloc] initWithFrame:NSMakeRect(0,0,360,1000)];
|
||||
_document.accessibilityLabel=@"调色参数";
|
||||
_scroll.documentView=_document; [self addSubview:_scroll];
|
||||
if(!_embedded){_managedPanel=[[DYManagedColorPanel alloc]initWithManager:_manager renderer:_renderer assetTarget:self];[_document addSubview:_managedPanel];}
|
||||
[self buildCards];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modelChanged:) name:@"DYModelChanged" object:_manager];
|
||||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(themeChanged:) name:DYThemeDidChange object:nil];
|
||||
@@ -507,7 +509,7 @@ static NSImage *DYWheelImage(void) {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
if(_embedded)[(id)_manager release];[_stackViews release];[_stackOrder release];[_stackRoots release];
|
||||
[_brand release]; [_subtitle release]; [_websiteLink release]; [_resetAll release]; [_save release]; [_load release]; [_export release];[_addModule release];
|
||||
[_scroll release]; [_document release]; [_sections release]; [_cards release]; [_controls release]; [_assetButtons release]; [_graphics release]; [_sampler release];
|
||||
[_managedPanel release];[_scroll release]; [_document release]; [_sections release]; [_cards release]; [_controls release]; [_assetButtons release]; [_graphics release]; [_sampler release];
|
||||
[_browser close];[_browser release];[_renderer release];[_library release];[_themeButtons release];[_tabs release];
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -546,7 +548,7 @@ static NSImage *DYWheelImage(void) {
|
||||
[self setNeedsLayout:YES];NSAccessibilityPostNotification(self,NSAccessibilityLayoutChangedNotification);
|
||||
}
|
||||
- (void)addLook:(id)sender {_visibleLooks=MIN(5,_visibleLooks+1);[self setNeedsLayout:YES];}
|
||||
- (void)previewChanged:(NSNotification *)note {if(_browser.visible)[_browser updatePreview:[_renderer lookLUTPreview]];}
|
||||
- (void)previewChanged:(NSNotification *)note {[_managedPanel refreshContext];if(_browser.visible)[_browser updatePreview:[_renderer lookLUTPreview]];}
|
||||
- (void)buildCards {
|
||||
NSInteger index=0;
|
||||
for(NSDictionary *section in _sections) {
|
||||
@@ -571,7 +573,6 @@ static NSImage *DYWheelImage(void) {
|
||||
NSMutableArray *body=[NSMutableArray array];
|
||||
NSString *key=section[@"key"]?:@"";
|
||||
if([key isEqual:@"primary"]) {
|
||||
if(!_embedded){DYManagedColorPanel *cms=[[[DYManagedColorPanel alloc]initWithManager:_manager renderer:_renderer assetTarget:self]autorelease];[card addSubview:cms];[body addObject:cms];}
|
||||
NSButton *migrate=DYButton(@"旧版输入 → 改用 CST",self,@selector(useCST:));migrate.identifier=@"legacyInput";migrate.toolTip=@"保留旧工程输入效果;点击后改用上方 CST 设置,可撤销";[card addSubview:migrate];[body addObject:migrate];
|
||||
}
|
||||
if([key localizedCaseInsensitiveContainsString:@"look"]) {
|
||||
@@ -717,6 +718,7 @@ static NSImage *DYWheelImage(void) {
|
||||
_addModule.frame=NSMakeRect(16,108,w-32,27);
|
||||
_scroll.frame=_embedded?NSMakeRect(0,0,w,h):NSMakeRect(0,144,w,MAX(80,h-144));
|
||||
CGFloat cw=MAX(244,_scroll.contentSize.width-32),y=8;
|
||||
if(_managedPanel){_managedPanel.frame=NSMakeRect(28,y,cw-24,_managedPanel.contentHeight);y+=_managedPanel.contentHeight+12;}
|
||||
for(NSMutableDictionary *c in _cards) {
|
||||
DYCard *card=c[@"view"];BOOL collapsed=[c[@"collapsed"]boolValue];NSString *key=c[@"section"][@"key"];
|
||||
card.hidden=[c[@"removed"]boolValue];if(card.hidden){y=[self layoutRepeatedToolsAfter:[@"base:" stringByAppendingString:key] y:y width:w];continue;}
|
||||
@@ -808,7 +810,9 @@ 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);for(NSDictionary*card in _cards)for(NSView*row in card[@"body"])if([row isKindOfClass:DYManagedColorPanel.class]){[(DYManagedColorPanel*)row refreshWithState:assets.colorManagement context:[_renderer colorContext]];row.alphaValue=1;}[_spiderPanel setMesh:assets.spiderMesh linked:assets.spiderLinked];
|
||||
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 混合"];
|
||||
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];
|
||||
DYInspectorToken *oldToken=nil;[get getCustomParameterValue:&oldToken fromParameter:DYInspectorParameterID atTime:t];
|
||||
_tabs[@"legacyInput"]=@(configured<.5&&(configured<0||profile>.5||[assets.paths[@"input"]length]||oldToken.schema<2));
|
||||
|
||||
@@ -6,7 +6,7 @@ NSDictionary *DYManagedColorDefaults(void){return @{@"version":@2,@"mode":@1,@"i
|
||||
NSArray<NSDictionary*> *DYManagedInputSpaces(void){NSMutableArray *a=[NSMutableArray array];for(const auto&s:dycm::spaces())[a addObject:@{@"id":@(unsigned(s.id)),@"name":@(s.label)}];return a;}
|
||||
NSArray<NSDictionary*> *DYManagedOutputSpaces(void){NSMutableArray *a=[NSMutableArray array];for(const auto&s:dycm::outputs())[a addObject:@{@"id":@(unsigned(s.id)),@"name":@(s.label)}];return a;}
|
||||
BOOL DYManagedColorValid(id state,NSError **error){
|
||||
BOOL valid=[state isKindOfClass:NSDictionary.class]&&[state count]<=8&&[state[@"version"]isEqual:@2]&&[state[@"engine"]isEqual:@"OpenColorIO-2.5.2"]&&[state[@"config"]isEqual:@"studio-config-v2.2.0_aces-v1.3_ocio-v2.4"];
|
||||
BOOL valid=[state isKindOfClass:NSDictionary.class]&&[state count]==7&&[state[@"version"]isEqual:@2]&&[state[@"engine"]isEqual:@"OpenColorIO-2.5.2"]&&[state[@"config"]isEqual:@"studio-config-v2.2.0_aces-v1.3_ocio-v2.4"];
|
||||
for(NSString *key in @[@"mode",@"input",@"output",@"gamutCompression"]){id v=[state isKindOfClass:NSDictionary.class]?state[key]:nil;double n=[v isKindOfClass:NSNumber.class]?[v doubleValue]:NAN;valid&=std::isfinite(n)&&n==floor(n);}
|
||||
if(valid){valid=[@[@1,@2,@3]containsObject:state[@"mode"]]&&[@[@0,@1]containsObject:state[@"gamutCompression"]];BOOL input=NO,output=NO;for(NSDictionary *s in DYManagedInputSpaces())input|=[s[@"id"]isEqual:state[@"input"]];for(NSDictionary *s in DYManagedOutputSpaces())output|=[s[@"id"]isEqual:state[@"output"]];valid&=input&&output;}
|
||||
if(!valid&&error)*error=[NSError errorWithDomain:@"com.dayu.color.cms" code:1 userInfo:@{NSLocalizedDescriptionKey:@"色彩管理设置无效或组件版本不匹配,未修改工程。"}];return valid;
|
||||
@@ -19,4 +19,4 @@ CGColorSpaceRef DYManagedTileSpace(FxImageTile *tile,NSInteger primaries){
|
||||
return nil;
|
||||
}
|
||||
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?:@"未知空间",@"destination":bn?:@"未知空间",@"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=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;}
|
||||
@@ -4,6 +4,7 @@
|
||||
@class DYRenderer;
|
||||
@interface DYManagedColorPanel : NSView
|
||||
- (instancetype)initWithManager:(id<PROAPIAccessing>)manager renderer:(DYRenderer*)renderer assetTarget:(id)target;
|
||||
- (void)refreshContext;
|
||||
- (void)refreshWithState:(NSDictionary*)state context:(NSDictionary*)context;
|
||||
- (CGFloat)contentHeight;
|
||||
@end
|
||||
@@ -9,11 +9,11 @@
|
||||
NSDictionary *_state;BOOL _refreshing;
|
||||
}
|
||||
- (BOOL)isFlipped{return YES;}
|
||||
- (CGFloat)contentHeight{return 268;}
|
||||
- (CGFloat)contentHeight{NSInteger m=[_state[@"mode"]integerValue];return m==0?112:m==1?190:302;}
|
||||
static NSTextField *cmsLabel(NSString*s){NSTextField*l=[NSTextField wrappingLabelWithString:s];l.font=[NSFont systemFontOfSize:11];l.textColor=DYThemeColor(@"text");return l;}
|
||||
- (instancetype)initWithManager:(id<PROAPIAccessing>)m renderer:(DYRenderer*)r assetTarget:(id)target {
|
||||
if((self=[super initWithFrame:NSZeroRect])){_manager=m;_renderer=[r retain];_assetTarget=target;self.identifier=@"managedColor";
|
||||
_mode=[[NSPopUpButton alloc]initWithFrame:NSZeroRect];[_mode addItemsWithTitles:@[@"旧版兼容",@"跟随 FCP 色彩管理",@"相机编码 → ACES",@"输入 LUT → ACES"]];_mode.target=self;_mode.action=@selector(modeChanged:);_mode.accessibilityLabel=@"色彩管理方式";
|
||||
_mode=[[NSPopUpButton alloc]initWithFrame:NSZeroRect];[_mode addItemsWithTitles:@[@"色彩管理 · 旧版兼容",@"色彩管理 · 跟随 FCP",@"相机编码 → ACES",@"输入 LUT → ACES"]];_mode.target=self;_mode.action=@selector(modeChanged:);_mode.accessibilityLabel=@"色彩管理方式";
|
||||
_inputLabel=[cmsLabel(@"输入空间")retain];_outputLabel=[cmsLabel(@"输出目标")retain];
|
||||
_input=[[NSPopUpButton alloc]initWithFrame:NSZeroRect];for(NSDictionary*s in DYManagedInputSpaces()){[_input addItemWithTitle:s[@"name"]];_input.lastItem.representedObject=s[@"id"];} _input.target=self;_input.action=@selector(settingsChanged:);_input.accessibilityLabel=@"新版输入空间";
|
||||
_output=[[NSPopUpButton alloc]initWithFrame:NSZeroRect];for(NSDictionary*s in DYManagedOutputSpaces()){[_output addItemWithTitle:s[@"name"]];_output.lastItem.representedObject=s[@"id"];} _output.target=self;_output.action=@selector(settingsChanged:);_output.accessibilityLabel=@"新版输出目标";
|
||||
@@ -24,14 +24,15 @@ static NSTextField *cmsLabel(NSString*s){NSTextField*l=[NSTextField wrappingLabe
|
||||
}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)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,65);_context.frame=NSMakeRect(2,220,w-4,45);}
|
||||
- (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;[_state release];_state=[s copy];NSInteger mode=s.count?[s[@"mode"]integerValue]:0;[_mode selectItemAtIndex:mode];
|
||||
_refreshing=YES;NSDictionary *saved=[s copy];[_state release];_state=saved;NSInteger mode=s.count?[s[@"mode"]integerValue]:0;[_mode selectItemAtIndex:mode];
|
||||
NSDictionary *values=s.count?s:DYManagedColorDefaults();for(NSMenuItem*i in _input.itemArray)if([i.representedObject isEqual:values[@"input"]])[_input selectItem:i];for(NSMenuItem*i in _output.itemArray)if([i.representedObject isEqual:values[@"output"]])[_output selectItem:i];
|
||||
_input.enabled=mode==2||mode==3;_output.enabled=mode==2||mode==3;_gamut.enabled=mode==2||mode==3;_gamut.state=[values[@"gamutCompression"]boolValue];_lut.hidden=mode!=3;_inputLabel.stringValue=mode==3?@"LUT 输出":@"输入空间";_outputLabel.stringValue=mode==1?@"跟随宿主":@"输出目标";
|
||||
_help.stringValue=mode==0?@"保留当前工程的原有颜色。选择新版后,一级层在 ACEScct 中调色,印片位于输出之前;可撤销或切回兼容方式。":mode==1?@"使用宿主实际颜色空间,不再次还原相机或执行显示映射。内部 ACEScct;旧式风格工具在明确的 Rec.709 修饰域运行。":mode==2?@"按所选相机编码解释兼容码值。请确认上游未还原、未自动符合;选择准确输入与输出目标。":@"使用输入 LUT,并按“LUT 输出”解释其结果;再进入 ACEScct 和所选输出变换。";
|
||||
_input.hidden=_inputLabel.hidden=_output.hidden=_outputLabel.hidden=_gamut.hidden=mode<2;_context.hidden=mode==0;_input.enabled=mode==2||mode==3;_output.enabled=mode==2||mode==3;_gamut.enabled=mode==2||mode==3;_gamut.state=[values[@"gamutCompression"]boolValue];_lut.hidden=mode!=3;_inputLabel.stringValue=mode==3?@"LUT 输出":@"输入空间";_outputLabel.stringValue=mode==1?@"跟随宿主":@"输出目标";
|
||||
_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)refreshContext{[self refreshWithState:_state context:[_renderer colorContext]];}
|
||||
- (void)writeState:(NSDictionary*)state {
|
||||
if(state&&!DYManagedColorValid(state,nil))return;id<FxCustomParameterActionAPI_v4>a=[_manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{id<FxUndoAPI>undo=[_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];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// Actual production entry points and independent CPU/profile reference vectors.
|
||||
{
|
||||
DYRenderer *cmsRenderer=[[[DYRenderer alloc]init]autorelease];DYToolDocument *empty=[[[DYToolDocument alloc]init]autorelease];
|
||||
NSMutableDictionary *state=[[DYManagedColorDefaults()mutableCopy]autorelease];
|
||||
run.need(@"cms-versioned-state-valid",DYManagedColorValid(state,nil)&&!DYManagedColorValid(@"bad",nil));
|
||||
DYAssetState *saved=[[[DYAssetState alloc]init]autorelease];saved.colorManagement=state;NSData *archive=[NSKeyedArchiver archivedDataWithRootObject:saved requiringSecureCoding:YES error:&error];DYAssetState *restored=[NSKeyedUnarchiver unarchivedObjectOfClass:DYAssetState.class fromData:archive error:&error];
|
||||
run.record(@"cms-secure-archive-independent-opt-in",[saved isEqual:restored]&&[restored.colorManagement isEqual:state]&&![[[DYAssetState alloc]init]autorelease].colorManagement);
|
||||
NSMutableDictionary *invalid=[[state mutableCopy]autorelease];invalid[@"output"]=@999;run.record(@"cms-rejects-unknown-output",!DYManagedColorValid(invalid,nil));
|
||||
DYUniforms u=defaults;u.skinProtection.x=0; // No grade is applied by default in the new working domain.
|
||||
Pixels probe(width*height*4);float vectors[][4]={{.18,.18,.18,1},{2,1.2,.3,1},{-.03,.1,.2,1},{.03,.01,.005,.1},{0,0,0,0},{.7,.2,.05,1}};
|
||||
for(size_t i=0;i<width*height;i++)for(int c=0;c<4;c++)probe[i*4+c]=vectors[i%6][c];
|
||||
auto upload=[&](const Pixels&p){[[source metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:p.data() bytesPerRow:width*8];};upload(probe);
|
||||
auto managed=[&](NSDictionary *s,DYUniforms v,NSDictionary *doc,NSString *name){NSError *e=nil;BOOL ok=[cmsRenderer renderSource:source destination:destination uniforms:v paths:@{} spider:nil tools:doc colorManagement:s hostPrimaries:kFxColorPrimaries_Rec709 error:&e];run.need(name,ok,@{@"error":reason(e)});return read(destination,gpu);};
|
||||
Pixels old=render(run,cmsRenderer,source,destination,gpu,u,@{},@"cms-v1-reference");Pixels compatibility=managed(nil,u,empty.document,@"cms-v1-absent-state");run.record(@"cms-v1-absent-state-bit-exact",difference(old,compatibility).maximum==0);
|
||||
Pixels host=managed(state,u,empty.document,@"cms-host-profile-neutral-render");run.record(@"cms-host-mode-preserves-grey-negative-superwhite-alpha",difference(probe,host).maximum<.004&&difference(probe,host).nonfinite==0,measure(difference(probe,host)));
|
||||
NSMutableDictionary *layers=DYMutablePlist(empty.document);for(int i=0;i<4;i++)DYInsertTool(layers,@"primary",@"base:primary");Pixels repeated=managed(state,u,layers,@"cms-four-neutral-primary-layers");run.record(@"cms-neutral-primary-layers-do-not-remap",difference(host,repeated).maximum==0);
|
||||
// All real physical profiles are interpreted, and src/dst keys cannot alias.
|
||||
CGColorSpaceRef a=CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB),b=CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearITUR_2020);[source setDiagnosticColorSpace:a];[destination setDiagnosticColorSpace:b];Pixels physical=managed(state,u,empty.document,@"cms-709-source-2020-destination");
|
||||
DYColorProfile *p=[[[DYColorProfile alloc]initWithSource:a target:b error:&error]autorelease];std::vector<DYCompositeRGBA>reference(width*height);for(size_t i=0;i<reference.size();i++)reference[i]={(float)probe[i*4],(float)probe[i*4+1],(float)probe[i*4+2],(float)probe[i*4+3]};auto converted=[p convertPixels:reference alpha:dycm::Alpha::Premultiplied budget:64*1024*1024 cancelled:nullptr error:&error];Pixels expected(probe.size());if(converted)for(size_t i=0;i<reference.size();i++){auto c=(*converted)[i];expected[i*4]=c.r;expected[i*4+1]=c.g;expected[i*4+2]=c.b;expected[i*4+3]=c.a;}
|
||||
NSDictionary *context=[cmsRenderer colorContext];run.record(@"cms-physical-profile-matrix-and-context-key",converted&&difference(physical,expected).maximum<.004&&![context[@"sourceKey"]isEqual:context[@"destinationKey"]],measure(difference(physical,expected)));[source setDiagnosticColorSpace:nil];[destination setDiagnosticColorSpace:nil];CGColorSpaceRelease(a);CGColorSpaceRelease(b);
|
||||
// Working grade has one exposure operation; a zero mask is an exact bypass.
|
||||
DYUniforms grade=u;grade.cm.exposure=1;Pixels exposed=managed(state,grade,empty.document,@"cms-working-exposure");run.record(@"cms-one-stop-working-grade-changes-pixels-preserves-alpha",difference(host,exposed).different>20&&difference(exposed,exposed).nonfinite==0&&exposed[3]==host[3]);
|
||||
NSMutableDictionary *mask=DYMutablePlist(DYNewMask(DYMaskRectangle));DYMaskParameters mp=DYMaskAtTime(mask,kCMTimeZero);mp.strength=0;mask[@"parameters"]=[NSData dataWithBytes:&mp length:sizeof(mp)];NSMutableDictionary *masked=DYMutablePlist(empty.document);masked[@"baseMasks"][@"primary"]=@[mask];Pixels zero=managed(state,grade,masked,@"cms-zero-mask");run.record(@"cms-zero-primary-mask-preserves-input",difference(zero,host).maximum==0);
|
||||
// Frame orientation is normalized at the actual host destination boundary.
|
||||
[destination setDiagnosticImageOrigin:kFxImageOrigin_BOTTOM_LEFT];Pixels flipped=managed(state,u,empty.document,@"cms-opposite-origin");BOOL orientation=YES;for(NSUInteger y=0;y<height;y++)for(NSUInteger x=0;x<width*4;x++)orientation&=fabs((float)flipped[y*width*4+x]-(float)host[(height-1-y)*width*4+x])<.004;run.record(@"cms-source-destination-origin-contract",orientation);[destination setDiagnosticImageOrigin:kFxImageOrigin_TOP_LEFT];
|
||||
// Declared code values -> OCIO input -> exactly one ODT -> physical host output.
|
||||
// CPU reference omits all renderer code; this catches repeated display mapping.
|
||||
Pixels codes(width*height*4);for(size_t i=0;i<width*height;i++){float v=.04f+.8f*float(i%31)/30;for(int c=0;c<3;c++){float channel=i%7?v:(.05f+.7f*float((i*(3+c*4)+c*7)%31)/30);codes[i*4+c]=powf((channel+.055f)/1.055f,2.4f);}codes[i*4+3]=i%7?.5:1;for(int c=0;c<3;c++)codes[i*4+c]*=codes[i*4+3];}upload(codes);state[@"mode"]=@2;
|
||||
auto cpuInput=[&](){std::vector<DYCompositeRGBA>r(width*height);for(size_t i=0;i<r.size();i++){float alpha=codes[i*4+3],c[3];for(int k=0;k<3;k++){float v=(float)codes[i*4+k]/alpha;c[k]=v<=.0031308f?v*12.92f:1.055f*powf(v,1/2.4f)-.055f;}r[i]={c[0]*alpha,c[1]*alpha,c[2]*alpha,alpha};}dycm::Transform::convert(dycm::Space([state[@"input"]unsignedIntValue]),dycm::Space::ACEScct).apply(r,dycm::Alpha::Premultiplied);return r;};
|
||||
auto cpuOutput=[&](std::vector<DYCompositeRGBA>r,int output){dycm::Transform::display(dycm::Space::ACEScct,dycm::Output(output),true).apply(r,dycm::Alpha::Premultiplied);CGColorSpaceRef target=CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB);DYColorProfile *profile=[[[DYColorProfile alloc]initWithDisplayOutput:dycm::Output(output) target:target error:&error]autorelease];CGColorSpaceRelease(target);auto out=[profile convertPixels:r alpha:dycm::Alpha::Premultiplied budget:64*1024*1024 cancelled:nullptr error:&error];Pixels result(codes.size());if(out)for(size_t i=0;i<r.size();i++){auto c=(*out)[i];result[i*4]=c.r;result[i*4+1]=c.g;result[i*4+2]=c.b;result[i*4+3]=c.a;}return result;};
|
||||
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;
|
||||
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.
|
||||
std::vector<float>look;NSUInteger lookSide=0;NSString *lookPath=[[NSBundle bundleForClass:renderer.class]pathForResource:@"kodak_2383" ofType:@"dylut" inDirectory:@"PrintLooks"];
|
||||
BOOL readLook=DYLUTReadCube(lookPath,look,lookSide,&error);auto scene=cpuInput();
|
||||
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"]=@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::vector<float>table;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;
|
||||
if(parse)for(size_t i=0;i<width*height;i++){float alpha=codes[i*4+3];float coord[3],f[3];int cell[3];for(int k=0;k<3;k++){float linear=(float)codes[i*4+k]/alpha;coord[k]=linear<=.0031308f?linear*12.92f:1.055f*powf(linear,1/2.4f)-.055f;float x=coord[k]*(size-1);cell[k]=MIN((int)floorf(x),(int)size-2);f[k]=x-cell[k];}for(int k=0;k<3;k++){float value=0;for(int z=0;z<2;z++)for(int y=0;y<2;y++)for(int x=0;x<2;x++){float weight=(x?f[0]:1-f[0])*(y?f[1]:1-f[1])*(z?f[2]:1-f[2]);value+=table[(((cell[2]+z)*size+cell[1]+y)*size+cell[0]+x)*4+k]*weight;}float linear=(float)direct[i*4+k]/alpha;float expected=linear<=.0031308f?linear*12.92f:1.055f*powf(linear,1/2.4f)-.055f;cubeError=MAX(cubeError,fabs(value-expected));}}
|
||||
run.record(@"cms-cube-off-grid-production-error",parse&&cubeError<.015,@{@"maxCodeValueError":@(cubeError)});
|
||||
run.record(@"cms-one-stop-grey-photometric-check",fabs((float)exposed[0]-.36f)<.005,@{@"linearGrey":@((float)exposed[0])});
|
||||
run.record(@"cms-preview-still-available",cmsRenderer.preview.length==320*180*16);
|
||||
upload(input);[source setDiagnosticImageOrigin:kFxImageOrigin_TOP_LEFT];[destination setDiagnosticImageOrigin:kFxImageOrigin_TOP_LEFT];
|
||||
}
|
||||
@@ -25,6 +25,7 @@
|
||||
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{
|
||||
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];
|
||||
if(!DYManagedColorValid(state,error))return NO;if(!tools)tools=@{@"schema":@2,@"layers":@[],@"baseMasks":@{}};if(!DYValidToolDocument(tools))return fail(error,@"调色层或蒙版数据无效。");
|
||||
@@ -59,11 +60,11 @@
|
||||
// measured HDR implementations; never silently clip them through old LUTs.
|
||||
NSDictionary *finishPaths=DYVisibleBaseToolPaths(paths,finishing);
|
||||
NSArray *activeFinish=DYManagedActiveFinishing(u,finishPaths,spider,finishing);
|
||||
if(mode!=1&&(output==6||output==7)&&activeFinish.count)return fail(error,@"HDR 输出目前支持一级调色与印片。请关闭基础、曲线、风格、胶片空间等 SDR 修饰工具,或选择 SDR 输出。");
|
||||
if(((mode!=1&&(output==6||output==7))||(mode==1&&primaries==kFxColorPrimaries_Rec2020))&&activeFinish.count)return fail(error,@"HDR 输出或跟随 Rec.2020 宿主时,目前支持一级调色与印片。请关闭 SDR 修饰工具;需要这些工具时,请明确选择 SDR 输出。");
|
||||
[self managedPreview:current origin:src.imageOrigin entry:entry];
|
||||
if(activeFinish.count){id<MTLTexture>out=next();if(!out)return fail(error,@"无法分配显示域修饰缓冲区。");_managedFinishing=YES;BOOL ok=NO;@try{ok=[self renderSource:tile(current) destination:tile(out) uniforms:u paths:finishPaths spider:spider tools:finishing error:error];}@finally{_managedFinishing=NO;}if(!ok)return NO;current=out;}
|
||||
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.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。");_exportManagedState=state.count?state:nil;@try{return [self exportLUT:url uniforms:u paths:paths spider:spider tools:tools error:error];}@finally{_exportManagedState=nil;}}}
|
||||
- (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;}}}
|
||||
@@ -221,17 +221,17 @@ static NSArray *DYManagedActiveFinishing(DYUniforms u,NSDictionary *paths,NSData
|
||||
- (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,请保存完整预设。");
|
||||
NSMutableDictionary *e=[self device:0 error:err];if(!e)return NO;id<MTLDevice>d=e[@"device"];const NSUInteger n=_exportManagedState?65:33,count=n*n*n,width=n*n,height=n;
|
||||
MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:width height:height mipmapped:NO];desc.storageMode=MTLStorageModeShared;desc.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;
|
||||
MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:(_exportManagedState?MTLPixelFormatRGBA32Float:MTLPixelFormatRGBA16Float) width:width height:height mipmapped:NO];desc.storageMode=MTLStorageModeShared;desc.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;
|
||||
id<MTLTexture>input=[d newTextureWithDescriptor:desc],output=[d newTextureWithDescriptor:desc];if(!input||!output){[input release];[output release];return fail(err,@"无法分配 LUT 色格");}
|
||||
std::vector<__fp16>values(count*4);for(NSUInteger i=0;i<count;i++){float v[3]={(float)(i%n)/(n-1),(float)((i/n)%n)/(n-1),(float)(i/(n*n))/(n-1)};for(int c=0;c<3;c++)values[i*4+c]=v[c]<=.04045f?v[c]/12.92f:powf((v[c]+.055f)/1.055f,2.4f);values[i*4+3]=1;}
|
||||
[input replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:values.data() bytesPerRow:width*8];
|
||||
std::vector<__fp16>values(count*4);std::vector<float>precise(_exportManagedState?count*4:0);for(NSUInteger i=0;i<count;i++){float v[3]={(float)(i%n)/(n-1),(float)((i/n)%n)/(n-1),(float)(i/(n*n))/(n-1)};for(int c=0;c<3;c++)values[i*4+c]=v[c]<=.04045f?v[c]/12.92f:powf((v[c]+.055f)/1.055f,2.4f);values[i*4+3]=1;if(_exportManagedState){for(int c=0;c<3;c++)precise[i*4+c]=v[c]<=.04045f?v[c]/12.92f:powf((v[c]+.055f)/1.055f,2.4f);precise[i*4+3]=1;}}
|
||||
[input replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:_exportManagedState?(const void*)precise.data():(const void*)values.data() bytesPerRow:width*(_exportManagedState?16:8)];
|
||||
DYExportTile *source=[[[DYExportTile alloc]initWithTexture:input registry:d.registryID]autorelease],*dest=[[[DYExportTile alloc]initWithTexture:output registry:d.registryID]autorelease];
|
||||
u.textureEnabled=0;u.clarityEnabled=0;u.dehazeEnabled=0;BOOL ok=NO;_exporting=YES;
|
||||
@try{ok=[self renderSource:source destination:dest uniforms:u paths:paths spider:spider tools:_toolDocument colorManagement:_exportManagedState hostPrimaries:kFxColorPrimaries_Rec709 error:err];}@finally{_exporting=NO;}
|
||||
if(ok)[output getBytes:values.data() bytesPerRow:width*8 fromRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0];[input release];[output release];if(!ok)return NO;
|
||||
if(ok)[output getBytes:_exportManagedState?(void*)precise.data():(void*)values.data() bytesPerRow:width*(_exportManagedState?16:8) fromRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0];[input release];[output release];if(!ok)return NO;
|
||||
NSMutableString *text=[NSMutableString stringWithString:@"TITLE \"大鱼调色\"\n# 包含 CST 与逐像素颜色;不包含纹理、清晰度和逐画面分析。\nLUT_3D_SIZE 33\nDOMAIN_MIN 0 0 0\nDOMAIN_MAX 1 1 1\n"];
|
||||
for(NSUInteger i=0;i<count;i++){float rgb[3];for(int c=0;c<3;c++){float v=values[i*4+c];rgb[c]=v<=.0031308f?v*12.92f:1.055f*powf(v,1/2.4f)-.055f;if(!std::isfinite(rgb[c]))return fail(err,@"LUT 输出含无效值");}[text appendFormat:@"%.8f %.8f %.8f\n",rgb[0],rgb[1],rgb[2]];}
|
||||
if(_exportManagedState){[text replaceOccurrencesOfString:@"LUT_3D_SIZE 33" withString:@"LUT_3D_SIZE 65" options:0 range:NSMakeRange(0,text.length)];[text insertString:@"# V2 input: declared camera/LUT code values, or sRGB in host mode. Output: sRGB / Rec.709.\n" atIndex:0];}
|
||||
for(NSUInteger i=0;i<count;i++){float rgb[3];for(int c=0;c<3;c++){float v=_exportManagedState?precise[i*4+c]:(float)values[i*4+c];rgb[c]=v<=.0031308f?v*12.92f:1.055f*powf(v,1/2.4f)-.055f;if(!std::isfinite(rgb[c]))return fail(err,@"LUT 输出含无效值");}[text appendFormat:@"%.8f %.8f %.8f\n",rgb[0],rgb[1],rgb[2]];}
|
||||
if(_exportManagedState){NSData *metadata=[NSJSONSerialization dataWithJSONObject:_exportManagedState options:NSJSONWritingSortedKeys error:nil];if(metadata)[text insertString:[NSString stringWithFormat:@"# DAYU_CMS_STATE %@\n",[[[NSString alloc]initWithData:metadata encoding:NSUTF8StringEncoding]autorelease]] atIndex:0];[text replaceOccurrencesOfString:@"LUT_3D_SIZE 33" withString:@"LUT_3D_SIZE 65" options:0 range:NSMakeRange(0,text.length)];[text insertString:@"# V2 input: declared camera/LUT code values, or sRGB in host mode. Output: sRGB / Rec.709.\n" atIndex:0];}
|
||||
return [text writeToURL:url atomically:YES encoding:NSUTF8StringEncoding error:err];
|
||||
}}
|
||||
@end
|
||||
@@ -14,8 +14,8 @@
|
||||
}
|
||||
- (BOOL)copyTile:(FxImageTile*)source to:(FxImageTile*)dest entry:(NSMutableDictionary*)e error:(NSError**)error {
|
||||
id<MTLDevice>device=e[@"device"];id<MTLTexture>a=[source metalTextureForDevice:device],b=[dest metalTextureForDevice:device];
|
||||
NSMutableDictionary *pipelines=e[@"pipelines"];NSString *key=[NSString stringWithFormat:@"copy-%lu",(unsigned long)b.pixelFormat];id<MTLRenderPipelineState>pipeline=pipelines[key];
|
||||
if(!pipeline){MTLRenderPipelineDescriptor *desc=[MTLRenderPipelineDescriptor new];desc.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];desc.fragmentFunction=[e[@"library"]newFunctionWithName:@"dyToolCopyFragment"];desc.colorAttachments[0].pixelFormat=b.pixelFormat;pipeline=[device newRenderPipelineStateWithDescriptor:desc error:error];[desc.vertexFunction release];[desc.fragmentFunction release];[desc release];if(!pipeline)return NO;pipelines[key]=pipeline;[pipeline release];}
|
||||
NSMutableDictionary *pipelines=e[@"pipelines"];NSString *key=[NSString stringWithFormat:@"copy-%d-%lu",_managedFinishing,(unsigned long)b.pixelFormat];id<MTLRenderPipelineState>pipeline=pipelines[key];
|
||||
if(!pipeline){MTLRenderPipelineDescriptor *desc=[MTLRenderPipelineDescriptor new];desc.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];desc.fragmentFunction=[e[@"library"]newFunctionWithName:_managedFinishing?@"dyManagedCopyFragment":@"dyToolCopyFragment"];desc.colorAttachments[0].pixelFormat=b.pixelFormat;pipeline=[device newRenderPipelineStateWithDescriptor:desc error:error];[desc.vertexFunction release];[desc.fragmentFunction release];[desc release];if(!pipeline)return NO;pipelines[key]=pipeline;[pipeline release];}
|
||||
FxRect s=source.tilePixelBounds,t=dest.tilePixelBounds;float width=s.right-s.left,height=s.top-s.bottom,l=(t.left-s.left)/width,r=(t.right-s.left)/width,top=(s.top-t.top)/height,bottom=(s.top-t.bottom)/height;
|
||||
if(source.imageOrigin==kFxImageOrigin_BOTTOM_LEFT){top=1-top;bottom=1-bottom;}
|
||||
float w=b.width,h=b.height;DYVertex2D v[]={{{w/2,-h/2},{r,bottom}},{{-w/2,-h/2},{l,bottom}},{{w/2,h/2},{r,top}},{{-w/2,h/2},{l,top}}};if(dest.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)for(auto &vertex:v)vertex.position.y=-vertex.position.y;
|
||||
|
||||
@@ -123,7 +123,7 @@ DYUniforms DYToolUniforms(NSDictionary *node){DYUniforms u;DYDefaultUniforms(&u)
|
||||
// new layers explicitly disable mapping so adding a neutral layer is identity.
|
||||
if([type isEqual:@"primary"]){u.primarySectionEnabled=1;u.cm.configured=1;u.cm.inputTransfer=u.cm.outputTransfer;u.cm.inputGamut=u.cm.outputGamut;u.cm.toneMapping=0;}
|
||||
for(NSDictionary *d in DYDescriptors()){NSNumber *v=node[@"values"][d[@"key"]];if(v&&[d[@"offset"]integerValue]>=0)*(float*)((uint8_t*)&u+[d[@"offset"]unsignedIntegerValue])=v.floatValue;}return u;}
|
||||
BOOL DYToolIsNeutral(NSDictionary *node){NSString *type=node[@"type"];DYUniforms u=DYToolUniforms(node);NSDictionary *section=DYToolSection(type);BOOL enabled=YES;if([type isEqual:@"primary"])enabled=u.primarySectionEnabled>.5;else if([type isEqual:@"base"])enabled=u.baseSectionEnabled>.5||u.colorSectionEnabled>.5;else for(NSDictionary *d in DYDescriptors())if([d[@"pid"]isEqual:section[@"enabled"]])enabled=*(float*)((uint8_t*)&u+[d[@"offset"]unsignedIntegerValue])>.5;if(!enabled)return YES;if([type isEqual:@"primary"]&&u.cm.toneMapping>.5)return NO;if([type isEqual:@"mixer"])return !DYChannelMixerActive(u);if([type isEqual:@"film"])return !DYFilmToolActive(u);if([type isEqual:@"skin"])return u.skinProtection.y==0;if([node[@"type"]isEqual:@"spider"]&&[node[@"spider"]length]){auto mesh=DYSpiderMesh(node[@"spider"]);for(float v:dy::meshSamples(mesh))if(v!=0)return NO;}if([node[@"paths"]count])return NO;for(NSDictionary *d in DYDescriptors()){NSNumber *v=node[@"values"][d[@"key"]];if(v&&v.floatValue!=[d[@"default"]floatValue])return NO;}return YES;}
|
||||
BOOL DYToolIsNeutral(NSDictionary *node){NSString *type=node[@"type"];DYUniforms u=DYToolUniforms(node);NSDictionary *section=DYToolSection(type);BOOL enabled=YES;if([type isEqual:@"primary"])enabled=u.primarySectionEnabled>.5;else if([type isEqual:@"base"])enabled=u.baseSectionEnabled>.5||u.colorSectionEnabled>.5;else for(NSDictionary *d in DYDescriptors())if([d[@"pid"]isEqual:section[@"enabled"]])enabled=*(float*)((uint8_t*)&u+[d[@"offset"]unsignedIntegerValue])>.5;if(!enabled)return YES;if([type isEqual:@"primary"]&&u.cm.toneMapping>.5)return NO;if([type isEqual:@"mixer"])return !DYChannelMixerActive(u);if([type isEqual:@"film"])return !DYFilmToolActive(u);if([type isEqual:@"skin"])return u.skinProtection.y==0;if([node[@"type"]isEqual:@"spider"]&&[node[@"spider"]length]){auto mesh=DYSpiderMesh(node[@"spider"]);for(float v:dy::meshSamples(mesh))if(v!=0)return NO;}if([node[@"paths"]count])return NO;for(NSDictionary *d in DYDescriptors()){NSNumber *v=node[@"values"][d[@"key"]];if([type isEqual:@"primary"]&&[d[@"key"]isEqual:@"cmtoneMapping"]&&v.floatValue==0)continue;if(v&&v.floatValue!=[d[@"default"]floatValue])return NO;}return YES;}
|
||||
|
||||
@implementation DYToolManager {
|
||||
id<PROAPIAccessing> _host;NSString *_nodeID,*_type;NSInteger _depth;CMTime _time;NSMutableDictionary *_pending;DYInspectorToken *_token;
|
||||
|
||||
+3
-3
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.7.4</string>
|
||||
<string>1.8.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>52</string>
|
||||
<string>53</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>PlugInKit</key>
|
||||
@@ -71,7 +71,7 @@
|
||||
<key>uuid</key>
|
||||
<string>1C17B73B-F229-4C09-A434-EAF6DFF5F22A</string>
|
||||
<key>version</key>
|
||||
<string>1.7.4</string>
|
||||
<string>1.8.0</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>className</key>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.7.4</string>
|
||||
<string>1.8.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>52</string>
|
||||
<string>53</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
在新工单中引用
屏蔽一个用户