// Regression for the user's failure case: scene grading precedes the main ODT. { DYRenderer *primaryRenderer=[[[DYRenderer alloc]init]autorelease];NSDictionary *v3=DYPrimaryColorDefaults();DYToolDocument *empty=[[[DYToolDocument alloc]init]autorelease]; run.need(@"primary-v3-independent-state-valid",DYManagedColorValid(v3,nil)&&DYPrimaryColorState(v3));NSMutableDictionary *bad=DYMutablePlist(v3);bad[@"input"]=@109;run.record(@"primary-v3-rejects-conflicting-global-input",!DYManagedColorValid(bad,nil)); DYAssetState *saved=[[[DYAssetState alloc]init]autorelease];saved.colorManagement=v3;NSData *encoded=[NSKeyedArchiver archivedDataWithRootObject:saved requiringSecureCoding:YES error:&error];DYAssetState *decoded=[NSKeyedUnarchiver unarchivedObjectOfClass:DYAssetState.class fromData:encoded error:&error];run.record(@"primary-v3-secure-state-roundtrip",[saved isEqual:decoded]); DYUniforms u=defaults;u.skinProtection.x=0;u.cm.configured=1;u.cm.inputTransfer=28;u.cm.inputGamut=27;u.cm.workingTransfer=10;u.cm.workingGamut=16;u.cm.outputTransfer=1002;u.cm.outputGamut=22;u.cm.toneMapping=1; auto decodeCarrier=[](float x){return x<=.04045f?x/12.92f:powf((x+.055f)/1.055f,2.4f);};auto encodeCarrier=[](float x){return x<=.0031308f?12.92f*x:1.055f*powf(x,1/2.4f)-.055f;}; std::vectorscene(width*height);float levels[]={.002f,.018f,.18f,1,4,16,32,64};for(size_t i=0;i pixels){dycm::Transform::convert(dycm::Space::ACEScg,dycm::Space::SonySLog3Cine).apply(pixels,dycm::Alpha::Premultiplied);Pixels out(pixels.size()*4);for(size_t i=0;ir(scene.size());for(size_t i=0;i&r){Pixels p(r.size()*4);for(size_t i=0;i.05); // Neutral additional layers are exact bypasses, with no second display map. NSMutableDictionary *doc=DYMutablePlist(empty.document);for(int i=0;i<4;i++)DYSeedPrimaryWorkingSpace((id)DYInsertTool(doc,@"primary",@"base:primary"),10,16);Pixels neutral=renderPrimary(u,doc,@"primary-four-inherited-neutral-layers");run.record(@"primary-new-layer-inherits-workspace-no-remap",difference(baseline,neutral).maximum==0); // Move the entire exposure correction into an independent layer. The result // 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); // 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); // Zero masks and zero mix bypass grade while retaining global input/output. NSMutableDictionary *mask=DYMutablePlist(DYNewMask(DYMaskRectangle)),*masked=DYMutablePlist(empty.document);DYMaskParameters mp=DYMaskAtTime(mask,kCMTimeZero);mp.strength=0;mask[@"parameters"]=[NSData dataWithBytes:&mp length:sizeof(mp)];masked[@"baseMasks"][@"primary"]=@[mask];Pixels zero=renderPrimary(reduced,masked,@"primary-zero-mask");reduced.cm.mix=0;Pixels zeroMix=renderPrimary(reduced,empty.document,@"primary-zero-grade-mix");run.record(@"primary-zero-mask-and-mix-retain-CST-boundaries",difference(zero,baseline).maximum==0&&difference(zeroMix,baseline).maximum==0); // A half-strength one-stop grade is 1.5x light, before mapping. DYUniforms half=u;half.cm.exposure=1;half.cm.mix=.5;Pixels halfFrame=renderPrimary(half,empty.document,@"primary-linear-light-half-mix");half.cm.exposure=log2f(1.5f);half.cm.mix=1;Pixels halfReference=renderPrimary(half,empty.document,@"primary-linear-light-mix-reference");run.record(@"primary-mix-in-linear-AP1",difference(halfFrame,halfReference).maximum<.003,measure(difference(halfFrame,halfReference))); // Print looks cross into their real ACEScct domain, then return to the chosen // working space. Neutral grade must not make the choice alter the print. DYUniforms print=u;print.filmPrint.x=1;print.filmPrint.y=.6;Pixels printDI=renderPrimary(print,empty.document,@"primary-print-DWG-before-output");print.cm.workingTransfer=1;print.cm.workingGamut=2;Pixels printACES=renderPrimary(print,empty.document,@"primary-print-ACES-before-output");Difference printDelta=difference(printDI,printACES);run.record(@"primary-print-domain-adapts-to-selected-working-space",printDelta.maximum<.005&&difference(printDI,baseline).different>20,measure(printDelta)); // The output controls change data output, and the optional display map is last. DYUniforms logOut=u;logOut.cm.outputTransfer=10;logOut.cm.outputGamut=16;logOut.cm.toneMapping=0;Pixels selectedOutput=renderPrimary(logOut,empty.document,@"primary-declared-Log-output");run.record(@"primary-declared-output-controls-restored",difference(intermediate,selectedOutput).maximum==0&&difference(selectedOutput,baseline).maximum>.05); DYUniforms unmapped=u;unmapped.cm.toneMapping=0;Pixels noMap=renderPrimary(unmapped,empty.document,@"primary-no-output-tone-map");run.record(@"primary-tone-mapping-switch-restored",difference(noMap,baseline).maximum>.05); 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;i0){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); // 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];idaction=[local apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[action startAction:nil];[(id)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::vectortable;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)}); // Cube output follows the selected encoding, independent of the monitor. linear.cm.exposure=0;linear.cm.outputGamut=22;float gammaValues[2]={};BOOL gammaExports=YES;int gammaIDs[]={1001,1003};for(int j=0;j<2;j++){linear.cm.outputTransfer=gammaIDs[j];NSURL *target=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:[NSString stringWithFormat:@"primary-gamma-%d.cube",gammaIDs[j]]]];e=nil;BOOL ok=[primaryRenderer exportLUT:target uniforms:linear paths:@{} spider:nil tools:empty.document colorManagement:v3 error:&e];std::vectorvalues;NSUInteger n=0;ok=ok&&DYLUTReadCube(target.path,values,n,&e)&&n==65;gammaExports&=ok;if(ok)gammaValues[j]=values[((32*n+32)*n+32)*4];}run.record(@"primary-Cube-restores-output-gamma-selection",gammaExports&&fabs(gammaValues[0]-powf(.5f,1/2.2f))<.001&&fabs(gammaValues[1]-powf(.5f,1/2.6f))<.001,@{@"Gamma22":@(gammaValues[0]),@"Gamma26":@(gammaValues[1])}); upload(input); }