Fix primary CST working domains and delayed output; 581 checks pass; seed new effects explicitly
这个提交包含在:
1 父节点
d5aba63b4e
当前提交
072bf881b9
16 个文件已更改
+452
-22
没有与搜索条件相匹配的文件
@@ -22,6 +22,7 @@
|
||||
// must be the same as correcting the root before its one final display map.
|
||||
NSMutableDictionary *one=DYMutablePlist(empty.document),*node=(id)DYInsertTool(one,@"primary",@"base:primary");DYSeedPrimaryWorkingSpace(node,10,16);node[@"values"][@"cmexposure"]=@(-4);DYUniforms reduced=u;reduced.cm.exposure=-4;Pixels beforeOutput=renderPrimary(reduced,empty.document,@"primary-four-stop-root-before-output"),extra=renderPrimary(u,one,@"primary-four-stop-extra-before-output");Difference order=difference(beforeOutput,extra);run.record(@"primary-independent-grade-before-main-output",order.maximum<.002&&order.nonfinite==0,measure(order));
|
||||
auto reducedScene=scene;for(auto &p:reducedScene){p.r/=16;p.g/=16;p.b/=16;}Pixels reducedInput=sceneInput(reducedScene);upload(reducedInput);Pixels knownReduced=renderPrimary(u,empty.document,@"primary-independent-OCIO-reduced-scene-input");Difference high=difference(beforeOutput,knownReduced);run.record(@"primary-highlights-recovered-before-mapping-reference",high.maximum<.008&&high.nonfinite==0,@{@"maxDifference":@(high.maximum),@"scene64afterMinus4":@((float)beforeOutput[7*4]),@"independentReference":@((float)knownReduced[7*4])});upload(logInput);
|
||||
NSMutableArray *patches=[NSMutableArray array];for(int k=0;k<8;k++){size_t i=k*5;float a=logInput[i*4+3];[patches addObject:@{@"index":@(i),@"code":@[@(encodeCarrier((float)logInput[i*4]/a)),@(encodeCarrier((float)logInput[i*4+1]/a)),@(encodeCarrier((float)logInput[i*4+2]/a))],@"expectedMinus4Linear709":@[@((float)beforeOutput[i*4]/a),@((float)beforeOutput[i*4+1]/a),@((float)beforeOutput[i*4+2]/a)]}];}NSData *fixture=[NSJSONSerialization dataWithJSONObject:@{@"patches":patches,@"input":@"Sony S-Log3 / S-Gamut3.Cine code carrier",@"exposure":@(-4)} options:NSJSONWritingPrettyPrinted error:nil];[fixture writeToFile:[runtime stringByAppendingPathComponent:@"primary-host-chart.json"] atomically:YES];
|
||||
// Local working curves are read from the node, including BASIS adapters.
|
||||
node[@"values"][@"cmexposure"]=@0;node[@"values"][@"cmcontrast"]=@.3;Pixels localDI=renderPrimary(u,one,@"primary-local-DI-contrast");node[@"values"][@"cmworkingTransfer"]=@1;node[@"values"][@"cmworkingGamut"]=@2;Pixels localACES=renderPrimary(u,one,@"primary-local-ACES-contrast");run.record(@"primary-local-working-selection-is-effective",difference(localDI,localACES).maximum>.001);
|
||||
node[@"values"][@"cminputTransfer"]=@1;node[@"values"][@"cminputGamut"]=@2;Pixels reinterpret=renderPrimary(u,one,@"primary-local-input-CST-selection");run.record(@"primary-local-input-CST-is-not-overridden",difference(reinterpret,localACES).maximum>.01);
|
||||
@@ -38,7 +39,8 @@
|
||||
DYUniforms invalid=data;invalid.hslHueA.x=20;NSError *e=nil;BOOL bounded=[primaryRenderer renderSource:source destination:destination uniforms:invalid paths:@{} spider:nil tools:empty.document colorManagement:v3 hostPrimaries:kFxColorPrimaries_Rec709 error:&e];run.record(@"primary-Log-data-output-rejects-SDR-finishing",!bounded&&e.localizedDescription.length>0);
|
||||
DYUniforms bypass=u;bypass.primarySectionEnabled=0;bypass.hslHueA.x=20;Pixels bypassFrame=renderPrimary(bypass,empty.document,@"primary-main-eye-keeps-other-tools");Pixels oldBypass=render(run,primaryRenderer,source,destination,gpu,bypass,@{},@"primary-eye-unmanaged-reference");run.record(@"primary-main-eye-bypasses-whole-CST-retains-tools",difference(bypassFrame,oldBypass).maximum==0);
|
||||
// Float domain crossings retain negative values, overrange and hidden RGB.
|
||||
DYUniforms linear=u;linear.cm.inputTransfer=linear.cm.workingTransfer=linear.cm.outputTransfer=20;linear.cm.inputGamut=linear.cm.workingGamut=linear.cm.outputGamut=2;linear.cm.toneMapping=0;Pixels extended(width*height*4);for(size_t i=0;i<width*height;i++){float a=i%4?.25f:0;extended[i*4]=a?decodeCarrier(-.03f)*a:.07f;extended[i*4+1]=a?decodeCarrier(.18f)*a:-.02f;extended[i*4+2]=a?decodeCarrier(4.f)*a:.5f;extended[i*4+3]=a;}upload(extended);Pixels exact=renderPrimary(linear,empty.document,@"primary-negative-superwhite-hidden-RGB");run.record(@"primary-float-domain-identity-retains-extended-values",difference(extended,exact).maximum<.002&&difference(extended,exact).nonfinite==0,measure(difference(extended,exact)));linear.cm.exposure=1;Pixels doubled=renderPrimary(linear,empty.document,@"primary-linear-exposure-extended-values");BOOL photometric=YES;for(size_t i=1;i<width*height;i++)if(extended[i*4+3]>0){float a=extended[i*4+3];photometric&=fabs(encodeCarrier((float)doubled[i*4+1]/a)-.36f)<.002&&fabs(encodeCarrier((float)doubled[i*4]/a)+.06f)<.002;}run.record(@"primary-one-stop-exposure-is-linear-light-with-negative-values",photometric);upload(logInput);
|
||||
DYUniforms linear=u;linear.cm.inputTransfer=linear.cm.workingTransfer=linear.cm.outputTransfer=20;linear.cm.inputGamut=linear.cm.workingGamut=linear.cm.outputGamut=2;linear.cm.toneMapping=0;Pixels extended(width*height*4);for(size_t i=0;i<width*height;i++){float a=i%4?.25f:0;extended[i*4]=a?decodeCarrier(-.03f)*a:.07f;extended[i*4+1]=a?decodeCarrier(.18f)*a:-.02f;extended[i*4+2]=a?decodeCarrier(4.f)*a:.5f;extended[i*4+3]=a;}upload(extended);Pixels exact=renderPrimary(linear,empty.document,@"primary-negative-superwhite-hidden-RGB");run.record(@"primary-float-domain-identity-retains-extended-values",difference(extended,exact).maximum<.002&&difference(extended,exact).nonfinite==0,measure(difference(extended,exact)));linear.cm.exposure=1;Pixels doubled=renderPrimary(linear,empty.document,@"primary-linear-exposure-extended-values");BOOL photometric=YES;for(size_t i=1;i<width*height;i++)if(extended[i*4+3]>0){float a=extended[i*4+3];photometric&=fabs(encodeCarrier((float)doubled[i*4+1]/a)-.36f)<.002&&fabs(encodeCarrier((float)doubled[i*4]/a)+.06f)<.002;}run.record(@"primary-one-stop-exposure-is-linear-light-with-negative-values",photometric,@{@"negative":@(encodeCarrier((float)doubled[4]/.25f)),@"grey":@(encodeCarrier((float)doubled[5]/.25f))});upload(logInput);
|
||||
DYUniforms idle=logOut;idle.texture=25;idle.textureEnabled=0;idle.postLUTStrength=0;idle.extraPostLUTStrengths[0]=.8;idle.extraLookSectionEnableds[0]=0;e=nil;BOOL idleOK=[primaryRenderer renderSource:source destination:destination uniforms:idle paths:@{@"look0":@"/nonexistent/disabled.cube",@"look1":@"/nonexistent/disabled2.cube"} spider:nil tools:empty.document colorManagement:v3 hostPrimaries:kFxColorPrimaries_Rec709 error:&e];run.record(@"primary-data-output-ignores-disabled-SDR-and-LUT-controls",idleOK&&difference(read(destination,gpu),selectedOutput).maximum==0,@{@"error":reason(e)});
|
||||
// Actual inspector must expose all three sets of selectors in V3.
|
||||
DYDiagnosticManager *host=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(host,nil);DYAssetState *assets=[[[DYAssetState alloc]init]autorelease];assets.colorManagement=v3;DYWriteAssets(host,assets,kCMTimeZero);DYInspector *view=[[[DYInspector alloc]initWithAPIManager:host renderer:primaryRenderer]autorelease];[view refresh];[view setFrame:NSMakeRect(0,0,400,780)];[view layoutSubtreeIfNeeded];NSDictionary *tabs=[view valueForKey:@"tabs"];run.record(@"primary-inspector-no-v2-selector-override",![tabs[@"managedColor"]boolValue]&&[tabs[@"primaryCMS"]boolValue]);NSMenuItem *add=[[[NSMenuItem alloc]init]autorelease];add.representedObject=@"primary";[view addModule:add];NSDictionary *added=[DYReadTools(host,kCMTimeZero).document[@"layers"]lastObject];run.record(@"primary-inspector-add-layer-inherits-workspace",[added[@"values"][@"cminputTransfer"]isEqual:@10]&&[added[@"values"][@"cmoutputGamut"]isEqual:@16]&&[added[@"values"][@"cmtoneMapping"]isEqual:@0]);NSMutableDictionary *followed=DYMutablePlist(DYReadTools(host,kCMTimeZero).document);DYFollowPrimaryWorkingSpace(followed,1,2);NSDictionary *following=[followed[@"layers"]lastObject];run.record(@"primary-workspace-change-updates-inherited-domains",[following[@"values"][@"cminputTransfer"]isEqual:@1]&&[following[@"values"][@"cmworkingGamut"]isEqual:@2]&&[following[@"values"][@"cmoutputTransfer"]isEqual:@1]);DYWriteTools(host,followed,kCMTimeZero);DYToolManager *local=[[[DYToolManager alloc]initWithHost:host node:following]autorelease];UInt32 workingID=0;for(NSDictionary*d in DYDescriptors())if([d[@"key"]isEqual:@"cmworkingTransfer"])workingID=[d[@"pid"]unsignedIntValue];id<FxCustomParameterActionAPI_v4>action=[local apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[action startAction:nil];[(id<FxParameterSettingAPI_v6>)local setFloatValue:10 toParameter:workingID atTime:kCMTimeZero];[action endAction:nil];followed=DYMutablePlist(DYReadTools(host,kCMTimeZero).document);DYFollowPrimaryWorkingSpace(followed,4,4);following=[followed[@"layers"]lastObject];run.record(@"primary-manual-local-space-retains-choice-and-follows-boundaries",[following[@"values"][@"cmworkingTransfer"]isEqual:@10]&&[following[@"values"][@"cminputTransfer"]isEqual:@4]&&[following[@"values"][@"cmoutputGamut"]isEqual:@4]&&[following[@"primaryFollow"]isEqual:@5]);NSDictionary *preset=[view presetSnapshot];run.record(@"primary-complete-preset-stores-v3-state",[preset[@"colorManagement"]isEqual:v3]&&[preset[@"version"]isEqual:@7]);
|
||||
NSURL *cube=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"primary-v3.cube"]];e=nil;BOOL exported=[primaryRenderer exportLUT:cube uniforms:logOut paths:@{} spider:nil tools:empty.document colorManagement:v3 error:&e];std::vector<float>table;NSUInteger side=0;BOOL parsed=exported&&DYLUTReadCube(cube.path,table,side,&e);run.record(@"primary-v3-Cube65-declared-encoding",parsed&&side==65&&[[NSString stringWithContentsOfURL:cube encoding:NSUTF8StringEncoding error:nil]containsString:@"V3 input"],@{@"error":reason(e)});
|
||||
|
||||
@@ -6,7 +6,7 @@ kernel void dyPrimaryCST(texture2d<float,access::read> a [[texture(0)]],texture2
|
||||
if(any(xy>=uint2(b.get_width(),b.get_height())))return;float4 c=a.read(xy);if(c.a>0)c.rgb=cst_float_air(float4(c.rgb/c.a,1),p).rgb*c.a;b.write(c,xy);
|
||||
}
|
||||
kernel void dyPrimaryGrade(texture2d<float,access::read> a [[texture(0)]],texture2d<float,access::write> b [[texture(1)]],constant DayuRenderParams& p [[buffer(0)]],constant CSTParams& back [[buffer(1)]],uint2 xy [[thread_position_in_grid]]){
|
||||
if(any(xy>=uint2(b.get_width(),b.get_height())))return;float4 c=a.read(xy);if(c.a>0){float4 v=float4(c.rgb/c.a,1);if(p.stages&1)v=cst_float_air(v,p.input);if(p.stages&2){if(p.reserved&8)v=cst_float_air(v,p.basisInput);v=basis_float_air(v,p.basis);if(p.reserved&8)v=cst_float_air(v,p.basisOutput);}if(p.stages&4)v=cst_float_air(v,p.output);v=cst_float_air(v,back);c.rgb=v.rgb*c.a;}b.write(c,xy);
|
||||
if(any(xy>=uint2(b.get_width(),b.get_height())))return;float4 c=a.read(xy);if(c.a>0){float4 v=float4(c.rgb/c.a,1);if(p.stages&1)v=cst_float_air(v,p.input);if(p.stages&2){if(p.reserved&8)v=cst_float_air(v,p.basisInput);v=basis_float_air(v,p.basis);if(p.reserved&8)v=cst_float_air(v,p.basisOutput);}if(p.stages&4)v=cst_float_air(v,p.output);if(back.inputTransfer!=back.outputTransfer||back.inputGamut!=back.outputGamut||back.toneMapping)v=cst_float_air(v,back);c.rgb=v.rgb*c.a;}b.write(c,xy);
|
||||
}
|
||||
kernel void dyPrimaryBlend(texture2d<float,access::read> before [[texture(0)]],texture2d<float,access::read> after [[texture(1)]],texture2d<float,access::write> output [[texture(2)]],device const DYToolMaskEntry* masks [[buffer(0)]],constant DYToolMaskHeader& h [[buffer(1)]],constant DYCSTMixParams& p [[buffer(2)]],uint2 xy [[thread_position_in_grid]]){
|
||||
if(any(xy>=uint2(output.get_width(),output.get_height())))return;float4 a=before.read(xy),b=after.read(xy);if(!(a.a>0)||!(b.a>0)){output.write(a,xy);return;}float3 ac=cst_float_air(float4(a.rgb/a.a,1),p.toLinear).rgb,bc=cst_float_air(float4(b.rgb/b.a,1),p.toLinear).rgb;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
if(u.primarySectionEnabled<.5||DYBaseToolRemoved(tools,@"primary"))return [self renderSource:src destination:dst uniforms:u paths:paths spider:spider tools:tools error:error];
|
||||
NSMutableDictionary*entry=[self device:dst.deviceRegistryID error:error];if(!entry)return NO;id<MTLDevice>d=entry[@"device"];id<MTLTexture>source=[src metalTextureForDevice:d];if(!source)return fail(error,@"一级 CST 输入纹理不可用。");
|
||||
uint64_t pixels=uint64_t(source.width)*source.height;if(!pixels||pixels>64ull*1024*1024||pixels*16*8>MAX(768ull*1024*1024,MIN(2ull*1024*1024*1024,d.recommendedMaxWorkingSetSize/2)))return fail(error,@"当前画面超过一级 CST 内存预算。");
|
||||
DYApplyRemovedBaseTools(&u,tools);BOOL root=u.primarySectionEnabled>.5;int wt=lroundf(u.cm.workingTransfer),wg=lroundf(u.cm.workingGamut);
|
||||
DYApplyRemovedBaseTools(&u,tools);BOOL root=u.primarySectionEnabled>.5;BOOL transparent=identityCM(u)&&!DYFilmPrintActive(u);int wt=lroundf(u.cm.workingTransfer),wg=lroundf(u.cm.workingGamut);
|
||||
NSMutableArray*pool=[NSMutableArray array];NSMutableSet*pinned=[NSMutableSet set];id<MTLTexture>current=nil;
|
||||
auto next=[&]()->id<MTLTexture>{for(id<MTLTexture>t in pool)if(t!=current&&![pinned containsObject:t])return t;MTLTextureDescriptor*td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float width:source.width height:source.height mipmapped:NO];td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;id<MTLTexture>t=[d newTextureWithDescriptor:td];if(t){[pool addObject:t];[t release];}return t;};
|
||||
auto dispatch=[&](NSString*name,const void*params,NSUInteger length,const void*extra=nullptr,NSUInteger extraLength=0){id<MTLTexture>out=next();if(!out)return fail(error,@"无法分配一级 CST 缓冲区。");BOOL ok=[self managedDispatch:name textures:@[current,out] data:params length:length extra:extra extraLength:extraLength entry:entry error:error];if(ok)current=out;return ok;};
|
||||
@@ -13,7 +13,7 @@
|
||||
auto tile=[&](id<MTLTexture>t){DYExportTile*v=[[[DYExportTile alloc]initWithTexture:t registry:d.registryID]autorelease];[v setBounds:src.tilePixelBounds origin:src.imageOrigin];[v setPixelAspect:src.pixelAspect];return v;};
|
||||
auto blend=[&](id<MTLTexture>before,NSArray*masks,float amount,NSString*type){if(!masks.count&&amount>=1)return YES;id<MTLTexture>out=next();if(!out)return fail(error,@"无法分配一级混合缓冲区。");DYToolMaskHeader h{};id<MTLBuffer>mb=[self maskBuffer:@{type:masks?:@[]} tile:src device:d header:&h];h.section=(int)[DYToolTypes()indexOfObject:type];DYCSTMixParams p={{wg,wt,2,20,0},{2,20,wg,wt,0},amount};id<MTLComputePipelineState>pipeline=[self managedKernel:@"dyPrimaryBlend" entry:entry error:error];if(!pipeline||!mb)return NO;id<MTLCommandBuffer>cb=[entry[@"queue"]commandBuffer];id<MTLComputeCommandEncoder>ce=[cb computeCommandEncoder];[ce setComputePipelineState:pipeline];[ce setTexture:before atIndex:0];[ce setTexture:current atIndex:1];[ce setTexture:out atIndex:2];[ce setBuffer:mb offset:0 atIndex:0];[ce setBytes:&h length:sizeof(h) atIndex:1];[ce setBytes:&p length:sizeof(p) atIndex:2];[ce dispatchThreads:MTLSizeMake(source.width,source.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription);current=out;return YES;};
|
||||
auto grade=[&](DYUniforms values,NSArray*masks,BOOL local){if(values.primarySectionEnabled<.5||values.cm.mix<=0)return YES;DYUniforms neutral=values;neutral.inputSectionEnabled=neutral.cm.outputEnabled=0;BOOL gradeNeutral=identityCM(neutral);if(!local&&gradeNeutral)return YES;if(local&&identityCM(values))return YES;
|
||||
DayuRenderParams p=DYCMRender(values.cm);p.input.toneMapping=0;CSTParams back={wg,wt,wg,wt,0};
|
||||
DayuRenderParams p=DYCMRender(values.cm);p.input.toneMapping=0;if((int)lroundf(values.cm.workingTransfer)==20){p.reserved|=8;p.basis.colorspace=10;p.basisInput={(int)lroundf(values.cm.workingGamut),20,(int)lroundf(values.cm.workingGamut),10,0};p.basisOutput={(int)lroundf(values.cm.workingGamut),10,(int)lroundf(values.cm.workingGamut),20,0};}CSTParams back={wg,wt,wg,wt,0};
|
||||
if(local){p.stages=(values.inputSectionEnabled>.5?1:0)|(gradeNeutral?0:2)|(values.cm.outputEnabled>.5?4:0);back={values.cm.outputEnabled>.5?(int)lroundf(values.cm.outputGamut):(int)lroundf(values.cm.workingGamut),values.cm.outputEnabled>.5?(int)lroundf(values.cm.outputTransfer):(int)lroundf(values.cm.workingTransfer),wg,wt,0};}
|
||||
else{p.stages=2;}
|
||||
id<MTLTexture>before=current;[pinned addObject:before];BOOL ok=dispatch(@"dyPrimaryGrade",&p,sizeof(p),&back,sizeof(back));if(ok)ok=blend(before,masks,values.cm.mix,@"primary");[pinned removeObject:before];return ok;
|
||||
@@ -24,8 +24,8 @@
|
||||
current=source;id<MTLTexture>carrier=next();uint32_t noLUT=0;if(!carrier||![self managedDispatch:@"dyManagedCarrier" textures:@[current,carrier,entry[@"identity"]] data:&noLUT length:4 extra:nullptr extraLength:0 entry:entry error:error])return NO;current=carrier;
|
||||
if(root&&u.inputSectionEnabled>.5&&!transform({(int)lroundf(u.cm.inputGamut),(int)lroundf(u.cm.inputTransfer),wg,wt,0}))return NO;
|
||||
if(!grade(u,tools[@"baseMasks"][@"primary"],NO))return NO;
|
||||
NSMutableDictionary*finishing=DYMutablePlist(tools);NSMutableSet*scene=[NSMutableSet set];for(NSString*ID in DYToolDisplayOrder(tools)){NSDictionary*node=DYToolWithID(tools,ID);if([node[@"type"]isEqual:@"primary"]){if(!grade(DYToolUniforms(node),node[@"masks"],YES))return NO;[scene addObject:ID];}}
|
||||
if(!print(u,tools[@"baseMasks"][@"film"]))return NO;for(NSString*ID in DYToolDisplayOrder(tools)){NSDictionary*node=DYToolWithID(tools,ID);if([node[@"type"]isEqual:@"film"]&&!print(DYToolUniforms(node),node[@"masks"]))return NO;}
|
||||
NSMutableDictionary*finishing=DYMutablePlist(tools);NSMutableSet*scene=[NSMutableSet set];for(NSString*ID in DYToolDisplayOrder(tools)){NSDictionary*node=DYToolWithID(tools,ID);if([node[@"type"]isEqual:@"primary"]){transparent&=identityCM(DYToolUniforms(node));if(!grade(DYToolUniforms(node),node[@"masks"],YES))return NO;[scene addObject:ID];}}
|
||||
if(!print(u,tools[@"baseMasks"][@"film"]))return NO;for(NSString*ID in DYToolDisplayOrder(tools)){NSDictionary*node=DYToolWithID(tools,ID);if([node[@"type"]isEqual:@"film"]){transparent&=!DYFilmPrintActive(DYToolUniforms(node));if(!print(DYToolUniforms(node),node[@"masks"]))return NO;}}
|
||||
for(NSString*ID in scene)DYRemoveTool(finishing,ID);for(NSMutableDictionary*node in finishing[@"layers"])if([node[@"type"]isEqual:@"film"])node[@"values"][@"filmPrintLook"]=@0;
|
||||
BOOL outputEnabled=root&&u.cm.outputEnabled>.5;int ot=outputEnabled?lroundf(u.cm.outputTransfer):wt,og=outputEnabled?lroundf(u.cm.outputGamut):wg;
|
||||
// Only this stage owns the main display rendering / tone mapping.
|
||||
@@ -33,7 +33,7 @@
|
||||
u.primarySectionEnabled=0;u.cm.configured=-1;u.inputProfile=u.preLUTStrength=0;u.filmPrint.x=0;NSDictionary*finishPaths=DYVisibleBaseToolPaths(paths,finishing);NSArray*activeFinish=DYPrimaryActiveFinishing(u,finishPaths,spider,finishing);
|
||||
BOOL display=outputEnabled&&ot>=1001&&ot<=1003;
|
||||
if(!display&&activeFinish.count)return fail(error,@"当前是 Log/线性码值输出。SDR 修饰工具需要显示输出,请选择 Gamma 输出,或关闭这些工具并保存完整预设。");
|
||||
if(display&&_exporting&&!activeFinish.count){if(!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;}else if(display){if(!transform({og,ot,22,20,0}))return NO;[self managedPreview:current origin:src.imageOrigin entry:entry];
|
||||
if(!display&&transparent&&!activeFinish.count){current=source;[self managedPreview:current origin:src.imageOrigin entry:entry];}else if(display&&_exporting&&!activeFinish.count){if(!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;}else if(display){if(!transform({og,ot,22,20,0}))return NO;[self managedPreview:current origin:src.imageOrigin entry:entry];
|
||||
if(activeFinish.count){id<MTLTexture>out=next();if(!out)return fail(error,@"无法分配 SDR 修饰缓冲区。");_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;}
|
||||
if(_exporting){if(!transform({22,20,og,ot,0})||!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;}else{CGColorSpaceRef from=CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB),to=DYManagedTileSpace(dst,primaries);DYColorProfile*p=to?[[[DYColorProfile alloc]initWithSource:from target:to error:error]autorelease]:nil;CGColorSpaceRelease(from);if(to)CGColorSpaceRelease(to);if(!p)return fail(error,@"宿主未提供明确的目标颜色空间。");id<MTLTexture>out=next();if(!out||![self managedProfile:p input:current output:out entry:entry error:error])return NO;current=out;}
|
||||
}else{if(!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;[self managedPreview:current origin:src.imageOrigin entry:entry];}
|
||||
|
||||
@@ -255,7 +255,7 @@ static NSArray *DYPrimaryActiveFinishing(DYUniforms u,NSDictionary *paths,NSData
|
||||
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=_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)];if(DYPrimaryColorState(_exportManagedState)){[text insertString:[NSString stringWithFormat:@"# V3 input: primary CST declared code values. Output: declared primary CST encoding.\n# PRIMARY_CST input=%d/%d working=%d/%d output=%d/%d mapping=%d\n",(int)u.cm.inputTransfer,(int)u.cm.inputGamut,(int)u.cm.workingTransfer,(int)u.cm.workingGamut,(int)u.cm.outputTransfer,(int)u.cm.outputGamut,(int)u.cm.toneMapping] atIndex:0];}else [text insertString:@"# V2 input: declared camera/LUT code values, or sRGB in host mode. Output: sRGB / Rec.709.\n" atIndex:0];}
|
||||
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)];if(DYPrimaryColorState(_exportManagedState)){[text insertString:[NSString stringWithFormat:@"# V3 input/output: code values defined by enabled primary CST stages; a disabled primary passes unmanaged host code values.\n# PRIMARY_CST enabled=%d input=%d/%d working=%d/%d output=%d/%d mapping=%d\n",u.primarySectionEnabled>.5,(int)(u.inputSectionEnabled>.5?u.cm.inputTransfer:u.cm.workingTransfer),(int)(u.inputSectionEnabled>.5?u.cm.inputGamut:u.cm.workingGamut),(int)u.cm.workingTransfer,(int)u.cm.workingGamut,(int)(u.cm.outputEnabled>.5?u.cm.outputTransfer:u.cm.workingTransfer),(int)(u.cm.outputEnabled>.5?u.cm.outputGamut:u.cm.workingGamut),(int)u.cm.toneMapping] atIndex:0];}else [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
|
||||
在新工单中引用
屏蔽一个用户