chore: bootstrap repository foundation

Solution layout, build rules with zero-package guard, in-house test
framework, localization runtime, brand mark rasteriser with ICO/PNG
generation, Core contracts (imaging, video, domain model, TIFF reader),
Titano.Tools (make-icon, i18n, xaml-lint, package-guard) and docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 08:59:40 +00:00
1 parent def3fadb6e
commit 83a54fb57b
109 files changed
+7523

No files matched your search

+134
View File
@@ -0,0 +1,134 @@
using Titano.Core.Imaging;
namespace Titano.Core.Video;
public enum VideoCodec
{
H264,
Hevc,
Av1,
Mjpeg,
JpegSequence,
PngSequence,
Tiff16Sequence,
LinearDngSequence,
Gif,
Apng,
}
public enum ContainerFormat
{
Mp4,
Avi,
ImageSequence,
Gif,
Apng,
}
public enum RateControl
{
Vbr,
Cbr,
Quality,
}
public enum CodecProfile
{
Auto,
H264Baseline,
H264Main,
H264High,
HevcMain,
HevcMain10,
Av1Main,
}
public static class VideoCodecInfo
{
public static ContainerFormat DefaultContainer(VideoCodec codec) => codec switch
{
VideoCodec.H264 or VideoCodec.Hevc or VideoCodec.Av1 => ContainerFormat.Mp4,
VideoCodec.Mjpeg => ContainerFormat.Avi,
VideoCodec.Gif => ContainerFormat.Gif,
VideoCodec.Apng => ContainerFormat.Apng,
_ => ContainerFormat.ImageSequence,
};
/// <summary>True for codecs every platform can produce without an OS encoder.</summary>
public static bool IsManaged(VideoCodec codec) => codec is not (VideoCodec.H264 or VideoCodec.Hevc or VideoCodec.Av1);
public static string FileExtension(VideoCodec codec) => codec switch
{
VideoCodec.H264 or VideoCodec.Hevc or VideoCodec.Av1 => ".mp4",
VideoCodec.Mjpeg => ".avi",
VideoCodec.Gif => ".gif",
VideoCodec.Apng => ".png",
VideoCodec.JpegSequence => ".jpg",
VideoCodec.PngSequence => ".png",
VideoCodec.Tiff16Sequence => ".tif",
VideoCodec.LinearDngSequence => ".dng",
_ => ".bin",
};
}
/// <summary>What an encoder on this machine can do (shown in Settings › Rendering).</summary>
public sealed record EncoderCapability(
VideoCodec Codec,
string Name,
bool Hardware,
int MaxWidth,
int MaxHeight,
bool SupportsTenBit,
string? Vendor = null);
/// <summary>Complete parameters of one encode.</summary>
public sealed record EncodeSettings
{
public required string OutputPath { get; init; }
public required VideoCodec Codec { get; init; }
public required int Width { get; init; }
public required int Height { get; init; }
public required Rational FrameRate { get; init; }
public CodecProfile Profile { get; init; } = CodecProfile.Auto;
public int BitDepth { get; init; } = 8;
public RateControl RateControl { get; init; } = RateControl.Vbr;
/// <summary>Average bit rate in bits per second (VBR/CBR).</summary>
public long BitRate { get; init; }
/// <summary>0–100 quality for <see cref="RateControl.Quality"/>, JPEG/MJPEG and GIF.</summary>
public int Quality { get; init; } = 90;
/// <summary>Distance between key frames in frames; 0 = encoder default (≈ 1 s).</summary>
public int GopLength { get; init; }
public int BFrames { get; init; } = 2;
public bool PreferHardware { get; init; } = true;
/// <summary>Optional specific encoder name from <see cref="EncoderCapability.Name"/>.</summary>
public string? EncoderName { get; init; }
}
/// <summary>One open encode. Frames are linear-light buffers at the output size.</summary>
public interface IVideoEncoderSession : IDisposable
{
/// <summary>Encoder actually used ("NVIDIA NVENC H.264", "Managed MJPEG").</summary>
string EncoderName { get; }
bool IsHardware { get; }
/// <summary>Appends a frame shown for <paramref name="duration90k"/> ticks of a 90 kHz clock.</summary>
void WriteFrame(ImageBuffer frame, long duration90k);
/// <summary>Flushes and closes the output. Without it, <see cref="IDisposable.Dispose"/> deletes the partial file.</summary>
void Complete();
}
/// <summary>A family of encoders (Media Foundation on Windows, managed everywhere).</summary>
public interface IVideoEncoderProvider
{
string Name { get; }
IReadOnlyList<EncoderCapability> Capabilities { get; }
bool CanEncode(EncodeSettings settings);
IVideoEncoderSession Open(EncodeSettings settings);
}
+29
View File
@@ -0,0 +1,29 @@
using System.Globalization;
namespace Titano.Core.Video;
/// <summary>An exact frame rate such as 24000/1001.</summary>
public readonly record struct Rational(int Numerator, int Denominator)
{
public double Value => (double)Numerator / Denominator;
public static Rational Fps23976 { get; } = new(24000, 1001);
public static Rational Fps2997 { get; } = new(30000, 1001);
public static Rational Fps5994 { get; } = new(60000, 1001);
public static Rational FromFps(double fps)
{
if (Math.Abs(fps - 23.976) < 0.01) return Fps23976;
if (Math.Abs(fps - 29.97) < 0.01) return Fps2997;
if (Math.Abs(fps - 59.94) < 0.01) return Fps5994;
if (Math.Abs(fps - Math.Round(fps)) < 1e-6) return new((int)Math.Round(fps), 1);
return new((int)Math.Round(fps * 1000), 1000);
}
/// <summary>Duration of one frame in 90 kHz ticks (MP4 timescale used by Titano).</summary>
public long FrameTicks90k => (long)Math.Round(90000.0 * Denominator / Numerator);
public override string ToString() => Denominator == 1
? Numerator.ToString(CultureInfo.InvariantCulture)
: Value.ToString("0.###", CultureInfo.InvariantCulture);
}