fix: import legacy-title Cube folders and verify all 26 supplied LUTs
这个提交包含在:
1 父节点
593aad9ecb
当前提交
497eef29fe
9 个文件已更改
+343
-25
没有与搜索条件相匹配的文件
@@ -0,0 +1,51 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import "../大鱼调色/Plugin/DYLUTLibrary.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
|
||||
// Read user-provided files in place; only import into a unique disposable library.
|
||||
static NSString *digest(NSURL *url) {
|
||||
NSData *data=[NSData dataWithContentsOfURL:url];if(!data)return @"unreadable";
|
||||
unsigned char bytes[CC_SHA256_DIGEST_LENGTH];CC_SHA256(data.bytes,(CC_LONG)data.length,bytes);
|
||||
NSMutableString *hex=[NSMutableString string];for(unsigned char byte:bytes)[hex appendFormat:@"%02x",byte];return hex;
|
||||
}
|
||||
int main(int argc,const char **argv){@autoreleasepool{
|
||||
if(argc!=3){fprintf(stderr,"usage: verify-external-lut-folder <folder> <report.json>\n");return 2;}
|
||||
NSFileManager *fm=NSFileManager.defaultManager;NSURL *source=[NSURL fileURLWithPath:[NSString stringWithUTF8String:argv[1]]];
|
||||
NSMutableArray *files=[NSMutableArray array],*rows=[NSMutableArray array];NSUInteger sidecars=0;
|
||||
for(NSURL *url in [fm enumeratorAtURL:source includingPropertiesForKeys:@[NSURLIsRegularFileKey] options:0 errorHandler:nil]){
|
||||
if([url.lastPathComponent hasPrefix:@"._"]){sidecars++;continue;}
|
||||
NSNumber *regular=nil;[url getResourceValue:®ular forKey:NSURLIsRegularFileKey error:nil];
|
||||
if(regular.boolValue&&[url.pathExtension.lowercaseString isEqual:@"cube"])[files addObject:url];
|
||||
}
|
||||
[files sortUsingComparator:^NSComparisonResult(NSURL *a,NSURL *b){return [a.path localizedStandardCompare:b.path];}];
|
||||
BOOL parsedAll=files.count>0;NSMutableDictionary *originalHashes=[NSMutableDictionary dictionary];
|
||||
for(NSURL *url in files){@autoreleasepool{
|
||||
NSError *error=nil;std::vector<float> values;NSUInteger size=0;BOOL parsed=DYLUTReadCube(url.path,values,size,&error);parsedAll&=parsed;
|
||||
originalHashes[url.lastPathComponent]=digest(url);
|
||||
[rows addObject:@{@"file":url.lastPathComponent,@"dimension":@(size),@"parsed":@(parsed),@"error":error.localizedDescription?:@""}];
|
||||
}}
|
||||
NSURL *temporary=[NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[@"dayu-external-lut-folder-" stringByAppendingString:NSUUID.UUID.UUIDString]]];
|
||||
DYLUTLibrary *library=[[DYLUTLibrary alloc]initWithRootURL:[temporary URLByAppendingPathComponent:@"library"]];
|
||||
__block BOOL done=NO;__block NSUInteger importedCount=0;__block NSError *importError=nil;
|
||||
__block double last=NSProcessInfo.processInfo.systemUptime,maxGap=0;__block NSUInteger ticks=0;
|
||||
NSTimer *timer=[NSTimer scheduledTimerWithTimeInterval:.005 repeats:YES block:^(NSTimer *t){double now=NSProcessInfo.processInfo.systemUptime;maxGap=MAX(maxGap,now-last);last=now;ticks++;(void)library.entries;}];
|
||||
NSProgress *task=[library importURLsAsync:@[source] completion:^(NSArray *imported,NSError *error){importedCount=imported.count;importError=[error retain];done=YES;}];
|
||||
double deadline=NSProcessInfo.processInfo.systemUptime+120;
|
||||
while(!done&&NSProcessInfo.processInfo.systemUptime<deadline)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.01]];
|
||||
[timer invalidate];if(!done)[task cancel];
|
||||
BOOL thumbnails=done&&!importError&&importedCount==files.count,identical=thumbnails;
|
||||
if(done&&!importError)for(NSDictionary *entry in library.entries){@autoreleasepool{
|
||||
NSError *error=nil;thumbnails&=DYLUTThumbnail(entry[@"path"],nil,0,0,NSMakeSize(64,36),&error)!=nil;
|
||||
identical&=[digest([NSURL fileURLWithPath:entry[@"path"]])isEqual:originalHashes[[entry[@"path"]lastPathComponent]]];
|
||||
}}
|
||||
BOOL originalUnchanged=YES;for(NSURL *url in files)originalUnchanged&=[digest(url)isEqual:originalHashes[url.lastPathComponent]];
|
||||
BOOL pass=done&&parsedAll&&!importError&&importedCount==files.count&&thumbnails&&identical&&originalUnchanged&&maxGap<.15;
|
||||
NSDictionary *report=@{@"pass":@(pass),@"sourceFolder":source.path,@"sourceFiles":@(files.count),@"appleDoubleSidecars":@(sidecars),@"files":rows,
|
||||
@"plannedFiles":@(MAX((int64_t)0,task.totalUnitCount)/2),@"importedFiles":@(importedCount),@"importError":importError.localizedDescription?:@"",
|
||||
@"allThumbnailsGenerated":@(thumbnails),@"importedContentsIdentical":@(identical),@"sourceFilesUnchanged":@(originalUnchanged),
|
||||
@"mainHeartbeatMaxGapMS":@(maxGap*1000),@"mainHeartbeatTicks":@(ticks),@"userLibraryModified":@NO,
|
||||
@"scope":@"User-supplied LUTs read only; isolated library import and thumbnail generation. No LUT data redistributed, no GUI or host parameter edits."};
|
||||
NSData *json=[NSJSONSerialization dataWithJSONObject:report options:NSJSONWritingPrettyPrinted error:nil];[json writeToFile:[NSString stringWithUTF8String:argv[2]] atomically:YES];
|
||||
if(done&&[fm fileExistsAtPath:temporary.path])[fm removeItemAtURL:temporary error:nil];[library release];[importError release];
|
||||
printf("%s: %lu sources, %lu imported\n",pass?"PASS":"FAIL",(unsigned long)files.count,(unsigned long)importedCount);return pass?0:1;
|
||||
}}
|
||||
+19
-1
@@ -45,6 +45,24 @@ int main(int argc,const char **argv){@autoreleasepool{
|
||||
require(gain&&near(out[0],.555)&&near(out[1],.28)&&near(out[2],.81),@"red gain trilinear interpolation");
|
||||
NSData *ranged=DYLUTTransformRGBA(input,1,1,domain.path,&error);out=(const float *)ranged.bytes;
|
||||
require(ranged&&near(out[0],.185)&&near(out[1],.14)&&near(out[2],.405),@"DOMAIN normalization resamples Cube");
|
||||
NSURL *legacy=write(temporary,@"LegacyMetadata/Legacy.cube",@"");
|
||||
NSMutableData *legacyBytes=[NSMutableData dataWithBytes:"TITLE \"" length:7];
|
||||
const unsigned char titleBytes[]={0xc7,0xe0,0xb3,0xc8};[legacyBytes appendBytes:titleBytes length:sizeof(titleBytes)];
|
||||
[legacyBytes appendData:[@"\"\n# legacy comment " dataUsingEncoding:NSUTF8StringEncoding]];[legacyBytes appendBytes:titleBytes length:sizeof(titleBytes)];
|
||||
[legacyBytes appendData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];[legacyBytes appendData:[cube()dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
require([legacyBytes writeToURL:legacy atomically:YES],@"write legacy-encoded descriptive metadata fixture");
|
||||
require(DYLUTReadCube(legacy.path,values,n,&error)&&n==2,@"legacy TITLE and comments do not invalidate ASCII numeric payload");
|
||||
require([DYLUTTransformRGBA(input,1,1,legacy.path,&error)isEqual:neutral],@"legacy descriptive encoding leaves numeric colors unchanged");
|
||||
NSURL *invalidNumeric=write(temporary,@"LegacyMetadata/InvalidNumeric.cube",@"");
|
||||
NSMutableData *invalidBytes=[NSMutableData dataWithData:[@"LUT_3D_SIZE 2\n0 0 0" dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
const unsigned char invalidByte=0xff;[invalidBytes appendBytes:&invalidByte length:1];
|
||||
[invalidBytes appendData:[@"\n1 0 0\n0 1 0\n1 1 0\n0 0 1\n1 0 1\n0 1 1\n1 1 1\n" dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
require([invalidBytes writeToURL:invalidNumeric atomically:YES],@"write corrupt numeric suffix fixture");
|
||||
require(!DYLUTReadCube(invalidNumeric.path,values,n,&error)&&values.empty()&&n==0,@"non-ASCII numeric suffix remains invalid");
|
||||
DYLUTLibrary *metadataLibrary=[[[DYLUTLibrary alloc]initWithRootURL:[temporary URLByAppendingPathComponent:@"MetadataLibrary"]]autorelease];
|
||||
NSArray *metadataImported=[metadataLibrary importURLs:@[legacy] error:&error];
|
||||
require(metadataImported.count==1&&[[NSData dataWithContentsOfFile:metadataImported[0][@"path"]]isEqual:legacyBytes],@"legacy metadata imports without rewriting source bytes");
|
||||
require(![metadataLibrary importURLs:@[invalidNumeric] error:&error]&&[error.localizedDescription containsString:@"InvalidNumeric.cube"]&&metadataLibrary.entries.count==1,@"failed import names the file and preserves previous library");
|
||||
NSData *clear=DYLUTTransformRGBA(sample(NAN,.2,.3),1,1,nil,&error);out=(const float *)clear.bytes;
|
||||
require(clear&&out[0]==0&&out[1]==0&&out[2]==0&&out[3]==0,@"invalid float samples become clear");
|
||||
require(!DYLUTTransformRGBA([NSData data],1,1,nil,&error),@"reject malformed float RGBA length");
|
||||
@@ -66,7 +84,7 @@ int main(int argc,const char **argv){@autoreleasepool{
|
||||
if(!DYLUTReadCube(red.path,local,dimension,NULL)||dimension!=2||!near(local[4],1.6))parallelState->store(false);
|
||||
}});
|
||||
require(parallelOK,@"concurrent table cache reads stay consistent");
|
||||
NSArray *invalid=@[@"LUT_3D_SIZE 1\n0 0 0\n",@"LUT_3D_SIZE 129\n",@"LUT_3D_SIZE 2\n0 0 0\n",@"LUT_1D_SIZE 2\n0 0 0\n1 1 1\n",@"LUT_3D_SIZE 2\nNaN 0 0\n",[cube() stringByAppendingString:@"0 0 0\n"],[cube() stringByAppendingString:@"DOMAIN_MAX 0 1 1\n"],[cube() stringByAppendingString:@"garbage\n"],[cube() stringByAppendingString:@"LUT_3D_SIZE 2\n"]];
|
||||
NSArray *invalid=@[@"",[cube()stringByReplacingOccurrencesOfString:@"LUT_3D_SIZE 2" withString:@"LUT_3D_SIZE 2junk"],[cube()stringByAppendingString:@"DOMAIN_MAX 1 1 1 junk\n"],@"LUT_3D_SIZE 1\n0 0 0\n",@"LUT_3D_SIZE 129\n",@"LUT_3D_SIZE 2\n0 0 0\n",@"LUT_1D_SIZE 2\n0 0 0\n1 1 1\n",@"LUT_3D_SIZE 2\nNaN 0 0\n",[cube() stringByAppendingString:@"0 0 0\n"],[cube() stringByAppendingString:@"DOMAIN_MAX 0 1 1\n"],[cube() stringByAppendingString:@"garbage\n"],[cube() stringByAppendingString:@"LUT_3D_SIZE 2\n"]];
|
||||
NSUInteger invalidIndex=0;
|
||||
for(NSString *text in invalid) {
|
||||
NSURL *url=write(temporary,[NSString stringWithFormat:@"Invalid%lu.cube",(unsigned long)invalidIndex++],text);
|
||||
|
||||
@@ -94,6 +94,31 @@ int main(int argc,const char *argv[]) {@autoreleasepool {
|
||||
NSUInteger folderViews=[[browser valueForKey:@"folderButtons"]count];
|
||||
[browser importSelectedURLs:@[source]];[browser close];done=NO;[library reloadAsync:^(NSError *failure){require(!failure,@"scan after browser close completes");done=YES;}];pump(^{return done;});
|
||||
require(library.entries.count==3025,@"closing during import cancels without changing existing library");
|
||||
// Host acknowledgement is the selection boundary, including rejection,
|
||||
// cancellation and an older completion arriving after a newer click.
|
||||
NSMutableArray *acknowledgements=[NSMutableArray array],*applyTasks=[NSMutableArray array];
|
||||
DYLUTBrowser *ackBrowser=[[DYLUTBrowser alloc]initWithLibrary:library preview:nil selectedPath:anchor.path palette:@{} selection:^NSProgress *(NSString *path,void (^completion)(NSError *)){
|
||||
[acknowledgements addObject:[[completion copy]autorelease]];NSProgress *task=[NSProgress discreteProgressWithTotalUnitCount:1];[applyTasks addObject:task];return task;
|
||||
}];
|
||||
pump(^{return [ackBrowser valueForKey:@"libraryTask"]==nil;});
|
||||
NSDictionary *ackTiles=[ackBrowser valueForKey:@"tiles"];NSArray *ackPaths=ackTiles.allKeys;require(ackPaths.count>=2,@"acknowledgement fixture has selectable thumbnails");
|
||||
id firstTile=ackTiles[ackPaths[0]],secondTile=ackTiles[ackPaths[1]];[firstTile setEnabled:YES];[secondTile setEnabled:YES];
|
||||
[ackBrowser thumbnailClicked:firstTile];
|
||||
require([[ackBrowser valueForKey:@"selectedPath"]isEqual:anchor.path]&&[[[ackBrowser valueForKey:@"statusLabel"]stringValue]hasPrefix:@"正在载入"],@"thumbnail stays loading until host application acknowledges");
|
||||
void (^rejected)(NSError *)=acknowledgements[0];rejected([NSError errorWithDomain:@"test.host" code:1 userInfo:@{NSLocalizedDescriptionKey:@"Host rejected this edit"}]);
|
||||
require([[ackBrowser valueForKey:@"selectedPath"]isEqual:anchor.path]&&[[[ackBrowser valueForKey:@"statusLabel"]stringValue]isEqual:@"Host rejected this edit"],@"host rejection preserves previous selection and reports the error");
|
||||
[ackBrowser thumbnailClicked:firstTile];[ackBrowser thumbnailClicked:secondTile];
|
||||
require([applyTasks[1]isCancelled],@"new thumbnail click cancels previous application task");
|
||||
void (^older)(NSError *)=acknowledgements[1];older(nil);
|
||||
require([[ackBrowser valueForKey:@"selectedPath"]isEqual:anchor.path],@"late older acknowledgement cannot mark a stale LUT selected");
|
||||
void (^latest)(NSError *)=acknowledgements[2];latest(nil);
|
||||
require([[ackBrowser valueForKey:@"selectedPath"]isEqual:ackPaths[1]],@"only acknowledged latest thumbnail becomes selected");
|
||||
[ackBrowser clearSelection:nil];
|
||||
require([[ackBrowser valueForKey:@"selectedPath"]isEqual:ackPaths[1]],@"removal also waits for host acknowledgement");
|
||||
void (^removed)(NSError *)=acknowledgements[3];removed(nil);require([ackBrowser valueForKey:@"selectedPath"]==nil,@"acknowledged removal clears selection");
|
||||
[ackBrowser thumbnailClicked:firstTile];[ackBrowser close];require([applyTasks.lastObject isCancelled],@"closing the browser cancels pending host application");
|
||||
void (^afterClose)(NSError *)=acknowledgements[4];afterClose(nil);require([ackBrowser valueForKey:@"selectedPath"]==nil,@"completion after close cannot change the selection");
|
||||
[acknowledgements removeAllObjects];[ackBrowser release];
|
||||
[browser release];report[@"largeCatalogEntries"]=@(visible);report[@"initialLiveThumbnailViews"]=@(tileCount);report[@"initialLiveFolderViews"]=@(folderViews);report[@"pass"]=@YES;
|
||||
#else
|
||||
report[@"mode"]=@"baseline synchronous import";
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
{
|
||||
"date": "2026-11-01",
|
||||
"status": "development-preflight-passed-formal-host-verification-pending",
|
||||
"status": "real-folder-preflight-passed-formal-host-verification-pending",
|
||||
"version": "1.1.4",
|
||||
"build": "15",
|
||||
"reportedTrigger": "External LUT imported successfully, then thumbnail clicked to apply",
|
||||
"reportedTrigger": [
|
||||
"External LUT thumbnail application hangs after successful import",
|
||||
"N12精选luts folder import fails"
|
||||
],
|
||||
"baselineCommit": "a2c8dfafcfe8c1974ec560b9586b78052356a0e4",
|
||||
"finding": "A preview-cache preheat did not pin the selected table or GPU texture; frame rendering still performed path metadata queries and could parse external text again. Browser acknowledged selection before the inspector finished application.",
|
||||
"changes": [
|
||||
"Decode and upload on the renderer preparation queue before committing the host path.",
|
||||
"Retain immutable selected snapshots independently of preview caches; no file metadata or parsing on prepared frame paths.",
|
||||
"Acknowledge browser selection only after preparation and accepted host write.",
|
||||
"Cancel stale requests before they can overwrite a newer host selection."
|
||||
"Cancel stale requests before they can overwrite a newer host selection.",
|
||||
"Keep preview work at utility priority and selected LUT preparation at user-initiated priority.",
|
||||
"Reuse prepared GPU device pipelines when the host supplies the actual registry ID.",
|
||||
"Allow legacy-encoded TITLE/comments while strictly validating ASCII numeric data and include the failing filename in import errors."
|
||||
],
|
||||
"nativeChecks": 92,
|
||||
"nativeChecks": 171,
|
||||
"nativePassed": true,
|
||||
"externalChecks": [
|
||||
{
|
||||
@@ -65,13 +71,205 @@
|
||||
"pass": true
|
||||
}
|
||||
],
|
||||
"browserChecks": 56,
|
||||
"browserChecks": 67,
|
||||
"browserPassed": true,
|
||||
"browserMainMaxGapMS": 7.393208332359791,
|
||||
"libraryChecks": 92,
|
||||
"browserMainMaxGapMS": 6.391000002622604,
|
||||
"libraryChecks": 112,
|
||||
"libraryPassed": true,
|
||||
"limitations": [
|
||||
"No failing user-supplied LUT file was available in this run; the original user hang is not yet independently reproduced.",
|
||||
"These preflight cases use synthetic local files and actual Metal/IOSurface rendering; live formal FCP acceptance remains a separate gate."
|
||||
]
|
||||
"The actual supplied folder import failure was reproduced and fixed. The earlier unspecified user thumbnail hang was not captured while occurring.",
|
||||
"Real-folder import, thumbnail and Metal checks passed; live formal Final Cut Pro acceptance remains pending.",
|
||||
"No older macOS, Intel or network-volume benchmark; no full VoiceOver audit."
|
||||
],
|
||||
"realFolder": {
|
||||
"sourceFolder": "/Volumes/备份/N12精选luts",
|
||||
"baseline": {
|
||||
"importedFiles": 0,
|
||||
"error": "LUT 必须是 UTF-8 文本",
|
||||
"failedFiles": [
|
||||
"青橙色.cube",
|
||||
"青橙色2.cube"
|
||||
]
|
||||
},
|
||||
"fixedImport": {
|
||||
"importError": "",
|
||||
"sourceFilesUnchanged": true,
|
||||
"mainHeartbeatMaxGapMS": 6.27491669729352,
|
||||
"userLibraryModified": false,
|
||||
"importedContentsIdentical": true,
|
||||
"mainHeartbeatTicks": 794,
|
||||
"allThumbnailsGenerated": true,
|
||||
"scope": "User-supplied LUTs read only; isolated library import and thumbnail generation. No LUT data redistributed, no GUI or host parameter edits.",
|
||||
"files": [
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "超强质感高对比.cube",
|
||||
"error": "",
|
||||
"dimension": 17
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "城市莫兰迪灰2 加亮.cube",
|
||||
"error": "",
|
||||
"dimension": 32
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "复古-大白鲨.cube",
|
||||
"error": "",
|
||||
"dimension": 33
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "复古胶片风.cube",
|
||||
"error": "",
|
||||
"dimension": 32
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "复古清新干净1.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "复古清新干净2.cube",
|
||||
"error": "",
|
||||
"dimension": 32
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "复古清新干净3.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "感性内敛色调.cube",
|
||||
"error": "",
|
||||
"dimension": 33
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "户外森林2.cube",
|
||||
"error": "",
|
||||
"dimension": 16
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "绿转白.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "绿转粉.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "绿转紫.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "内景(柔皮肤).cube",
|
||||
"error": "",
|
||||
"dimension": 33
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "青橙色.cube",
|
||||
"error": "",
|
||||
"dimension": 32
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "青橙色2.cube",
|
||||
"error": "",
|
||||
"dimension": 32
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "清新亮调.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "万能青橙色.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "质感超高对比.cube",
|
||||
"error": "",
|
||||
"dimension": 33
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "质感低对比.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "质感高对比1.cube",
|
||||
"error": "",
|
||||
"dimension": 33
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "质感高对比2.cube",
|
||||
"error": "",
|
||||
"dimension": 33
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "质感高对比暗部发红.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "质感中对比.cube",
|
||||
"error": "",
|
||||
"dimension": 33
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "自然高对比高饱和.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "自然清新.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
},
|
||||
{
|
||||
"parsed": true,
|
||||
"file": "AAChangyong1.cube",
|
||||
"error": "",
|
||||
"dimension": 64
|
||||
}
|
||||
],
|
||||
"sourceFolder": "/Volumes/备份/N12精选luts",
|
||||
"pass": true,
|
||||
"importedFiles": 26,
|
||||
"sourceFiles": 26,
|
||||
"appleDoubleSidecars": 0,
|
||||
"plannedFiles": 26
|
||||
},
|
||||
"metal": {
|
||||
"checks": 171,
|
||||
"pass": true,
|
||||
"files": 26,
|
||||
"scope": "Every supplied LUT prepared asynchronously and rendered through actual Metal/IOSurface. No user file changes or LUT redistribution."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,6 +249,24 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
deadline=NSProcessInfo.processInfo.systemUptime+10;
|
||||
while(!cancelledDone&&NSProcessInfo.processInfo.systemUptime<deadline)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.01]];
|
||||
run.record(@"external-preparation-cancellation",cancelledDone&&cancellationReported);
|
||||
NSString *userFolder=NSProcessInfo.processInfo.environment[@"DY_DIAGNOSTIC_LUT_FOLDER"];
|
||||
if(userFolder.length){
|
||||
NSUInteger userCount=0;BOOL allUserFrames=YES;
|
||||
NSURL *folder=[NSURL fileURLWithPath:userFolder];
|
||||
for(NSURL *file in [NSFileManager.defaultManager enumeratorAtURL:folder includingPropertiesForKeys:@[NSURLIsRegularFileKey] options:NSDirectoryEnumerationSkipsHiddenFiles errorHandler:nil]){@autoreleasepool{
|
||||
NSNumber *regular=nil;[file getResourceValue:®ular forKey:NSURLIsRegularFileKey error:nil];
|
||||
if(!regular.boolValue||![file.pathExtension.lowercaseString isEqual:@"cube"])continue;
|
||||
__block BOOL ready=NO;__block NSError *failure=nil;
|
||||
[externalRenderer prepareLUTPath:file.path completion:^(NSError *result){failure=[result retain];ready=YES;}];
|
||||
double until=NSProcessInfo.processInfo.systemUptime+30;
|
||||
while(!ready&&NSProcessInfo.processInfo.systemUptime<until)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.01]];
|
||||
run.need([@"user-lut-preparation:" stringByAppendingString:file.lastPathComponent],ready&&!failure,@{@"error":reason(failure)});[failure release];
|
||||
Pixels frame=render(run,externalRenderer,source,destination,gpu,externalUniforms,@{@"look0":file.path},[@"user-lut-render:" stringByAppendingString:file.lastPathComponent]);
|
||||
Difference delta=difference(neutral,frame);BOOL good=delta.nonfinite==0;allUserFrames&=good;userCount++;
|
||||
run.record([@"user-lut-finite-frame:" stringByAppendingString:file.lastPathComponent],good,measure(delta));
|
||||
}}
|
||||
run.record(@"user-folder-all-luts-prepared-and-rendered",userCount>0&&allUserFrames,@{@"files":@(userCount),@"sourceFolder":userFolder,@"sourceFilesModified":@NO});
|
||||
}
|
||||
[gpu release];
|
||||
} @catch(NSException *exception) {
|
||||
run.record(@"diagnostic-exception",false,@{@"exception":exception.name?:@"unknown",@"message":exception.reason?:@"unknown"});
|
||||
|
||||
@@ -412,7 +412,7 @@ static NSImage *DYWheelImage(void) {
|
||||
self.layer.backgroundColor=[DYThemePalette()[@"background"] CGColor];
|
||||
self.appearance=[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
|
||||
_brand=[DYLabel(@"◒ 大鱼调色",16) retain]; _brand.font=[NSFont boldSystemFontOfSize:16];_brand.textColor=DYInk();
|
||||
_subtitle=[DYLabel([[NSBundle bundleForClass:self.class]objectForInfoDictionaryKey:@"CFBundleShortVersionString"]?:@"1.1.3",9) retain]; _subtitle.textColor=DYThemeColor(@"secondary");
|
||||
_subtitle=[DYLabel([[NSBundle bundleForClass:self.class]objectForInfoDictionaryKey:@"CFBundleShortVersionString"]?:@"1.1.4",9) retain]; _subtitle.textColor=DYThemeColor(@"secondary");
|
||||
_resetAll=[DYButton(@"↺",self,@selector(resetAll:)) retain];_resetAll.bordered=NO; _resetAll.toolTip=@"恢复全部调色参数与 LUT";_resetAll.accessibilityLabel=@"全部还原";
|
||||
_save=[DYButton(@"保存预设",self,@selector(savePreset:)) retain];
|
||||
_load=[DYButton(@"载入预设",self,@selector(loadPreset:)) retain];
|
||||
|
||||
@@ -138,7 +138,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
if((self=[super initWithWindow:panel])){
|
||||
NSString *savedFolder=[[NSUserDefaults standardUserDefaults]stringForKey:DYBrowserFolderPreference];
|
||||
_library=[library retain];_preview=[rgba copy];_selectedPath=[path copy];_folder=[(savedFolder?:@"*") copy];_selection=[selection copy];
|
||||
_folderButtons=[NSMutableArray new];_tiles=[NSMutableDictionary new];_queuedPaths=[NSMutableSet new];_thumbnailCache=[NSCache new];_thumbnailCache.countLimit=600;_thumbnailCache.totalCostLimit=64*1024*1024;_previewQueue=dispatch_queue_create("com.dayu.color.lut-thumbnails",DISPATCH_QUEUE_SERIAL);
|
||||
_folderButtons=[NSMutableArray new];_tiles=[NSMutableDictionary new];_queuedPaths=[NSMutableSet new];_thumbnailCache=[NSCache new];_thumbnailCache.countLimit=600;_thumbnailCache.totalCostLimit=64*1024*1024;_previewQueue=dispatch_queue_create("com.dayu.color.lut-thumbnails",DISPATCH_QUEUE_SERIAL);dispatch_set_target_queue(_previewQueue,dispatch_get_global_queue(QOS_CLASS_UTILITY,0));
|
||||
panel.title=@"风格 LUT";panel.minSize=NSMakeSize(760,420);panel.releasedWhenClosed=NO;panel.hidesOnDeactivate=NO;panel.delegate=self;
|
||||
_root=[[DYBrowserCanvas alloc]initWithFrame:NSMakeRect(0,0,760,560)];_root.accessibilityLabel=@"LUT 缩略图浏览库";panel.contentView=_root;
|
||||
_titleLabel=[BrowserLabel(@"LUT 文件夹",14)retain];_titleLabel.font=[NSFont systemFontOfSize:14 weight:NSFontWeightSemibold];
|
||||
|
||||
+15
-9
@@ -74,6 +74,13 @@ static BOOL DYLUTCancelled(NSProgress *progress,NSError **error) {
|
||||
if(error)*error=[NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:@{NSLocalizedDescriptionKey:@"已取消 LUT 加载"}];
|
||||
return YES;
|
||||
}
|
||||
static NSError *DYLUTFileError(NSError *error,NSURL *url) {
|
||||
if(error.code==NSUserCancelledError&&[error.domain isEqual:NSCocoaErrorDomain])return error;
|
||||
NSMutableDictionary *info=[NSMutableDictionary dictionaryWithDictionary:error.userInfo?:@{}];
|
||||
info[NSLocalizedDescriptionKey]=[NSString stringWithFormat:@"%@:%@",url.lastPathComponent,error.localizedDescription?:@"无法读取此 LUT"];
|
||||
info[NSFilePathErrorKey]=url.path;if(error)info[NSUnderlyingErrorKey]=error;
|
||||
return [NSError errorWithDomain:error.domain?:DYLUTLibraryErrorDomain code:error?error.code:1 userInfo:info];
|
||||
}
|
||||
static BOOL DYLUTParse(NSString *path,std::vector<float>& data,NSUInteger& size,NSProgress *progress,NSError **error) {
|
||||
data.clear();size=0;
|
||||
NSDictionary *attributes=[[NSFileManager defaultManager]attributesOfItemAtPath:path error:error];
|
||||
@@ -92,10 +99,9 @@ static BOOL DYLUTParse(NSString *path,std::vector<float>& data,NSUInteger& size,
|
||||
for(float v:data)if(!std::isfinite(v))return DYLUTFail(error,@"输入 LUT 含无效数字");
|
||||
size=n;return YES;
|
||||
}
|
||||
// Validate encoding once, then parse byte spans without allocating an
|
||||
// NSString, NSArray and temporary strings for every numeric row.
|
||||
NSString *text=[[NSString alloc]initWithData:bytes encoding:NSUTF8StringEncoding];
|
||||
if(!text)return DYLUTFail(error,@"LUT 必须是 UTF-8 文本");[text release];
|
||||
// Cube commands and numbers use ASCII. Descriptive TITLE/comments can
|
||||
// legitimately use legacy encodings; they never affect the numeric table.
|
||||
if(!bytes.length)return DYLUTFail(error,@"LUT 文件为空");
|
||||
std::string storage((const char *)bytes.bytes,bytes.length);
|
||||
static locale_t numericLocale;static dispatch_once_t localeOnce;dispatch_once(&localeOnce,^{numericLocale=newlocale(LC_NUMERIC_MASK,"C",NULL);});
|
||||
float domainMin[3]={0,0,0},domainMax[3]={1,1,1};BOOL foundSize=NO;
|
||||
@@ -112,15 +118,15 @@ static BOOL DYLUTParse(NSString *path,std::vector<float>& data,NSUInteger& size,
|
||||
auto starts=[&](std::string_view prefix){return line.substr(0,prefix.size())==prefix;};
|
||||
if(starts("LUT_3D_SIZE")) {
|
||||
auto v=trim(line.substr(11));int n=0;auto result=std::from_chars(v.data(),v.data()+v.size(),n);
|
||||
if(result.ec!=std::errc{}||foundSize||n<2||n>128)return DYLUTFail(error,@"LUT 尺寸应为 2–128,且只能声明一次");
|
||||
if(result.ec!=std::errc{}||!trim(v.substr(result.ptr-v.data())).empty()||foundSize||n<2||n>128)return DYLUTFail(error,@"LUT 尺寸应为 2–128,且只能声明一次");
|
||||
size=n;foundSize=YES;data.reserve(size*size*size*4);
|
||||
} else if(starts("DOMAIN_MIN")||starts("DOMAIN_MAX")) {
|
||||
auto v=line.substr(10);if(!number(v,r)||!number(v,g)||!number(v,b))return DYLUTFail(error,@"LUT DOMAIN 范围无效");
|
||||
auto v=line.substr(10);if(!number(v,r)||!number(v,g)||!number(v,b)||!trim(v).empty())return DYLUTFail(error,@"LUT DOMAIN 范围无效");
|
||||
float *domain=starts("DOMAIN_MIN")?domainMin:domainMax;domain[0]=r;domain[1]=g;domain[2]=b;
|
||||
} else if(starts("TITLE")||starts("LUT_3D_INPUT_RANGE"))continue;
|
||||
else if(starts("LUT_1D_SIZE"))return DYLUTFail(error,@"请选择三维 .cube LUT");
|
||||
else {
|
||||
auto v=line;if(!number(v,r)||!number(v,g)||!number(v,b)||!std::isfinite(r)||!std::isfinite(g)||!std::isfinite(b))return DYLUTFail(error,@"LUT 含无效数据行");
|
||||
auto v=line;if(!number(v,r)||!number(v,g)||!number(v,b)||!trim(v).empty()||!std::isfinite(r)||!std::isfinite(g)||!std::isfinite(b))return DYLUTFail(error,[NSString stringWithFormat:@"LUT 第 %lu 行含无效数字或多余内容",(unsigned long)rows]);
|
||||
data.insert(data.end(),{r,g,b,1});if(data.size()>128*128*128*4)return DYLUTFail(error,@"LUT 数据过多");
|
||||
}
|
||||
}
|
||||
@@ -370,7 +376,7 @@ static BOOL DYLUTEnsureDirectory(NSURL *directory,NSURL *root,NSError **error) {
|
||||
NSError *itemError=nil;BOOL valid=NO;
|
||||
@autoreleasepool{
|
||||
progress.localizedDescription=[NSString stringWithFormat:@"正在校验 %lld/%lu",progress.completedUnitCount+1,(unsigned long)plans.count];progress.localizedAdditionalDescription=[plan[@"source"]lastPathComponent];
|
||||
std::vector<float> values;NSUInteger n=0;valid=!DYLUTCancelled(progress,&itemError)&&DYLUTReadCancellable([plan[@"source"]path],values,n,progress,&itemError);[itemError retain];
|
||||
std::vector<float> values;NSUInteger n=0;valid=!DYLUTCancelled(progress,&itemError)&&DYLUTReadCancellable([plan[@"source"]path],values,n,progress,&itemError);if(!valid)itemError=DYLUTFileError(itemError,plan[@"source"]);[itemError retain];
|
||||
}
|
||||
if(!valid){if(error)*error=[itemError autorelease];else[itemError release];return nil;}[itemError release];progress.completedUnitCount++;
|
||||
}
|
||||
@@ -389,7 +395,7 @@ static BOOL DYLUTEnsureDirectory(NSURL *directory,NSURL *root,NSError **error) {
|
||||
if(![fm copyItemAtURL:plan[@"source"] toURL:destination error:&itemError])return NO;[created addObject:destination];
|
||||
std::vector<float> values;NSUInteger n=0;if(!DYLUTReadCancellable(destination.path,values,n,progress,&itemError))return NO;
|
||||
[imported addObject:DYLUTEntry(destination,_rootURL)];return YES;
|
||||
}();[itemError retain];
|
||||
}();if(!copied)itemError=DYLUTFileError(itemError,plan[@"source"]);[itemError retain];
|
||||
}
|
||||
if(!copied){if(error)*error=[itemError autorelease];else[itemError release];success=NO;break;}[itemError release];progress.completedUnitCount++;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ static id<MTLTexture> texture3D(id<MTLDevice>d,const float*values,NSUInteger n){
|
||||
}
|
||||
@end
|
||||
@implementation DYRenderer
|
||||
- (instancetype)init{if((self=[super init])){_previewLock=[NSObject new];_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_preparedLUTs=[NSMutableDictionary new];_activeLUTPaths=[NSSet new];_lutPreparationQueue=dispatch_queue_create("com.dayu.color.lut-upload",DISPATCH_QUEUE_SERIAL);_tables=[DYColorTables new];}return self;}
|
||||
- (instancetype)init{if((self=[super init])){_previewLock=[NSObject new];_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_preparedLUTs=[NSMutableDictionary new];_activeLUTPaths=[NSSet new];_lutPreparationQueue=dispatch_queue_create("com.dayu.color.lut-upload",DISPATCH_QUEUE_SERIAL);dispatch_set_target_queue(_lutPreparationQueue,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0));_tables=[DYColorTables new];}return self;}
|
||||
- (void)dealloc{[_devices release];[_luts release];[_preparedLUTs release];[_activeLUTPaths release];dispatch_release(_lutPreparationQueue);[_tables release];[_preview release];[_lookLUTPreview release];[_previewLock release];[super dealloc];}
|
||||
- (void)trimPreparedLUTsKeeping:(NSString *)path {
|
||||
if(_preparedLUTs.count<=12)return;
|
||||
@@ -54,7 +54,9 @@ static id<MTLTexture> texture3D(id<MTLDevice>d,const float*values,NSUInteger n){
|
||||
id<MTLCommandQueue>q=[d newCommandQueue];entry=[NSMutableDictionary dictionaryWithDictionary:@{@"device":d,@"library":lib,@"queue":q,@"pipelines":[NSMutableDictionary dictionary]}];
|
||||
for(NSString*fn in @[@"dyUnpremultiply",@"dyWhitesSceneStatistics",@"dyLUTExportKernel",@"dyInputAnalysis"]){id<MTLFunction>f=[lib newFunctionWithName:fn];if(!f){fail(err,[fn stringByAppendingString:@" 缺失"]);[lib release];[q release];[d release];return nil;}id<MTLComputePipelineState>p=[d newComputePipelineStateWithFunction:f error:err];[f release];if(!p){[lib release];[q release];[d release];return nil;}entry[fn]=p;[p release];}
|
||||
float identity[32];for(int z=0;z<2;z++)for(int y=0;y<2;y++)for(int x=0;x<2;x++){int i=((z*2+y)*2+x)*4;identity[i]=x;identity[i+1]=y;identity[i+2]=z;identity[i+3]=1;}id<MTLTexture>neutral=texture3D(d,identity,2);if(!neutral){fail(err,@"无法分配中性 LUT");return nil;}entry[@"identity"]=neutral;
|
||||
_devices[k]=entry;[d release];[lib release];[q release];return entry;
|
||||
// Preparing before the first frame may use registry 0. Reuse those pipelines
|
||||
// when the host subsequently supplies that device's actual registry ID.
|
||||
_devices[k]=entry;_devices[@(d.registryID)]=entry;[d release];[lib release];[q release];return entry;
|
||||
}
|
||||
- (id<MTLTexture>)lut:(NSString*)path entry:(NSDictionary*)e error:(NSError**)err{
|
||||
if(!path.length)return e[@"identity"];
|
||||
@@ -80,7 +82,7 @@ static id<MTLTexture> texture3D(id<MTLDevice>d,const float*values,NSUInteger n){
|
||||
id<MTLTexture>h=[_tables hslForDevice:d uniforms:u],w=[_tables whiteBalanceForDevice:d uniforms:u],g=[_tables gradingForDevice:d uniforms:u];if(!h||!w||!g){fail(err,_tables.lastError?:@"颜色查表构建失败");return nil;}[ts addObjectsFromArray:@[h,w,g]];return ts;
|
||||
}
|
||||
- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{@synchronized(self){@autoreleasepool{
|
||||
[_activeLUTPaths release];_activeLUTPaths=[[NSSet alloc]initWithArray:paths.allValues];
|
||||
[_activeLUTPaths release];_activeLUTPaths=[[NSSet alloc]initWithArray:paths.allValues?:@[]];
|
||||
NSMutableDictionary*e=[self device:dst.deviceRegistryID error:err];if(!e)return NO;id<MTLDevice>d=e[@"device"];id<MTLTexture>input=[src metalTextureForDevice:d],output=[dst metalTextureForDevice:d];if(!input||!output)return fail(err,@"宿主图像纹理不可用");
|
||||
NSArray*ts=[self textures:paths uniforms:&u entry:e error:err];if(!ts)return NO;
|
||||
NSMutableDictionary*ps=e[@"pipelines"];NSNumber*format=@(output.pixelFormat);id<MTLRenderPipelineState>pipeline=ps[format];if(!pipeline){MTLRenderPipelineDescriptor*p=[MTLRenderPipelineDescriptor new];p.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];p.fragmentFunction=[e[@"library"]newFunctionWithName:@"dyFragment"];p.colorAttachments[0].pixelFormat=output.pixelFormat;pipeline=[d newRenderPipelineStateWithDescriptor:p error:err];[p.vertexFunction release];[p.fragmentFunction release];[p release];if(!pipeline)return NO;ps[format]=pipeline;[pipeline release];}
|
||||
|
||||
在新工单中引用
屏蔽一个用户