WIP verify eight print-look resources and append compatible controls
这个提交包含在:
1 父节点
e7fa8e6cf5
当前提交
7d895750cf
18 个文件已更改
+248
-7
没有与搜索条件相匹配的文件
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Import the eight identity-verified local LMT tables into standalone Dayu data.
|
||||
|
||||
Run inspect_colorfinale_print --export first. Independent half decoding must
|
||||
match every float returned by the installed reference's own cubeData property.
|
||||
No vendor executable or shader is copied into the product.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import array
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
import struct
|
||||
import zlib
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
REFERENCE = Path('/Applications/ColorFinale.app/Contents/PlugIns/ColorFinale.pluginkit/Contents/Frameworks/RenderingEngine.framework/Versions/A')
|
||||
IDENTITY = '32dca93459347e5ad363cb145d0ccf84b933b2045eee2c9535676a01744b84e3'
|
||||
NAMES = ['kodak_2383', 'kodak_2393', 'kodak_2302_bw', 'fuji_3510', 'fuji_3513', 'fuji_3519', 'fuji_3521', 'agfa_cp30']
|
||||
|
||||
|
||||
def digest(data):
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--reference-export', required=True, type=Path)
|
||||
args = parser.parse_args()
|
||||
assert digest((REFERENCE / 'RenderingEngine').read_bytes()) == IDENTITY, 'Reference identity changed'
|
||||
output = ROOT / '\u5927\u9c7c\u8c03\u8272/Plugin/Resources/PrintLooks'
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
records = []
|
||||
for number, name in enumerate(NAMES, 1):
|
||||
source = (REFERENCE / 'Resources' / (name + '.lmt')).read_bytes()
|
||||
# Observed local resource format: repeated SHA256 mask, RGB binary16,
|
||||
# 65 cubed, red axis fastest. The literal prefix is exactly 23 bytes.
|
||||
mask = hashlib.sha256(b'FT.ColorFinale.LMT.2026' + name.encode()).digest()
|
||||
half = bytes(value ^ mask[index % 32] for index, value in enumerate(source))
|
||||
assert len(half) == 65**3 * 6
|
||||
floats = array.array('f')
|
||||
for pixel in struct.iter_unpack('<eee', half):
|
||||
assert all(math.isfinite(value) for value in pixel)
|
||||
floats.extend((*pixel, 1.0))
|
||||
if struct.pack('=I', 1) != struct.pack('<I', 1):
|
||||
floats.byteswap()
|
||||
raw = floats.tobytes()
|
||||
assert raw == (args.reference_export / (name + '.rgba32f')).read_bytes(), name + ': native cubeData mismatch'
|
||||
blob = struct.pack('<4sII6f', b'DYLT', 65, len(raw), 0, 0, 0, 1, 1, 1) + zlib.compress(raw, 9)
|
||||
destination = output / (name + '.dylut')
|
||||
destination.write_bytes(blob)
|
||||
records.append(dict(index=number, name=name, side=65, sourceSHA256=digest(source), rgba32SHA256=digest(raw),
|
||||
bytes=len(blob), sha256=digest(blob), resource=str(destination.relative_to(ROOT)),
|
||||
nativeCubeDataByteIdentical=True))
|
||||
manifest = dict(referenceVersion='2.16.2 (625)', referenceSHA256=IDENTITY, tables=records,
|
||||
cubeOrder='red fastest; green; blue', interpolation='tetrahedral (six cases)',
|
||||
sourceRole='data only; no reference executable or shader shipped')
|
||||
(ROOT / 'research/PrintLooksResources.json').write_text(json.dumps(manifest, indent=2) + '\n')
|
||||
print(json.dumps(dict(tables=len(records), bytes=sum(item['bytes'] for item in records), nativeCubeDataByteIdentical=True)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,48 @@
|
||||
// Read-only reference metadata probe; never linked into the product.
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreImage/CoreImage.h>
|
||||
#import <objc/runtime.h>
|
||||
#import <objc/message.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
int main(int argc,const char **argv){@autoreleasepool{
|
||||
NSString *path=@"/Applications/ColorFinale.app/Contents/PlugIns/ColorFinale.pluginkit/Contents/Frameworks/RenderingEngine.framework/Versions/A/RenderingEngine";
|
||||
if(!dlopen(path.fileSystemRepresentation,RTLD_NOW|RTLD_LOCAL)){fprintf(stderr,"%s\n",dlerror());return 1;}
|
||||
NSMutableDictionary *out=[NSMutableDictionary dictionary];
|
||||
if(argc==2&&strcmp(argv[1],"--matrix")==0){
|
||||
Class space=NSClassFromString(@"FTColorSpace");id from=((id(*)(id,SEL))objc_msgSend)((id)space,sel_registerName("Rec709Linear"));id to=((id(*)(id,SEL))objc_msgSend)((id)space,sel_registerName("ACEScg"));
|
||||
CIContext *context=[CIContext contextWithOptions:@{kCIContextWorkingColorSpace:NSNull.null,kCIContextOutputColorSpace:NSNull.null}];
|
||||
float input[16]={1,0,0,1,0,1,0,1,0,0,1,1,1,1,1,1};
|
||||
for(int direction=0;direction<2;direction++){
|
||||
CIFilter *f=((id(*)(id,SEL,id,id))objc_msgSend)((id)NSClassFromString(@"FTColorSpaceFilter"),sel_registerName("filterFromColorSpace:toColorSpace:"),direction?to:from,direction?from:to);
|
||||
if(!f)return 5;[f setValue:[CIImage imageWithBitmapData:[NSData dataWithBytes:input length:sizeof(input)] bytesPerRow:sizeof(input) size:CGSizeMake(4,1) format:kCIFormatRGBAf colorSpace:nil]forKey:kCIInputImageKey];float result[16]={};[context render:f.outputImage toBitmap:result rowBytes:sizeof(result) bounds:CGRectMake(0,0,4,1) format:kCIFormatRGBAf colorSpace:nil];
|
||||
NSMutableArray *values=[NSMutableArray array];for(int i=0;i<16;i++)[values addObject:@(result[i])];out[direction?@"AP1-to-709":@"709-to-AP1"]=values;
|
||||
}
|
||||
NSData *json=[NSJSONSerialization dataWithJSONObject:out options:NSJSONWritingPrettyPrinted error:nil];fwrite(json.bytes,1,json.length,stdout);return 0;
|
||||
}
|
||||
if(argc==3&&strcmp(argv[1],"--export")==0){
|
||||
NSString *directory=@(argv[2]);[[NSFileManager defaultManager]createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
NSMutableArray *exports=[NSMutableArray array];
|
||||
for(NSString *name in @[@"kodak_2383",@"kodak_2393",@"kodak_2302_bw",@"fuji_3510",@"fuji_3513",@"fuji_3519",@"fuji_3521",@"agfa_cp30"]){
|
||||
id filter=((id(*)(id,SEL,id))objc_msgSend)((id)NSClassFromString(@"FTAcesLMTFilter"),sel_registerName("filterWithLMT:"),name);
|
||||
NSData *data=[filter valueForKey:@"cubeData"];if(data.length!=65*65*65*16)return 3;
|
||||
NSString *destination=[directory stringByAppendingPathComponent:[name stringByAppendingString:@".rgba32f"]];
|
||||
if(![data writeToFile:destination atomically:YES])return 4;
|
||||
[exports addObject:@{@"name":name,@"bytes":@(data.length),@"path":destination}];
|
||||
}
|
||||
NSData *json=[NSJSONSerialization dataWithJSONObject:exports options:NSJSONWritingPrettyPrinted error:nil];fwrite(json.bytes,1,json.length,stdout);return 0;
|
||||
}
|
||||
for(NSString *name in @[@"FTAcesLMTFilter",@"FTLMTCIImageProcessor",@"FTCubeProcessor",@"FTCubeCIImageProcessor",@"FTColorCubeFilter",@"FTAcesTypes",@"FTColorSpace"]){
|
||||
Class cls=NSClassFromString(name);if(!cls)continue;
|
||||
NSMutableDictionary *entry=[NSMutableDictionary dictionary];
|
||||
for(int meta=0;meta<2;meta++){
|
||||
unsigned count=0;Method *methods=class_copyMethodList(meta?object_getClass(cls):cls,&count);NSMutableArray *list=[NSMutableArray array];
|
||||
for(unsigned i=0;i<count;i++)[list addObject:@{@"selector":NSStringFromSelector(method_getName(methods[i])),@"encoding":@(method_getTypeEncoding(methods[i]))}];free(methods);entry[meta?@"class":@"instance"]=list;
|
||||
}
|
||||
unsigned n=0;Ivar *ivars=class_copyIvarList(cls,&n);NSMutableArray *ivs=[NSMutableArray array];
|
||||
for(unsigned i=0;i<n;i++)[ivs addObject:@{@"name":@(ivar_getName(ivars[i])),@"type":@(ivar_getTypeEncoding(ivars[i])),@"offset":@(ivar_getOffset(ivars[i]))}];free(ivars);entry[@"ivars"]=ivs;
|
||||
out[name]=entry;
|
||||
}
|
||||
NSData *json=[NSJSONSerialization dataWithJSONObject:out options:NSJSONWritingPrettyPrinted|NSJSONWritingSortedKeys error:nil];
|
||||
if(!json)return 2;fwrite(json.bytes,1,json.length,stdout);fputc('\n',stdout);return 0;
|
||||
}}
|
||||
在新工单中引用
屏蔽一个用户