feat(project): settle phase 4 contracts: conditional settings format, transforms, look, output size
Groundwork for owner review 1, phase 4, so the parallel packages build on fixed contracts and strings. - Settings: camera rotate/mirror/flip/straighten and a look, declared after the existing members and omitted at default. ToJson writes the lowest format that renders the same (2 only while a transform or look is used), so projects without them keep byte-identical text and hash; an old-build simulation test proves the order survives an older build's round trip. - RenderSize and RenderRules: proportions win over a fixed preset box, and the routing format a job needs. - FrameOrientation, CropFrame, OrientationEdit, LookFilter (identity) and FrameFinish (look, then knee) wired into the render pipeline and preview; RenderGeometry gains view-frame members equivalent to today. - Protocol trailing members for node, job and server formats; SyncText keys; EditPath counts transforms and the look as hand values. - New en/it strings and tooltips, five icons, test fixtures moved to v3 as the first unread format, and the 18 DECISIONS rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ad29977b9
commit
e4364c4f25
43 files changed
+1544
-178
No files matched your search
@@ -5,6 +5,7 @@ using Chronos.App.Jobs;
|
||||
using Chronos.Core.Advice;
|
||||
using Chronos.Core.Analysis;
|
||||
using Chronos.Core.Analysis.Deep;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
@@ -223,13 +224,16 @@ public static class EditPath
|
||||
|| (setting.IsAuto(project) && EditorSettings.Applies(setting, project, deep));
|
||||
}
|
||||
|
||||
/// <summary>Values of the section set by hand that are not Auto settings: crop, offsets and camera moves; fit to a duration; the exposure offset.</summary>
|
||||
/// <summary>
|
||||
/// Values of the section set by hand that are not Auto settings: crop, offsets, orientation and camera moves; fit to a
|
||||
/// duration; the exposure offset and the look.
|
||||
/// </summary>
|
||||
private static bool HasHandValues(ProjectSettings project, AdvisorSection section) => section switch
|
||||
{
|
||||
AdvisorSection.Camera => CropMargins.Of(project.Camera.Crop).Any(m => m > 0) || project.Camera.OffsetX != 0 || project.Camera.OffsetY != 0
|
||||
|| project.Camera.Keyframes.Count > 0,
|
||||
AdvisorSection.Camera => !CropFrame.IsWhole(project.Camera.Crop) || project.Camera.OffsetX != 0 || project.Camera.OffsetY != 0
|
||||
|| project.Camera.Keyframes.Count > 0 || project.Camera.IsOriented,
|
||||
AdvisorSection.Timing => project.Timing.FitToSeconds is > 0,
|
||||
AdvisorSection.Exposure => project.Exposure.ExposureOffsetEv != 0,
|
||||
AdvisorSection.Exposure => project.Exposure.ExposureOffsetEv != 0 || project.Look is not null,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public sealed class PreviewFrame(int index, ImageBuffer corrected, ImageBuffer o
|
||||
/// The corrected-frame preview through the render pipeline at preview size (BRIEF §12.3). The render pipeline has no
|
||||
/// single-frame entry point, so the per-frame steps of <c>RenderRun</c> are followed here: corrections from
|
||||
/// <see cref="RenderPreparation"/> exactly as a render prepares them, then each frame through the render's exposure
|
||||
/// stage, its single geometry warp and the highlight knee. Stacking and motion blur need neighbouring frames and are
|
||||
/// stage, its single geometry warp and its finish (look, then highlight knee). Stacking and motion blur need neighbouring frames and are
|
||||
/// left to the render.
|
||||
/// <para>
|
||||
/// Preparing is split so a slider never decodes the sequence again: a measuring preparation (luminance, colour means,
|
||||
@@ -282,7 +282,7 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
|
||||
raw.Dispose();
|
||||
raw = framed;
|
||||
}
|
||||
if (request.Project.Exposure.HighlightKnee is > 0 and < 1 and var knee) ExposureProcessor.Apply(corrected, 0, null, knee);
|
||||
FrameFinish.Apply(corrected, request.Project.Look, request.Project.Exposure.HighlightKnee);
|
||||
return (corrected, raw, request.Framing == PreviewFraming.Output ? null : plan);
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -87,6 +87,13 @@ public static class SyncText
|
||||
["camera.offsetX"] = "Server.Setting.CameraOffset",
|
||||
["camera.offsetY"] = "Server.Setting.CameraOffset",
|
||||
["camera.keyframes"] = "Server.Setting.Keyframes",
|
||||
["camera.rotate"] = "Server.Setting.Rotation",
|
||||
["camera.mirror"] = "Server.Setting.Mirror",
|
||||
["camera.flip"] = "Server.Setting.Flip",
|
||||
["camera.straighten"] = "Server.Setting.Straighten",
|
||||
["look"] = "Server.Setting.Look",
|
||||
["look.filter"] = "Server.Setting.LookFilter",
|
||||
["look.strength"] = "Server.Setting.LookStrength",
|
||||
["stack.mode"] = "Server.Setting.Stacking",
|
||||
["stack.length"] = "Server.Setting.TrailLength",
|
||||
["export.preset"] = "Server.Setting.ExportPreset",
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace Chronos.Core.Imaging.Color;
|
||||
|
||||
/// <summary>
|
||||
/// The built-in colour looks (owner review 1, R6): parametric, so a server or a Docker image renders them without LUT
|
||||
/// files. Each look is a linear-light 3×3 matrix, a contrast power about 0.18 and a lift, blended with the picture by its
|
||||
/// strength; values are never clamped (the highlight knee that follows compresses any overshoot). Applied to output
|
||||
/// frames only (<see cref="Chronos.Core.Render.FrameFinish"/>), never seen by measuring, flow or stacking.
|
||||
/// </summary>
|
||||
public static class LookFilter
|
||||
{
|
||||
/// <summary>The identity look's name.</summary>
|
||||
public const string None = "none";
|
||||
|
||||
/// <summary>Every look this Chronos renders, in the order the editor lists them; names are lower case.</summary>
|
||||
public static IReadOnlyList<string> Names { get; } = [None, "mono", "sepia", "warm", "cool", "vivid", "muted", "fade"];
|
||||
|
||||
/// <summary>A name this Chronos renders: null (none) or one of <see cref="Names"/> (ordinal, case-sensitive).</summary>
|
||||
public static bool IsKnown(string? name) => name is null || Names.Contains(name, StringComparer.Ordinal);
|
||||
|
||||
/// <summary>
|
||||
/// Applies the look <paramref name="filter"/> at <paramref name="strength"/> (0..1) to the colour planes of a
|
||||
/// linear-light <paramref name="image"/> in place; a fourth (alpha) channel is left untouched. None, an unknown name and
|
||||
/// a strength of 0 leave the image as it is.
|
||||
/// </summary>
|
||||
public static void Apply(ImageBuffer image, string? filter, double strength)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(image);
|
||||
if (filter is null or None || !(strength > 0) || !IsKnown(filter)) return;
|
||||
// Every look renders as the identity until the looks are implemented.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
namespace Chronos.Core.Imaging.Geometry;
|
||||
|
||||
/// <summary>The part of a crop box a pointer drags (owner review 1, R5): the inside moves it, a handle resizes it.</summary>
|
||||
public enum CropHandle
|
||||
{
|
||||
None,
|
||||
|
||||
/// <summary>Inside the box: moves it.</summary>
|
||||
Inside,
|
||||
TopLeft,
|
||||
Top,
|
||||
TopRight,
|
||||
Right,
|
||||
BottomRight,
|
||||
Bottom,
|
||||
BottomLeft,
|
||||
Left,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The crop box locked to the output proportions (owner review 1, R5), in normalised view-frame units ([0,1]² of the view
|
||||
/// T, <see cref="FrameOrientation"/>). <c>lockRatio</c> is the box's width over its height in these units: the output
|
||||
/// ratio × H'/W' (<c>RenderGeometry.LockRatio</c>). Every box returned keeps that ratio, lies inside [0,1]² and is at least
|
||||
/// <see cref="MinimumShare"/> of <see cref="Largest"/>. The editor writes the box itself to <c>CameraSettings.Crop</c>
|
||||
/// with the offsets at 0, so <see cref="AspectRatio.FitCrop"/> returns it unchanged at render time.
|
||||
/// </summary>
|
||||
public static class CropFrame
|
||||
{
|
||||
/// <summary>The smallest box, as a share of the largest one (per side).</summary>
|
||||
public const double MinimumShare = 0.1;
|
||||
|
||||
private static readonly RectD Whole = new(0, 0, 1, 1);
|
||||
|
||||
/// <summary>The largest box of <paramref name="lockRatio"/> inside [0,1]², centred.</summary>
|
||||
public static RectD Largest(double lockRatio) => AspectRatio.FitCrop(Whole, Checked(lockRatio));
|
||||
|
||||
/// <summary>
|
||||
/// A stored crop as a rectangle: <paramref name="crop"/> clamped to [0,1]² as the render reads it, the whole view for
|
||||
/// null or an invalid crop (not four finite values, or too small).
|
||||
/// </summary>
|
||||
public static RectD Of(double[]? crop)
|
||||
{
|
||||
if (crop is not [var x0, var y0, var w0, var h0] || !double.IsFinite(x0 + y0 + w0 + h0)) return Whole;
|
||||
var x = double.Clamp(x0, 0, 1);
|
||||
var y = double.Clamp(y0, 0, 1);
|
||||
var w = double.Min(w0, 1 - x);
|
||||
var h = double.Min(h0, 1 - y);
|
||||
return w <= 1e-3 || h <= 1e-3 ? Whole : new RectD(x, y, w, h);
|
||||
}
|
||||
|
||||
/// <summary>A box as <c>CameraSettings.Crop</c>; null for the whole view.</summary>
|
||||
public static double[]? ToCrop(RectD box) => IsWhole(box) ? null : [box.X, box.Y, box.Width, box.Height];
|
||||
|
||||
/// <summary>The crop shows the whole view (null, invalid, or covering [0,1]²): nothing is cut.</summary>
|
||||
public static bool IsWhole(double[]? crop) => IsWhole(Of(crop));
|
||||
|
||||
/// <summary>
|
||||
/// The locked box an editor shows and edits for a stored crop: the largest box of <paramref name="lockRatio"/> inside it,
|
||||
/// placed by the offsets as the render places it (<see cref="AspectRatio.FitCrop"/>). The first edit of a legacy free
|
||||
/// crop with offsets bakes them in this way.
|
||||
/// </summary>
|
||||
public static RectD Locked(double[]? crop, double lockRatio, double offsetX = 0, double offsetY = 0) =>
|
||||
AspectRatio.FitCrop(Of(crop), Checked(lockRatio), double.IsFinite(offsetX) ? offsetX : 0, double.IsFinite(offsetY) ? offsetY : 0);
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="box"/> made valid: its centre kept, its size forced to <paramref name="lockRatio"/> (same area),
|
||||
/// between the minimum and <see cref="Largest"/>, then moved inside [0,1]².
|
||||
/// </summary>
|
||||
public static RectD Clamp(RectD box, double lockRatio)
|
||||
{
|
||||
var largest = Largest(lockRatio);
|
||||
var area = double.IsFinite(box.Width * box.Height) && box.Width > 0 && box.Height > 0 ? box.Width * box.Height : largest.Width * largest.Height;
|
||||
var height = double.Clamp(double.Sqrt(area / lockRatio), largest.Height * MinimumShare, largest.Height);
|
||||
var width = double.Min(height * lockRatio, largest.Width);
|
||||
height = width / lockRatio;
|
||||
var cx = double.IsFinite(box.CenterX) ? box.CenterX : 0.5;
|
||||
var cy = double.IsFinite(box.CenterY) ? box.CenterY : 0.5;
|
||||
return Placed(cx - width / 2, cy - height / 2, width, height);
|
||||
}
|
||||
|
||||
/// <summary><paramref name="box"/> moved by (<paramref name="dx"/>, <paramref name="dy"/>), stopping at the edges of [0,1]².</summary>
|
||||
public static RectD Move(RectD box, double dx, double dy) => Placed(box.X + dx, box.Y + dy, box.Width, box.Height);
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="start"/> resized by dragging <paramref name="handle"/> to (<paramref name="x"/>, <paramref name="y"/>):
|
||||
/// a corner is anchored at the opposite corner, an edge at the opposite edge and stays centred on the other axis; with
|
||||
/// <paramref name="aboutCentre"/> (Alt) the centre stays. The ratio stays <paramref name="lockRatio"/>, the size between
|
||||
/// the minimum and what fits in [0,1]² from the anchor. <see cref="CropHandle.Inside"/> and <see cref="CropHandle.None"/>
|
||||
/// return <paramref name="start"/>.
|
||||
/// </summary>
|
||||
public static RectD ResizeFrom(RectD start, CropHandle handle, double x, double y, double lockRatio, bool aboutCentre = false)
|
||||
{
|
||||
Checked(lockRatio);
|
||||
if (handle is CropHandle.None or CropHandle.Inside) return start;
|
||||
// The anchor: the opposite corner or edge midpoint, or the centre; the handle's side signs (−1, 0, +1) per axis.
|
||||
var (sx, sy) = handle switch
|
||||
{
|
||||
CropHandle.TopLeft => (-1, -1),
|
||||
CropHandle.Top => (0, -1),
|
||||
CropHandle.TopRight => (1, -1),
|
||||
CropHandle.Right => (1, 0),
|
||||
CropHandle.BottomRight => (1, 1),
|
||||
CropHandle.Bottom => (0, 1),
|
||||
CropHandle.BottomLeft => (-1, 1),
|
||||
_ => (-1, 0),
|
||||
};
|
||||
var ax = aboutCentre || sx == 0 ? start.CenterX : sx > 0 ? start.X : start.Right;
|
||||
var ay = aboutCentre || sy == 0 ? start.CenterY : sy > 0 ? start.Y : start.Bottom;
|
||||
var reach = aboutCentre ? 2 : 1;
|
||||
// The height the pointer asks for along each moving axis; a corner takes the larger of the two.
|
||||
var fromX = sx == 0 ? 0 : double.Max(0, sx * (x - ax)) * reach / lockRatio;
|
||||
var fromY = sy == 0 ? 0 : double.Max(0, sy * (y - ay)) * reach;
|
||||
var height = sx == 0 ? fromY : sy == 0 ? fromX : double.Max(fromX, fromY);
|
||||
// The room around the anchor in each direction the box grows.
|
||||
double RoomX() => sx == 0 || aboutCentre ? 2 * double.Min(ax, 1 - ax) : sx > 0 ? 1 - ax : ax;
|
||||
double RoomY() => sy == 0 || aboutCentre ? 2 * double.Min(ay, 1 - ay) : sy > 0 ? 1 - ay : ay;
|
||||
var largest = Largest(lockRatio);
|
||||
var maxHeight = double.Min(double.Min(RoomY(), RoomX() / lockRatio), largest.Height);
|
||||
height = double.Clamp(height, double.Min(largest.Height * MinimumShare, maxHeight), maxHeight);
|
||||
var width = height * lockRatio;
|
||||
var left = aboutCentre || sx == 0 ? ax - width / 2 : sx > 0 ? ax : ax - width;
|
||||
var top = aboutCentre || sy == 0 ? ay - height / 2 : sy > 0 ? ay : ay - height;
|
||||
return Placed(left, top, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="box"/> for new proportions (an aspect change): the same centre, the same area where it fits, the new
|
||||
/// ratio, kept inside [0,1]².
|
||||
/// </summary>
|
||||
public static RectD Refit(RectD box, double lockRatio) => Clamp(box, lockRatio);
|
||||
|
||||
/// <summary>
|
||||
/// The Camera step's rows for a box: its size as a share of <see cref="Largest"/> (0.1..1), and its centre within the
|
||||
/// slack per axis (−1 = left/top, 0 = centred, +1 = right/bottom; 0 where there is no slack).
|
||||
/// </summary>
|
||||
public static (double Size, double X, double Y) ToRows(RectD box, double lockRatio)
|
||||
{
|
||||
var largest = Largest(lockRatio);
|
||||
var size = double.Clamp(box.Height / largest.Height, MinimumShare, 1);
|
||||
static double Place(double start, double length) => 1 - length > 1e-9 ? double.Clamp(2 * start / (1 - length) - 1, -1, 1) : 0;
|
||||
return (size, Place(box.X, box.Width), Place(box.Y, box.Height));
|
||||
}
|
||||
|
||||
/// <summary>The box of the Camera step's rows (<see cref="ToRows"/>).</summary>
|
||||
public static RectD FromRows(double size, double x, double y, double lockRatio)
|
||||
{
|
||||
var largest = Largest(lockRatio);
|
||||
var share = double.Clamp(double.IsFinite(size) ? size : 1, MinimumShare, 1);
|
||||
var (width, height) = (largest.Width * share, largest.Height * share);
|
||||
static double Start(double place, double length) => (1 - length) * (1 + double.Clamp(double.IsFinite(place) ? place : 0, -1, 1)) / 2;
|
||||
return new RectD(Start(x, width), Start(y, height), width, height);
|
||||
}
|
||||
|
||||
/// <summary>The view has room for the box to move along x (<paramref name="horizontal"/>) or y.</summary>
|
||||
public static bool HasSlack(RectD box, bool horizontal) => (horizontal ? 1 - box.Width : 1 - box.Height) > 1e-9;
|
||||
|
||||
private static bool IsWhole(RectD box) => box.X <= 0 && box.Y <= 0 && box.Right >= 1 && box.Bottom >= 1;
|
||||
|
||||
/// <summary>A box of the given size moved inside [0,1]².</summary>
|
||||
private static RectD Placed(double left, double top, double width, double height) =>
|
||||
new(double.Clamp(left, 0, double.Max(0, 1 - width)), double.Clamp(top, 0, double.Max(0, 1 - height)), width, height);
|
||||
|
||||
private static double Checked(double lockRatio)
|
||||
{
|
||||
if (!(lockRatio > 0) || double.IsInfinity(lockRatio)) throw new ArgumentOutOfRangeException(nameof(lockRatio));
|
||||
return lockRatio;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using Chronos.Core.Project;
|
||||
|
||||
namespace Chronos.Core.Imaging.Geometry;
|
||||
|
||||
/// <summary>
|
||||
/// The view frame T of a camera (owner review 1, R6): the decoded (Exif-oriented, stabilised) frame of
|
||||
/// <see cref="FrameWidth"/>×<see cref="FrameHeight"/> turned by <see cref="Turns"/> quarter turns clockwise, then mirrored
|
||||
/// and flipped in screen axes, then straightened by <see cref="Straighten"/> degrees clockwise about its centre and
|
||||
/// magnified by <see cref="CoverZoom"/> so no border shows. <see cref="FrameToView"/> is <c>O = S · F · Q</c> in
|
||||
/// pixel-centre coordinates (<see cref="Affine2D"/>); the quarter turns and the mirror/flip are exact integer matrices, so
|
||||
/// an unstraightened view resamples to an exact permutation of the pixels. The crop and the keyframe centres are
|
||||
/// normalised in T. Pixels are never turned after decode: the render folds <see cref="ViewToFrame"/> into its single warp.
|
||||
/// </summary>
|
||||
public sealed record FrameOrientation
|
||||
{
|
||||
/// <summary>The largest straighten angle in degrees, either way.</summary>
|
||||
public const double MaxStraighten = 15;
|
||||
|
||||
private FrameOrientation(int turns, bool mirror, bool flip, double straighten, int frameWidth, int frameHeight)
|
||||
{
|
||||
Turns = turns;
|
||||
Mirror = mirror;
|
||||
Flip = flip;
|
||||
Straighten = straighten;
|
||||
FrameWidth = frameWidth;
|
||||
FrameHeight = frameHeight;
|
||||
(ViewWidth, ViewHeight) = turns % 2 == 1 ? (frameHeight, frameWidth) : (frameWidth, frameHeight);
|
||||
CoverZoom = CoverZoomOf(straighten, ViewWidth, ViewHeight);
|
||||
FrameToView = Straightening(1) * MirrorFlip() * QuarterTurns();
|
||||
ViewToFrame = QuarterTurns().Invert() * MirrorFlip() * Straightening(-1);
|
||||
}
|
||||
|
||||
/// <summary>Quarter turns clockwise, 0..3.</summary>
|
||||
public int Turns { get; }
|
||||
|
||||
/// <summary>Left and right swapped after the turns.</summary>
|
||||
public bool Mirror { get; }
|
||||
|
||||
/// <summary>Top and bottom swapped after the turns.</summary>
|
||||
public bool Flip { get; }
|
||||
|
||||
/// <summary>Degrees clockwise, within ±<see cref="MaxStraighten"/>.</summary>
|
||||
public double Straighten { get; }
|
||||
|
||||
/// <summary>The decoded frame's size in pixels.</summary>
|
||||
public int FrameWidth { get; }
|
||||
|
||||
public int FrameHeight { get; }
|
||||
|
||||
/// <summary>The view frame's size in pixels: the frame's, swapped for an odd number of turns.</summary>
|
||||
public int ViewWidth { get; }
|
||||
|
||||
public int ViewHeight { get; }
|
||||
|
||||
/// <summary>The straighten's cover zoom c = cos|θ| + max(W'/H', H'/W')·sin|θ| (1 without straighten); never stored.</summary>
|
||||
public double CoverZoom { get; }
|
||||
|
||||
/// <summary>Frame pixel-centre coordinates to view pixel-centre coordinates (O).</summary>
|
||||
public Affine2D FrameToView { get; }
|
||||
|
||||
/// <summary>View pixel-centre coordinates to frame pixel-centre coordinates (O⁻¹), for <see cref="GeometrySettings.Warp"/>.</summary>
|
||||
public Affine2D ViewToFrame { get; }
|
||||
|
||||
/// <summary>No turn, mirror, flip or straighten: the view is the frame.</summary>
|
||||
public bool IsIdentity => Turns == 0 && !Mirror && !Flip && Straighten == 0;
|
||||
|
||||
/// <summary>The orientation of <paramref name="camera"/> for a frame of the given size, its values normalised (<see cref="TurnsOf"/>, <see cref="StraightenOf"/>).</summary>
|
||||
public static FrameOrientation Of(CameraSettings camera, int frameWidth, int frameHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
return Of(camera.Rotate, camera.Mirror, camera.Flip, camera.Straighten, frameWidth, frameHeight);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Of(CameraSettings, int, int)"/>
|
||||
public static FrameOrientation Of(int rotate, bool mirror, bool flip, double straighten, int frameWidth, int frameHeight)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameWidth);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameHeight);
|
||||
return new FrameOrientation(TurnsOf(rotate), mirror, flip, StraightenOf(straighten), frameWidth, frameHeight);
|
||||
}
|
||||
|
||||
/// <summary>The identity orientation of a frame of the given size.</summary>
|
||||
public static FrameOrientation Identity(int frameWidth, int frameHeight) => Of(0, false, false, 0, frameWidth, frameHeight);
|
||||
|
||||
/// <summary>The same orientation for a frame of another size (a decode at another long edge).</summary>
|
||||
public FrameOrientation Resized(int frameWidth, int frameHeight) => frameWidth == FrameWidth && frameHeight == FrameHeight
|
||||
? this
|
||||
: Of(Turns * 90, Mirror, Flip, Straighten, frameWidth, frameHeight);
|
||||
|
||||
/// <summary>A rotation stored in degrees is a multiple of 90 (anything else renders as no turn).</summary>
|
||||
public static bool IsValidRotate(int rotate) => rotate % 90 == 0;
|
||||
|
||||
/// <summary>Quarter turns clockwise, 0..3, of a rotation in degrees; 0 when it is not a multiple of 90.</summary>
|
||||
public static int TurnsOf(int rotate) => IsValidRotate(rotate) ? ((rotate / 90 % 4) + 4) % 4 : 0;
|
||||
|
||||
/// <summary>A straighten angle as rendered: clamped to ±<see cref="MaxStraighten"/>, 0 when not finite.</summary>
|
||||
public static double StraightenOf(double degrees) => double.IsFinite(degrees) ? double.Clamp(degrees, -MaxStraighten, MaxStraighten) : 0;
|
||||
|
||||
/// <summary>The angle is rendered as stored (finite and within ±<see cref="MaxStraighten"/>).</summary>
|
||||
public static bool IsValidStraighten(double degrees) => double.IsFinite(degrees) && double.Abs(degrees) <= MaxStraighten;
|
||||
|
||||
/// <summary>
|
||||
/// The smallest zoom about the centre at which a view of <paramref name="viewWidth"/>×<paramref name="viewHeight"/>
|
||||
/// rotated by <paramref name="degrees"/> still covers the whole view: cos|θ| + max(W/H, H/W)·sin|θ|.
|
||||
/// </summary>
|
||||
public static double CoverZoomOf(double degrees, double viewWidth, double viewHeight)
|
||||
{
|
||||
if (degrees == 0) return 1;
|
||||
var (sin, cos) = double.SinCos(double.Abs(degrees) * double.Pi / 180);
|
||||
return cos + double.Max(viewWidth / viewHeight, viewHeight / viewWidth) * sin;
|
||||
}
|
||||
|
||||
/// <summary>Q: the quarter turns, frame → turned frame, exact.</summary>
|
||||
private Affine2D QuarterTurns() => Turns switch
|
||||
{
|
||||
1 => new Affine2D(0, -1, 1, 0, FrameHeight - 1, 0),
|
||||
2 => new Affine2D(-1, 0, 0, -1, FrameWidth - 1, FrameHeight - 1),
|
||||
3 => new Affine2D(0, 1, -1, 0, 0, FrameWidth - 1),
|
||||
_ => Affine2D.Identity,
|
||||
};
|
||||
|
||||
/// <summary>F: mirror and flip in the turned frame, exact (its own inverse).</summary>
|
||||
private Affine2D MirrorFlip() => new(Mirror ? -1 : 1, 0, 0, Flip ? -1 : 1, Mirror ? ViewWidth - 1 : 0, Flip ? ViewHeight - 1 : 0);
|
||||
|
||||
/// <summary>S (<paramref name="direction"/> 1) or S⁻¹ (−1): the straighten and its cover zoom about the view's centre.</summary>
|
||||
private Affine2D Straightening(int direction)
|
||||
{
|
||||
if (Straighten == 0) return Affine2D.Identity;
|
||||
var scale = direction > 0 ? CoverZoom : 1 / CoverZoom;
|
||||
return Affine2D.About(Affine2D.Similarity(scale, direction * Straighten * double.Pi / 180, 0, 0), (ViewWidth - 1) / 2.0, (ViewHeight - 1) / 2.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using Chronos.Core.Project;
|
||||
|
||||
namespace Chronos.Core.Imaging.Geometry;
|
||||
|
||||
/// <summary>One press of the Camera step's orientation controls, as the user sees the picture (owner review 1, R6).</summary>
|
||||
public enum OrientationOp
|
||||
{
|
||||
/// <summary>A quarter turn anticlockwise on screen.</summary>
|
||||
RotateLeft,
|
||||
|
||||
/// <summary>A quarter turn clockwise on screen.</summary>
|
||||
RotateRight,
|
||||
|
||||
/// <summary>Left and right swapped on screen.</summary>
|
||||
Mirror,
|
||||
|
||||
/// <summary>Top and bottom swapped on screen.</summary>
|
||||
Flip,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies an orientation press to a camera so the content stays framed (owner review 1, R6): the picture as shown turns
|
||||
/// or mirrors, and the crop, its offsets and the keyframe centres (normalised in the view frame) move with it. A quarter
|
||||
/// turn transposes a non-square aspect (the manual value, or the Auto's advised one: 16:9 becomes 9:16); its stored
|
||||
/// direction is inverted while exactly one of mirror and flip is set, as a mirror reverses the sense of a turn. Mirror and
|
||||
/// flip toggle their member, negate the straighten (a mirrored level horizon stays level) and the keyframe rolls. Each
|
||||
/// press is one edit (one undo step).
|
||||
/// </summary>
|
||||
public static class OrientationEdit
|
||||
{
|
||||
/// <summary>The camera after <paramref name="op"/>.</summary>
|
||||
public static CameraSettings Apply(CameraSettings camera, OrientationOp op)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
var map = PointMap(op);
|
||||
var turn = op is OrientationOp.RotateLeft or OrientationOp.RotateRight;
|
||||
var mirrored = op is OrientationOp.Mirror or OrientationOp.Flip;
|
||||
var result = camera with
|
||||
{
|
||||
Crop = camera.Crop is { Length: 4 } crop ? Remap(crop, op) : camera.Crop,
|
||||
OffsetX = op switch
|
||||
{
|
||||
OrientationOp.RotateRight => Negated(camera.OffsetY),
|
||||
OrientationOp.RotateLeft => camera.OffsetY,
|
||||
OrientationOp.Mirror => Negated(camera.OffsetX),
|
||||
_ => camera.OffsetX,
|
||||
},
|
||||
OffsetY = op switch
|
||||
{
|
||||
OrientationOp.RotateRight => camera.OffsetX,
|
||||
OrientationOp.RotateLeft => Negated(camera.OffsetX),
|
||||
OrientationOp.Flip => Negated(camera.OffsetY),
|
||||
_ => camera.OffsetY,
|
||||
},
|
||||
Keyframes = [.. camera.Keyframes.Select(k => Remap(k, map, mirrored))],
|
||||
Aspect = turn ? Transposed(camera.Aspect) : camera.Aspect,
|
||||
};
|
||||
if (turn)
|
||||
{
|
||||
// A turn seen through one mirror is the opposite turn of the stored (unmirrored) picture.
|
||||
var clockwise = (op == OrientationOp.RotateRight) ^ (camera.Mirror ^ camera.Flip);
|
||||
var turns = (FrameOrientation.TurnsOf(camera.Rotate) + (clockwise ? 1 : 3)) % 4;
|
||||
return result with { Rotate = turns * 90 };
|
||||
}
|
||||
return op == OrientationOp.Mirror
|
||||
? result with { Mirror = !camera.Mirror, Straighten = Negated(camera.Straighten) }
|
||||
: result with { Flip = !camera.Flip, Straighten = Negated(camera.Straighten) };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The project after <paramref name="op"/>: <see cref="Apply(CameraSettings, OrientationOp)"/>, and the keyframes
|
||||
/// parked on photos this copy does not hold (<see cref="ProjectSettings.PendingFrames"/>) moved the same way.
|
||||
/// </summary>
|
||||
public static ProjectSettings Apply(ProjectSettings project, OrientationOp op)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
var map = PointMap(op);
|
||||
var mirrored = op is OrientationOp.Mirror or OrientationOp.Flip;
|
||||
return project with
|
||||
{
|
||||
Camera = Apply(project.Camera, op),
|
||||
PendingFrames = project.PendingFrames is { } pending
|
||||
? [.. pending.Select(p => p.Keyframes is { Count: > 0 } keys ? p with { Keyframes = [.. keys.Select(k => Remap(k, map, mirrored))] } : p)]
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>A normalised point of the view before <paramref name="op"/> in the view after it.</summary>
|
||||
public static (double X, double Y) MapPoint(double x, double y, OrientationOp op) => PointMap(op)(x, y);
|
||||
|
||||
/// <summary>A normalised [x, y, w, h] crop of the view before <paramref name="op"/> in the view after it.</summary>
|
||||
public static double[] Remap(double[] crop, OrientationOp op)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(crop);
|
||||
if (crop is not [var x, var y, var w, var h]) return crop;
|
||||
return op switch
|
||||
{
|
||||
OrientationOp.RotateRight => [Clean(1 - y - h), x, h, w],
|
||||
OrientationOp.RotateLeft => [y, Clean(1 - x - w), h, w],
|
||||
OrientationOp.Mirror => [Clean(1 - x - w), y, w, h],
|
||||
_ => [x, Clean(1 - y - h), w, h],
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>A non-square aspect transposed ("16:9" → "9:16"): the manual value and the advised one; "source" and text it cannot read stay.</summary>
|
||||
public static Auto<string> Transposed(Auto<string> aspect)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(aspect);
|
||||
return aspect with { Manual = Transposed(aspect.Manual), AutoValue = Transposed(aspect.AutoValue) };
|
||||
}
|
||||
|
||||
private static string? Transposed(string? text) =>
|
||||
AspectRatio.TryParse(text, out var ratio) && !ratio.IsSource && ratio.Width != ratio.Height ? AspectRatio.Custom(ratio.Height, ratio.Width).ToString() : text;
|
||||
|
||||
private static Func<double, double, (double X, double Y)> PointMap(OrientationOp op) => op switch
|
||||
{
|
||||
OrientationOp.RotateRight => (x, y) => (Clean(1 - y), x),
|
||||
OrientationOp.RotateLeft => (x, y) => (y, Clean(1 - x)),
|
||||
OrientationOp.Mirror => (x, y) => (Clean(1 - x), y),
|
||||
_ => (x, y) => (x, Clean(1 - y)),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A remapped coordinate rounded to 12 decimals, so that undoing a press (four turns, two mirrors) gives back the stored
|
||||
/// value and the same canonical text rather than one a rounding error away.
|
||||
/// </summary>
|
||||
private static double Clean(double value) => double.Round(value, 12);
|
||||
|
||||
/// <summary>The value negated, never −0 (which JSON would write as "-0").</summary>
|
||||
private static double Negated(double value) => value == 0 ? 0 : -value;
|
||||
|
||||
private static CameraKey Remap(CameraKey key, Func<double, double, (double X, double Y)> map, bool mirrored)
|
||||
{
|
||||
var (x, y) = map(key.CenterX, key.CenterY);
|
||||
return key with { CenterX = x, CenterY = y, Rotation = mirrored ? Negated(key.Rotation) : key.Rotation };
|
||||
}
|
||||
}
|
||||
@@ -238,17 +238,17 @@ public static class ProjectContent
|
||||
/// <summary>The settings format (<see cref="ProjectSettings.Version"/>) a project's text declares; 1 when it says none or is not a project.</summary>
|
||||
public static int FormatOf(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return ProjectSettings.CurrentVersion;
|
||||
if (string.IsNullOrWhiteSpace(json)) return ProjectSettings.BaseVersion;
|
||||
try
|
||||
{
|
||||
return JsonNode.Parse(json, new JsonNodeOptions { PropertyNameCaseInsensitive = true }) is JsonObject project
|
||||
&& project["version"] is JsonValue value && value.TryGetValue<int>(out var version) && version > 0
|
||||
? version
|
||||
: ProjectSettings.CurrentVersion;
|
||||
: ProjectSettings.BaseVersion;
|
||||
}
|
||||
catch (Exception ex) when (ex is JsonException or ArgumentException)
|
||||
{
|
||||
return ProjectSettings.CurrentVersion;
|
||||
return ProjectSettings.BaseVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,16 +164,59 @@ public sealed record MotionSettings
|
||||
|
||||
public sealed record CameraSettings
|
||||
{
|
||||
/// <summary>Normalised crop (0..1) or null for the full frame.</summary>
|
||||
/// <summary>
|
||||
/// Normalised [x, y, width, height] of the view frame (oriented, straightened and cover-zoomed: see
|
||||
/// <see cref="Rotate"/>), or null for the whole view. The editor writes the box locked to <see cref="Aspect"/> with
|
||||
/// the offsets at 0; the render fits any other rectangle to the aspect.
|
||||
/// </summary>
|
||||
public double[]? Crop { get; init; }
|
||||
|
||||
/// <summary>"source", "16:9", "21:9", "4:3", "3:2", "1:1", "9:16", "4:5" or "w:h".</summary>
|
||||
/// <summary>
|
||||
/// The output proportions: "source", "16:9", "21:9", "4:3", "3:2", "1:1", "9:16", "4:5" or "w:h". A preset of a fixed
|
||||
/// size adapts its size to them (4K at 9:16 = 2160×3840); "source" keeps the preset's own.
|
||||
/// </summary>
|
||||
public Auto<string> Aspect { get; init; } = new();
|
||||
|
||||
/// <summary>Placement of the aspect-fitted crop inside <see cref="Crop"/>, −1..1 per axis; 0 for a crop the editor wrote.</summary>
|
||||
public double OffsetX { get; init; }
|
||||
|
||||
/// <inheritdoc cref="OffsetX"/>
|
||||
public double OffsetY { get; init; }
|
||||
|
||||
/// <summary>Virtual-camera keyframes; their centres are normalised in the view frame, like <see cref="Crop"/>.</summary>
|
||||
public IReadOnlyList<CameraKey> Keyframes { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Quarter turns of the picture in degrees clockwise (0, 90, 180 or 270), after the Exif orientation applied at decode.
|
||||
/// A value that is not a multiple of 90 renders as 0 (<c>Export.Render.RotationIgnored</c>). Settings format 2.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public int Rotate { get; init; }
|
||||
|
||||
/// <summary>Left and right swapped, in screen axes after <see cref="Rotate"/>. Settings format 2.</summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public bool Mirror { get; init; }
|
||||
|
||||
/// <summary>Top and bottom swapped, in screen axes after <see cref="Rotate"/>. Settings format 2.</summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public bool Flip { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Free-angle levelling in degrees, positive clockwise, after <see cref="Mirror"/> and <see cref="Flip"/>, with an
|
||||
/// automatic cover zoom (never stored) that never shows a border. Clamped to ±15, a value that is not finite counting as
|
||||
/// 0 (<c>Export.Render.StraightenClamped</c>). Settings format 2.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public double Straighten { get; init; }
|
||||
|
||||
/// <summary>Quarter turns clockwise, 0..3; meaningful only when <see cref="Rotate"/> is a multiple of 90.</summary>
|
||||
[JsonIgnore]
|
||||
public int Turns => ((Rotate / 90 % 4) + 4) % 4;
|
||||
|
||||
/// <summary>A turn, mirror, flip or straighten is set: the view frame differs from the decoded frame.</summary>
|
||||
[JsonIgnore]
|
||||
public bool IsOriented => Rotate % 360 != 0 || Mirror || Flip || Straighten != 0;
|
||||
|
||||
/// <summary>Members this Chronos does not know (written by a newer one): kept as they are, so they survive a round trip.</summary>
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, JsonElement>? Extra { get; set; }
|
||||
@@ -240,13 +283,50 @@ public sealed record ExportSettings
|
||||
public Dictionary<string, JsonElement>? Extra { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The colour look of a render (owner review 1, R6): a built-in parametric filter blended by its strength, applied to
|
||||
/// every output frame in linear light before the highlight knee. <see cref="ProjectSettings.Look"/> is null for none.
|
||||
/// </summary>
|
||||
public sealed record LookSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// The filter's name: null or "none", "mono", "sepia", "warm", "cool", "vivid", "muted" or "fade"
|
||||
/// (<c>LookFilter.Names</c>). A text, not an enum, so a newer Chronos can add looks; one this Chronos does not know
|
||||
/// renders as none (<c>Export.Render.LookIgnored</c>).
|
||||
/// </summary>
|
||||
public string? Filter { get; init; }
|
||||
|
||||
/// <summary>Share of the filter applied, 0..1; null for 1.</summary>
|
||||
public double? Strength { get; init; }
|
||||
|
||||
/// <summary>The look leaves the picture as it is.</summary>
|
||||
[JsonIgnore]
|
||||
public bool IsIdentity => Filter is null or "none" || Strength is <= 0;
|
||||
|
||||
/// <summary>Members this Chronos does not know (written by a newer one): kept as they are, so they survive a round trip.</summary>
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, JsonElement>? Extra { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "project" of a sequence (<c>.chronos/project.json</c>, BRIEF §7): every render decision. Originals are
|
||||
/// never modified; all edits live here.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The settings format (<see cref="Version"/>) is conditional: <see cref="ToJson"/> writes the lowest format that renders
|
||||
/// the same (<see cref="RequiredFormat"/>), so a project that uses nothing newer keeps format 1, its canonical text and its
|
||||
/// hash, and older builds read it as before. Rules for a member added later: one that changes pixels and that the previous
|
||||
/// format would ignore raises the written format only while it is used; it is declared after the existing members of its
|
||||
/// section (before <c>Extra</c>) and omitted at its default, so an older build keeps it in <c>Extra</c> and writes it
|
||||
/// back in the same place; a list of choices that may grow is a text, never an enum.
|
||||
/// </remarks>
|
||||
public sealed record ProjectSettings
|
||||
{
|
||||
public const int CurrentVersion = 1;
|
||||
/// <summary>The highest settings format this Chronos reads; a project of a higher one opens read-only (<see cref="IsNewerFormat"/>).</summary>
|
||||
public const int CurrentVersion = 2;
|
||||
|
||||
/// <summary>The format of a project that uses nothing added since the first one, which most projects are written as.</summary>
|
||||
public const int BaseVersion = 1;
|
||||
|
||||
/// <summary>Layout of a project edited as JSON (<see cref="MoveFramePositions"/>): indented like <see cref="ToJson"/>.</summary>
|
||||
private static readonly JsonSerializerOptions IndentedJson = new() { WriteIndented = true };
|
||||
@@ -254,7 +334,8 @@ public sealed record ProjectSettings
|
||||
/// <summary>Member names as a project edited as JSON reads them (an older or hand-written file may use any casing).</summary>
|
||||
private static readonly JsonNodeOptions CaseInsensitive = new() { PropertyNameCaseInsensitive = true };
|
||||
|
||||
public int Version { get; init; } = CurrentVersion;
|
||||
/// <summary>The settings format read; <see cref="ToJson"/> writes <see cref="WrittenFormat"/>.</summary>
|
||||
public int Version { get; init; } = BaseVersion;
|
||||
public TimingSettings Timing { get; init; } = new();
|
||||
public ExposureSettings Exposure { get; init; } = new();
|
||||
public MotionSettings Motion { get; init; } = new();
|
||||
@@ -274,6 +355,9 @@ public sealed record ProjectSettings
|
||||
/// </summary>
|
||||
public IReadOnlyList<PendingFrame>? PendingFrames { get; init; }
|
||||
|
||||
/// <summary>The colour look (owner review 1, R6); null for none, which the editor writes whenever the look is the identity.</summary>
|
||||
public LookSettings? Look { get; init; }
|
||||
|
||||
/// <summary>The hero waits for its photo, so advice does not choose one meanwhile.</summary>
|
||||
[JsonIgnore]
|
||||
public bool HeroPending => PendingFrames?.Any(p => p.Hero) == true;
|
||||
@@ -292,7 +376,22 @@ public sealed record ProjectSettings
|
||||
[JsonIgnore]
|
||||
public bool IsNewerFormat => Version > CurrentVersion;
|
||||
|
||||
public string ToJson() => JsonSerializer.Serialize(this, ProjectJson.Default.ProjectSettings);
|
||||
/// <summary>
|
||||
/// The lowest settings format that renders these settings the same: 2 while a turn, mirror, flip or straighten
|
||||
/// (<see cref="CameraSettings.IsOriented"/>) or a look other than the identity is set, otherwise <see cref="BaseVersion"/>.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public int RequiredFormat => Camera.IsOriented || Look is { IsIdentity: false } ? 2 : BaseVersion;
|
||||
|
||||
/// <summary>The format <see cref="ToJson"/> writes: <see cref="RequiredFormat"/>, or a newer format read, kept as it is.</summary>
|
||||
[JsonIgnore]
|
||||
public int WrittenFormat => IsNewerFormat ? Version : RequiredFormat;
|
||||
|
||||
/// <summary>
|
||||
/// The settings as JSON, stamped with <see cref="WrittenFormat"/>. Every serialisation of a project goes through here,
|
||||
/// so the version written always matches the members used.
|
||||
/// </summary>
|
||||
public string ToJson() => JsonSerializer.Serialize(Version == WrittenFormat ? this : this with { Version = WrittenFormat }, ProjectJson.Default.ProjectSettings);
|
||||
|
||||
/// <summary>
|
||||
/// Reads a project; members missing from <paramref name="json"/> (an API client's partial settings, an older file)
|
||||
|
||||
@@ -50,7 +50,8 @@ public sealed record SelfTestOptions
|
||||
/// </summary>
|
||||
public static partial class SelfTest
|
||||
{
|
||||
public static IReadOnlyList<SelfTestCheck> Checks { get; } = [.. PlanChecks(), .. ExportChecks(), .. CodecChecks(), .. RenderChecks(), .. ProcessingChecks(), .. RobustnessChecks()];
|
||||
public static IReadOnlyList<SelfTestCheck> Checks { get; } = [.. PlanChecks(), .. ExportChecks(), .. CodecChecks(), .. RenderChecks(), .. ProcessingChecks(), .. GeometryChecks(),
|
||||
.. ColourChecks(), .. RobustnessChecks()];
|
||||
|
||||
public static async Task<IReadOnlyList<SelfTestResult>> RunAsync(SelfTestOptions? options = null, IProgress<SelfTestResult>? progress = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Chronos.Core.Render.Diagnostics;
|
||||
|
||||
/// <summary>Colour look checks (owner review 1, R6).</summary>
|
||||
public static partial class SelfTest
|
||||
{
|
||||
private static IEnumerable<SelfTestCheck> ColourChecks() => [];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Chronos.Core.Render.Diagnostics;
|
||||
|
||||
/// <summary>Orientation, straighten and output-proportion checks (owner review 1, R5/R6).</summary>
|
||||
public static partial class SelfTest
|
||||
{
|
||||
private static IEnumerable<SelfTestCheck> GeometryChecks() => [];
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Globalization;
|
||||
using Chronos.Core.Analysis;
|
||||
using Chronos.Core.Imaging;
|
||||
using Chronos.Core.Imaging.Color;
|
||||
using Chronos.Core.Project;
|
||||
|
||||
namespace Chronos.Core.Render;
|
||||
|
||||
/// <summary>
|
||||
/// The last pixel step of every output frame (owner review 1, R6), shared by the render, the editor's preview, the server
|
||||
/// and the render nodes: the colour look (<see cref="LookFilter"/>) and then the highlight knee, in linear light, after
|
||||
/// stacking, interpolation and motion blur and before the encoder. The knee comes last so it compresses any overshoot the
|
||||
/// look leaves. Measuring, flow and stacking never see either.
|
||||
/// </summary>
|
||||
public static class FrameFinish
|
||||
{
|
||||
/// <summary>
|
||||
/// The knee a render applies: <paramref name="highlightKnee"/> when it lies in (0, 1), else none, with
|
||||
/// <c>Export.Render.KneeIgnored</c> added to <paramref name="warnings"/> for a value out of range.
|
||||
/// </summary>
|
||||
public static double? Knee(double? highlightKnee, ICollection<RenderWarning>? warnings = null)
|
||||
{
|
||||
if (highlightKnee is not { } knee) return null;
|
||||
if (knee is > 0 and < 1) return knee;
|
||||
warnings?.Add(new RenderWarning("Export.Render.KneeIgnored", knee.ToString(CultureInfo.InvariantCulture)));
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The look a render applies: null for none, the identity, or a filter this Chronos does not know, which adds
|
||||
/// <c>Export.Render.LookIgnored</c> to <paramref name="warnings"/>.
|
||||
/// </summary>
|
||||
public static LookSettings? Look(LookSettings? look, ICollection<RenderWarning>? warnings = null)
|
||||
{
|
||||
if (look is null || look.IsIdentity) return null;
|
||||
if (LookFilter.IsKnown(look.Filter)) return look;
|
||||
warnings?.Add(new RenderWarning("Export.Render.LookIgnored", look.Filter ?? string.Empty));
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>The share of a look applied: its strength clamped to 0..1, 1 when not given (or not finite).</summary>
|
||||
public static double Strength(LookSettings look)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(look);
|
||||
return look.Strength is { } strength && double.IsFinite(strength) ? double.Clamp(strength, 0, 1) : 1;
|
||||
}
|
||||
|
||||
/// <summary>Neither a look nor a knee would change a frame.</summary>
|
||||
public static bool IsIdentity(LookSettings? look, double? knee) => (look is null || look.IsIdentity || !LookFilter.IsKnown(look.Filter)) && knee is not (> 0 and < 1);
|
||||
|
||||
/// <summary>
|
||||
/// Finishes a linear-light output <paramref name="frame"/> in place: <paramref name="look"/> (none when null, the
|
||||
/// identity or unknown), then the soft highlight knee when <paramref name="knee"/> lies in (0, 1).
|
||||
/// </summary>
|
||||
public static void Apply(ImageBuffer frame, LookSettings? look, double? knee)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(frame);
|
||||
if (look is { IsIdentity: false } && LookFilter.IsKnown(look.Filter)) LookFilter.Apply(frame, look.Filter, Strength(look));
|
||||
if (knee is > 0 and < 1 and var k) ExposureProcessor.Apply(frame, 0, null, k);
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,10 @@ public sealed class RenderGeometry
|
||||
private readonly int _maxWorkingLongEdge;
|
||||
|
||||
private RenderGeometry(VirtualCamera? camera, RectD crop, double offsetX, double offsetY, double stabilizationZoom, int sourceWidth, int sourceHeight,
|
||||
int outputWidth, int outputHeight, double fittedWidth, double fittedHeight, double maxZoom, int maxWorkingLongEdge, IReadOnlyList<RenderWarning> warnings)
|
||||
int outputWidth, int outputHeight, double fittedWidth, double fittedHeight, double maxZoom, int maxWorkingLongEdge, IReadOnlyList<RenderWarning> warnings,
|
||||
double outputRatio)
|
||||
{
|
||||
OutputRatio = outputRatio;
|
||||
_camera = camera;
|
||||
_crop = crop;
|
||||
_offsetX = offsetX;
|
||||
@@ -51,6 +53,30 @@ public sealed class RenderGeometry
|
||||
public int OutputWidth { get; }
|
||||
public int OutputHeight { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Width of the view frame T at full resolution (<see cref="FrameOrientation"/>): the source turned, mirrored and
|
||||
/// straightened. <see cref="CameraSettings.Crop"/> and the keyframe centres are normalised in it.
|
||||
/// </summary>
|
||||
public int ViewWidth => SourceWidth;
|
||||
|
||||
/// <inheritdoc cref="ViewWidth"/>
|
||||
public int ViewHeight => SourceHeight;
|
||||
|
||||
/// <summary>The output ratio (width / height) the crop is fitted to (<see cref="RenderSize.Ratio"/>), before rounding to whole pixels.</summary>
|
||||
public double OutputRatio { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The crop box's width over its height in normalised view units (<see cref="OutputRatio"/> × <see cref="ViewHeight"/> /
|
||||
/// <see cref="ViewWidth"/>): the lock ratio of <see cref="CropFrame"/>.
|
||||
/// </summary>
|
||||
public double LockRatio => OutputRatio * ViewHeight / ViewWidth;
|
||||
|
||||
/// <summary>
|
||||
/// The crop the editor shows and edits, normalised in the view frame and the same on every frame: the stored crop
|
||||
/// fitted to the output ratio and placed by the offsets (<see cref="CropFrame.Locked"/>).
|
||||
/// </summary>
|
||||
public RectD EditableCrop => AspectRatio.FitCrop(_crop, LockRatio, _offsetX, _offsetY);
|
||||
|
||||
/// <summary>Remarks about ignored camera values.</summary>
|
||||
public IReadOnlyList<RenderWarning> Warnings { get; }
|
||||
|
||||
@@ -112,14 +138,14 @@ public sealed class RenderGeometry
|
||||
var cameraPath = Camera(camera.Keyframes, warnings);
|
||||
var maxZoom = (cameraPath?.Keyframes.Max(k => k.Zoom) ?? 1) * stabilizationZoom;
|
||||
return new RenderGeometry(cameraPath, crop, camera.OffsetX, camera.OffsetY, stabilizationZoom, sourceWidth, sourceHeight, width, height,
|
||||
fitted.Width, fitted.Height, maxZoom, maxWorkingLongEdge, warnings);
|
||||
fitted.Width, fitted.Height, maxZoom, maxWorkingLongEdge, warnings, ratio);
|
||||
}
|
||||
|
||||
/// <summary>The same geometry rendering into a different output size (e.g. capped by the encoder).</summary>
|
||||
public RenderGeometry WithOutputSize(int width, int height) => width == OutputWidth && height == OutputHeight
|
||||
? this
|
||||
: new RenderGeometry(_camera, _crop, _offsetX, _offsetY, _stabilizationZoom, SourceWidth, SourceHeight, width, height, _fittedWidth, _fittedHeight,
|
||||
_maxZoom, _maxWorkingLongEdge, Warnings);
|
||||
_maxZoom, _maxWorkingLongEdge, Warnings, OutputRatio);
|
||||
|
||||
/// <summary>Camera pose at a (fractional) source position, including the stabilisation zoom.</summary>
|
||||
public CameraState PoseAt(double sourcePosition)
|
||||
@@ -146,6 +172,62 @@ public sealed class RenderGeometry
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The view frame→decoded frame map (O⁻¹, <see cref="FrameOrientation.ViewToFrame"/>) for a frame of
|
||||
/// <paramref name="frameWidth"/>×<paramref name="frameHeight"/> pixels, without stabilisation: what maps overlays
|
||||
/// drawn in frame pixels (the horizon, the region mask) into the view through its inverse.
|
||||
/// </summary>
|
||||
public Affine2D ViewToFrame(int frameWidth, int frameHeight)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameWidth);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameHeight);
|
||||
return Affine2D.Identity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The whole view frame of one decoded frame at <paramref name="outputWidth"/>×<paramref name="outputHeight"/>
|
||||
/// pixels, without crop, camera pose or stabilisation: the editor's Source framing of an oriented camera.
|
||||
/// </summary>
|
||||
public GeometrySettings ViewFor(int frameWidth, int frameHeight, int outputWidth, int outputHeight)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(outputWidth);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(outputHeight);
|
||||
return new GeometrySettings
|
||||
{
|
||||
Aspect = AspectRatio.Source,
|
||||
OutputWidth = outputWidth,
|
||||
OutputHeight = outputHeight,
|
||||
Warp = ViewToFrame(frameWidth, frameHeight),
|
||||
Border = BorderMode.Clamp,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The footprint of a planned output frame (<see cref="GeometryStage.Plan"/> of <see cref="For"/> on a frame of
|
||||
/// <paramref name="frameWidth"/>×<paramref name="frameHeight"/>) in the view frame: the bounding box of its warped
|
||||
/// corners, normalised and clamped to [0,1]²; the whole view without a plan. The Export step's crop mask.
|
||||
/// </summary>
|
||||
public RectD FootprintInView(GeometryPlan? plan, int frameWidth, int frameHeight)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameWidth);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(frameHeight);
|
||||
if (plan is not { } p) return new RectD(0, 0, 1, 1);
|
||||
var toView = ViewToFrame(frameWidth, frameHeight).Invert() * p.OutputToSource;
|
||||
double left = double.MaxValue, top = double.MaxValue, right = double.MinValue, bottom = double.MinValue;
|
||||
foreach (var (u, v) in new[] { (-0.5, -0.5), (p.OutputWidth - 0.5, -0.5), (-0.5, p.OutputHeight - 0.5), (p.OutputWidth - 0.5, p.OutputHeight - 0.5) })
|
||||
{
|
||||
var (x, y) = toView.Apply(u, v);
|
||||
(left, top, right, bottom) = (double.Min(left, x + 0.5), double.Min(top, y + 0.5), double.Max(right, x + 0.5), double.Max(bottom, y + 0.5));
|
||||
}
|
||||
var (viewWidth, viewHeight) = ViewSizeOf(frameWidth, frameHeight);
|
||||
left = double.Clamp(left / viewWidth, 0, 1);
|
||||
top = double.Clamp(top / viewHeight, 0, 1);
|
||||
return new RectD(left, top, double.Clamp(right / viewWidth, 0, 1) - left, double.Clamp(bottom / viewHeight, 0, 1) - top);
|
||||
}
|
||||
|
||||
/// <summary>The view frame's size for a decoded frame of the given size.</summary>
|
||||
private static (int Width, int Height) ViewSizeOf(int frameWidth, int frameHeight) => (frameWidth, frameHeight);
|
||||
|
||||
private static RectD NormalisedCrop(double[]? crop, List<RenderWarning> warnings)
|
||||
{
|
||||
var full = new RectD(0, 0, 1, 1);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Chronos.Core.Render;
|
||||
/// <see cref="IRenderFrameSource"/> at the working size; per-frame exposure corrections (deflicker, holy grail, white
|
||||
/// balance, regions) are applied; stabilisation, virtual camera and crop are resampled once to the output size;
|
||||
/// fractional positions are synthesised from the bidirectional flow; motion blur follows the flow with shutter-angle
|
||||
/// composition; stacking (median, mean, star trails) and the highlight knee come last, then the encoder. Encoding of a
|
||||
/// composition; stacking (median, mean, star trails) and the finish (look, then highlight knee: <see cref="FrameFinish"/>) come last, then the encoder. Encoding of a
|
||||
/// frame overlaps the processing of the next. Cancellation and failures leave no output behind (sessions delete their
|
||||
/// partial files on dispose) and every background task is awaited, so exceptions surface exactly once.
|
||||
/// </summary>
|
||||
@@ -111,7 +111,8 @@ internal sealed class RenderRun : IDisposable
|
||||
private readonly List<RenderWarning> _warnings = [];
|
||||
private readonly Stopwatch _clock = new();
|
||||
private readonly int _workingEdge;
|
||||
private readonly float? _knee;
|
||||
private readonly double? _knee;
|
||||
private readonly LookSettings? _look;
|
||||
private readonly double _targetShutter;
|
||||
private readonly FlowQuality _flowQuality;
|
||||
private OpticalFlowEngine? _flowEngine;
|
||||
@@ -131,12 +132,8 @@ internal sealed class RenderRun : IDisposable
|
||||
_geometry = setup.Geometry;
|
||||
_prepared = new PreparedFrameCache(int.Max(3, options.CacheFrames));
|
||||
_workingEdge = _geometry.WorkingLongEdge;
|
||||
var exposure = input.Project.Exposure;
|
||||
if (exposure.HighlightKnee is { } knee)
|
||||
{
|
||||
if (knee is > 0 and < 1) _knee = (float)knee;
|
||||
else _warnings.Add(new RenderWarning("Export.Render.KneeIgnored", knee.ToString(CultureInfo.InvariantCulture)));
|
||||
}
|
||||
_knee = FrameFinish.Knee(input.Project.Exposure.HighlightKnee, _warnings);
|
||||
_look = FrameFinish.Look(input.Project.Look, _warnings);
|
||||
var motion = input.Project.Motion;
|
||||
_targetShutter = double.Clamp(motion.TargetShutterAngle.Resolve(180.0), 0, 360);
|
||||
_flowQuality = motion.FlowQuality.Resolve(options.DefaultFlowQuality) switch
|
||||
@@ -403,14 +400,14 @@ internal sealed class RenderRun : IDisposable
|
||||
if (ev != 0 || (gains is { } g && g != ChannelGains.Identity)) ExposureProcessor.Apply(frame, ev, gains);
|
||||
}
|
||||
|
||||
/// <summary>Applies the knee and hands the frame to the encoder once the previous frame is encoded; owns <paramref name="frame"/>.</summary>
|
||||
/// <summary>Finishes the frame (look, then knee) and hands it to the encoder once the previous frame is encoded; owns <paramref name="frame"/>.</summary>
|
||||
private async Task EmitAsync(ImageBuffer frame, long duration90k)
|
||||
{
|
||||
ImageBuffer? preview = null;
|
||||
try
|
||||
{
|
||||
await FlushEncodingAsync().ConfigureAwait(false);
|
||||
if (_knee is { } knee) ExposureProcessor.Apply(frame, 0, null, knee);
|
||||
FrameFinish.Apply(frame, _look, _knee);
|
||||
_done++;
|
||||
if (_options.PreviewInterval > 0 && (_done - 1) % _options.PreviewInterval == 0) preview = Resampler.Thumbnail(frame, _options.PreviewLongEdge);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Project;
|
||||
|
||||
namespace Chronos.Core.Render;
|
||||
|
||||
/// <summary>
|
||||
/// What a render needs of the program that runs it (owner review 1, phase 4): the settings format a render node or server
|
||||
/// must read to render a job as this Chronos would. Computed for routing and gating only, never written into the settings.
|
||||
/// </summary>
|
||||
public static class RenderRules
|
||||
{
|
||||
/// <summary>
|
||||
/// The settings format a render of <paramref name="settings"/> with <paramref name="export"/> on a source of the given
|
||||
/// (Exif-oriented) size needs: the format the settings are written in (<see cref="ProjectSettings.WrittenFormat"/>), and
|
||||
/// at least 2 when the chosen proportions change a fixed-size preset's size (<see cref="RenderSize"/>), which a format-1
|
||||
/// program would render at the preset's own ratio.
|
||||
/// </summary>
|
||||
public static int RequiredFormat(ProjectSettings settings, ResolvedExport export, int sourceWidth, int sourceHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(settings);
|
||||
ArgumentNullException.ThrowIfNull(export);
|
||||
var format = settings.WrittenFormat;
|
||||
if (export.Width > 0 && export.Height > 0 && sourceWidth > 0 && sourceHeight > 0 && !RenderSize.IsSource(settings.Camera)
|
||||
&& RenderSize.Of(settings.Camera, export, sourceWidth, sourceHeight) != PresetSize(export))
|
||||
format = int.Max(format, 2);
|
||||
return format;
|
||||
}
|
||||
|
||||
/// <summary>A fixed-size preset's size as a format-1 program renders it (even for codecs that are not managed).</summary>
|
||||
private static (int Width, int Height) PresetSize(ResolvedExport export) =>
|
||||
RenderSize.Of(new CameraSettings(), export, 1, 1);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Video;
|
||||
|
||||
namespace Chronos.Core.Render;
|
||||
|
||||
/// <summary>
|
||||
/// The output size of a render (owner review 1, R5: "the chosen proportions win"), before the encoder caps it
|
||||
/// (<see cref="EncoderSelector"/>): one pure function shared by the render (<see cref="RenderGeometry"/>), the editor's
|
||||
/// Export step and the server's job routing.
|
||||
/// <list type="table">
|
||||
/// <item><term>Fixed-size preset, aspect not "source"</term><description>The aspect fitted in the preset's box, the box turned to portrait for a ratio below 1 (<see cref="Adapt"/>): 4K at 9:16 = 2160×3840.</description></item>
|
||||
/// <item><term>Fixed-size preset, "source"</term><description>The preset's size.</description></item>
|
||||
/// <item><term>One side given</term><description>The other side from the ratio.</description></item>
|
||||
/// <item><term>No side given</term><description>The aspect-fitted crop of the view, scaled down to the decode cap.</description></item>
|
||||
/// </list>
|
||||
/// Sizes are made even for codecs that are not managed (H.264, HEVC, AV1), and at least 2 (1 for managed codecs).
|
||||
/// </summary>
|
||||
public static class RenderSize
|
||||
{
|
||||
/// <summary>The output size of <paramref name="export"/> for <paramref name="camera"/> on a source of the given Exif-oriented size.</summary>
|
||||
/// <param name="maxWorkingLongEdge">Decode-size cap (0 = none); it also caps source-sized outputs, as in <see cref="RenderGeometry.Create"/>.</param>
|
||||
public static (int Width, int Height) Of(CameraSettings camera, ResolvedExport export, int sourceWidth, int sourceHeight, int maxWorkingLongEdge = 0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
ArgumentNullException.ThrowIfNull(export);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(sourceWidth);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(sourceHeight);
|
||||
var ratio = Ratio(camera, export, sourceWidth, sourceHeight);
|
||||
int width, height;
|
||||
if (export.Width > 0 && export.Height > 0) (width, height) = IsSource(camera) ? (export.Width, export.Height) : Adapt(export.Width, export.Height, ratio);
|
||||
else if (export.Width > 0) (width, height) = (export.Width, (int)double.Round(export.Width / ratio));
|
||||
else if (export.Height > 0) (width, height) = ((int)double.Round(export.Height * ratio), export.Height);
|
||||
else
|
||||
{
|
||||
var (viewWidth, viewHeight) = ViewSize(camera, sourceWidth, sourceHeight);
|
||||
var crop = CropFrame.Of(camera.Crop);
|
||||
var fitted = AspectRatio.FitCrop(new RectD(crop.X * viewWidth, crop.Y * viewHeight, crop.Width * viewWidth, crop.Height * viewHeight), ratio,
|
||||
camera.OffsetX, camera.OffsetY);
|
||||
var scale = maxWorkingLongEdge > 0 ? double.Min(1, maxWorkingLongEdge / double.Max(fitted.Width, fitted.Height)) : 1;
|
||||
(width, height) = ((int)double.Round(fitted.Width * scale), (int)double.Round(fitted.Height * scale));
|
||||
}
|
||||
var managed = VideoCodecInfo.IsManaged(export.Codec);
|
||||
if (!managed)
|
||||
{
|
||||
width &= ~1;
|
||||
height &= ~1;
|
||||
}
|
||||
return (int.Max(managed ? 1 : 2, width), int.Max(managed ? 1 : 2, height));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The output ratio (width / height) the crop is fitted to: the aspect's, or for "source" (and an aspect that cannot be
|
||||
/// read) the fixed-size preset's ratio, else the view's (the source turned by <see cref="CameraSettings.Rotate"/>).
|
||||
/// </summary>
|
||||
public static double Ratio(CameraSettings camera, ResolvedExport export, int sourceWidth, int sourceHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
ArgumentNullException.ThrowIfNull(export);
|
||||
if (Aspect(camera) is { IsSource: false } aspect) return aspect.Width / (double)aspect.Height;
|
||||
if (export.Width > 0 && export.Height > 0) return export.Width / (double)export.Height;
|
||||
var (viewWidth, viewHeight) = ViewSize(camera, sourceWidth, sourceHeight);
|
||||
return viewWidth / (double)viewHeight;
|
||||
}
|
||||
|
||||
/// <summary>The view frame's size for a source of the given size: swapped for an odd number of quarter turns.</summary>
|
||||
public static (int Width, int Height) ViewSize(CameraSettings camera, int sourceWidth, int sourceHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
return FrameOrientation.TurnsOf(camera.Rotate) % 2 == 1 ? (sourceHeight, sourceWidth) : (sourceWidth, sourceHeight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The largest size of <paramref name="ratio"/> inside the box <paramref name="boxWidth"/>×<paramref name="boxHeight"/>
|
||||
/// turned to landscape for a ratio of 1 or more and to portrait below 1, rounded to whole pixels: 3840×2160 gives
|
||||
/// 2160×3840 at 9:16, 2160×2160 at 1:1, 2160×2700 at 4:5 and 3840×1646 at 21:9; 1080×1920 gives 1920×1080 at 16:9.
|
||||
/// </summary>
|
||||
public static (int Width, int Height) Adapt(int boxWidth, int boxHeight, double ratio)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(boxWidth);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(boxHeight);
|
||||
if (!(ratio > 0) || double.IsInfinity(ratio)) throw new ArgumentOutOfRangeException(nameof(ratio));
|
||||
var (longEdge, shortEdge) = (int.Max(boxWidth, boxHeight), int.Min(boxWidth, boxHeight));
|
||||
var (width, height) = ratio < 1 ? (shortEdge, longEdge) : (longEdge, shortEdge);
|
||||
return width / (double)height > ratio
|
||||
? (int.Max(1, (int)double.Round(height * ratio)), height)
|
||||
: (width, int.Max(1, (int)double.Round(width / ratio)));
|
||||
}
|
||||
|
||||
/// <summary>The camera's aspect resolves to "source" (or to text that cannot be read, which renders as source).</summary>
|
||||
public static bool IsSource(CameraSettings camera) => Aspect(camera) is not { IsSource: false };
|
||||
|
||||
private static AspectRatio? Aspect(CameraSettings camera) =>
|
||||
AspectRatio.TryParse(camera.Aspect.Resolve("source"), out var aspect) ? aspect : null;
|
||||
}
|
||||
@@ -13,6 +13,10 @@ public sealed record ServerLimits(long MaxUploadBytes, int ChunkSizeBytes, int P
|
||||
/// File extensions the archive files as photos (lower case, no dot): the admin panel's upload dialog offers and sends only
|
||||
/// these (owner review 2, R3). Null from servers that do not announce them.
|
||||
/// </param>
|
||||
/// <param name="SettingsFormat">
|
||||
/// The highest project settings format the server reads and renders (<c>ProjectSettings.CurrentVersion</c>, owner review 1,
|
||||
/// phase 4); null from an older server, which reads format 1 only. The desktop holds back a push or a render that needs more.
|
||||
/// </param>
|
||||
public sealed record ServerInfo(
|
||||
string Name,
|
||||
string Version,
|
||||
@@ -21,7 +25,8 @@ public sealed record ServerInfo(
|
||||
string? TlsFingerprint,
|
||||
IReadOnlyList<string> Formats,
|
||||
ServerLimits Limits,
|
||||
IReadOnlyList<string>? Extensions = null);
|
||||
IReadOnlyList<string>? Extensions = null,
|
||||
int? SettingsFormat = null);
|
||||
|
||||
/// <summary>Names of <see cref="ServerInfo.Capabilities"/> that clients act on.</summary>
|
||||
public static class ServerCapabilities
|
||||
|
||||
@@ -28,7 +28,11 @@ public sealed record CreateJobRequest(string Kind, IReadOnlyList<Guid> Target, s
|
||||
/// <c>POST /api/v1/nodes/register</c>: a client offers its GPU encoders (BRIEF §14.7). <see cref="MaxWidth"/> ×
|
||||
/// <see cref="MaxHeight"/> is the largest output of any of them, for encoders that announce no limit of their own.
|
||||
/// </summary>
|
||||
public sealed record RegisterNodeRequest(string ClientName, IReadOnlyList<NodeEncoder> Encoders, int MaxWidth, int MaxHeight);
|
||||
/// <param name="SettingsFormat">
|
||||
/// The highest project settings format the node renders (<c>ProjectSettings.CurrentVersion</c>); 1 from an older node,
|
||||
/// which is then never given a job that needs more (<see cref="RenderJobParameters.RequiredSettingsFormat"/>).
|
||||
/// </param>
|
||||
public sealed record RegisterNodeRequest(string ClientName, IReadOnlyList<NodeEncoder> Encoders, int MaxWidth, int MaxHeight, int SettingsFormat = 1);
|
||||
|
||||
/// <summary>
|
||||
/// One encoder of a render node. <see cref="MaxWidth"/> × <see cref="MaxHeight"/> is its largest output (0 = not announced:
|
||||
@@ -59,8 +63,13 @@ public sealed record JobPriorityRequest(string Priority);
|
||||
/// frames before the render.</param>
|
||||
/// <param name="ProjectId">The project whose version is rendered (owner review 2, R8); recorded with the render.</param>
|
||||
/// <param name="ProjectVersionId">The project version rendered; recorded with the render.</param>
|
||||
/// <param name="RequiredSettingsFormat">
|
||||
/// The settings format a program must read to render the job as asked (<c>RenderRules.RequiredFormat</c>: the settings'
|
||||
/// format, at least 2 when the chosen proportions change a fixed preset's size); 1 in a job of an older server. A hint for
|
||||
/// routing: a node recomputes it from the settings it claims.
|
||||
/// </param>
|
||||
public sealed record RenderJobParameters(string PresetName, string PresetJson, string Codec, int Width, int Height, bool UseProxies, string? SettingsJson,
|
||||
Guid? ProjectId = null, Guid? ProjectVersionId = null);
|
||||
Guid? ProjectId = null, Guid? ProjectVersionId = null, int RequiredSettingsFormat = 1);
|
||||
|
||||
/// <summary>
|
||||
/// <c>POST /api/v1/nodes/{id}/jobs/{jobId}/result</c>: the finished output a node is about to upload in chunks. A
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<ui:IconData x:Key="Icon.Eye" Stroke="M1.5 8 C3.5 4 12.5 4 14.5 8 C12.5 12 3.5 12 1.5 8 Z M5.8 8 A2.2 2.2 0 1 0 10.2 8 A2.2 2.2 0 1 0 5.8 8 Z" />
|
||||
<ui:IconData x:Key="Icon.Filmstrip" Stroke="M3.0 2.5 H13.0 A1.5 1.5 0 0 1 14.5 4.0 V12.0 A1.5 1.5 0 0 1 13.0 13.5 H3.0 A1.5 1.5 0 0 1 1.5 12.0 V4.0 A1.5 1.5 0 0 1 3.0 2.5 Z M4.5 2.5 V13.5 M11.5 2.5 V13.5 M1.5 6 H4.5 M1.5 10 H4.5 M11.5 6 H14.5 M11.5 10 H14.5" />
|
||||
<ui:IconData x:Key="Icon.Filter" Stroke="M1.5 2.5 H14.5 L9.5 8.5 V13.5 L6.5 12 V8.5 Z" />
|
||||
<ui:IconData x:Key="Icon.Flip" Stroke="M1.5 8 H3 M5.5 8 H7.5 M10 8 H12 M14 8 H14.5 M4 6 H12.5 V1.5 Z" Fill="M4 10 L12.5 14.5 V10 Z" />
|
||||
<ui:IconData x:Key="Icon.Folder" Stroke="M1.5 4 A1 1 0 0 1 2.5 3 H6 L7.5 4.5 H13.5 A1 1 0 0 1 14.5 5.5 V12.5 A1 1 0 0 1 13.5 13.5 H2.5 A1 1 0 0 1 1.5 12.5 Z" />
|
||||
<ui:IconData x:Key="Icon.FolderOpen" Stroke="M1.5 12.5 V4 A1 1 0 0 1 2.5 3 H6 L7.5 4.5 H12.5 V6.5 M1.5 12.5 L3.5 7 H14.5 L12.5 13.5 H2.5 A1 1 0 0 1 1.5 12.5 Z" />
|
||||
<ui:IconData x:Key="Icon.Forward" Stroke="M3 8 H13 M9 4 L13 8 L9 12" IsDirectional="True" />
|
||||
@@ -60,6 +61,7 @@
|
||||
<ui:IconData x:Key="Icon.Logs" Stroke="M3.5 1.5 H9.5 L12.5 4.5 V14.5 H3.5 Z M5.5 7 H10.5 M5.5 9.5 H10.5 M5.5 12 H8.5" IsDirectional="True" />
|
||||
<ui:IconData x:Key="Icon.Menu" Stroke="M2.5 4 H13.5 M2.5 8 H13.5 M2.5 12 H13.5" />
|
||||
<ui:IconData x:Key="Icon.Minus" Stroke="M3 8 H13" />
|
||||
<ui:IconData x:Key="Icon.Mirror" Stroke="M8 1.5 V3 M8 5.5 V7.5 M8 10 V12 M8 14 V14.5 M6 4 V12.5 H1.5 Z" Fill="M10 4 L14.5 12.5 H10 Z" />
|
||||
<ui:IconData x:Key="Icon.Moon" Stroke="M9.5 1.8 A6.5 6.5 0 1 0 14.2 11.2 A5.5 5.5 0 0 1 9.5 1.8 Z" />
|
||||
<ui:IconData x:Key="Icon.More" Fill="M2.4 8 A1.1 1.1 0 1 0 4.6 8 A1.1 1.1 0 1 0 2.4 8 ZM6.9 8 A1.1 1.1 0 1 0 9.1 8 A1.1 1.1 0 1 0 6.9 8 ZM11.4 8 A1.1 1.1 0 1 0 13.6 8 A1.1 1.1 0 1 0 11.4 8 Z" />
|
||||
<ui:IconData x:Key="Icon.Motion" Stroke="M1.5 8 C3.5 3 5.5 3 7.5 8 C9.5 13 11.5 13 14.5 8" />
|
||||
@@ -75,6 +77,8 @@
|
||||
<ui:IconData x:Key="Icon.Reset" Stroke="M3.67 6.00 A5 5 0 1 1 5.50 12.83 M3.2 3.2 V6.2 H6.2" />
|
||||
<ui:IconData x:Key="Icon.Retry" Stroke="M10.75 3.24 A5.5 5.5 0 1 1 4.46 3.79 M13.2 2.6 L13.2 5.3 L10.5 5.3" />
|
||||
<ui:IconData x:Key="Icon.Ring" Stroke="M4.5 8 A3.5 3.5 0 1 0 11.5 8 A3.5 3.5 0 1 0 4.5 8 Z" />
|
||||
<ui:IconData x:Key="Icon.RotateLeft" Stroke="M5.5 9.5 H10.5 A1 1 0 0 1 11.5 10.5 V13.5 A1 1 0 0 1 10.5 14.5 H5.5 A1 1 0 0 1 4.5 13.5 V10.5 A1 1 0 0 1 5.5 9.5 Z M3.02 6.18 A5.5 5.5 0 0 1 12.98 6.18 M2.39 3.86 L3.02 6.18 L5.19 5.16" />
|
||||
<ui:IconData x:Key="Icon.RotateRight" Stroke="M5.5 9.5 H10.5 A1 1 0 0 1 11.5 10.5 V13.5 A1 1 0 0 1 10.5 14.5 H5.5 A1 1 0 0 1 4.5 13.5 V10.5 A1 1 0 0 1 5.5 9.5 Z M3.02 6.18 A5.5 5.5 0 0 1 12.98 6.18 M10.81 5.16 L12.98 6.18 L13.61 3.86" />
|
||||
<ui:IconData x:Key="Icon.Search" Stroke="M2.5 7 A4.5 4.5 0 1 0 11.5 7 A4.5 4.5 0 1 0 2.5 7 Z M10.4 10.4 L14 14" />
|
||||
<ui:IconData x:Key="Icon.Sequence" Stroke="M2 12.5 L11.5 3 L13 4.5 L3.5 14 H2 Z" />
|
||||
<ui:IconData x:Key="Icon.Server" Stroke="M4.5 12.5 A3 3 0 0 1 4.2 6.5 A4 4 0 0 1 11.9 5.5 A3.5 3.5 0 0 1 12.2 12.5 Z" />
|
||||
@@ -85,6 +89,7 @@
|
||||
<ui:IconData x:Key="Icon.Star" Stroke="M8 1.8 L9.9 5.8 L14.2 6.3 L11 9.3 L11.9 13.6 L8 11.4 L4.1 13.6 L5 9.3 L1.8 6.3 L6.1 5.8 Z" />
|
||||
<ui:IconData x:Key="Icon.StarFilled" Fill="M8 1.8 L9.9 5.8 L14.2 6.3 L11 9.3 L11.9 13.6 L8 11.4 L4.1 13.6 L5 9.3 L1.8 6.3 L6.1 5.8 Z" />
|
||||
<ui:IconData x:Key="Icon.Stop" Fill="M5.0 3.5 H11.0 A1.5 1.5 0 0 1 12.5 5.0 V11.0 A1.5 1.5 0 0 1 11.0 12.5 H5.0 A1.5 1.5 0 0 1 3.5 11.0 V5.0 A1.5 1.5 0 0 1 5.0 3.5 Z" />
|
||||
<ui:IconData x:Key="Icon.Straighten" Stroke="M1.5 12.5 H14.5 M2.5 12.5 L13 6 M8.45 8.81 A7 7 0 0 1 9.50 12.50" />
|
||||
<ui:IconData x:Key="Icon.SuccessCircle" Stroke="M1.5 8 A6.5 6.5 0 1 0 14.5 8 A6.5 6.5 0 1 0 1.5 8 Z M5 8.3 L7.1 10.3 L11 6" />
|
||||
<ui:IconData x:Key="Icon.Sun" Stroke="M5 8 A3 3 0 1 0 11 8 A3 3 0 1 0 5 8 Z M8 1 V2.5 M8 13.5 V15 M1 8 H2.5 M13.5 8 H15 M3 3 L4 4 M12 12 L13 13 M3 13 L4 12 M12 4 L13 3" />
|
||||
<ui:IconData x:Key="Icon.Sync" Stroke="M9.88 2.83 A5.5 5.5 0 0 1 9.88 13.17 M6.12 13.17 A5.5 5.5 0 0 1 6.12 2.83 M13.5 6.5 L13.2 9.4 L10.6 8.4 M2.5 9.5 L2.8 6.6 L5.4 7.6" />
|
||||
|
||||
Reference in new issue
Block a user