From 8951725be233eff73627464fd78315b358d8fae4 Mon Sep 17 00:00:00 2001 From: mac Date: Sun, 1 Nov 2026 15:37:26 +0800 Subject: [PATCH] feat: decode UTF-16 and UTF-32 Cube LUTs without rewriting their bytes --- tools/create_lut_encoding_fixture.py | 40 + tools/verify_lut_encoding.mm | 56 ++ verification/LUTEncoding.json | 1043 +++++++++++++++++++++++ 大鱼调色/Plugin/DYInspector.mm | 2 +- 大鱼调色/Plugin/DYLUTLibrary.mm | 74 +- 大鱼调色/Plugin/Info.plist | 4 +- 大鱼调色/Wrapper Application/Info.plist | 4 +- 7 files changed, 1212 insertions(+), 11 deletions(-) create mode 100644 tools/create_lut_encoding_fixture.py create mode 100644 tools/verify_lut_encoding.mm create mode 100644 verification/LUTEncoding.json diff --git a/tools/create_lut_encoding_fixture.py b/tools/create_lut_encoding_fixture.py new file mode 100644 index 0000000..52ddff5 --- /dev/null +++ b/tools/create_lut_encoding_fixture.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +"""Rebuild synthetic encoding fixtures in the fixed product cache, never user LUTs.""" +from pathlib import Path +import hashlib +import json + +ROOT = Path.home() / "Library/Caches/CodexBuilds/com.dayu.color/fcp-qa/编码兼容验收" + + +def main(): + ROOT.mkdir(parents=True, exist_ok=True) + matrix = [("utf-8", False), ("utf-8", True)] + matrix += [(codec, bom) for codec in ("utf-16-le", "utf-16-be", "utf-32-le", "utf-32-be") for bom in (False, True)] + matrix += [(codec, False) for codec in ("gb18030", "big5", "shift_jis", "cp1252", "mac_roman", "iso8859-1")] + marks = {"utf-8": b"\xef\xbb\xbf", "utf-16-le": b"\xff\xfe", "utf-16-be": b"\xfe\xff", + "utf-32-le": b"\xff\xfe\0\0", "utf-32-be": b"\0\0\xfe\xff"} + previous = ROOT / "fixtures.json" + known = json.loads(previous.read_text())["files"] if previous.exists() else [] + known = {item["file"]: item["sha256"] for item in known} + rows = [] + for index, (codec, bom) in enumerate(matrix): + title = "Unicode 中文 🎬" if codec.startswith("utf-") else "中文標題" if codec in ("gb18030", "big5") else "日本語" if codec == "shift_jis" else "Café" + newline = ("\n", "\r\n", "\r")[index % 3] + name = codec.upper() + ("-BOM" if bom else "-NoBOM") + ".cube" + text = [f'TITLE "{title}"', '# Encoding compatibility fixture only', 'LUT_3D_SIZE 33', 'DOMAIN_MIN 0 0 0', 'DOMAIN_MAX 1 1 1'] + gain = .7 + .04 * index + text.extend(f"{x/32*gain:.7f} {y/32:.7f} {z/32:.7f}" for z in range(33) for y in range(33) for x in range(33)) + data = (marks[codec] if bom else b"") + (newline.join(text) + newline).encode(codec) + target = ROOT / name + if target.exists(): + assert hashlib.sha256(target.read_bytes()).hexdigest() == known.get(name), f"Existing fixture changed; preserve it: {target}" + target.write_bytes(data) + rows.append(dict(file=name, codec=codec, bom=bom, sha256=hashlib.sha256(data).hexdigest(), bytes=len(data), dimension=33)) + report = dict(synthetic=True, sourceFolder=str(ROOT), files=rows, count=len(rows), bytes=sum(x["bytes"] for x in rows)) + previous.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n") + print(json.dumps({k: v for k, v in report.items() if k != "files"}, ensure_ascii=False)) + + +if __name__ == "__main__": + main() diff --git a/tools/verify_lut_encoding.mm b/tools/verify_lut_encoding.mm new file mode 100644 index 0000000..5763628 --- /dev/null +++ b/tools/verify_lut_encoding.mm @@ -0,0 +1,56 @@ +#import +#import "../大鱼调色/Plugin/DYLUTLibrary.h" +#include + +static NSMutableArray *checks; +static void need(BOOL pass,NSString *name){[checks addObject:@{@"name":name,@"pass":@(pass)}];if(!pass){fprintf(stderr,"FAIL %s\n",name.UTF8String);exit(1);}} +static NSString *cube(NSUInteger n){ + NSMutableString *s=[NSMutableString stringWithString:@"# 中文 / 日本語 / café / 🎨\nTITLE \"Unicode 🎬\"\nLUT_3D_SIZE "];[s appendFormat:@"%lu\nDOMAIN_MIN 0 0 0\nDOMAIN_MAX 1 1 1\n",(unsigned long)n]; + for(NSUInteger z=0;z v;NSUInteger n=0;need(!DYLUTReadCube(url.path,v,n,&error)&&v.empty()&&n==0&&[error.localizedDescription containsString:@"编码损坏"],@"reject malformed Unicode without a lossy fallback");} + NSURL *invalid=[root URLByAppendingPathComponent:@"BadNumbers.cube"];need([encoded([base stringByAppendingString:@"NaN 0 0\n"],NSUTF32BigEndianStringEncoding,YES)writeToURL:invalid atomically:YES],@"write encoded invalid numbers");std::vector v;NSUInteger n=0;need(!DYLUTReadCube(invalid.path,v,n,&error)&&v.empty()&&n==0,@"Unicode decoding does not weaken numeric validation"); + // Cold large UTF-32 file exercises background conversion and cancellation. + NSURL *large=[valid URLByAppendingPathComponent:@"Large-UTF32BE.cube"];NSData *largeBytes=encoded(cube(65),NSUTF32BigEndianStringEncoding,YES);need([largeBytes writeToURL:large atomically:YES],@"write cold 65-cube UTF-32 fixture");originals[large.lastPathComponent]=largeBytes; + DYLUTLibrary *library=[[DYLUTLibrary alloc]initWithRootURL:[root URLByAppendingPathComponent:@"Library"]];__block BOOL done=NO;__block double last=NSProcessInfo.processInfo.systemUptime,gap=0;__block NSUInteger ticks=0,imported=0; + NSTimer *timer=[NSTimer scheduledTimerWithTimeInterval:.005 repeats:YES block:^(NSTimer *t){double now=NSProcessInfo.processInfo.systemUptime;gap=MAX(gap,now-last);last=now;ticks++;(void)library.entries;}]; + [library importURLsAsync:@[valid] completion:^(NSArray *items,NSError *failure){need(!failure,@"mixed encoding folder imports asynchronously");imported=items.count;done=YES;}];pump(^{return done;});[timer invalidate];need(imported==originals.count,@"all encoded files imported");need(ticks>0&&gap<.15,@"main loop remains responsive during Unicode conversion"); + for(NSDictionary *entry in library.entries)need([[NSData dataWithContentsOfFile:entry[@"path"]]isEqual:originals[[entry[@"path"]lastPathComponent]]],@"import preserves exact encoded bytes"); + NSURL *cancelURL=[root URLByAppendingPathComponent:@"Cancel-UTF32BE.cube"];need([largeBytes writeToURL:cancelURL atomically:YES],@"write uncached cancellation fixture");done=NO;NSProgress *task=DYLUTPrepareAsync(cancelURL.path,^(NSError *failure){need(failure.code==NSUserCancelledError,@"cancelled Unicode conversion reports cancellation");done=YES;});NSTimer *cancel=[NSTimer scheduledTimerWithTimeInterval:.001 repeats:NO block:^(NSTimer *t){[task cancel];}];pump(^{return done;});[cancel invalidate]; + NSDictionary *report=@{@"pass":@YES,@"checks":@(checks.count),@"results":checks,@"encodedImportFiles":@(imported),@"mainHeartbeatMaxGapMS":@(gap*1000),@"mainHeartbeatTicks":@(ticks),@"largeEncodedBytes":@(largeBytes.length),@"scope":@"Synthetic isolated UTF-8/16/32 LE/BE BOM/no-BOM, line endings, Unicode spacing, exact colors, corruption, async import and cancellation. No user files modified."}; + need([[NSJSONSerialization dataWithJSONObject:report options:NSJSONWritingPrettyPrinted error:nil]writeToFile:[NSString stringWithUTF8String:argv[1]] atomically:YES],@"write encoding report");[library release];need([fm removeItemAtURL:root error:nil],@"clean encoding fixtures");printf("PASS %lu checks, main gap %.3f ms\n",(unsigned long)checks.count,gap*1000);return 0; +}} diff --git a/verification/LUTEncoding.json b/verification/LUTEncoding.json new file mode 100644 index 0000000..c00a973 --- /dev/null +++ b/verification/LUTEncoding.json @@ -0,0 +1,1043 @@ +{ + "date": "2026-11-01T07:37:26.869189+00:00", + "status": "encoding-preflight-passed-formal-host-pending", + "version": "1.1.5", + "build": "16", + "baselineCommit": "6d48b653a571bcf9df9371072a32a42324c88368", + "supported": [ + "UTF-8 with or without BOM", + "UTF-16 LE/BE with or without BOM", + "UTF-32 LE/BE with or without BOM", + "ASCII-compatible legacy TITLE/comments; GB18030, Big5, Shift JIS, Windows-1252, MacRoman and ISO-8859-1 fixtures", + "LF, CRLF, CR; Unicode horizontal spacing; Unicode line separators in wide text" + ], + "behavior": [ + "Background cancellable in-memory Unicode conversion; never rewrite user source or imported bytes.", + "Infer BOM-less wide encodings from recognizable Cube prefix, never delete arbitrary NUL bytes.", + "Reject truncated code units, invalid surrogate pairs, invalid UTF-32 scalars and corrupt numeric rows without lossy fallback.", + "Binary dylut input and GPU math/model are unchanged." + ], + "encoding": { + "pass": true, + "checks": 179, + "mainHeartbeatMaxGapMS": 6.282333517447114, + "scope": "Synthetic isolated UTF-8/16/32 LE/BE BOM/no-BOM, line endings, Unicode spacing, exact colors, corruption, async import and cancellation. No user files modified.", + "results": [ + { + "name": "create isolated encoding fixtures", + "pass": true + }, + { + "name": "write independent UTF-8 baseline", + "pass": true + }, + { + "name": "baseline color result", + "pass": true + }, + { + "name": "Encoding-00.cube", + "pass": true + }, + { + "name": "Encoding-00.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-00.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-01.cube", + "pass": true + }, + { + "name": "Encoding-01.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-01.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-02.cube", + "pass": true + }, + { + "name": "Encoding-02.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-02.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-03.cube", + "pass": true + }, + { + "name": "Encoding-03.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-03.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-04.cube", + "pass": true + }, + { + "name": "Encoding-04.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-04.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-05.cube", + "pass": true + }, + { + "name": "Encoding-05.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-05.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-06.cube", + "pass": true + }, + { + "name": "Encoding-06.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-06.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-07.cube", + "pass": true + }, + { + "name": "Encoding-07.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-07.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-08.cube", + "pass": true + }, + { + "name": "Encoding-08.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-08.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-09.cube", + "pass": true + }, + { + "name": "Encoding-09.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-09.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-10.cube", + "pass": true + }, + { + "name": "Encoding-10.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-10.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-11.cube", + "pass": true + }, + { + "name": "Encoding-11.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-11.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-12.cube", + "pass": true + }, + { + "name": "Encoding-12.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-12.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-13.cube", + "pass": true + }, + { + "name": "Encoding-13.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-13.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-14.cube", + "pass": true + }, + { + "name": "Encoding-14.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-14.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-15.cube", + "pass": true + }, + { + "name": "Encoding-15.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-15.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-16.cube", + "pass": true + }, + { + "name": "Encoding-16.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-16.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-17.cube", + "pass": true + }, + { + "name": "Encoding-17.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-17.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-18.cube", + "pass": true + }, + { + "name": "Encoding-18.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-18.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-19.cube", + "pass": true + }, + { + "name": "Encoding-19.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-19.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-20.cube", + "pass": true + }, + { + "name": "Encoding-20.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-20.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-21.cube", + "pass": true + }, + { + "name": "Encoding-21.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-21.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-22.cube", + "pass": true + }, + { + "name": "Encoding-22.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-22.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-23.cube", + "pass": true + }, + { + "name": "Encoding-23.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-23.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-24.cube", + "pass": true + }, + { + "name": "Encoding-24.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-24.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-25.cube", + "pass": true + }, + { + "name": "Encoding-25.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-25.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-26.cube", + "pass": true + }, + { + "name": "Encoding-26.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-26.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-27.cube", + "pass": true + }, + { + "name": "Encoding-27.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-27.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-28.cube", + "pass": true + }, + { + "name": "Encoding-28.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-28.cube thumbnail", + "pass": true + }, + { + "name": "Encoding-29.cube", + "pass": true + }, + { + "name": "Encoding-29.cube exact numeric equivalence", + "pass": true + }, + { + "name": "Encoding-29.cube thumbnail", + "pass": true + }, + { + "name": "Spacing-4.cube", + "pass": true + }, + { + "name": "Spacing-4.cube nonbreaking spaces", + "pass": true + }, + { + "name": "Spacing-2483028224.cube", + "pass": true + }, + { + "name": "Spacing-2483028224.cube nonbreaking spaces", + "pass": true + }, + { + "name": "Spacing-2415919360.cube", + "pass": true + }, + { + "name": "Spacing-2415919360.cube nonbreaking spaces", + "pass": true + }, + { + "name": "Spacing-2617245952.cube", + "pass": true + }, + { + "name": "Spacing-2617245952.cube nonbreaking spaces", + "pass": true + }, + { + "name": "Spacing-2550137088.cube", + "pass": true + }, + { + "name": "Spacing-2550137088.cube nonbreaking spaces", + "pass": true + }, + { + "name": "UnicodeLines-2483028224.cube", + "pass": true + }, + { + "name": "UnicodeLines-2483028224.cube Unicode line separators", + "pass": true + }, + { + "name": "UnicodeLines-2415919360.cube", + "pass": true + }, + { + "name": "UnicodeLines-2415919360.cube Unicode line separators", + "pass": true + }, + { + "name": "UnicodeLines-2617245952.cube", + "pass": true + }, + { + "name": "UnicodeLines-2617245952.cube Unicode line separators", + "pass": true + }, + { + "name": "UnicodeLines-2550137088.cube", + "pass": true + }, + { + "name": "UnicodeLines-2550137088.cube Unicode line separators", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write malformed Unicode fixture", + "pass": true + }, + { + "name": "reject malformed Unicode without a lossy fallback", + "pass": true + }, + { + "name": "write encoded invalid numbers", + "pass": true + }, + { + "name": "Unicode decoding does not weaken numeric validation", + "pass": true + }, + { + "name": "write cold 65-cube UTF-32 fixture", + "pass": true + }, + { + "name": "mixed encoding folder imports asynchronously", + "pass": true + }, + { + "name": "asynchronous operation completes", + "pass": true + }, + { + "name": "all encoded files imported", + "pass": true + }, + { + "name": "main loop remains responsive during Unicode conversion", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "import preserves exact encoded bytes", + "pass": true + }, + { + "name": "write uncached cancellation fixture", + "pass": true + }, + { + "name": "cancelled Unicode conversion reports cancellation", + "pass": true + }, + { + "name": "asynchronous operation completes", + "pass": true + } + ], + "largeEncodedBytes": 54925360, + "encodedImportFiles": 40, + "mainHeartbeatTicks": 234 + }, + "library": { + "checks": 112, + "pass": true + }, + "mixedFixture": { + "importError": "", + "sourceFilesUnchanged": true, + "mainHeartbeatMaxGapMS": 5.948000121861696, + "userLibraryModified": false, + "importedContentsIdentical": true, + "mainHeartbeatTicks": 266, + "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": "BIG5-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "CP1252-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "GB18030-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "ISO8859-1-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "MAC_ROMAN-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "SHIFT_JIS-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-8-BOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-8-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-16-BE-BOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-16-BE-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-16-LE-BOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-16-LE-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-32-BE-BOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-32-BE-NoBOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-32-LE-BOM.cube", + "error": "", + "dimension": 33 + }, + { + "parsed": true, + "file": "UTF-32-LE-NoBOM.cube", + "error": "", + "dimension": 33 + } + ], + "sourceFolder": "/Users/mac/Library/Caches/CodexBuilds/com.dayu.color/fcp-qa/编码兼容验收", + "pass": true, + "importedFiles": 16, + "sourceFiles": 16, + "appleDoubleSidecars": 0, + "plannedFiles": 16 + }, + "n12Regression": { + "importError": "", + "sourceFilesUnchanged": true, + "mainHeartbeatMaxGapMS": 6.252833176404238, + "userLibraryModified": false, + "importedContentsIdentical": true, + "mainHeartbeatTicks": 1701, + "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 + }, + "limitations": [ + "No claim of support for every historical charset or a non-Cube/binary LUT format.", + "Live FCP acceptance and final installed GPU checks remain pending." + ] +} diff --git a/大鱼调色/Plugin/DYInspector.mm b/大鱼调色/Plugin/DYInspector.mm index 5591f16..603d54e 100644 --- a/大鱼调色/Plugin/DYInspector.mm +++ b/大鱼调色/Plugin/DYInspector.mm @@ -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.4",9) retain]; _subtitle.textColor=DYThemeColor(@"secondary"); + _subtitle=[DYLabel([[NSBundle bundleForClass:self.class]objectForInfoDictionaryKey:@"CFBundleShortVersionString"]?:@"1.1.5",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]; diff --git a/大鱼调色/Plugin/DYLUTLibrary.mm b/大鱼调色/Plugin/DYLUTLibrary.mm index 7e494e4..8430848 100644 --- a/大鱼调色/Plugin/DYLUTLibrary.mm +++ b/大鱼调色/Plugin/DYLUTLibrary.mm @@ -81,6 +81,71 @@ static NSError *DYLUTFileError(NSError *error,NSURL *url) { info[NSFilePathErrorKey]=url.path;if(error)info[NSUnderlyingErrorKey]=error; return [NSError errorWithDomain:error.domain?:DYLUTLibraryErrorDomain code:error?error.code:1 userInfo:info]; } +static bool DYLUTUnicodeSpace(uint32_t c) { + return c==0x20||(c>=9&&c<=13)||c==0x85||c==0xa0||c==0x1680|| + (c>=0x2000&&c<=0x200a)||c==0x2028||c==0x2029||c==0x202f||c==0x205f||c==0x3000; +} +static void DYLUTAppendScalar(std::string& text,uint32_t c) { + if(DYLUTUnicodeSpace(c)) { + text+=char(c==13?'\r':c==10||c==0x85||c==0x2028||c==0x2029?'\n':' ');return; + } + if(c<0x80)text+=char(c); + else if(c<0x800){text+=char(0xc0|(c>>6));text+=char(0x80|(c&63));} + else if(c<0x10000){text+=char(0xe0|(c>>12));text+=char(0x80|((c>>6)&63));text+=char(0x80|(c&63));} + else {text+=char(0xf0|(c>>18));text+=char(0x80|((c>>12)&63));text+=char(0x80|((c>>6)&63));text+=char(0x80|(c&63));} +} +// Normalize only the working copy. Imports retain their original bytes. Narrow +// files remain byte-transparent so legacy TITLE/comment encodings still work. +static BOOL DYLUTText(NSData *bytes,std::string& text,NSProgress *progress,NSError **error) { + const uint8_t *p=(const uint8_t *)bytes.bytes;size_t length=bytes.length,offset=0,width=1;bool little=true; + if(!length)return DYLUTFail(error,@"LUT 文件为空"); + auto unit=[&](size_t at,size_t w,bool le){uint32_t c=0;for(size_t k=0;k=4&&unit(0,4,true)==0x0000feff){width=4;offset=4;} + else if(length>=4&&unit(0,4,false)==0x0000feff){width=4;offset=4;little=false;} + else if(length>=2&&unit(0,2,true)==0xfeff){width=2;offset=2;} + else if(length>=2&&unit(0,2,false)==0xfeff){width=2;offset=2;little=false;} + else if(length>=3&&!memcmp(p,"\xef\xbb\xbf",3))offset=3; + else { + // Without a BOM, infer byte order only from a recognizable Cube prefix. + // Never remove arbitrary NUL bytes or guess an encoding from the title. + auto prefix=[&](size_t w,bool le){bool whitespace=false; + for(size_t at=0;at+w<=length&&at<128;at+=w){uint32_t c=unit(at,w,le); + if(DYLUTUnicodeSpace(c)||c==0xfeff){whitespace=true;continue;} + return c=='#'||(c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||c=='+'||c=='-'||c=='.'; + }return whitespace; + }; + for(size_t w:{size_t(4),size_t(2)}) { + if(prefix(w,true)){width=w;break;} + if(prefix(w,false)){width=w;little=false;break;} + } + } + if(width==1){text.assign((const char *)p+offset,length-offset);return !DYLUTCancelled(progress,error);} + NSString *encoding=[NSString stringWithFormat:@"UTF-%lu%@",(unsigned long)(width*8),little?@"LE":@"BE"]; + auto invalid=[&](NSString *detail){return DYLUTFail(error,[NSString stringWithFormat:@"%@ 编码损坏:%@",encoding,detail]);}; + if((length-offset)%width)return invalid(@"文件结尾不完整"); + text.clear();text.reserve((length-offset)/width); + size_t nextCancellationCheck=offset; + for(size_t at=offset;at=nextCancellationCheck){if(DYLUTCancelled(progress,error))return NO;nextCancellationCheck=at+16384;} + uint32_t c=unit(at,width,little); + if(width==2&&c>=0xd800&&c<=0xdbff){ + if(at+4>length)return invalid(@"缺少配对字符");uint32_t next=unit(at+2,2,little); + if(next<0xdc00||next>0xdfff)return invalid(@"字符配对无效");c=0x10000+((c-0xd800)<<10)+(next-0xdc00);at+=2; + }else if(c>=0xd800&&c<=0xdfff)return invalid(@"孤立的配对字符"); + if(c>0x10ffff||c==0)return invalid(@"含无效字符"); + DYLUTAppendScalar(text,c); + } + return !DYLUTCancelled(progress,error); +} +static std::string_view DYLUTTrim(std::string_view v) { + while(!v.empty()) { + unsigned char c=v.front();size_t count=0; + if(c==' '||(c>=9&&c<=13))count=1; + else if(v.size()>=2&&v.substr(0,2)=="\xc2\xa0")count=2; + else if(v.size()>=3&&(v.substr(0,3)=="\xe1\x9a\x80"||v.substr(0,3)=="\xe2\x80\xaf"||v.substr(0,3)=="\xe2\x81\x9f"||v.substr(0,3)=="\xe3\x80\x80"||(v.substr(0,2)=="\xe2\x80"&&(unsigned char)v[2]>=0x80&&(unsigned char)v[2]<=0x8a)))count=3; + if(!count)break;v.remove_prefix(count); + }return v; +} static BOOL DYLUTParse(NSString *path,std::vector& data,NSUInteger& size,NSProgress *progress,NSError **error) { data.clear();size=0; NSDictionary *attributes=[[NSFileManager defaultManager]attributesOfItemAtPath:path error:error]; @@ -99,20 +164,17 @@ static BOOL DYLUTParse(NSString *path,std::vector& data,NSUInteger& size, for(float v:data)if(!std::isfinite(v))return DYLUTFail(error,@"输入 LUT 含无效数字"); size=n;return YES; } - // 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); + std::string storage;if(!DYLUTText(bytes,storage,progress,error))return NO; 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; std::string_view remaining(storage);NSUInteger rows=0; if(remaining.size()>=3&&remaining.substr(0,3)=="\xef\xbb\xbf")remaining.remove_prefix(3); - auto trim=[](std::string_view v){while(!v.empty()&&(v.front()==' '||v.front()=='\t'||v.front()=='\r'))v.remove_prefix(1);return v;}; + auto trim=DYLUTTrim; auto number=[&](std::string_view& v,float& value){v=trim(v);if(v.empty())return false;char *end=nullptr;value=strtof_l(v.data(),&end,numericLocale);if(end==v.data()||end>v.data()+v.size())return false;v.remove_prefix(end-v.data());return true;}; while(!remaining.empty()) { if((rows++&1023)==0&&DYLUTCancelled(progress,error))return NO; size_t end=remaining.find_first_of("\r\n");std::string_view line=remaining.substr(0,end); - if(end==std::string_view::npos)remaining={};else remaining.remove_prefix(end+1); + if(end==std::string_view::npos)remaining={};else {size_t count=end+1;if(remaining[end]=='\r'&&countCFBundlePackageType XPC! CFBundleShortVersionString - 1.1.4 + 1.1.5 CFBundleVersion - 15 + 16 NSHumanReadableCopyright PlugInKit diff --git a/大鱼调色/Wrapper Application/Info.plist b/大鱼调色/Wrapper Application/Info.plist index 5fdf45b..bb26ccb 100644 --- a/大鱼调色/Wrapper Application/Info.plist +++ b/大鱼调色/Wrapper Application/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1.4 + 1.1.5 CFBundleVersion - 15 + 16 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright