refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. 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 #6.
This commit is contained in:
1 parent
c99842cc86
commit
f2b58522b9
1801 files changed
+11804
-10676
No files matched your search
@@ -0,0 +1,206 @@
|
||||
using System.Globalization;
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Core.Motion;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Video;
|
||||
|
||||
namespace Chronos.Core.Render;
|
||||
|
||||
/// <summary>
|
||||
/// Output size, decode size and per-frame warp of a render. <see cref="CameraSettings.Crop"/> is a normalised
|
||||
/// [x, y, width, height] rectangle of the camera view; the output aspect is the export's when it fixes both dimensions,
|
||||
/// otherwise the camera aspect (source = frame aspect). Virtual-camera keyframes are keyed to source frame positions, so
|
||||
/// they stay attached to the content when timing, frame rate or fitting change. The stabiliser correction, the camera
|
||||
/// pose (zoomed by the stabilisation zoom) and the crop become one output→source map, resampled once.
|
||||
/// </summary>
|
||||
public sealed class RenderGeometry
|
||||
{
|
||||
private static readonly CameraState Neutral = new(0.5, 0.5, 1, 0);
|
||||
private readonly VirtualCamera? _camera;
|
||||
private readonly RectD _crop;
|
||||
private readonly double _offsetX;
|
||||
private readonly double _offsetY;
|
||||
private readonly double _stabilizationZoom;
|
||||
private readonly double _fittedWidth;
|
||||
private readonly double _fittedHeight;
|
||||
private readonly double _maxZoom;
|
||||
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)
|
||||
{
|
||||
_camera = camera;
|
||||
_crop = crop;
|
||||
_offsetX = offsetX;
|
||||
_offsetY = offsetY;
|
||||
_stabilizationZoom = stabilizationZoom;
|
||||
SourceWidth = sourceWidth;
|
||||
SourceHeight = sourceHeight;
|
||||
OutputWidth = outputWidth;
|
||||
OutputHeight = outputHeight;
|
||||
_fittedWidth = fittedWidth;
|
||||
_fittedHeight = fittedHeight;
|
||||
_maxZoom = maxZoom;
|
||||
_maxWorkingLongEdge = maxWorkingLongEdge;
|
||||
Warnings = warnings;
|
||||
}
|
||||
|
||||
public int SourceWidth { get; }
|
||||
public int SourceHeight { get; }
|
||||
public int OutputWidth { get; }
|
||||
public int OutputHeight { get; }
|
||||
|
||||
/// <summary>Remarks about ignored camera values.</summary>
|
||||
public IReadOnlyList<RenderWarning> Warnings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Long edge to decode source frames at: enough that the most zoomed-in view still has one source pixel per output
|
||||
/// pixel, never more than the source, capped by <see cref="RenderOptions.MaxWorkingLongEdge"/>.
|
||||
/// </summary>
|
||||
public int WorkingLongEdge
|
||||
{
|
||||
get
|
||||
{
|
||||
var needed = double.Max(OutputWidth / _fittedWidth, OutputHeight / _fittedHeight) * _maxZoom;
|
||||
var edge = (int)double.Ceiling(int.Max(SourceWidth, SourceHeight) * double.Min(1, needed));
|
||||
edge = int.Clamp(edge, int.Min(16, int.Max(SourceWidth, SourceHeight)), int.Max(SourceWidth, SourceHeight));
|
||||
return _maxWorkingLongEdge > 0 ? int.Min(edge, _maxWorkingLongEdge) : edge;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Plans the geometry of <paramref name="export"/> for a source of the given full-resolution size.</summary>
|
||||
/// <param name="stabilizationZoom">Zoom that hides stabilisation borders (<see cref="RenderCorrections.StabilizationZoom"/>).</param>
|
||||
/// <param name="maxWorkingLongEdge">Decode-size cap (0 = none); it also caps source-sized outputs.</param>
|
||||
public static RenderGeometry Create(CameraSettings camera, ResolvedExport export, int sourceWidth, int sourceHeight, double stabilizationZoom = 1, int maxWorkingLongEdge = 0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
ArgumentNullException.ThrowIfNull(export);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(sourceWidth);
|
||||
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(sourceHeight);
|
||||
var warnings = new List<RenderWarning>();
|
||||
var crop = NormalisedCrop(camera.Crop, warnings);
|
||||
if (!AspectRatio.TryParse(camera.Aspect.Resolve("source"), out var aspect))
|
||||
{
|
||||
warnings.Add(new RenderWarning("Export.Render.AspectIgnored", camera.Aspect.Resolve(string.Empty)));
|
||||
aspect = AspectRatio.Source;
|
||||
}
|
||||
var fixedSize = export.Width > 0 && export.Height > 0;
|
||||
var ratio = fixedSize ? export.Width / (double)export.Height : aspect.Resolve(sourceWidth, sourceHeight);
|
||||
if (fixedSize && !aspect.IsSource && double.Abs(aspect.Resolve(sourceWidth, sourceHeight) / ratio - 1) > 0.01)
|
||||
warnings.Add(new RenderWarning("Export.Render.AspectFromPreset", aspect.ToString(), string.Create(CultureInfo.InvariantCulture, $"{export.Width}:{export.Height}")));
|
||||
var cropPixels = new RectD(crop.X * sourceWidth, crop.Y * sourceHeight, crop.Width * sourceWidth, crop.Height * sourceHeight);
|
||||
var fitted = AspectRatio.FitCrop(cropPixels, ratio, camera.OffsetX, camera.OffsetY);
|
||||
|
||||
int width, height;
|
||||
if (fixedSize) (width, height) = (export.Width, export.Height);
|
||||
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 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));
|
||||
}
|
||||
if (!VideoCodecInfo.IsManaged(export.Codec))
|
||||
{
|
||||
width &= ~1;
|
||||
height &= ~1;
|
||||
}
|
||||
width = int.Max(VideoCodecInfo.IsManaged(export.Codec) ? 1 : 2, width);
|
||||
height = int.Max(VideoCodecInfo.IsManaged(export.Codec) ? 1 : 2, height);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
|
||||
/// <summary>Camera pose at a (fractional) source position, including the stabilisation zoom.</summary>
|
||||
public CameraState PoseAt(double sourcePosition)
|
||||
{
|
||||
var pose = _camera?.Evaluate(sourcePosition) ?? Neutral;
|
||||
return pose with { Zoom = pose.Zoom * _stabilizationZoom };
|
||||
}
|
||||
|
||||
/// <summary>Geometry of one decoded frame of <paramref name="frameWidth"/>×<paramref name="frameHeight"/> pixels.</summary>
|
||||
/// <param name="stabilization">The frame's stabiliser correction at this frame size (source → stabilised).</param>
|
||||
public GeometrySettings For(int frameWidth, int frameHeight, double sourcePosition, Affine2D stabilization)
|
||||
{
|
||||
var view = VirtualCamera.ViewToSource(PoseAt(sourcePosition), frameWidth, frameHeight);
|
||||
return new GeometrySettings
|
||||
{
|
||||
Crop = new RectD(_crop.X * frameWidth, _crop.Y * frameHeight, _crop.Width * frameWidth, _crop.Height * frameHeight),
|
||||
Aspect = AspectRatio.Source,
|
||||
OffsetX = _offsetX,
|
||||
OffsetY = _offsetY,
|
||||
OutputWidth = OutputWidth,
|
||||
OutputHeight = OutputHeight,
|
||||
Warp = stabilization.IsIdentity() ? view : stabilization.Invert() * view,
|
||||
Border = BorderMode.Clamp,
|
||||
};
|
||||
}
|
||||
|
||||
private static RectD NormalisedCrop(double[]? crop, List<RenderWarning> warnings)
|
||||
{
|
||||
var full = new RectD(0, 0, 1, 1);
|
||||
if (crop is null) return full;
|
||||
if (crop.Length != 4 || !crop.All(double.IsFinite))
|
||||
{
|
||||
warnings.Add(new RenderWarning("Export.Render.CropIgnored"));
|
||||
return full;
|
||||
}
|
||||
var x = double.Clamp(crop[0], 0, 1);
|
||||
var y = double.Clamp(crop[1], 0, 1);
|
||||
var w = double.Min(crop[2], 1 - x);
|
||||
var h = double.Min(crop[3], 1 - y);
|
||||
if (w <= 1e-3 || h <= 1e-3)
|
||||
{
|
||||
warnings.Add(new RenderWarning("Export.Render.CropIgnored"));
|
||||
return full;
|
||||
}
|
||||
return new RectD(x, y, w, h);
|
||||
}
|
||||
|
||||
private static VirtualCamera? Camera(IReadOnlyList<CameraKey> keys, List<RenderWarning> warnings)
|
||||
{
|
||||
if (keys.Count == 0) return null;
|
||||
var frames = new Dictionary<int, CameraKeyframe>();
|
||||
foreach (var k in keys)
|
||||
{
|
||||
if (!double.IsFinite(k.CenterX + k.CenterY + k.Zoom + k.Rotation))
|
||||
{
|
||||
warnings.Add(new RenderWarning("Export.Render.KeyframeIgnored", k.Frame.ToString(CultureInfo.InvariantCulture)));
|
||||
continue;
|
||||
}
|
||||
frames[k.Frame] = new CameraKeyframe(k.Frame, k.CenterX, k.CenterY, double.Max(1, k.Zoom), k.Rotation) { Easing = Easing(k.Easing, warnings) };
|
||||
}
|
||||
return frames.Count == 0 ? null : new VirtualCamera(frames.Values);
|
||||
}
|
||||
|
||||
/// <summary>"Linear", "EaseIn", "EaseOut", "EaseInOut" or "x1,y1,x2,y2" control points (CSS cubic-bezier).</summary>
|
||||
private static BezierEasing Easing(string? text, List<RenderWarning> warnings)
|
||||
{
|
||||
switch (text?.Trim().ToLowerInvariant())
|
||||
{
|
||||
case null or "" or "easeinout": return BezierEasing.EaseInOut;
|
||||
case "linear": return BezierEasing.Linear;
|
||||
case "easein": return BezierEasing.EaseIn;
|
||||
case "easeout": return BezierEasing.EaseOut;
|
||||
}
|
||||
var parts = text.Split(',');
|
||||
if (parts.Length == 4
|
||||
&& double.TryParse(parts[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var x1) && x1 is >= 0 and <= 1
|
||||
&& double.TryParse(parts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var y1) && double.IsFinite(y1)
|
||||
&& double.TryParse(parts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var x2) && x2 is >= 0 and <= 1
|
||||
&& double.TryParse(parts[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var y2) && double.IsFinite(y2))
|
||||
return new BezierEasing(x1, y1, x2, y2);
|
||||
warnings.Add(new RenderWarning("Export.Render.EasingIgnored", text));
|
||||
return BezierEasing.EaseInOut;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user