fix(imaging): record only what decoding proves and find GPR JPEGs across sequences
- Preview sizes come from probes and unscaled decodes: a size-limited decode picks the smallest preview that reaches its edge (CR3 PRVW 1620x1080), so renders and deep passes record its tier without a size and the output cap keeps the largest preview's. - A read error is not an undecodable file: ImageDecoder.Decode throws the IOException when a provider could not read the file and none produced pixels. Deep passes never flag frames they could not read or that vanished, and frames only an interrupted earlier run found undecodable are decoded again before they are flagged. - Renders resolve stand-ins only for frames the pipeline asks for; frames the read-ahead meets on the way (skipped by speed-ups) are left alone. - A GoPro GPR finds its JPEG in the index when an import or upload kept it in a sequence of its own (same original stem and capture time), for probes, deep analysis, renders, thumbnails, proxies and the editor; GPRs whose JPEG is indexed later are probed again. - Thumbnails judge an embedded preview by its own JPEG header. - PostgreSQL writes tier fields 1000 frames per statement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
19 files changed
+689
-111
No files matched your search
@@ -128,6 +128,105 @@ public sealed class RenderJobTests(TestContext context)
|
||||
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 frames = await SequenceFrames.LoadAsync(fx.Db, fx.Archive.Archive, sequence, useProxies: false, 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(), new ImageDecoder([fx.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