feat(core): project settings with Auto/manual values and export presets
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
5 files changed
+423
No files matched your search
@@ -0,0 +1,31 @@
|
||||
namespace Titano.Core.Project;
|
||||
|
||||
/// <summary>
|
||||
/// A parameter the advisor can decide (BRIEF §10.4). In Auto the advisor's <see cref="AutoValue"/> applies and
|
||||
/// <see cref="ReasonKey"/>/<see cref="ReasonArgs"/> explain it; touching the control stores a manual
|
||||
/// <see cref="Manual"/> value; reset returns to Auto.
|
||||
/// </summary>
|
||||
public sealed record Auto<T>
|
||||
{
|
||||
public bool IsAuto { get; init; } = true;
|
||||
|
||||
/// <summary>The advisor's value (null until analysis provides one).</summary>
|
||||
public T? AutoValue { get; init; }
|
||||
|
||||
/// <summary>The user's value when <see cref="IsAuto"/> is false.</summary>
|
||||
public T? Manual { get; init; }
|
||||
|
||||
/// <summary>Localization key of the reason shown in the Auto pill tooltip.</summary>
|
||||
public string? ReasonKey { get; init; }
|
||||
|
||||
public IReadOnlyList<string>? ReasonArgs { get; init; }
|
||||
|
||||
/// <summary>The value in force: manual when set by the user, otherwise the advisor's, otherwise <paramref name="fallback"/>.</summary>
|
||||
public T Resolve(T fallback) => !IsAuto && Manual is not null ? Manual : AutoValue ?? fallback;
|
||||
|
||||
public Auto<T> WithManual(T value) => this with { IsAuto = false, Manual = value };
|
||||
|
||||
public Auto<T> Reset() => this with { IsAuto = true, Manual = default };
|
||||
|
||||
public Auto<T> WithAdvice(T value, string? reasonKey, params string[] args) => this with { AutoValue = value, ReasonKey = reasonKey, ReasonArgs = args };
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Titano.Core.Project;
|
||||
|
||||
public enum TimingMode
|
||||
{
|
||||
/// <summary>Every source frame lasts one output frame.</summary>
|
||||
Constant,
|
||||
|
||||
/// <summary>Output time follows capture time (deliberate intervalometer pauses are kept short, gaps preserved).</summary>
|
||||
Adaptive,
|
||||
|
||||
/// <summary>Missing frames in sparse gaps are synthesised from motion.</summary>
|
||||
Interpolated,
|
||||
|
||||
/// <summary>A monotone curve maps output time to source position (speed ramps).</summary>
|
||||
Remapped,
|
||||
}
|
||||
|
||||
public enum RegionMode
|
||||
{
|
||||
Off,
|
||||
Auto,
|
||||
Horizon,
|
||||
Luminance,
|
||||
}
|
||||
|
||||
public enum FlowQualitySetting
|
||||
{
|
||||
Draft,
|
||||
Balanced,
|
||||
Best,
|
||||
}
|
||||
|
||||
public enum StackSetting
|
||||
{
|
||||
None,
|
||||
Median,
|
||||
Mean,
|
||||
StarTrails,
|
||||
}
|
||||
|
||||
/// <summary>A control point of the time-remap curve: output fraction → source fraction (both 0..1).</summary>
|
||||
public sealed record CurvePoint(double X, double Y);
|
||||
|
||||
/// <summary>Virtual-camera keyframe in normalised coordinates.</summary>
|
||||
public sealed record CameraKey(int Frame, double CenterX, double CenterY, double Zoom, double Rotation, string Easing = "EaseInOut");
|
||||
|
||||
public sealed record TimingSettings
|
||||
{
|
||||
public Auto<TimingMode> Mode { get; init; } = new();
|
||||
|
||||
/// <summary>Output frame rate as "num/den" or an integer (e.g. "24000/1001", "30").</summary>
|
||||
public Auto<string> FrameRate { get; init; } = new();
|
||||
|
||||
/// <summary>When set, the plan is scaled so the video lasts this many seconds.</summary>
|
||||
public double? FitToSeconds { get; init; }
|
||||
|
||||
public IReadOnlyList<CurvePoint> RemapCurve { get; init; } = [new(0, 0), new(1, 1)];
|
||||
}
|
||||
|
||||
public sealed record ExposureSettings
|
||||
{
|
||||
public Auto<bool> Deflicker { get; init; } = new();
|
||||
|
||||
/// <summary>Local-regression window in frames (odd).</summary>
|
||||
public Auto<int> DeflickerWindow { get; init; } = new();
|
||||
|
||||
/// <summary>0..1: share of the flicker removed.</summary>
|
||||
public Auto<double> DeflickerStrength { get; init; } = new();
|
||||
|
||||
public Auto<RegionMode> Regions { get; init; } = new();
|
||||
|
||||
public Auto<bool> HolyGrail { get; init; } = new();
|
||||
|
||||
/// <summary>Transition length in frames for redistributed exposure steps.</summary>
|
||||
public Auto<int> TransitionLength { get; init; } = new();
|
||||
|
||||
public Auto<bool> WhiteBalanceSmoothing { get; init; } = new();
|
||||
|
||||
/// <summary>Global exposure offset in EV applied after correction.</summary>
|
||||
public double ExposureOffsetEv { get; init; }
|
||||
|
||||
/// <summary>Soft highlight knee (linear), null = hard clip at the encoder.</summary>
|
||||
public double? HighlightKnee { get; init; } = 0.9;
|
||||
}
|
||||
|
||||
public sealed record MotionSettings
|
||||
{
|
||||
public Auto<bool> MotionBlur { get; init; } = new();
|
||||
|
||||
/// <summary>Target shutter angle in degrees (180 = film look).</summary>
|
||||
public Auto<double> TargetShutterAngle { get; init; } = new();
|
||||
|
||||
public Auto<FlowQualitySetting> FlowQuality { get; init; } = new();
|
||||
|
||||
public Auto<bool> Stabilize { get; init; } = new();
|
||||
|
||||
/// <summary>Path smoothing in frames (Gaussian sigma).</summary>
|
||||
public Auto<double> StabilizeSmoothing { get; init; } = new();
|
||||
}
|
||||
|
||||
public sealed record CameraSettings
|
||||
{
|
||||
/// <summary>Normalised crop (0..1) or null for the full frame.</summary>
|
||||
public double[]? Crop { get; init; }
|
||||
|
||||
/// <summary>"source", "16:9", "21:9", "4:3", "3:2", "1:1", "9:16", "4:5" or "w:h".</summary>
|
||||
public Auto<string> Aspect { get; init; } = new();
|
||||
|
||||
public double OffsetX { get; init; }
|
||||
public double OffsetY { get; init; }
|
||||
public IReadOnlyList<CameraKey> Keyframes { get; init; } = [];
|
||||
}
|
||||
|
||||
public sealed record StackSettings
|
||||
{
|
||||
public StackSetting Mode { get; init; } = StackSetting.None;
|
||||
|
||||
/// <summary>Window (median/mean) or trail length (star trails) in frames.</summary>
|
||||
public int Length { get; init; } = 9;
|
||||
}
|
||||
|
||||
/// <summary>Values of an export; null fields take the preset's value (BRIEF §11.4: editing any value makes it "Custom").</summary>
|
||||
public sealed record ExportOverrides
|
||||
{
|
||||
public string? Codec { get; init; }
|
||||
public string? Container { get; init; }
|
||||
public string? Profile { get; init; }
|
||||
public int? BitDepth { get; init; }
|
||||
public int? Width { get; init; }
|
||||
public int? Height { get; init; }
|
||||
public string? FrameRate { get; init; }
|
||||
public long? BitRate { get; init; }
|
||||
public int? GopFrames { get; init; }
|
||||
public int? BFrames { get; init; }
|
||||
public int? Quality { get; init; }
|
||||
public string? RateControl { get; init; }
|
||||
public string? Encoder { get; init; }
|
||||
}
|
||||
|
||||
public sealed record ExportSettings
|
||||
{
|
||||
/// <summary>Id of the selected preset (built-in or user); "custom" when values differ from every preset.</summary>
|
||||
public Auto<string> Preset { get; init; } = new();
|
||||
|
||||
public ExportOverrides Overrides { get; init; } = new();
|
||||
|
||||
/// <summary>Output file name template (tokens: date, title, preset, width, height, fps, codec).</summary>
|
||||
public string NameTemplate { get; init; } = "{date} {title} - {preset}";
|
||||
|
||||
/// <summary>Output folder; null = the sequence's exports folder.</summary>
|
||||
public string? Folder { get; init; }
|
||||
|
||||
/// <summary>Presets queued together by "Render another preset" / batch.</summary>
|
||||
public IReadOnlyList<string> Batch { get; init; } = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "project" of a sequence (<c>.titano/project.json</c>, BRIEF §7): every render decision. Originals are
|
||||
/// never modified; all edits live here.
|
||||
/// </summary>
|
||||
public sealed record ProjectSettings
|
||||
{
|
||||
public const int CurrentVersion = 1;
|
||||
|
||||
public int Version { get; init; } = CurrentVersion;
|
||||
public TimingSettings Timing { get; init; } = new();
|
||||
public ExposureSettings Exposure { get; init; } = new();
|
||||
public MotionSettings Motion { get; init; } = new();
|
||||
public CameraSettings Camera { get; init; } = new();
|
||||
public StackSettings Stack { get; init; } = new();
|
||||
public ExportSettings Export { get; init; } = new();
|
||||
|
||||
/// <summary>Frame indices excluded from renders.</summary>
|
||||
public IReadOnlyList<int> ExcludedFrames { get; init; } = [];
|
||||
|
||||
/// <summary>Index of the hero frame (sequence thumbnail).</summary>
|
||||
public int? HeroFrame { get; init; }
|
||||
|
||||
public string ToJson() => JsonSerializer.Serialize(this, ProjectJson.Default.ProjectSettings);
|
||||
|
||||
public static ProjectSettings FromJson(string json)
|
||||
{
|
||||
var settings = JsonSerializer.Deserialize(json, ProjectJson.Default.ProjectSettings) ?? new ProjectSettings();
|
||||
if (settings.Version > CurrentVersion)
|
||||
throw new InvalidDataException($"project.json version {settings.Version} is newer than this Titano ({CurrentVersion}).");
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(
|
||||
WriteIndented = true,
|
||||
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
UseStringEnumConverter = true,
|
||||
PropertyNameCaseInsensitive = true)]
|
||||
[JsonSerializable(typeof(ProjectSettings))]
|
||||
internal sealed partial class ProjectJson : JsonSerializerContext;
|
||||
Reference in new issue
Block a user