refactor!: rename Titano to Chronos and move CI and releases to Gitea
CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
CI / Build and test (pull_request) Failing after 2m3s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
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. 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) and pe-check. 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>
This commit is contained in:
1 parent
c99842cc86
commit
5f27a86406
1799 files changed
+11728
-10668
No files matched your search
@@ -0,0 +1,213 @@
|
||||
using Chronos.Core.Codecs.Jpeg;
|
||||
using Chronos.Core.Codecs.Png;
|
||||
using Chronos.Core.Codecs.Tiff;
|
||||
using Chronos.Core.Imaging;
|
||||
using Chronos.Core.Render.Diagnostics;
|
||||
using Chronos.Core.Video;
|
||||
using Chronos.Core.Video.Managed;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Core.Tests.Export;
|
||||
|
||||
public sealed class ManagedEncoderTests
|
||||
{
|
||||
private const int Width = 48;
|
||||
private const int Height = 32;
|
||||
private static readonly Rational Fps = new(30, 1);
|
||||
|
||||
private readonly TestContext _context;
|
||||
|
||||
public ManagedEncoderTests(TestContext context) => _context = context;
|
||||
|
||||
private static ImageBuffer Frame(int seed)
|
||||
{
|
||||
var image = new ImageBuffer(Width, Height);
|
||||
for (var y = 0; y < Height; y++)
|
||||
{
|
||||
for (var x = 0; x < Width; x++)
|
||||
{
|
||||
image[0, x, y] = (x + seed * 7) % Width / (float)Width;
|
||||
image[1, x, y] = y / (float)Height * 0.8f;
|
||||
image[2, x, y] = (x * y + seed * 13) % 23 / 22f * 0.5f;
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private static EncodeSettings Settings(string path, VideoCodec codec, int bitDepth = 8) =>
|
||||
new() { OutputPath = path, Codec = codec, Width = Width, Height = Height, FrameRate = Fps, BitDepth = bitDepth, Quality = 95 };
|
||||
|
||||
/// <summary>Three distinct frames lasting one, two and one periods.</summary>
|
||||
private static void Encode(IVideoEncoderSession session)
|
||||
{
|
||||
long[] durations = [3000, 6000, 3000];
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
using var frame = Frame(i);
|
||||
session.WriteFrame(frame, durations[i]);
|
||||
}
|
||||
session.Complete();
|
||||
}
|
||||
|
||||
private static double Psnr(ImageBuffer expected, ImageBuffer actual)
|
||||
{
|
||||
var a = PixelConvert.ToInterleaved8(expected, 3);
|
||||
var b = PixelConvert.ToInterleaved8(actual, 3);
|
||||
double sum = 0;
|
||||
for (var i = 0; i < a.Length; i++) sum += (a[i] - b[i]) * (a[i] - b[i]);
|
||||
return sum == 0 ? double.PositiveInfinity : 10 * Math.Log10(255.0 * 255 / (sum / a.Length));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MjpegAviRepeatsHeldFramesOnTheConstantRateGrid()
|
||||
{
|
||||
var dir = _context.CreateTempDirectory();
|
||||
var path = Path.Combine(dir, "out.avi");
|
||||
using (var session = new ManagedEncoderProvider().Open(Settings(path, VideoCodec.Mjpeg))) Encode(session);
|
||||
var avi = AviReader.Read(File.ReadAllBytes(path));
|
||||
Assert.Equal(4, avi.Frames.Count);
|
||||
Assert.Equal(4, avi.HeaderFrames);
|
||||
Assert.Equal(4, avi.IndexEntries);
|
||||
Assert.Equal(Fps, avi.FrameRate);
|
||||
Assert.BytesEqual(avi.Frames[1], avi.Frames[2]);
|
||||
using var decoded = JpegDecoder.DecodeToLinear(avi.Frames[3]);
|
||||
using var expected = Frame(2);
|
||||
Assert.Greater(Psnr(expected, decoded), 35);
|
||||
Assert.SequenceEqual(new[] { "out.avi" }, Directory.GetFiles(dir).Select(Path.GetFileName));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Case(VideoCodec.JpegSequence, 8)]
|
||||
[Case(VideoCodec.PngSequence, 8)]
|
||||
[Case(VideoCodec.PngSequence, 16)]
|
||||
[Case(VideoCodec.Tiff16Sequence, 16)]
|
||||
[Case(VideoCodec.LinearDngSequence, 16)]
|
||||
public void SequencesWriteNumberedFilesIntoTheOutputFolder(VideoCodec codec, int bitDepth)
|
||||
{
|
||||
var dir = _context.CreateTempDirectory();
|
||||
var folder = Path.Combine(dir, "Harbour - sequence");
|
||||
using (var session = new ManagedEncoderProvider().Open(Settings(folder, codec, bitDepth))) Encode(session);
|
||||
Assert.SequenceEqual(new[] { "Harbour - sequence" }, Directory.GetFileSystemEntries(dir).Select(Path.GetFileName));
|
||||
var ext = VideoCodecInfo.FileExtension(codec);
|
||||
var files = Directory.GetFiles(folder).Order(StringComparer.Ordinal).ToArray();
|
||||
Assert.SequenceEqual(Enumerable.Range(1, 4).Select(i => $"Harbour - sequence_{i:D6}{ext}"), files.Select(Path.GetFileName));
|
||||
Assert.BytesEqual(File.ReadAllBytes(files[1]), File.ReadAllBytes(files[2]));
|
||||
using var expected = Frame(2);
|
||||
var bytes = File.ReadAllBytes(files[3]);
|
||||
switch (codec)
|
||||
{
|
||||
case VideoCodec.JpegSequence:
|
||||
using (var jpeg = JpegDecoder.DecodeToLinear(bytes)) Assert.Greater(Psnr(expected, jpeg), 35);
|
||||
break;
|
||||
case VideoCodec.PngSequence when bitDepth == 8:
|
||||
Assert.BytesEqual(PixelConvert.ToInterleaved8(expected, 3), PngDecoder.Decode(bytes).Pixels8);
|
||||
break;
|
||||
case VideoCodec.PngSequence:
|
||||
Assert.SequenceEqual(PixelConvert.ToInterleaved16(expected, 3), PngDecoder.Decode(bytes).Pixels16!);
|
||||
break;
|
||||
case VideoCodec.Tiff16Sequence:
|
||||
using (var tiff = TiffImageReader.Decode(bytes))
|
||||
{
|
||||
for (var i = 0; i < tiff.Data.Length; i += 7) Assert.Approximately(expected.Data[i], tiff.Data[i], 2e-4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
using (var dng = TiffImageReader.Decode(bytes))
|
||||
{
|
||||
for (var i = 0; i < dng.Data.Length; i += 7) Assert.Approximately(expected.Data[i], dng.Data[i], 1.0 / 65535);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Case(VideoCodec.Gif)]
|
||||
[Case(VideoCodec.Apng)]
|
||||
public void AnimationsKeepVariableDurations(VideoCodec codec)
|
||||
{
|
||||
var dir = _context.CreateTempDirectory();
|
||||
var path = Path.Combine(dir, "out" + VideoCodecInfo.FileExtension(codec));
|
||||
using (var session = new ManagedEncoderProvider().Open(Settings(path, codec))) Encode(session);
|
||||
var bytes = File.ReadAllBytes(path);
|
||||
var animation = codec == VideoCodec.Gif ? GifReader.Decode(bytes) : ApngReader.Decode(bytes);
|
||||
Assert.Equal(3, animation.Frames.Count);
|
||||
if (codec == VideoCodec.Apng)
|
||||
{
|
||||
Assert.SequenceEqual(new long[] { 3000, 6000, 3000 }, animation.Frames.Select(f => f.Duration90k));
|
||||
using var decoded = animation.ToLinear(1);
|
||||
using var expected = Frame(1);
|
||||
Assert.True(Psnr(expected, decoded) > 60);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Approximately(12000, animation.Duration90k, 900);
|
||||
using var decoded = animation.ToLinear(1);
|
||||
using var expected = Frame(1);
|
||||
Assert.Greater(Psnr(expected, decoded), 22);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Case(VideoCodec.Mjpeg)]
|
||||
[Case(VideoCodec.PngSequence)]
|
||||
[Case(VideoCodec.Gif)]
|
||||
[Case(VideoCodec.Apng)]
|
||||
public void DisposingWithoutCompleteLeavesNothing(VideoCodec codec)
|
||||
{
|
||||
var dir = _context.CreateTempDirectory();
|
||||
var path = Path.Combine(dir, "partial" + (VideoCodecInfo.DefaultContainer(codec) == ContainerFormat.ImageSequence ? string.Empty : VideoCodecInfo.FileExtension(codec)));
|
||||
using (var session = new ManagedEncoderProvider().Open(Settings(path, codec)))
|
||||
{
|
||||
using var frame = Frame(0);
|
||||
session.WriteFrame(frame, 3000);
|
||||
session.WriteFrame(frame, 3000);
|
||||
}
|
||||
Assert.Empty(Directory.GetFileSystemEntries(dir));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SequenceWriteFailuresSurfaceAndLeaveNothing()
|
||||
{
|
||||
var dir = _context.CreateTempDirectory();
|
||||
var session = new ManagedEncoderProvider().Open(Settings(Path.Combine(dir, "seq"), VideoCodec.PngSequence));
|
||||
using var frame = Frame(0);
|
||||
session.WriteFrame(frame, 3000);
|
||||
Directory.Delete(Directory.GetDirectories(dir, ".seq.*.tmp").Single(), recursive: true);
|
||||
Exception? error = null;
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < 20; i++) session.WriteFrame(frame, 3000);
|
||||
session.Complete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
error = ex;
|
||||
}
|
||||
session.Dispose();
|
||||
Assert.True(error is IOException, $"unexpected {error?.GetType().Name}");
|
||||
Assert.Empty(Directory.GetFileSystemEntries(dir));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SessionsValidateTheirInput()
|
||||
{
|
||||
var dir = _context.CreateTempDirectory();
|
||||
var provider = new ManagedEncoderProvider();
|
||||
using (var session = provider.Open(Settings(Path.Combine(dir, "a.avi"), VideoCodec.Mjpeg)))
|
||||
{
|
||||
using var wrong = new ImageBuffer(Width + 2, Height);
|
||||
Assert.Throws<ArgumentException>(() => session.WriteFrame(wrong, 3000));
|
||||
Assert.Throws<InvalidOperationException>(session.Complete);
|
||||
}
|
||||
Assert.Empty(Directory.GetFileSystemEntries(dir));
|
||||
|
||||
var existing = Directory.CreateDirectory(Path.Combine(dir, "taken")).FullName;
|
||||
Assert.Throws<IOException>(() => provider.Open(Settings(existing, VideoCodec.PngSequence)));
|
||||
Assert.False(provider.CanEncode(Settings(Path.Combine(dir, "x.mp4"), VideoCodec.H264)));
|
||||
Assert.False(provider.CanEncode(Settings(Path.Combine(dir, "x"), VideoCodec.PngSequence, bitDepth: 10)));
|
||||
Assert.True(provider.CanEncode(Settings(Path.Combine(dir, "x"), VideoCodec.PngSequence, bitDepth: 16)));
|
||||
Assert.Throws<NotSupportedException>(() => provider.Open(Settings(Path.Combine(dir, "x.mp4"), VideoCodec.Hevc)));
|
||||
Assert.Equal(7, provider.Capabilities.Count);
|
||||
Assert.True(provider.Capabilities.All(c => !c.Hardware && VideoCodecInfo.IsManaged(c.Codec)));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user