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>
108 lines
3.8 KiB
C#
108 lines
3.8 KiB
C#
using Chronos.Core.Codecs.Jpeg;
|
||
using Chronos.Testing;
|
||
|
||
namespace Chronos.Core.Tests.Codecs;
|
||
|
||
/// <summary>Lossless JPEG (SOF3) round trips: every predictor, precisions 2–16, components, restarts.</summary>
|
||
public sealed class JpegLosslessTests
|
||
{
|
||
private static ushort[] Raw(int width, int height, int components, int precision, int seed)
|
||
{
|
||
var rng = new Random(seed);
|
||
var max = (1 << precision) - 1;
|
||
var samples = new ushort[width * height * components];
|
||
for (var y = 0; y < height; y++)
|
||
{
|
||
for (var x = 0; x < width; x++)
|
||
{
|
||
for (var c = 0; c < components; c++)
|
||
{
|
||
// Smooth ramp + sensor noise, with a few clipped highlights and black pixels.
|
||
var v = (x * 3 + y * 5 + c * 97) % (max + 1) * 0.7 + rng.Next(Math.Max(1, max / 64));
|
||
if (rng.Next(200) == 0) v = max;
|
||
if (rng.Next(300) == 0) v = 0;
|
||
samples[(y * width + x) * components + c] = (ushort)Math.Clamp((int)v, 0, max);
|
||
}
|
||
}
|
||
}
|
||
return samples;
|
||
}
|
||
|
||
[Theory]
|
||
[Case(1)]
|
||
[Case(2)]
|
||
[Case(3)]
|
||
[Case(4)]
|
||
[Case(5)]
|
||
[Case(6)]
|
||
[Case(7)]
|
||
public void EveryPredictorRoundTrips(int predictor)
|
||
{
|
||
var samples = Raw(37, 23, 3, 12, predictor);
|
||
var jpeg = JpegLosslessEncoder.Encode(samples, 37, 23, 3, 12, predictor);
|
||
var decoded = JpegLosslessDecoder.Decode(jpeg);
|
||
Assert.Equal(37, decoded.Width);
|
||
Assert.Equal(23, decoded.Height);
|
||
Assert.Equal(3, decoded.Components);
|
||
Assert.Equal(12, decoded.Precision);
|
||
Assert.SequenceEqual(samples, decoded.Samples);
|
||
}
|
||
|
||
[Theory]
|
||
[Case(2, 1)]
|
||
[Case(8, 1)]
|
||
[Case(14, 2)]
|
||
[Case(16, 1)]
|
||
[Case(16, 4)]
|
||
public void PrecisionsAndComponentCounts(int precision, int components)
|
||
{
|
||
var samples = Raw(19, 11, components, precision, precision);
|
||
foreach (var predictor in new[] { 1, 4, 7 })
|
||
{
|
||
var decoded = JpegLosslessDecoder.Decode(JpegLosslessEncoder.Encode(samples, 19, 11, components, precision, predictor));
|
||
Assert.SequenceEqual(samples, decoded.Samples);
|
||
}
|
||
}
|
||
|
||
[Theory]
|
||
[Case(1)]
|
||
[Case(19)]
|
||
[Case(25)]
|
||
[Case(64)]
|
||
public void RestartIntervalsRoundTrip(int interval)
|
||
{
|
||
var samples = Raw(19, 13, 2, 14, interval);
|
||
foreach (var predictor in new[] { 1, 6 })
|
||
{
|
||
var jpeg = JpegLosslessEncoder.Encode(samples, 19, 13, 2, 14, predictor, restartInterval: interval);
|
||
Assert.SequenceEqual(samples, JpegLosslessDecoder.Decode(jpeg).Samples);
|
||
}
|
||
}
|
||
|
||
[Test]
|
||
public void PointTransformRestoresScaledSamples()
|
||
{
|
||
var samples = Raw(16, 9, 1, 16, 3).Select(s => (ushort)(s & ~7)).ToArray();
|
||
var jpeg = JpegLosslessEncoder.Encode(samples, 16, 9, 1, 16, predictor: 5, pointTransform: 3);
|
||
Assert.SequenceEqual(samples, JpegLosslessDecoder.Decode(jpeg).Samples);
|
||
}
|
||
|
||
[Test]
|
||
public void GeneralDecoderExposesLosslessAsImage()
|
||
{
|
||
var samples = Raw(10, 6, 3, 8, 1);
|
||
var image = JpegDecoder.Decode(JpegLosslessEncoder.Encode(samples, 10, 6, 3, 8));
|
||
Assert.Equal(JpegProcess.Lossless, image.Info.Process);
|
||
Assert.Equal(3, image.Components);
|
||
Assert.SequenceEqual(samples.Select(s => (byte)s), image.Pixels8!);
|
||
var wide = Raw(10, 6, 1, 14, 2);
|
||
var gray = JpegDecoder.Decode(JpegLosslessEncoder.Encode(wide, 10, 6, 1, 14));
|
||
Assert.Equal(14, gray.BitDepth);
|
||
Assert.SequenceEqual(wide, gray.Pixels16!);
|
||
}
|
||
|
||
[Test]
|
||
public void DctStreamIsRejectedByLosslessDecoder() =>
|
||
Assert.Throws<InvalidDataException>(() => JpegLosslessDecoder.Decode(JpegEncoder.Encode(new byte[48], 4, 4, 3)));
|
||
}
|