Lays down every contract the later parcels of owner review 1 phase 5 build on, so they compile against shared types without touching each other's files. - Settings format 3: export.playback (direction, loops, fades, hold), omitted at its default and member by member; RequiredFormat is 3 only while used. - OutputProgram public API with a forward-only body; still-frame job parameters (StillFrame, StillPhoto) routed to format-3 nodes only. - Render.Sha256/Kind, RenderCopy, RenderKind; JobKind.VideoCopy = 24. - Migration 0010 (sqlite, postgres): renders.sha256/kind, ix_renders_created, render_copies without a foreign key. - Videos protocol DTOs, client calls, ServerCapabilities.Videos (declared, not announced yet), ServerSettingsDto.VideosPath. - IVideoLibrary with a NotImplemented stub registered on the server; TrashKind.Videos, VideoTrashNames, VideoErrors. - en and it strings for the whole phase, five icons, decisions 1-22 and the open-question defaults; tests that used format 3 as "newer" now use 4. Refs #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
4.6 KiB
C#
82 lines
4.6 KiB
C#
using Chronos.Core.Project;
|
|
using Chronos.Core.Video;
|
|
|
|
namespace Chronos.Core.Render;
|
|
|
|
/// <summary>One frame the encoder receives, in emission order (<see cref="OutputProgram"/>).</summary>
|
|
/// <param name="PlanIndex">The frame of <see cref="RenderPlan.Frames"/> rendered for it.</param>
|
|
/// <param name="Duration90k">How long it shows, on the 90 kHz clock: the planned frame's duration, a share of it (a held
|
|
/// frame split per slot inside a fade), or longer (the hold at the end).</param>
|
|
/// <param name="Gain">The linear-light multiplier of the fade to and from black, applied after the look and the knee
|
|
/// (<c>FrameFinish</c>): 1 leaves the frame as it is, 0 is black. Already in linear light (the sRGB ramp converted), so a
|
|
/// fade looks even.</param>
|
|
public readonly record struct ProgramEntry(int PlanIndex, long Duration90k, double Gain);
|
|
|
|
/// <summary>
|
|
/// The output program of a render (owner review 1, R8): the plan's frames in the order and for the time they are emitted,
|
|
/// with the fade gain of each, from the export's <see cref="PlaybackSettings"/>. Reverse is the plan backwards; a boomerang
|
|
/// is forward then backward without repeating the turning frame; loops repeat the pass (a boomerang's later passes start at
|
|
/// its second frame, so the joint is not doubled); the hold extends the last emitted frame; fades longer than half of the
|
|
/// program are scaled to fit (warning <see cref="FadesShortenedWarning"/>). Every pass is rendered again, so the render
|
|
/// time grows with <see cref="Count"/>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Phase 5 groundwork: the API is final; <see cref="Build(IReadOnlyList{PlannedFrame}, PlaybackSettings?, Rational)"/> emits
|
|
/// the plan forward once, without fades or hold, until the output program parcel completes it.
|
|
/// </remarks>
|
|
public sealed class OutputProgram
|
|
{
|
|
/// <summary>Warning key: the fades were longer than half of the program and were scaled to fit.</summary>
|
|
public const string FadesShortenedWarning = "Export.Render.FadesShortened";
|
|
|
|
/// <summary>Warning key: the playback names a direction this Chronos does not know ({0}); the video plays forward.</summary>
|
|
public const string DirectionUnknownWarning = "Export.Render.DirectionUnknown";
|
|
|
|
/// <summary>Warning key: a boomerang is not rendered with star trails; the video plays forward.</summary>
|
|
public const string BoomerangStackWarning = "Export.Render.BoomerangStack";
|
|
|
|
private OutputProgram(IReadOnlyList<ProgramEntry> entries, IReadOnlyList<RenderWarning> warnings)
|
|
{
|
|
Entries = entries;
|
|
Warnings = warnings;
|
|
long total = 0;
|
|
foreach (var entry in entries) total += entry.Duration90k;
|
|
Duration90k = total;
|
|
}
|
|
|
|
/// <summary>The emitted frames, in order.</summary>
|
|
public IReadOnlyList<ProgramEntry> Entries { get; }
|
|
|
|
/// <summary>Frames the encoder receives (and the render renders).</summary>
|
|
public int Count => Entries.Count;
|
|
|
|
/// <summary>Exact total duration on the 90 kHz clock, holds included.</summary>
|
|
public long Duration90k { get; }
|
|
|
|
/// <summary>The duration in seconds.</summary>
|
|
public double DurationSeconds => Duration90k / 90000.0;
|
|
|
|
/// <summary>What the program changed of the playback asked for (fades shortened, an unknown direction played forward).</summary>
|
|
public IReadOnlyList<RenderWarning> Warnings { get; }
|
|
|
|
/// <summary>The program of <paramref name="plan"/>'s frames played as <paramref name="playback"/> says (null: forward once).</summary>
|
|
public static OutputProgram Build(RenderPlan plan, PlaybackSettings? playback, Rational frameRate)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(plan);
|
|
return Build(plan.Frames, playback, frameRate);
|
|
}
|
|
|
|
/// <summary>The program of the planned <paramref name="frames"/> played as <paramref name="playback"/> says (null: forward once).</summary>
|
|
/// <param name="frameRate">The output frame rate: the grid a held frame is split on inside a fade.</param>
|
|
public static OutputProgram Build(IReadOnlyList<PlannedFrame> frames, PlaybackSettings? playback, Rational frameRate)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(frames);
|
|
if (frameRate.Numerator <= 0 || frameRate.Denominator <= 0) throw new ArgumentOutOfRangeException(nameof(frameRate));
|
|
var warnings = new List<RenderWarning>();
|
|
if (playback?.Direction is { } direction && !PlaybackDirection.IsKnown(direction)) warnings.Add(new RenderWarning(DirectionUnknownWarning, direction));
|
|
var entries = new ProgramEntry[frames.Count];
|
|
for (var i = 0; i < frames.Count; i++) entries[i] = new ProgramEntry(i, frames[i].Duration90k, 1);
|
|
return new OutputProgram(entries, warnings);
|
|
}
|
|
}
|