feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) (#26)
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.
Closes #19
Closes #20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #26.
This commit is contained in:
1 parent
db389a54f2
commit
188b2c2e55
355 files changed
+10549
-1061
No files matched your search
@@ -39,6 +39,23 @@ public sealed class AnalysisJobTests(TestContext context)
|
||||
Longitude = 12.3,
|
||||
});
|
||||
|
||||
[Test]
|
||||
public async Task LightAnalysisAdvisesTheAspectOfTheTurnedView()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Flickering());
|
||||
var turned = new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } };
|
||||
await fx.Db.Sequences.EditAsync(sequence.Id, new SequenceEdit { SettingsJson = turned.ToJson() }, null, fx.Ct);
|
||||
await fx.StartEngineAsync();
|
||||
|
||||
var job = await fx.EnqueueAsync(ProcessingJobs.LightAnalysis([sequence.Id], sequence.DisplayTitle));
|
||||
await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
var project = ProjectSettings.FromJson(await File.ReadAllTextAsync(fx.Folder(sequence).ProjectPath, fx.Ct));
|
||||
Assert.Equal(90, project.Camera.Rotate);
|
||||
Assert.Equal("9:16", project.Camera.Aspect.AutoValue);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task LightAnalysisFillsAutoValuesAndKeepsManualOnes()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using Chronos.Core.Diagnostics.Synthetic;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Processing;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Data.Tests.Processing;
|
||||
|
||||
/// <summary>
|
||||
/// The project of a sequence as the engine reads and writes it (owner review 1, phase 4): a format-1 project stays format 1
|
||||
/// through every edit that uses nothing newer, a transform raises it to 2 and its removal brings it back, and settings of
|
||||
/// a newer Chronos are refused saying so in the user's language.
|
||||
/// </summary>
|
||||
[Category("processing")]
|
||||
public sealed class ProjectStoreTests(TestContext context)
|
||||
{
|
||||
[Test]
|
||||
public async Task AnEditNeverRaisesTheFormatOfAProjectThatUsesNothingNewer()
|
||||
{
|
||||
await using var fixture = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fixture.AddAsync(SyntheticSequence.Create(new SyntheticSequenceOptions { Width = 64, Height = 48, FrameCount = 4 }));
|
||||
var store = new ProjectStore(fixture.Db, new SequenceWriter(new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) }));
|
||||
async Task<int> StoredFormatAsync()
|
||||
{
|
||||
var row = (await fixture.Db.Sequences.GetAsync(sequence.Id, fixture.Ct))!;
|
||||
var file = await File.ReadAllTextAsync(fixture.Folder(sequence).ProjectPath, fixture.Ct);
|
||||
Assert.Equal(row.SettingsJson, file, "the index and project.json hold the same text");
|
||||
return ProjectContent.FormatOf(file);
|
||||
}
|
||||
|
||||
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.5 } }, fixture.Ct));
|
||||
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
|
||||
// A read project of the base format is never stamped higher, even when it says the highest this Chronos reads.
|
||||
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Version = ProjectSettings.CurrentVersion, HeroFrame = 2 }, fixture.Ct));
|
||||
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
|
||||
|
||||
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Camera = p.Camera with { Rotate = 90 } }, fixture.Ct));
|
||||
Assert.Equal(2, await StoredFormatAsync());
|
||||
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Camera = p.Camera with { Rotate = 0 } }, fixture.Ct));
|
||||
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
|
||||
Assert.False(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Version = ProjectSettings.BaseVersion }, fixture.Ct), "nothing changed");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SettingsOfANewerChronosAreRefusedSayingSo()
|
||||
{
|
||||
var refused = Assert.Throws<InvalidDataException>(() => ProjectStore.Parse("""{"version":3,"camera":{"rotate":90}}"""));
|
||||
Assert.Equal(Loc.L("Errors.Render.NewerSettings"), refused.Message);
|
||||
Assert.Equal(90, ProjectStore.Parse("""{"version":2,"camera":{"rotate":90}}""").Camera.Rotate);
|
||||
// Text that is not a project keeps its own reason.
|
||||
Assert.NotEqual(Loc.L("Errors.Render.NewerSettings"), Assert.Throws<InvalidDataException>(() => ProjectStore.Parse("[1]")).Message);
|
||||
}
|
||||
}
|
||||
@@ -599,6 +599,105 @@ public sealed class RenderJobTests(TestContext context)
|
||||
Assert.SequenceEqual(["mjpeg", "gif"], ProcessingJobs.Split(posted, 96, 64).Select(p => p.Codec));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Owner review 1, phase 4: a render job carries the output size its settings give it (the chosen proportions win over a
|
||||
/// fixed-size preset, a quarter turn swaps a source-sized output) and the settings format its render needs, so a render
|
||||
/// node is matched to what it will write; a job posted by an older client gets both from the server (<see cref="ProcessingJobs.Split"/>).
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void RenderJobsCarryTheSizeAndFormatOfTheirSettings()
|
||||
{
|
||||
var sequence = new Sequence { Id = Guid.CreateVersion7(), ArchiveId = Guid.CreateVersion7(), Folder = "Synthetic", Title = "Roof" };
|
||||
var uhd = new ExportSettings { Preset = new Auto<string>().WithManual("4k-h264") };
|
||||
var portrait = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("9:16") } };
|
||||
static Chronos.Protocol.RenderJobParameters Read(Chronos.Data.Archiving.Jobs.ArchiveJobRequest request) => ProcessingJobs.ReadRender(request.ParametersJson).Parameters;
|
||||
|
||||
var adapted = Read(ProcessingJobs.Render(sequence, uhd, 6000, 4000, portrait));
|
||||
Assert.Equal((2160, 3840, 2), (adapted.Width, adapted.Height, adapted.RequiredSettingsFormat));
|
||||
var source = Read(ProcessingJobs.Render(sequence, uhd, 6000, 4000, new ProjectSettings()));
|
||||
Assert.Equal((3840, 2160, 1), (source.Width, source.Height, source.RequiredSettingsFormat));
|
||||
// A source-sized output turns with the picture; the turn needs format 2.
|
||||
var png = new ExportSettings { Preset = new Auto<string>().WithManual("png-sequence") };
|
||||
var turned = Read(ProcessingJobs.Render(sequence, png, 6000, 4000, new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } }));
|
||||
Assert.Equal((4000, 6000, 2), (turned.Width, turned.Height, turned.RequiredSettingsFormat));
|
||||
// The sequence's own settings when the job embeds none.
|
||||
var own = Read(ProcessingJobs.Render(sequence with { SettingsJson = portrait.ToJson() }, uhd, 6000, 4000));
|
||||
Assert.Equal((2160, 3840, 2), (own.Width, own.Height, own.RequiredSettingsFormat));
|
||||
|
||||
// Posted by an older client (the preset's size, no format) with a batch: the server sizes each job for the settings.
|
||||
var posted = Read(ProcessingJobs.Render(sequence, uhd with { Batch = ["1080p-h264"] }, 6000, 4000)) with { SettingsJson = portrait.ToJson() };
|
||||
Assert.Equal((3840, 2160, 1), (posted.Width, posted.Height, posted.RequiredSettingsFormat));
|
||||
var split = ProcessingJobs.Split(posted, 6000, 4000, portrait);
|
||||
Assert.SequenceEqual([(2160, 3840, 2), (1080, 1920, 2)], split.Select(p => (p.Width, p.Height, p.RequiredSettingsFormat)));
|
||||
Assert.Equal(split[0], ProcessingJobs.Routed(split[0], portrait, 6000, 4000), "a size already adapted stays");
|
||||
// The sequence's settings change between posting and routing: the size comes from the preset again, never from the
|
||||
// size a newer client already adapted (2160×2160 for 1:1 would adapt to 2160×1215 for 16:9).
|
||||
var square = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("1:1") } };
|
||||
var wide = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("16:9") } };
|
||||
var squared = Read(ProcessingJobs.Render(sequence, uhd, 6000, 4000, square));
|
||||
Assert.Equal((2160, 2160), (squared.Width, squared.Height));
|
||||
var rerouted = ProcessingJobs.Routed(squared, wide, 6000, 4000);
|
||||
Assert.Equal((3840, 2160), (rerouted.Width, rerouted.Height), "the preset's box adapted to the new aspect");
|
||||
var tall = Read(ProcessingJobs.Render(sequence, uhd, 6000, 4000, new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("4:5") } }));
|
||||
Assert.Equal((2160, 2700), (tall.Width, tall.Height));
|
||||
Assert.Equal((3840, 2160), (ProcessingJobs.Routed(tall, wide, 6000, 4000).Width, ProcessingJobs.Routed(tall, wide, 6000, 4000).Height));
|
||||
Assert.Equal((3840, 2160, 1), ProcessingJobs.Split(posted, 6000, 4000).Select(p => (p.Width, p.Height, p.RequiredSettingsFormat)).First(),
|
||||
"settings that cannot be read keep the size the job was posted with");
|
||||
// What the desktop asks of a server before a render: the highest format of the export and its batch.
|
||||
Assert.Equal(1, ProcessingJobs.RequiredFormat(portrait, png, 6000, 4000), "a source-sized output keeps the proportions");
|
||||
Assert.Equal(2, ProcessingJobs.RequiredFormat(portrait, png with { Batch = ["4k-h264"] }, 6000, 4000));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Owner review 1, phase 4, end to end: a turned, portrait project with a look renders each output at the size its job
|
||||
/// was routed with (the fixed box adapted to 9:16, the source-sized output on the turned view) and records it so.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ATurnedPortraitProjectRendersAtTheSizeItsJobWasRoutedWith()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Scene());
|
||||
await fx.StartEngineAsync();
|
||||
|
||||
var settings = new ProjectSettings
|
||||
{
|
||||
Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("9:16"), Rotate = 90, Straighten = 2 },
|
||||
Look = new LookSettings { Filter = "sepia", Strength = 0.6 },
|
||||
};
|
||||
var request = ProcessingJobs.Render(sequence, Mjpeg with { Batch = ["png-sequence"] }, 96, 64, settings);
|
||||
var routed = ProcessingJobs.ReadRender(request.ParametersJson).Parameters;
|
||||
Assert.Equal((54, 96, 2), (routed.Width, routed.Height, routed.RequiredSettingsFormat));
|
||||
await fx.WaitForAsync((await fx.EnqueueAsync(request)).Id, JobState.Done);
|
||||
|
||||
var renders = (await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct)).OrderBy(r => r.OutputPath, StringComparer.Ordinal).ToList();
|
||||
Assert.SequenceEqual([(54, 96), (54, 96)], renders.Select(r => (r.Width, r.Height)));
|
||||
var pngs = Directory.GetFiles(Path.Combine(fx.Folder(sequence).Exports, "clip-PNG")).Order().ToList();
|
||||
Assert.Equal(Frames, pngs.Count);
|
||||
using var decoded = DecoderFactory.CreateServer().Decode(new DecodeRequest(pngs[^1]));
|
||||
Assert.Equal((54, 96), (Assert.NotNull(decoded).Pixels.Width, decoded.Pixels.Height));
|
||||
}
|
||||
|
||||
/// <summary>Settings of a newer Chronos fail the render with the reason in the user's language, never as an English message.</summary>
|
||||
[Test]
|
||||
public async Task AnOverFormatRenderFailsSayingANewerChronosIsNeeded()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Scene());
|
||||
await fx.StartEngineAsync();
|
||||
|
||||
var parameters = ProcessingJobs.ReadRender(ProcessingJobs.Render(sequence, Mjpeg, 96, 64).ParametersJson).Parameters with
|
||||
{
|
||||
SettingsJson = """{"version":3,"camera":{"rotate":90},"grade":{"lut":"teal"}}""",
|
||||
};
|
||||
var request = new Chronos.Data.Archiving.Jobs.ArchiveJobRequest(JobKind.Render, [sequence.Id], "newer",
|
||||
System.Text.Json.JsonSerializer.Serialize(parameters, Chronos.Protocol.ProtocolJson.Default.RenderJobParameters), JobPriority.User);
|
||||
Assert.Equal(3, ProcessingJobs.ReadRender(ProcessingJobs.Render(sequence, Mjpeg, 96, 64,
|
||||
ProjectSettings.FromJson(parameters.SettingsJson, allowNewer: true)).ParametersJson).Parameters.RequiredSettingsFormat, "routed to none older");
|
||||
var failed = await fx.WaitForAsync((await fx.EnqueueAsync(request)).Id, JobState.Failed);
|
||||
Assert.Equal(Loc.L("Errors.Render.NewerSettings"), failed.Error);
|
||||
Assert.Empty(await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct));
|
||||
}
|
||||
|
||||
/// <summary>MJPEG job parameters whose preset JSON is <paramref name="presetJson"/>.</summary>
|
||||
private static string WithPreset(string presetJson) => System.Text.Json.JsonSerializer.Serialize(
|
||||
new Chronos.Protocol.RenderJobParameters("MJPEG", presetJson, "mjpeg", 96, 64, false, null), Chronos.Protocol.ProtocolJson.Default.RenderJobParameters);
|
||||
|
||||
Reference in new issue
Block a user