Support text-annotated Cube rows with Custom LUT zero-fill compatibility

这个提交包含在:
mac 于 2026-11-02 20:13:29 +08:00 提交
1 父节点 5c547100c1
当前提交 58a17de438
10 个文件已更改
+1307 -1072

没有与搜索条件相匹配的文件

+23
查看文件
@@ -362,6 +362,29 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
run.record(@"analysis-applies-selected-input-LUT",analysisDifferent&&analysisChanges>100,@{@"changedComponents":@(analysisChanges),@"maxAbsoluteError":@(analysisMaximum)});
NSString *lookFile=[runtime stringByAppendingPathComponent:@"diagnostic-look.cube"];NSMutableString *cube=[NSMutableString stringWithString:@"TITLE \"Self test look\"\nLUT_3D_SIZE 2\nDOMAIN_MIN 0 0 0\nDOMAIN_MAX 1 1 1\n"];
for(int b=0;b<2;b++)for(int g=0;g<2;g++)for(int r=0;r<2;r++)[cube appendFormat:@"%.8f %.8f %.8f\n",.7f*r+.1f,.8f*g+.05f,.85f*b+.02f];error=nil;run.need(@"temporary-look-file",[cube writeToFile:lookFile atomically:YES encoding:NSUTF8StringEncoding error:&error],@{@"error":reason(error)});
NSString *noteFile=[runtime stringByAppendingPathComponent:@"noted.cube"],*noteOracle=[runtime stringByAppendingPathComponent:@"note-oracle.cube"];
NSString *noteRows=@"LUT_3D_SIZE 2\n0.25 v3文字 100 分\n1 0 说明99\n0 1 0 后记123\n1 1 0\n0 0 1\n1 0 1\n0 1 1\n1 1 1\n";
NSString *oracleRows=@"LUT_3D_SIZE 2\n0.25 0 0\n1 0 0\n0 1 0\n1 1 0\n0 0 1\n1 0 1\n0 1 1\n1 1 1\n";
run.need(@"lut-note-fixtures",[noteRows writeToFile:noteFile atomically:YES encoding:NSUTF8StringEncoding error:&error]&&[oracleRows writeToFile:noteOracle atomically:YES encoding:NSUTF8StringEncoding error:&error]);
std::vector<float> notedTable,oracleTable;NSUInteger notedSide=0,oracleSide=0;
run.record(@"lut-note-retains-prefix-zero-fills-without-row-shift",DYLUTReadCube(noteFile,notedTable,notedSide,&error)&&DYLUTReadCube(noteOracle,oracleTable,oracleSide,&error)&&notedSide==2&&oracleSide==2&&notedTable==oracleTable);
u=defaults;u.lookSectionEnabled=1;u.postLUTStrength=1;
Pixels notePixels=render(run,renderer,source,destination,gpu,u,@{@"look0":noteFile},@"lut-note-metal-render");
Pixels oraclePixels=render(run,renderer,source,destination,gpu,u,@{@"look0":noteOracle},@"lut-note-oracle-metal-render");
Difference noteDelta=difference(notePixels,oraclePixels);run.record(@"lut-note-metal-exact-canonical-colors",noteDelta.nonfinite==0&&noteDelta.maximum==0,measure(noteDelta));
NSString *userLUT=NSProcessInfo.processInfo.environment[@"DY_DIAGNOSTIC_LUT_FILE"],*userOracle=NSProcessInfo.processInfo.environment[@"DY_DIAGNOSTIC_LUT_ORACLE"];
if(userLUT.length&&userOracle.length){
NSData *original=[NSData dataWithContentsOfFile:userLUT];DYLUTLibrary *isolated=[[[DYLUTLibrary alloc]initWithRootURL:[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"user-lut-library"]]]autorelease];
NSArray *items=[isolated importURLs:@[[NSURL fileURLWithPath:userLUT]] error:&error];
run.need(@"user-lut-isolated-import",items.count==1,@{@"error":reason(error)});
NSString *imported=items[0][@"path"];std::vector<float> userTable,userExpected;NSUInteger userSide=0,expectedSide=0;
run.record(@"user-lut-exact-canonical-table",DYLUTReadCube(imported,userTable,userSide,&error)&&DYLUTReadCube(userOracle,userExpected,expectedSide,&error)&&userSide==expectedSide&&userTable==userExpected,@{@"dimension":@(userSide),@"rows":@(userTable.size()/4)});
run.record(@"user-lut-thumbnail",DYLUTThumbnail(imported,nil,0,0,NSMakeSize(160,90),&error)!=nil);
Pixels actual=render(run,renderer,source,destination,gpu,u,@{@"look0":imported},@"user-lut-metal-render");
Pixels expected=render(run,renderer,source,destination,gpu,u,@{@"look0":userOracle},@"user-lut-oracle-metal-render");
Difference delta=difference(actual,expected);run.record(@"user-lut-metal-exact-canonical-colors",delta.nonfinite==0&&delta.maximum==0,measure(delta));
run.record(@"user-lut-original-and-import-bytes-preserved",original&&[original isEqual:[NSData dataWithContentsOfFile:userLUT]]&&[original isEqual:[NSData dataWithContentsOfFile:imported]]);
}
NSDictionary *paths=@{@"look0":lookFile,@"look1":lookFile,@"look2":lookFile,@"look3":lookFile,@"look4":lookFile};u=defaults;u.lookSectionEnabled=1;u.postLUTStrength=.35f;u.extraPostLUTStrengths=(DYFloat4){.4f,.5f,.6f,.7f};Pixels looks=render(run,renderer,source,destination,gpu,u,paths,@"renderer-five-look-pass");Difference looksDifference=difference(neutral,looks);run.record(@"five-look-mixes-affect-frame",looksDifference.nonfinite==0&&looksDifference.different>100,measure(looksDifference));
checkFoldedGroup(u,offsetof(DYUniforms,lookSectionEnabled),paths,@"disabled-look-bypasses-retained-LUTs");
NSURL *exportURL=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"diagnostic-export.cube"]];error=nil;run.need(@"renderer-export-33cube",[renderer exportLUT:exportURL uniforms:u paths:paths error:&error],@{@"error":reason(error),@"path":exportURL.path});
+24 -1
查看文件
@@ -146,6 +146,16 @@ static std::string_view DYLUTTrim(std::string_view v) {
if(!count)break;v.remove_prefix(count);
}return v;
}
static bool DYLUTTextNote(std::string_view text,locale_t numericLocale) {
if(text.empty())return false;
// A note must be separated from the preceding number and start with real
// text. Do not reinterpret malformed bytes or NaN/Inf as an annotation.
char *end=nullptr;strtof_l(text.data(),&end,numericLocale);
if(end!=text.data())return false;
NSString *note=[[[NSString alloc]initWithBytes:text.data() length:text.size()
encoding:NSUTF8StringEncoding]autorelease];
return note.length&&[NSCharacterSet.letterCharacterSet characterIsMember:[note characterAtIndex:0]];
}
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];
@@ -188,7 +198,20 @@ static BOOL DYLUTParse(NSString *path,std::vector<float>& data,NSUInteger& size,
} 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)||!trim(v).empty()||!std::isfinite(r)||!std::isfinite(g)||!std::isfinite(b))return DYLUTFail(error,[NSString stringWithFormat:@"LUT 第 %lu 行含无效数字或多余内容",(unsigned long)rows]);
auto v=line;float rgb[3]={0,0,0};bool valid=true;
for(int c=0;c<3;c++) {
auto token=trim(v);
if(!number(v,rgb[c])) {
// Custom LUT compatibility: retain the numeric prefix,
// zero unread channels, and keep this row's table position.
// Never search annotations for digits or skip a table row.
valid=c>0&&DYLUTTextNote(token,numericLocale);v={};break;
}
if(!std::isfinite(rgb[c])||(!v.empty()&&trim(v).size()==v.size())){valid=false;break;}
}
auto tail=trim(v);
if(!valid||(!tail.empty()&&!DYLUTTextNote(tail,numericLocale)))return DYLUTFail(error,[NSString stringWithFormat:@"LUT 第 %lu 行含无效数字或多余内容",(unsigned long)rows]);
r=rgb[0];g=rgb[1];b=rgb[2];
data.insert(data.end(),{r,g,b,1});if(data.size()>128*128*128*4)return DYLUTFail(error,@"LUT 数据过多");
}
}
+3 -3
查看文件
@@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.7.0</string>
<string>1.7.1</string>
<key>CFBundleVersion</key>
<string>45</string>
<string>46</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.0</string>
<string>1.7.1</string>
</dict>
<dict>
<key>className</key>
+2 -2
查看文件
@@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.7.0</string>
<string>1.7.1</string>
<key>CFBundleVersion</key>
<string>45</string>
<string>46</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>