Completes the Core side of owner review 1 phase 5 (R8): OutputProgram turns the plan into the emitted entries (reverse, boomerang without a doubled turn, loops, a hold of whole periods, fades split per period over held frames and shortened with a warning when longer than half the program). The render follows the program: star trails accumulate in program order, median/mean windows stay per plan frame in either direction, a boomerang with trails plays forward with a warning, and the fade gain is the last FrameFinish step. Workload and estimates come from the program, so loops and holds show in time and size. A still target (RenderTarget.StillFrame) renders one source frame with every correction and no playback into one PNG, JPEG or TIFF 16-bit file (EncodeSettings.SingleImage, StillImageSession), named by ExportNaming.StillPath and recorded with kind still, fps 0 and duration 0. Refs #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
3.4 KiB
C#
64 lines
3.4 KiB
C#
using Chronos.Core.Export;
|
|
using Chronos.Core.Project;
|
|
using Chronos.Core.Video;
|
|
|
|
namespace Chronos.Core.Render;
|
|
|
|
/// <summary>
|
|
/// What a render needs of the program that runs it (owner review 1, phase 4): the settings format a render node or server
|
|
/// must read to render a job as this Chronos would. Computed for routing and gating only, never written into the settings.
|
|
/// </summary>
|
|
public static class RenderRules
|
|
{
|
|
/// <summary>
|
|
/// The settings format a still job needs (owner review 1, R8, "Save frame"): an older program reads the job as a render
|
|
/// of the whole video, so it must never claim one.
|
|
/// </summary>
|
|
public const int StillFormat = 3;
|
|
|
|
/// <summary>The codecs a still frame is saved with, in the order "Save frame" offers them: PNG, JPEG and TIFF 16-bit.</summary>
|
|
public static IReadOnlyList<VideoCodec> StillCodecs { get; } = [VideoCodec.PngSequence, VideoCodec.JpegSequence, VideoCodec.Tiff16Sequence];
|
|
|
|
/// <summary>
|
|
/// <see cref="RequiredFormat(ProjectSettings, ResolvedExport, int, int)"/>, and at least <see cref="StillFormat"/> for a
|
|
/// still job (<paramref name="still"/>: one frame saved as an image).
|
|
/// </summary>
|
|
public static int RequiredFormat(ProjectSettings settings, ResolvedExport export, int sourceWidth, int sourceHeight, bool still)
|
|
{
|
|
var format = RequiredFormat(settings, export, sourceWidth, sourceHeight);
|
|
return still ? int.Max(format, StillFormat) : format;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The settings format a render of <paramref name="target"/> needs: <see cref="RequiredFormat(ProjectSettings, ResolvedExport, int, int, bool)"/>
|
|
/// for its export, a still when <see cref="RenderTarget.StillFrame"/> is set.
|
|
/// </summary>
|
|
public static int RequiredFormat(ProjectSettings settings, RenderTarget target, int sourceWidth, int sourceHeight)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(target);
|
|
return RequiredFormat(settings, target.Export, sourceWidth, sourceHeight, target.IsStill);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The settings format a render of <paramref name="settings"/> with <paramref name="export"/> on a source of the given
|
|
/// (Exif-oriented) size needs: the format the settings are written in (<see cref="ProjectSettings.WrittenFormat"/>, 3 when
|
|
/// <see cref="ExportSettings.Playback"/> plays other than forward once, so the settings must carry the export the job
|
|
/// renders), and at least 2 when the chosen proportions change a fixed-size preset's size (<see cref="RenderSize"/>), which
|
|
/// a format-1 program would render at the preset's own ratio.
|
|
/// </summary>
|
|
public static int RequiredFormat(ProjectSettings settings, ResolvedExport export, int sourceWidth, int sourceHeight)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(settings);
|
|
ArgumentNullException.ThrowIfNull(export);
|
|
var format = settings.WrittenFormat;
|
|
if (export.Width > 0 && export.Height > 0 && sourceWidth > 0 && sourceHeight > 0 && !RenderSize.IsSource(settings.Camera)
|
|
&& RenderSize.Of(settings.Camera, export, sourceWidth, sourceHeight) != PresetSize(export))
|
|
format = int.Max(format, 2);
|
|
return format;
|
|
}
|
|
|
|
/// <summary>A fixed-size preset's size as a format-1 program renders it (even for codecs that are not managed).</summary>
|
|
private static (int Width, int Height) PresetSize(ResolvedExport export) =>
|
|
RenderSize.Of(new CameraSettings(), export, 1, 1);
|
|
}
|