Merge branch 'or1p4-p2' into or1-p4
This commit is contained in:
commit
d067219764
4 files changed
+537
-6
No files matched your search
@@ -0,0 +1,82 @@
|
||||
using Chronos.Core.Imaging;
|
||||
using Chronos.Core.Imaging.Color;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Render;
|
||||
using Chronos.Testing;
|
||||
using static Chronos.Core.Tests.Render.RenderFixture;
|
||||
|
||||
namespace Chronos.Core.Tests.Render;
|
||||
|
||||
/// <summary>The colour look in renders (owner review 1, R6): once per output frame, after stacking, before the knee.</summary>
|
||||
public sealed class LookRenderTests(TestContext context)
|
||||
{
|
||||
private static ProjectSettings With(LookSettings? look, double? knee = null, StackSettings? stack = null) =>
|
||||
Plain with { Look = look, Exposure = new ExposureSettings { HighlightKnee = knee }, Stack = stack ?? new StackSettings() };
|
||||
|
||||
private static void SameFrames(IReadOnlyList<ImageBuffer> expected, IReadOnlyList<ImageBuffer> actual)
|
||||
{
|
||||
Assert.Equal(expected.Count, actual.Count);
|
||||
for (var i = 0; i < expected.Count; i++) Assert.True(expected[i].Data.SequenceEqual(actual[i].Data), $"frame {i}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheIdentityLooksRenderTheSameBytesAsNoLook()
|
||||
{
|
||||
var (plain, _) = await CaptureAsync(Input(Source(4), With(null)), cancellationToken: context.Cancellation);
|
||||
foreach (var look in new[] { new LookSettings { Filter = LookFilter.None }, new LookSettings { Filter = "vivid", Strength = 0 } })
|
||||
{
|
||||
var (encode, result) = await CaptureAsync(Input(Source(4), With(look)), cancellationToken: context.Cancellation);
|
||||
SameFrames(plain.Frames, encode.Frames);
|
||||
Assert.Empty(result.Warnings);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnUnknownLookRendersAsNoneWithAWarning()
|
||||
{
|
||||
var (plain, _) = await CaptureAsync(Input(Source(4), With(null)), cancellationToken: context.Cancellation);
|
||||
var (encode, result) = await CaptureAsync(Input(Source(4), With(new LookSettings { Filter = "technicolor" })), cancellationToken: context.Cancellation);
|
||||
SameFrames(plain.Frames, encode.Frames);
|
||||
Assert.Contains(result.Warnings, w => w.Key == "Export.Render.LookIgnored" && w.Args.SequenceEqual(["technicolor"]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ACaptureWithALookIsTheFinishOfThePlainCapture()
|
||||
{
|
||||
// The look comes before the knee: the plain render has no knee, so the finish adds both in its own order.
|
||||
var look = new LookSettings { Filter = "sepia", Strength = 0.7 };
|
||||
var source = Source(6, configure: o => o with { StartEv = 1, EndEv = 2 });
|
||||
var (plain, _) = await CaptureAsync(Input(source, With(null)), cancellationToken: context.Cancellation);
|
||||
var (encode, result) = await CaptureAsync(Input(source, With(look, knee: 0.85)), cancellationToken: context.Cancellation);
|
||||
Assert.Empty(result.Warnings);
|
||||
foreach (var frame in plain.Frames) FrameFinish.Apply(frame, look, 0.85);
|
||||
SameFrames(plain.Frames, encode.Frames);
|
||||
Assert.Less(encode.Frames.Max(f => f.Data.ToArray().Max()), 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AMedianStackWithMonoIsMonoOfTheMedian()
|
||||
{
|
||||
var stack = new StackSettings { Mode = StackSetting.Median, Length = 5 };
|
||||
var source = Source(9, motion: i => (0.5 * i, 0));
|
||||
var (median, _) = await CaptureAsync(Input(source, With(null, stack: stack)), cancellationToken: context.Cancellation);
|
||||
var (mono, _) = await CaptureAsync(Input(source, With(new LookSettings { Filter = "mono" }, stack: stack)), cancellationToken: context.Cancellation);
|
||||
foreach (var frame in median.Frames) LookFilter.Apply(frame, "mono", 1);
|
||||
SameFrames(median.Frames, mono.Frames);
|
||||
Assert.True(mono.Frames.All(f => f.Plane(0).SequenceEqual(f.Plane(1)) && f.Plane(1).SequenceEqual(f.Plane(2))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PngOutputWithALookIsByteIdenticalAcrossRuns()
|
||||
{
|
||||
var dir = context.CreateTempDirectory();
|
||||
var project = With(new LookSettings { Filter = "fade", Strength = 0.8 }, knee: 0.9);
|
||||
var first = await Pipeline().RenderAsync(Input(Source(5), project), Target(dir, Preset("png-sequence") with { BitDepth = 16 }, "a"), cancellationToken: context.Cancellation);
|
||||
var second = await Pipeline().RenderAsync(Input(Source(5), project), Target(dir, Preset("png-sequence") with { BitDepth = 16 }, "b"), cancellationToken: context.Cancellation);
|
||||
var a = Directory.GetFiles(first.OutputPath).Order(StringComparer.Ordinal).ToArray();
|
||||
var b = Directory.GetFiles(second.OutputPath).Order(StringComparer.Ordinal).ToArray();
|
||||
Assert.Equal(5, a.Length);
|
||||
Assert.Equal(a.Length, b.Length);
|
||||
for (var i = 0; i < a.Length; i++) Assert.BytesEqual(File.ReadAllBytes(a[i]), File.ReadAllBytes(b[i]));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user