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
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user