Merge branch 'fix/imaging-metadata': decode tiers, preview-only and undecodable frames, GPR companions, MakerNote fields
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
70 files changed
+2201
-124
No files matched your search
@@ -113,18 +113,148 @@ public sealed class RenderJobTests(TestContext context)
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Scene());
|
||||
// Damaged after indexing: nothing flags the frame, so only decoding finds out.
|
||||
await File.WriteAllBytesAsync(Path.Combine(fx.Archive.Paths.Root, "Synthetic", ProcessingFixture.FileName(10)), new byte[5000], fx.Ct);
|
||||
// Every file damaged after indexing: nothing flags them, and no frame can stand in for another.
|
||||
for (var i = 0; i < Frames; i++)
|
||||
await File.WriteAllBytesAsync(Path.Combine(fx.Archive.Paths.Root, "Synthetic", ProcessingFixture.FileName(i)), new byte[5000], fx.Ct);
|
||||
await fx.StartEngineAsync();
|
||||
|
||||
var job = await fx.EnqueueAsync(ProcessingJobs.Render(sequence, Mjpeg, 96, 64));
|
||||
var failed = await fx.WaitForAsync(job.Id, JobState.Failed);
|
||||
|
||||
Assert.Equal(Loc.L(SequenceFrameSource.FrameUnreadableKey, "11", ProcessingFixture.FileName(10)), failed.Error);
|
||||
Assert.Equal(Loc.L(SequenceFrameSource.FrameUnreadableKey, "1", ProcessingFixture.FileName(0)), failed.Error);
|
||||
Assert.Empty(Entries(fx.Folder(sequence).Exports));
|
||||
Assert.Empty(await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AFrameThatNoLongerDecodesIsReplacedByItsNeighbourAndLeftOutNextTime()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Scene());
|
||||
// Damaged after indexing: nothing flags the frame, so only decoding finds out (BRIEF §8.2 tier 3).
|
||||
await File.WriteAllBytesAsync(Path.Combine(fx.Archive.Paths.Root, "Synthetic", ProcessingFixture.FileName(10)), new byte[5000], fx.Ct);
|
||||
await fx.StartEngineAsync();
|
||||
|
||||
var job = await fx.EnqueueAsync(ProcessingJobs.Render(sequence, Mjpeg, 96, 64));
|
||||
var done = await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
Assert.Contains(Loc.L("Export.Log.StandIns", "11"), done.LogTail);
|
||||
Assert.SequenceEqual(["clip-MJPEG.avi"], Entries(fx.Folder(sequence).Exports));
|
||||
var row = (await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct))[10];
|
||||
Assert.Equal(FrameFlags.Undecodable, row.Flags);
|
||||
var sidecar = Titano.Core.Archiving.ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath);
|
||||
Assert.Equal((DecodeTier.Unavailable, FrameFlags.Undecodable), (sidecar.Frames[10].Tier, sidecar.Frames[10].Flags));
|
||||
Assert.Equal(DecodeTier.Native, sidecar.Frames[9].Tier);
|
||||
Assert.True(sidecar.Status.HasFlag(SequenceStatus.HasWarnings), "the sequence warns at once");
|
||||
Assert.True((await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!.Status.HasFlag(SequenceStatus.HasWarnings), "index status");
|
||||
|
||||
// The next render plans without the frame, so nothing has to stand in for it.
|
||||
var again = await fx.EnqueueAsync(ProcessingJobs.Render(sequence, Mjpeg, 96, 64));
|
||||
var second = await fx.WaitForAsync(again.Id, JobState.Done);
|
||||
Assert.False(second.LogTail?.Contains(Loc.L("Export.Log.StandIns", "11"), StringComparison.Ordinal) == true, "no stand-in");
|
||||
Assert.Count(2, await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AFrameThatCannotBeReadIsShownAsItsNeighbourButNeverFlagged()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Scene());
|
||||
// Another program holds the file during the render (antivirus, backup): a read error says nothing about the file.
|
||||
fx.Decoder.Unreadable[ProcessingFixture.FileName(10)] = 0;
|
||||
await fx.StartEngineAsync();
|
||||
|
||||
var job = await fx.EnqueueAsync(ProcessingJobs.Render(sequence, Mjpeg, 96, 64));
|
||||
var done = await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
Assert.Contains(Loc.L("Export.Log.StandIns", "11"), done.LogTail);
|
||||
var sidecar = Titano.Core.Archiving.ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath);
|
||||
Assert.Equal(FrameFlags.None, sidecar.Frames[10].Flags & FrameFlags.Undecodable);
|
||||
Assert.NotEqual(DecodeTier.Unavailable, sidecar.Frames[10].Tier);
|
||||
Assert.False(sidecar.Status.HasFlag(SequenceStatus.HasWarnings), "no warning");
|
||||
Assert.Equal(FrameFlags.None, (await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct))[10].Flags);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASmallRenderKeepsTheStoredSizeOfTheLargestPreview()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Scene());
|
||||
// A CR3 on the server: the probe finds its full-size 6000×4000 preview, which caps the output.
|
||||
for (var i = 0; i < Frames; i++)
|
||||
fx.Decoder.Tiers[ProcessingFixture.FileName(i)] = new FileTier(ImageFileFormat.Jpeg, DecodeTier.EmbeddedPreview, "test-preview", "test", 6000, 4000);
|
||||
await fx.StartEngineAsync();
|
||||
var light = await fx.EnqueueAsync(ProcessingJobs.LightAnalysis([sequence.Id]));
|
||||
await fx.WaitForAsync(light.Id, JobState.Done);
|
||||
var probed = Titano.Core.Archiving.ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Frames[3];
|
||||
Assert.Equal((FrameFlags.PreviewOnly, (int?)6000, (int?)4000), (probed.Flags, probed.PreviewW, probed.PreviewH));
|
||||
|
||||
// A small render decodes the smallest preview that reaches its size (1620×1080): that is not the largest.
|
||||
for (var i = 0; i < Frames; i++) fx.Decoder.PreviewDecodes[ProcessingFixture.FileName(i)] = (1620, 1080);
|
||||
var job = await fx.EnqueueAsync(ProcessingJobs.Render(sequence, Mjpeg, 96, 64));
|
||||
await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
var frames = Titano.Core.Archiving.ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Frames;
|
||||
Assert.True(frames.All(f => f is { Tier: DecodeTier.EmbeddedPreview, PreviewW: 6000, PreviewH: 4000 }), "sidecar preview sizes kept");
|
||||
var rows = await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct);
|
||||
Assert.True(rows.All(f => (f.PreviewWidth, f.PreviewHeight) == (6000, 4000)), "index preview sizes kept");
|
||||
Assert.Equal((6000, 4000), (Titano.Core.Advice.SequenceContext.FromFrames(rows).PreviewWidth, Titano.Core.Advice.SequenceContext.FromFrames(rows).PreviewHeight));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FramesARenderNodeReceivesKeepTheirTierFields()
|
||||
{
|
||||
var dto = new Titano.Protocol.FrameDto(Guid.CreateVersion7(), Guid.CreateVersion7(), 3, "IMG_0004.CR3", 25_000_000, new string('a', 64),
|
||||
new DateTime(2026, 9, 28, 18, 0, 20), 120, 1.0 / 250, 8, 100, 24, 6, 6000, 4000, "cr3",
|
||||
(long)(FrameFlags.PreviewOnly | FrameFlags.Intervalometer), 1620, 1080);
|
||||
|
||||
var frame = RenderNodeClient.ToFrame(dto);
|
||||
Assert.Equal((ImageFileFormat.Cr3, FrameFlags.PreviewOnly | FrameFlags.Intervalometer, 1620, 1080),
|
||||
(frame.Format, frame.Flags, frame.PreviewWidth, frame.PreviewHeight));
|
||||
// The node's advisor caps a portrait sequence at its previews, oriented like the main image.
|
||||
var tiers = Titano.Core.Advice.SequenceContext.FromFrames([frame]);
|
||||
Assert.Equal((1, 1080, 1620), (tiers.PreviewOnlyCount, tiers.PreviewWidth, tiers.PreviewHeight));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task OnlyFramesTheRenderShowsGetAStandIn()
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Scene());
|
||||
foreach (var i in new[] { 1, 3 })
|
||||
await File.WriteAllBytesAsync(Path.Combine(fx.Archive.Paths.Root, "Synthetic", ProcessingFixture.FileName(i)), new byte[5000], fx.Ct);
|
||||
var decoder = new ImageDecoder([fx.Decoder]);
|
||||
var frames = await SequenceFrames.LoadAsync(fx.Db, fx.Archive.Archive, sequence, useProxies: false, decoder, fx.Ct);
|
||||
|
||||
// A plan that skips the odd frames (a speed-up): the read-ahead meets frames 1 and 3, the pipeline never asks.
|
||||
var source = new SequenceFrameSource(frames, frames.LightFrames(), decoder, new FrameWindowOptions { Ahead = 4 })
|
||||
{
|
||||
Originals = true,
|
||||
RenderExcluded = new HashSet<int>(),
|
||||
};
|
||||
await using (source)
|
||||
{
|
||||
foreach (var index in new[] { 0, 2, 4, 6 })
|
||||
{
|
||||
using var frame = await source.GetFrameAsync(index, 64, DecodePurpose.Render, fx.Ct);
|
||||
Assert.Equal(64, frame.Width);
|
||||
}
|
||||
// The read-ahead decodes in the background: wait until it has met frame 4 (index 3).
|
||||
for (var waited = 0; !source.Observed.ContainsKey(3) && waited < 200; waited++) await Task.Delay(50, fx.Ct);
|
||||
}
|
||||
Assert.Equal(DecodeTier.Unavailable, source.Observed[3].Tier);
|
||||
Assert.Empty(source.StandIns);
|
||||
|
||||
// Asked for, a damaged frame shows its neighbour and is listed.
|
||||
await using var asked = new SequenceFrameSource(frames, frames.LightFrames(), new ImageDecoder([fx.Decoder]))
|
||||
{
|
||||
RenderExcluded = new HashSet<int>(),
|
||||
};
|
||||
using (var standIn = await asked.GetFrameAsync(3, 64, DecodePurpose.Render, fx.Ct))
|
||||
Assert.Equal(64, standIn.Width);
|
||||
Assert.SequenceEqual([3], asked.StandIns);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARenderInterruptedByACrashStartsItsOutputAgainCleanly()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user