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>
85 lines
4.1 KiB
C#
85 lines
4.1 KiB
C#
using System.Text.Json;
|
|
using Chronos.Core.Imaging;
|
|
using Chronos.Core.Imaging.Decoders;
|
|
using Chronos.Core.Metadata;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Tests.Decoding;
|
|
|
|
/// <summary>Real camera files from tests/fixtures/manifest.json (fetched by <c>Chronos.Tools fixtures</c>); each test is
|
|
/// skipped when its file is absent. A native decode must reach the expected size and look like the camera's own
|
|
/// embedded preview (luminance correlation), which catches wrong byte orders, CFA phases or colour matrices.</summary>
|
|
public sealed class ExternalFixtureTests(TestContext context)
|
|
{
|
|
private const int Edge = 256;
|
|
|
|
private static JsonElement Entry(string name)
|
|
{
|
|
var manifest = JsonDocument.Parse(File.ReadAllText(Path.Combine(TestContext.FixturesDirectory, "manifest.json")));
|
|
foreach (var f in manifest.RootElement.GetProperty("files").EnumerateArray())
|
|
{
|
|
if (f.GetProperty("name").GetString() == name) return f.Clone();
|
|
}
|
|
throw new InvalidOperationException("No manifest entry " + name);
|
|
}
|
|
|
|
[Theory]
|
|
[Case("google-pixel-4a.dng")]
|
|
[Case("canon-eos-5d-mark-iii.cr2")]
|
|
[Case("nikon-d850.nef")]
|
|
[Case("sony-ilce-7m3.arw")]
|
|
[Case("fujifilm-x-t2.raf")]
|
|
[Case("pentax-k-1.pef")]
|
|
[Timeout(20_000)]
|
|
public void DecodesNativelyAndMatchesThePreview(string name)
|
|
{
|
|
var path = Path.Combine(TestContext.FixturesDirectory, "external", name);
|
|
if (!File.Exists(path)) TestContext.Skip($"{name} not fetched (run Chronos.Tools fixtures)");
|
|
var entry = Entry(name);
|
|
var metadata = MetadataReader.Read(path);
|
|
Assert.Equal(entry.GetProperty("format").GetString(), metadata.Format.ToString());
|
|
var probe = new ManagedDecoderProvider().Probe(path);
|
|
context.Log($"{name}: {probe}; {metadata.Make} {metadata.Model}, {metadata.Width}x{metadata.Height}, orientation {metadata.Orientation}");
|
|
Assert.Equal(DecodeTier.Native, probe.Tier);
|
|
|
|
var decoder = DecoderFactory.CreateServer();
|
|
using var native = decoder.Decode(new DecodeRequest(path, Edge, DecodePurpose.Render, ApplyOrientation: false));
|
|
Assert.Equal(DecodeTier.Native, native!.Tier);
|
|
var (w, h) = (entry.GetProperty("width").GetInt32(), entry.GetProperty("height").GetInt32());
|
|
Assert.InRange(native.SourceWidth, w * 0.98, w * 1.02);
|
|
Assert.InRange(native.SourceHeight, h * 0.98, h * 1.02);
|
|
foreach (var v in native.Pixels.Data)
|
|
{
|
|
if (!float.IsFinite(v)) Assert.Fail("non-finite pixel");
|
|
}
|
|
|
|
using var preview = decoder.Decode(new DecodeRequest(path, Edge, DecodePurpose.Render, ApplyOrientation: false, ForcePreview: true));
|
|
if (preview is null || preview.Tier != DecodeTier.EmbeddedPreview) TestContext.Skip("no embedded preview to compare with");
|
|
var correlation = Correlation(native.Pixels, preview.Pixels);
|
|
context.Log($"luminance correlation with the embedded preview: {correlation:F3}");
|
|
Assert.Greater(correlation, 0.8);
|
|
}
|
|
|
|
/// <summary>Pearson correlation of sRGB-encoded luminance after resizing both to a common 64-pixel-wide grid.</summary>
|
|
private static double Correlation(ImageBuffer a, ImageBuffer b)
|
|
{
|
|
var height = int.Max(1, (int)double.Round(64.0 * a.Height / a.Width));
|
|
using var ra = Resampler.Resize(a, 64, height, ResampleFilter.Box);
|
|
using var rb = Resampler.Resize(b, 64, height, ResampleFilter.Box);
|
|
var n = ra.PlaneLength;
|
|
double sa = 0, sb = 0, saa = 0, sbb = 0, sab = 0;
|
|
for (var i = 0; i < n; i++)
|
|
{
|
|
double la = ColorSpace.EncodeFast(ColorSpace.Luminance(ra.Plane(0)[i], ra.Plane(1)[i], ra.Plane(2)[i]));
|
|
double lb = ColorSpace.EncodeFast(ColorSpace.Luminance(rb.Plane(0)[i], rb.Plane(1)[i], rb.Plane(2)[i]));
|
|
sa += la;
|
|
sb += lb;
|
|
saa += la * la;
|
|
sbb += lb * lb;
|
|
sab += la * lb;
|
|
}
|
|
var cov = sab / n - sa / n * (sb / n);
|
|
return cov / double.Sqrt(double.Max(saa / n - sa / n * (sa / n), 1e-12) * double.Max(sbb / n - sb / n * (sb / n), 1e-12));
|
|
}
|
|
}
|