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

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:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-05 01:09:09 +01:00
1 parent db389a54f2
commit 188b2c2e55
355 files changed
+10549 -1061

No files matched your search

+83 -11
View File
@@ -5,6 +5,7 @@ using Chronos.Core.Export;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Core.Render;
using Chronos.Core.Video;
using Chronos.Data.Archiving.Jobs;
using Chronos.Protocol;
@@ -28,15 +29,17 @@ public static class ProcessingJobs
/// <summary>
/// <see cref="JobKind.Render"/> of one sequence. <paramref name="export"/> (preset, overrides, name template,
/// folder, batch) replaces the project's export section; <paramref name="project"/> embeds the settings to render,
/// null renders the sequence's current project. <paramref name="sourceWidth"/>×<paramref name="sourceHeight"/>
/// stands in for a preset without a fixed size, so render nodes can match the job by resolution.
/// null renders the sequence's current project. <paramref name="sourceWidth"/>×<paramref name="sourceHeight"/> (the
/// frames' Exif-oriented size) gives the output size of the settings rendered (<see cref="RenderSize"/>; the sequence's
/// own when <paramref name="project"/> is null), so render nodes can match the job by resolution, and the settings
/// format the render needs (<see cref="RenderRules.RequiredFormat"/>).
/// </summary>
public static ArchiveJobRequest Render(Sequence sequence, ExportSettings export, int sourceWidth, int sourceHeight, ProjectSettings? project = null,
bool useProxies = false)
{
ArgumentNullException.ThrowIfNull(sequence);
ArgumentNullException.ThrowIfNull(export);
var parameters = Parameters(export, sourceWidth, sourceHeight, project?.ToJson(), useProxies);
var parameters = Parameters(export, sourceWidth, sourceHeight, project?.ToJson(), useProxies, project ?? ReadSettings(sequence.SettingsJson));
return new ArchiveJobRequest(JobKind.Render, [sequence.Id], RenderLabel(sequence.DisplayTitle, parameters.PresetName),
JsonSerializer.Serialize(parameters, ProtocolJson.Default.RenderJobParameters), JobPriority.User);
}
@@ -80,20 +83,22 @@ public static class ProcessingJobs
/// <summary>
/// A posted render job as one job per preset, as <see cref="RenderEach"/> makes them (a render node uploads one file
/// per job): the job itself when it has no batch; otherwise its own preset, then each batch preset with its own values,
/// all with the job's project and proxy choice. <paramref name="sourceWidth"/>×<paramref name="sourceHeight"/> stands in
/// for a batch preset without a fixed size.
/// all with the job's project and proxy choice. <paramref name="sourceWidth"/>×<paramref name="sourceHeight"/> (the
/// frames' Exif-oriented size) stands in for a batch preset without a fixed size. With the <paramref name="settings"/>
/// the job renders, every job gets the output size and the settings format its render needs (<see cref="Routed"/>);
/// without them, the job keeps the size it was posted with and each batch preset its preset's.
/// </summary>
/// <exception cref="InvalidDataException">The preset JSON is not an export section.</exception>
public static IReadOnlyList<RenderJobParameters> Split(RenderJobParameters parameters, int sourceWidth, int sourceHeight)
public static IReadOnlyList<RenderJobParameters> Split(RenderJobParameters parameters, int sourceWidth, int sourceHeight, ProjectSettings? settings = null)
{
ArgumentNullException.ThrowIfNull(parameters);
var export = ReadExport(parameters.PresetJson);
var batch = BatchPresets(export).ToList();
if (batch.Count == 0) return [parameters];
var own = batch.Count == 0 ? parameters : parameters with { PresetJson = JsonSerializer.Serialize(export with { Batch = [] }, ProcessingJson.Default.ExportSettings) };
return
[
parameters with { PresetJson = JsonSerializer.Serialize(export with { Batch = [] }, ProcessingJson.Default.ExportSettings) },
.. batch.Select(id => Parameters(BatchExport(export, id), sourceWidth, sourceHeight, parameters.SettingsJson, parameters.UseProxies) with
settings is null ? own : Routed(own, settings, sourceWidth, sourceHeight),
.. batch.Select(id => Parameters(BatchExport(export, id), sourceWidth, sourceHeight, parameters.SettingsJson, parameters.UseProxies, settings) with
{
ProjectId = parameters.ProjectId,
ProjectVersionId = parameters.ProjectVersionId,
@@ -101,6 +106,59 @@ public static class ProcessingJobs
];
}
/// <summary>
/// A render job's parameters with the output size and the settings format a render of <paramref name="settings"/> needs
/// (owner review 1, phase 4: the chosen proportions win over a fixed-size preset, a quarter turn swaps a source-sized
/// output). The size comes from the job's preset, as the render does: never from the size the job was posted with,
/// which a newer client already adapted to the settings of the moment (a long edge kept for 1:1 cannot be adapted back
/// to 16:9 once the sequence's settings change). Other presets are sized on the source. The format is at least the one
/// the job was posted with.
/// </summary>
/// <exception cref="InvalidDataException">The preset JSON is not an export section.</exception>
public static RenderJobParameters Routed(RenderJobParameters parameters, ProjectSettings settings, int sourceWidth, int sourceHeight)
{
ArgumentNullException.ThrowIfNull(parameters);
ArgumentNullException.ThrowIfNull(settings);
var resolved = ExportResolver.Resolve(ReadExport(parameters.PresetJson));
var (width, height) = Size(settings, resolved, sourceWidth, sourceHeight) ?? (parameters.Width, parameters.Height);
return parameters with
{
Width = width,
Height = height,
RequiredSettingsFormat = int.Max(parameters.RequiredSettingsFormat, RequiredFormat(settings, resolved, sourceWidth, sourceHeight)),
};
}
/// <summary>
/// The settings format a render of <paramref name="settings"/> with <paramref name="export"/> and each of its batch
/// presets needs (the highest <see cref="RenderRules.RequiredFormat"/> of them): what a server or a render node must read
/// to render it as this Chronos would.
/// </summary>
public static int RequiredFormat(ProjectSettings settings, ExportSettings export, int sourceWidth, int sourceHeight)
{
ArgumentNullException.ThrowIfNull(settings);
ArgumentNullException.ThrowIfNull(export);
return BatchPresets(export).Select(id => ExportResolver.Resolve(BatchExport(export, id))).Prepend(ExportResolver.Resolve(export))
.Max(resolved => RequiredFormat(settings, resolved, sourceWidth, sourceHeight));
}
/// <summary>
/// Project settings read for their output size and format, a newer Chronos's too (its format stands); null when there
/// are none or the text is not a project.
/// </summary>
public static ProjectSettings? ReadSettings(string? settingsJson)
{
if (string.IsNullOrWhiteSpace(settingsJson)) return null;
try
{
return ProjectSettings.FromJson(settingsJson, allowNewer: true);
}
catch (JsonException)
{
return null;
}
}
/// <summary>
/// One <see cref="Render"/> job per preset of <paramref name="export"/>: its preset, then each batch preset with its
/// own values. For a server: a render node uploads one file per job, so a batch must not travel as one job.
@@ -128,13 +186,27 @@ public static class ProcessingJobs
internal static ExportSettings BatchExport(ExportSettings export, string presetId) =>
new() { Preset = new Auto<string>().WithManual(presetId), NameTemplate = export.NameTemplate, Folder = export.Folder };
private static RenderJobParameters Parameters(ExportSettings export, int sourceWidth, int sourceHeight, string? settingsJson, bool useProxies)
/// <param name="settings">The settings rendered, for the output size and the format (else read from <paramref name="settingsJson"/>); unknown, the preset's size.</param>
private static RenderJobParameters Parameters(ExportSettings export, int sourceWidth, int sourceHeight, string? settingsJson, bool useProxies,
ProjectSettings? settings = null)
{
var resolved = ExportResolver.Resolve(export);
settings ??= ReadSettings(settingsJson);
var (width, height) = (settings is null ? null : Size(settings, resolved, sourceWidth, sourceHeight))
?? (resolved.Width > 0 ? resolved.Width : sourceWidth, resolved.Height > 0 ? resolved.Height : sourceHeight);
var format = settings is null ? ProjectSettings.BaseVersion : RequiredFormat(settings, resolved, sourceWidth, sourceHeight);
return new RenderJobParameters(PresetName(resolved), JsonSerializer.Serialize(export, ProcessingJson.Default.ExportSettings), CodecName(resolved.Codec),
resolved.Width > 0 ? resolved.Width : sourceWidth, resolved.Height > 0 ? resolved.Height : sourceHeight, useProxies, settingsJson);
width, height, useProxies, settingsJson, RequiredSettingsFormat: format);
}
/// <summary>The output size of <paramref name="settings"/> with <paramref name="export"/> (<see cref="RenderSize.Of"/>); null without a source size.</summary>
private static (int Width, int Height)? Size(ProjectSettings settings, ResolvedExport export, int sourceWidth, int sourceHeight) =>
sourceWidth > 0 && sourceHeight > 0 ? RenderSize.Of(settings.Camera, export, sourceWidth, sourceHeight) : null;
/// <summary><see cref="RenderRules.RequiredFormat"/>; without a source size, the format the settings are written in.</summary>
private static int RequiredFormat(ProjectSettings settings, ResolvedExport export, int sourceWidth, int sourceHeight) =>
sourceWidth > 0 && sourceHeight > 0 ? RenderRules.RequiredFormat(settings, export, sourceWidth, sourceHeight) : settings.WrittenFormat;
/// <summary>Codec name in job parameters and render-node capabilities ("h264", "hevc", "mjpeg", "pngsequence"…).</summary>
public static string CodecName(VideoCodec codec) => codec.ToString().ToLowerInvariant();