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>
120 lines
5.0 KiB
C#
120 lines
5.0 KiB
C#
using System.Buffers.Binary;
|
|
using Chronos.Core.Metadata.Bmff;
|
|
using Chronos.Core.Metadata.Tiff;
|
|
using Chronos.Core.Metadata.Xmp;
|
|
|
|
namespace Chronos.Core.Metadata;
|
|
|
|
/// <summary>Formats with "minimal" metadata (BRIEF §8.1): GIF and BMP sizes; JPEG XR IFD (size, Exif, GPS, XMP);
|
|
/// JPEG XL size header plus the container's Exif and XML boxes.</summary>
|
|
internal static class MinimalFormatParser
|
|
{
|
|
private const ushort JxrImageWidth = 0xBC80;
|
|
private const ushort JxrImageHeight = 0xBC81;
|
|
|
|
public static void ParseGif(MetadataBuilder m)
|
|
{
|
|
Span<byte> h = stackalloc byte[10];
|
|
if (m.Stream.TryReadAt(0, h)) m.SetContainerSize(BinaryPrimitives.ReadUInt16LittleEndian(h[6..]), BinaryPrimitives.ReadUInt16LittleEndian(h[8..]));
|
|
else m.Warn("GIF header truncated");
|
|
}
|
|
|
|
/// <summary>BITMAPCOREHEADER (16-bit sizes) or BITMAPINFOHEADER and later (signed 32-bit; negative height = top-down).</summary>
|
|
public static void ParseBmp(MetadataBuilder m)
|
|
{
|
|
Span<byte> h = stackalloc byte[26];
|
|
if (!m.Stream.TryReadAt(0, h))
|
|
{
|
|
m.Warn("BMP header truncated");
|
|
return;
|
|
}
|
|
if (BinaryPrimitives.ReadUInt32LittleEndian(h[14..]) == 12)
|
|
{
|
|
m.SetContainerSize(BinaryPrimitives.ReadUInt16LittleEndian(h[18..]), BinaryPrimitives.ReadUInt16LittleEndian(h[20..]));
|
|
return;
|
|
}
|
|
var width = BinaryPrimitives.ReadInt32LittleEndian(h[18..]);
|
|
var height = BinaryPrimitives.ReadInt32LittleEndian(h[22..]);
|
|
if (height != int.MinValue) m.SetContainerSize(width, Math.Abs(height));
|
|
}
|
|
|
|
/// <summary>JPEG XR: a little-endian TIFF-like IFD (magic 0x01BC) with standard Make/Exif/GPS/XMP tags.</summary>
|
|
public static void ParseJpegXr(MetadataBuilder m)
|
|
{
|
|
Span<byte> h = stackalloc byte[8];
|
|
if (!m.Stream.TryReadAt(0, h))
|
|
{
|
|
m.Warn("JPEG XR header truncated");
|
|
return;
|
|
}
|
|
var r = TiffReader.ForEmbedded(m.Stream, 0, littleEndian: true);
|
|
if (r.ReadIfd(BinaryPrimitives.ReadUInt32LittleEndian(h[4..])) is { } ifd)
|
|
{
|
|
ExifParser.ReadTree(r, ifd, m, [ifd.Position]);
|
|
m.SetContainerSize(IfdValue.Int(r, ifd, JxrImageWidth) ?? 0, IfdValue.Int(r, ifd, JxrImageHeight) ?? 0);
|
|
}
|
|
m.AddWarnings(r.Warnings);
|
|
}
|
|
|
|
/// <summary>JPEG XL: bare codestream (FF 0A) or ISO-BMFF container with jxlc/jxlp, Exif and "xml " boxes.</summary>
|
|
public static void ParseJpegXl(MetadataBuilder m)
|
|
{
|
|
Span<byte> h = stackalloc byte[2];
|
|
if (m.Stream.TryReadAt(0, h) && h[0] == 0xFF && h[1] == 0x0A)
|
|
{
|
|
ReadSizeHeader(m, 0);
|
|
return;
|
|
}
|
|
var codestream = false;
|
|
foreach (var box in BmffReader.ReadChildren(m.Stream, 0, m.Length))
|
|
{
|
|
m.ThrowIfCancelled();
|
|
if (box.Is("Exif")) ExifParser.ParseOffsetPrefixed(m, box.PayloadStart, box.PayloadLength);
|
|
else if (box.Is("xml ")) m.AddXmp(m.Stream.ReadAt(box.PayloadStart, box.PayloadLength, XmpParser.MaxPacketBytes));
|
|
else if (!codestream && box.Is("jxlc")) codestream = ReadSizeHeader(m, box.PayloadStart);
|
|
else if (!codestream && box.Is("jxlp")) codestream = ReadSizeHeader(m, box.PayloadStart + 4);
|
|
}
|
|
}
|
|
|
|
/// <summary>Codestream SizeHeader (ISO/IEC 18181-1 §D.2): small sizes in multiples of 8, else U32 distributions;
|
|
/// width either explicit or derived from a fixed aspect ratio.</summary>
|
|
private static bool ReadSizeHeader(MetadataBuilder m, long position)
|
|
{
|
|
Span<byte> b = stackalloc byte[18];
|
|
var n = m.Stream.ReadUpTo(position, b);
|
|
if (n < 3 || b[0] != 0xFF || b[1] != 0x0A)
|
|
{
|
|
m.Warn("JPEG XL codestream signature missing");
|
|
return false;
|
|
}
|
|
b[n..].Clear();
|
|
var bits = new BitReader(BinaryPrimitives.ReadUInt128LittleEndian(b[2..]));
|
|
var small = bits.Read(1) == 1;
|
|
var height = small ? (bits.Read(5) + 1) * 8 : Distribution(ref bits) + 1;
|
|
var ratio = (int)bits.Read(3);
|
|
var width = ratio != 0
|
|
? height * (ulong)RatioNumerator[ratio] / (ulong)RatioDenominator[ratio]
|
|
: small ? (bits.Read(5) + 1) * 8 : Distribution(ref bits) + 1;
|
|
if (width <= int.MaxValue && height <= int.MaxValue) m.SetContainerSize((int)width, (int)height);
|
|
return true;
|
|
}
|
|
|
|
private static ReadOnlySpan<int> RatioNumerator => [0, 1, 12, 4, 3, 16, 5, 2];
|
|
private static ReadOnlySpan<int> RatioDenominator => [1, 1, 10, 3, 2, 9, 4, 1];
|
|
|
|
private static ulong Distribution(ref BitReader bits) => bits.Read(bits.Read(2) switch { 0 => 9, 1 => 13, 2 => 18, _ => 30 });
|
|
|
|
/// <summary>LSB-first bit reader over the 128 bits following the signature (a SizeHeader uses at most 68).</summary>
|
|
private struct BitReader(UInt128 value)
|
|
{
|
|
private UInt128 _value = value;
|
|
|
|
public ulong Read(int count)
|
|
{
|
|
var v = (ulong)(_value & ((UInt128.One << count) - 1));
|
|
_value >>= count;
|
|
return v;
|
|
}
|
|
}
|
|
}
|