Files
Chronos/src/Titano.Core/Render/RenderModels.cs
T
Claude 3780105f36 feat(render): preparation pass, render geometry and pipeline
RenderPreparation measures (or reuses cached) luminance, colour, region
and camera-path series and turns them into per-frame corrections.
RenderPipeline renders planned frames through exposure, one geometry
resample, flow synthesis, motion blur, stacking and the knee, overlapping
encoding with processing; cancellation and failures leave no output and
no unobserved exceptions. Batch renders share one preparation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-02 11:09:02 +00:00

128 lines
5.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Titano.Core.Analysis;
using Titano.Core.Export;
using Titano.Core.Imaging;
using Titano.Core.Motion;
using Titano.Core.Project;
namespace Titano.Core.Render;
/// <summary>Everything a render of one sequence reads, shared by every preset of a batch.</summary>
public sealed record RenderInput
{
public required IRenderFrameSource Source { get; init; }
/// <summary>Capture metadata, one entry per source frame.</summary>
public required IReadOnlyList<SourceFrameInfo> Frames { get; init; }
public required ProjectSettings Project { get; init; }
/// <summary>Cached deep-analysis results; missing parts are measured by the preparation pass.</summary>
public PrecomputedAnalysis? Analysis { get; init; }
}
/// <summary>One output of a render: the resolved export values and where the file (or sequence folder) goes.</summary>
/// <param name="OutputPath">Full path of the file, or of the folder for image sequences (see <see cref="ExportNaming.OutputPath"/>).</param>
public sealed record RenderTarget(ResolvedExport Export, string OutputPath);
/// <summary>Tuning of a render that is not part of the project.</summary>
public sealed record RenderOptions
{
public static RenderOptions Default { get; } = new();
/// <summary>Long edge of the frames measured by the preparation pass.</summary>
public int AnalysisLongEdge { get; init; } = 512;
/// <summary>Upper bound of the decode size (0 = as large as the output geometry needs); previews set a small value.</summary>
public int MaxWorkingLongEdge { get; init; }
/// <summary>A downscaled copy of every n-th rendered frame is reported for the live preview (0 = never).</summary>
public int PreviewInterval { get; init; }
public int PreviewLongEdge { get; init; } = 640;
/// <summary>Prepared (exposure-corrected, warped) frames kept for flow and interpolation neighbours (at least 3).</summary>
public int CacheFrames { get; init; } = 4;
public RenderPlanOptions Plan { get; init; } = RenderPlanOptions.Default;
}
public enum RenderStage
{
/// <summary>Measuring the sequence (luminance, colour, camera path).</summary>
Preparing,
/// <summary>Rendering and encoding output frames.</summary>
Rendering,
/// <summary>Flushing and committing the output.</summary>
Finishing,
}
/// <summary>Progress of a render. <see cref="Preview"/> (when present) belongs to the receiver, which disposes it.</summary>
/// <param name="Done">Frames measured (Preparing) or output frames rendered (Rendering).</param>
/// <param name="Total">Frames of the current stage.</param>
/// <param name="FramesPerSecond">Recent throughput of the current stage.</param>
/// <param name="Remaining">Estimated time to the end of the stage; null until measurable.</param>
public sealed record RenderProgress(RenderStage Stage, int Done, int Total, double FramesPerSecond, TimeSpan Elapsed, TimeSpan? Remaining, ImageBuffer? Preview = null)
{
public double Fraction => Total > 0 ? (double)Done / Total : 0;
}
/// <summary>
/// Results of the advisor's deep analysis reused by the preparation (all arrays have one entry per source frame).
/// Invalid or mismatched parts are ignored and measured again.
/// </summary>
public sealed record PrecomputedAnalysis
{
/// <summary>Trimmed-mean log2 luminance (NaN = unusable frame).</summary>
public double[]? LogLuminance { get; init; }
/// <summary>Mean linear red, green and blue (white-balance smoothing).</summary>
public double[]? MeanRed { get; init; }
public double[]? MeanGreen { get; init; }
public double[]? MeanBlue { get; init; }
/// <summary>Sky/land mask with the region series measured through it.</summary>
public RegionMask? Regions { get; init; }
public double[]? SkyLogLuminance { get; init; }
public double[]? LandLogLuminance { get; init; }
/// <summary>Stabilisation solved over the sequence, one correction per source frame, in pixels of a frame of
/// <see cref="StabilizationWidth"/>×<see cref="StabilizationHeight"/>.</summary>
public StabilizationResult? Stabilization { get; init; }
public int StabilizationWidth { get; init; }
public int StabilizationHeight { get; init; }
/// <summary>Path smoothing σ the stabilisation was solved with; a different project value triggers a new solve.</summary>
public double StabilizationSmoothing { get; init; }
}
/// <summary>A localisable remark about a render (key plus invariant-culture arguments).</summary>
public sealed record RenderWarning(string Key, IReadOnlyList<string> Args)
{
public RenderWarning(string key, params string[] args) : this(key, (IReadOnlyList<string>)args)
{
}
public override string ToString() => Args.Count == 0 ? Key : $"{Key}({string.Join(", ", Args)})";
}
/// <summary>A render that cannot start or continue for a reason the user can act on.</summary>
public sealed class RenderException : Exception
{
public RenderException(string reasonKey, string message, IReadOnlyList<string>? args = null, Exception? innerException = null)
: base(message, innerException)
{
ReasonKey = reasonKey;
Args = args ?? [];
}
/// <summary>Localisation key of the reason (e.g. <see cref="EncoderNotices.NeedsRenderNode"/>).</summary>
public string ReasonKey { get; }
public IReadOnlyList<string> Args { get; }
}