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:
Claude committed 2026-10-12 11:46:58 +00:00
commit 348d580d4d
70 files changed
+2201 -124

No files matched your search

@@ -1,9 +1,12 @@
using Titano.App.Infrastructure;
using Titano.App.Library;
using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Data.Repositories;
using Titano.Data.Sync;
using Titano.Protocol;
using Titano.Testing;
using Titano.Ui.Controls;
namespace Titano.App.Tests.Library;
@@ -70,6 +73,25 @@ public sealed class RemoteCardsTests
Assert.Equal(SyncState.RemoteOnly, card.SyncState);
}
[Test]
public void PreviewOnlyFramesShowAChipWithTheirCount()
{
// A server sequence of CR3s it reads only through their previews (BRIEF §8.2 tier 2).
var link = Link("Aurora");
var dto = new SequenceDto(link.RemoteId, "Aurora", "Aurora", "2026/2026-02-20 Nikon Z 8", "NIKON CORPORATION", "NIKON Z 8", null,
new DateTime(2026, 2, 20, 21, 0, 0), new DateTime(2026, 2, 21, 1, 8, 0), 1_860, 8.0, 50_000_000_000, (int)SequenceStatus.AnalyzedLight, 0, null,
[], 0, null, 1, 1, 0, null, DateTimeOffset.UtcNow, PreviewOnlyCount: 1_860);
var card = RemoteCards.Build([new SyncEntry(null, link, SyncStatus.RemoteOnly)], new Dictionary<Guid, SequenceDto> { [dto.Id] = dto }).Single();
Assert.Equal(1_860, card.PreviewOnlyCount);
Assert.Equal(1_860, RemoteCards.ToSequence(dto).PreviewOnlyCount);
var chip = SequenceItem.BuildStatuses(card, analysing: false).Single(s => s.Kind == StatusKind.PreviewOnly);
Assert.Equal(Formatting.Count(1_860), chip.Text);
Assert.Equal(Loc.Plural("Tooltips.Library.Status.PreviewOnly", 1_860), chip.ToolTip);
Assert.NotEqual(Loc.Plural("Tooltips.Library.Status.PreviewOnly", 1), chip.ToolTip, "plural forms");
Assert.False(SequenceItem.BuildStatuses(card with { PreviewOnlyCount = 0 }, analysing: false).Any(s => s.Kind == StatusKind.PreviewOnly), "no chip without them");
}
[Test]
public void CardsSortAmongThePagesAndFollowTheFilter()
{
@@ -0,0 +1,241 @@
using System.Text;
using Titano.Core.Advice;
using Titano.Core.Analysis;
using Titano.Core.Analysis.Deep;
using Titano.Core.Archiving;
using Titano.Core.Codecs.Jpeg;
using Titano.Core.Diagnostics.Synthetic;
using Titano.Core.Imaging;
using Titano.Core.Imaging.Decoders;
using Titano.Core.Metadata;
using Titano.Core.Model;
using Titano.Core.Project;
using Titano.Core.Tests.Analysis.Deep;
using Titano.Core.Tests.Raw;
using Titano.Testing;
namespace Titano.Core.Tests.Archiving;
/// <summary>Decode tiers of frames (BRIEF §8.2): sidecar fields, flags, thumbnails from previews, and what the advisor reads.</summary>
[Category("archive")]
public sealed class DecodeTierTests(TestContext context)
{
private static readonly DateTime Start = new(2026, 9, 28, 18, 0, 0);
private static SidecarFrame Sidecar(int orientation = 1, int? previewW = null, int? previewH = null) => new()
{
Id = Guid.CreateVersion7(),
File = "originals/IMG_0001.CR2",
Format = ImageFileFormat.Cr2,
W = 6000,
H = 4000,
Orientation = orientation,
PreviewW = previewW,
PreviewH = previewH,
};
[Test]
public void TheTierSetsItsFlagsAndThePreviewSize()
{
var frame = Sidecar(orientation: 6) with { Flags = FrameFlags.Duplicate };
// FileTier sizes are oriented; the sidecar keeps them like W and H, before orientation.
var preview = SequenceFrames.WithTier(frame, new FileTier(ImageFileFormat.Cr2, DecodeTier.EmbeddedPreview, "managed-preview", "body", 1080, 1620));
Assert.Equal((DecodeTier.EmbeddedPreview, FrameFlags.Duplicate | FrameFlags.PreviewOnly, (int?)1620, (int?)1080),
(preview.Tier, preview.Flags, preview.PreviewW, preview.PreviewH));
var none = SequenceFrames.WithTier(preview, new FileTier(ImageFileFormat.Cr2, DecodeTier.Unavailable, null, "nothing", 0, 0));
Assert.Equal((FrameFlags.Duplicate | FrameFlags.Undecodable, (int?)1620), (none.Flags, none.PreviewW));
var native = SequenceFrames.WithTier(none, new FileTier(ImageFileFormat.Cr2, DecodeTier.Native, "wic", null, 4000, 6000));
Assert.Equal((DecodeTier.Native, FrameFlags.Duplicate, (int?)1620), (native.Tier, native.Flags, native.PreviewW));
// A host without a native decoder for the format proves nothing about the file: tier kept, flag left as it was.
var beyond = SequenceFrames.WithTier(native, new FileTier(ImageFileFormat.Cr2, DecodeTier.Unavailable, null, "nothing here", 0, 0), damaged: false);
Assert.Equal((DecodeTier.Unavailable, FrameFlags.Duplicate), (beyond.Tier, beyond.Flags));
Assert.Equal(FrameFlags.Duplicate | FrameFlags.Undecodable,
SequenceFrames.WithTier(none, new FileTier(ImageFileFormat.Cr2, DecodeTier.Unavailable, null, "nothing here", 0, 0), damaged: false).Flags);
}
[Test]
public void SidecarsKeepTheTierAndThePreviewSizeAndOlderOnesReadAsUnknown()
{
var path = Path.Combine(context.CreateTempDirectory(), "sequence.json");
var frame = SequenceFrames.WithTier(Sidecar(previewW: 1620, previewH: 1080),
new FileTier(ImageFileFormat.Cr2, DecodeTier.EmbeddedPreview, "managed-preview", null, 1620, 1080));
ManifestStore.WriteSequence(path, new SequenceManifest { Id = Guid.CreateVersion7(), Frames = [frame] });
var json = File.ReadAllText(path);
Assert.Contains("\"tier\":\"EmbeddedPreview\"", json);
Assert.Contains("\"previewW\":1620", json);
var read = ManifestStore.ReadSequence(path).Frames.Single();
Assert.Equal((DecodeTier.EmbeddedPreview, FrameFlags.PreviewOnly, (int?)1620, (int?)1080), (read.Tier, read.Flags, read.PreviewW, read.PreviewH));
// A frame never probed writes no tier, and a sidecar from before tiers reads as unknown.
ManifestStore.WriteSequence(path, new SequenceManifest { Id = Guid.CreateVersion7(), Frames = [Sidecar()] });
Assert.DoesNotContain("tier", File.ReadAllText(path).Split('"'));
var older = ManifestStore.ParseSequence(Encoding.UTF8.GetBytes(
"""{"id":"0192f7a0-0000-7000-8000-000000000001","frames":[{"id":"0192f7a0-0000-7000-8000-000000000002","file":"a.jpg","tier":"SomethingNew"}]}"""), "test");
Assert.Equal((DecodeTier)0, older.Frames.Single().Tier);
}
[Test]
public void IndexingKeepsTheSizeOfTheLargestPreview()
{
var metadata = new FrameMetadata
{
Format = ImageFileFormat.Cr2,
Width = 6000,
Height = 4000,
Previews = [new EmbeddedPreview(4096, 90_000, 1620, 1080, PreviewKind.Preview), new EmbeddedPreview(100, 4000, 160, 120, PreviewKind.Thumbnail)],
};
var frame = SequenceFrames.FromMetadata(Guid.CreateVersion7(), "a.cr2", "a.cr2", 10, null, metadata);
Assert.Equal((4096L, (int?)1620, (int?)1080, (DecodeTier)0), (frame.PreviewOffset!.Value, frame.PreviewW, frame.PreviewH, frame.Tier));
Assert.Null(SequenceFrames.FromMetadata(Guid.CreateVersion7(), "b.jpg", "b.jpg", 10, null, new FrameMetadata { Format = ImageFileFormat.Jpeg }).PreviewW);
}
[Test]
public void ThumbnailsUseAStoredPreviewOnlyWhenItReachesTheThumbnailSize()
{
var archive = new ArchivePaths(context.CreateTempDirectory("archive"));
var sequence = archive.Sequence("s");
Directory.CreateDirectory(sequence.Originals);
using var scene = SyntheticRaw.Smooth(640, 480);
var dng = SyntheticDng.Write(scene, new DngSpec());
var renderer = new FrameImageRenderer(DecoderFactory.CreateServer());
EncodedImage Thumbnail(string name, int previewWidth, bool sizeKnown, int? storedWidth = null)
{
// The preview is appended after the DNG, which the TIFF offsets never reach.
var preview = TestPhotos.Jpeg(Start, 3, width: previewWidth, height: previewWidth * 3 / 4);
File.WriteAllBytes(Path.Combine(sequence.Originals, name), [.. dng, .. preview]);
var stored = storedWidth ?? previewWidth;
var frame = new SidecarFrame
{
Id = Guid.CreateVersion7(),
File = "originals/" + name,
Format = ImageFileFormat.Dng,
W = 640,
H = 480,
PreviewOffset = dng.Length,
PreviewLength = preview.Length,
PreviewW = sizeKnown ? stored : null,
PreviewH = sizeKnown ? stored * 3 / 4 : null,
};
return renderer.Thumbnail(sequence, frame)!;
}
// A 200 px preview would leave the thumbnail short of 320 px (ENG-10): the RAW is developed instead.
var small = Thumbnail("small.dng", 200, sizeKnown: true);
Assert.Equal((320, 240, DecodeTier.Native), (small.Width, small.Height, small.Tier));
var unknown = Thumbnail("unknown.dng", 200, sizeKnown: false);
Assert.Equal((320, DecodeTier.Native), (unknown.Width, unknown.Tier));
// The stored size can be a GPR companion's, larger than the embedded preview: the JPEG's own header decides.
var companionSized = Thumbnail("companion.dng", 200, sizeKnown: true, storedWidth: 4000);
Assert.Equal((320, DecodeTier.Native), (companionSized.Width, companionSized.Tier));
var large = Thumbnail("large.dng", 400, sizeKnown: true);
Assert.Equal((320, 240, DecodeTier.EmbeddedPreview), (large.Width, large.Height, large.Tier));
Assert.Equal(320, JpegDecoder.ReadInfo(large.Jpeg).Width);
}
[Test]
public void TheAdvisorCapsTheOutputAtThePreviewsOfPreviewOnlyFrames()
{
var sequence = Guid.CreateVersion7();
Frame Row(int index, FrameFlags flags, int previewW, int previewH) => new()
{
Id = Guid.CreateVersion7(),
SequenceId = sequence,
Index = index,
RelativePath = $"s/{index}.cr3",
FileName = $"{index}.cr3",
CapturedAt = Start.AddSeconds(5 * index),
ExposureTime = 1.0 / 250,
FNumber = 8,
Iso = 100,
Width = 6000,
Height = 4000,
Orientation = 6,
Flags = flags,
PreviewWidth = previewW,
PreviewHeight = previewH,
};
var rows = Enumerable.Range(0, 20)
.Select(i => Row(i, i == 19 ? FrameFlags.Undecodable : i < 15 ? FrameFlags.PreviewOnly : FrameFlags.None, i == 3 ? 1280 : 1620, i == 3 ? 960 : 1080))
.ToList();
var context = SequenceContext.FromFrames(rows);
// Portrait frames: the previews are oriented like the main image; the most common preview size wins.
Assert.Equal((4000, 6000, 15, 1080, 1620), (context.SourceWidth, context.SourceHeight, context.PreviewOnlyCount, context.PreviewWidth, context.PreviewHeight));
var light = LightAnalyzer.Analyze(rows);
Assert.SequenceEqual(Enumerable.Range(0, 15), light.PreviewOnlyFrames);
Assert.SequenceEqual([19], light.UndecodableFrames);
var preview = light.Findings.Single(f => f.Key == FindingKeys.PreviewOnly);
Assert.Equal((FindingSeverity.Info, (object)15), (preview.Severity, preview.Arguments[0]));
Assert.Equal(FindingSeverity.Warning, light.Findings.Single(f => f.Key == DeepFindingKeys.UnreadableFrames).Severity);
var result = Advisor.Recommend(light, null, context);
var resolution = result.Find(AdvisorParameters.Resolution)!;
Assert.Equal(AdvisorKeys.ResolutionPreview, resolution.ReasonKey);
Assert.SequenceEqual([15, 1080, 1620], resolution.ReasonArgs.Select(Convert.ToInt32));
}
[Test]
public async Task FramesBothAnalysesFoundUndecodableAreListedOnce()
{
// Frame 4 does not decode; frame 7 is not read either (missing, or beyond this host), which never flags it.
var source = new SyntheticFrameSource(SyntheticSequence.Create(new SyntheticSequenceOptions { Width = 96, Height = 64, FrameCount = 12 }))
{
Undecodable = [4, 7],
};
var deep = await DeepAnalyzer.AnalyzeAsync(source, DeepScenes.Options);
var metadata = Enumerable.Range(0, source.Count).Select(source.Metadata).ToList();
var context = new SequenceContext { FrameCount = source.Count, SourceWidth = 96, SourceHeight = 64 };
// Before the deep pass flagged the frame, only its own finding names them.
var unflagged = Advisor.Recommend(LightAnalyzer.Analyze(metadata), deep, context).Findings.Where(f => f.Key == DeepFindingKeys.UnreadableFrames).ToList();
Assert.SequenceEqual([4, 7], unflagged.Single().Frames);
// Once frame 4 is flagged both analyses report it: one finding over both lists, counted once.
var flagged = metadata.Select(m => m.Index == 4 ? m with { Flags = FrameFlags.Undecodable } : m).ToList();
var light = LightAnalyzer.Analyze(flagged);
Assert.SequenceEqual([4], light.Findings.Single(f => f.Key == DeepFindingKeys.UnreadableFrames).Frames);
var merged = Advisor.Recommend(light, deep, context).Findings.Single(f => f.Key == DeepFindingKeys.UnreadableFrames);
Assert.SequenceEqual([4, 7], merged.Frames);
Assert.Equal((FindingSeverity.Warning, 2), (merged.Severity, Convert.ToInt32(merged.Arguments.Single())));
// A frame flagged since the deep pass (a render found it broken) joins the list too.
var later = LightAnalyzer.Analyze(flagged.Select(m => m.Index == 9 ? m with { Flags = FrameFlags.Undecodable } : m).ToList());
var all = Advisor.Recommend(later, deep, context).Findings.Single(f => f.Key == DeepFindingKeys.UnreadableFrames);
Assert.Equal((3, 3), (all.Frames.Count, Convert.ToInt32(all.Arguments.Single())));
}
[Test]
public void FramesTheCamerasIntervalometerShotTimeTheirGapsAdaptively()
{
var metadata = new FrameMetadata { Format = ImageFileFormat.Rw2, IntervalShooting = true };
Assert.Equal(FrameFlags.Intervalometer, SequenceFrames.FromMetadata(Guid.CreateVersion7(), "a.rw2", "a.rw2", 10, null, metadata).Flags);
Assert.Equal(FrameFlags.None, SequenceFrames.FromMetadata(Guid.CreateVersion7(), "b.rw2", "b.rw2", 10, null, metadata with { IntervalShooting = false }).Flags);
// 60 frames 10 s apart with one 40 s gap: a sparse gap alone keeps the timing constant (motion unmeasured).
LightFrame Frame(int i, FrameFlags flags) => new()
{
Index = i,
CapturedAt = Start.AddSeconds(10 * i + (i >= 30 ? 30 : 0)),
Width = 6000,
Height = 4000,
Flags = flags,
};
var context = new SequenceContext { FrameCount = 60, SourceWidth = 6000, SourceHeight = 4000 };
var plain = LightAnalyzer.Analyze([.. Enumerable.Range(0, 60).Select(i => Frame(i, FrameFlags.None))]);
Assert.Equal(0, plain.IntervalometerFrames);
var free = Advisor.Recommend(plain, null, context).Find(AdvisorParameters.TimingMode)!;
Assert.Equal((AdvisorKeys.TimingSparseGaps, (object?)TimingMode.Constant), (free.ReasonKey, free.Value));
// The camera's own intervalometer shot them: its pause was deliberate, so adaptive timing keeps it short.
var shot = LightAnalyzer.Analyze([.. Enumerable.Range(0, 60).Select(i => Frame(i, FrameFlags.Intervalometer))]);
Assert.Equal(60, shot.IntervalometerFrames);
var advice = Advisor.Recommend(shot, null, context).Find(AdvisorParameters.TimingMode)!;
Assert.Equal((AdvisorKeys.TimingIntervalometer, (object?)TimingMode.Adaptive), (advice.ReasonKey, advice.Value));
Assert.Equal(1, Convert.ToInt32(advice.ReasonArgs.Single()));
}
}
@@ -5,6 +5,8 @@ using Titano.Core.Codecs.Tiff;
using Titano.Core.Imaging;
using Titano.Core.Imaging.Decoders;
using Titano.Core.Metadata;
using Titano.Core.Metadata.Tiff;
using Titano.Core.Tests.Metadata.Builders;
using Titano.Core.Tests.Raw;
using Titano.Testing;
using static Titano.Core.Tests.Raw.NativeRawWriters;
@@ -201,6 +203,122 @@ public sealed class ManagedDecoderProviderTests(TestContext context)
}
}
[Test]
public void TheChainProbesEachFileForItsTier()
{
var server = DecoderFactory.CreateServer();
// JPEG, PNG and TIFF decode natively whatever they hold: the probe does not even open them.
Assert.Equal(DecodeTier.Native, server.Probe(Path.Combine(_dir, "absent.jpg"), ImageFileFormat.Jpeg).Tier);
var supported = server.Probe(Write("IMG_5.CR2", Cr2File("Canon EOS 5D Mark III")), ImageFileFormat.Cr2);
Assert.Equal((DecodeTier.Native, "managed-cr2"), (supported.Tier, supported.Decoder));
// An unsupported body decodes only through its 64×48 preview, rotated like the main image (orientation 6).
var preview = server.Probe(Write("IMG_6.CR2", Cr2File("Canon EOS R99", orientation: 6)), ImageFileFormat.Cr2);
Assert.Equal((DecodeTier.EmbeddedPreview, 48, 64), (preview.Tier, preview.Width, preview.Height));
Assert.Contains("no colour matrix", preview.Reason);
using var scene = SyntheticRaw.Smooth(W, H);
var nef = Nef(Sensor(scene, "Nikon D850", CfaPattern.Bayer("RGGB"), W, H, 0, 0, 600, 16383), 14, NefEncoding.Lossless);
var unknownBody = System.Text.Encoding.Latin1.GetBytes(System.Text.Encoding.Latin1.GetString(nef).Replace("NIKON D850", "NIKON Z99X"));
var none = server.Probe(Write("DSC_7.NEF", unknownBody), ImageFileFormat.Nef);
Assert.Equal(DecodeTier.Unavailable, none.Tier);
Assert.Contains("no embedded preview", none.Reason);
// A Windows-like provider native for CR3 answers from its codec list, before the managed preview tier.
var client = DecoderFactory.CreateClient(new FakeProvider());
var cr3 = client.Probe(Path.Combine(_dir, "absent.cr3"), ImageFileFormat.Cr3);
Assert.Equal((DecodeTier.Native, "fake"), (cr3.Tier, cr3.Decoder));
Assert.Equal(DecodeTier.Unavailable, client.Probe(Write("y.webp", Fixtures.WebP()), ImageFileFormat.WebP).Tier);
}
[Test]
public void GoProRawDecodesThroughTheJpegBesideIt()
{
var gpr = Write("GOPR0001.GPR", Gpr(previewWidth: 64, previewHeight: 48));
var server = DecoderFactory.CreateServer();
// Alone, a GPR (VC-5, out of scope) shows its embedded preview.
using (var alone = server.Decode(new DecodeRequest(gpr)))
Assert.Equal(("managed-preview", 64), (alone!.Decoder, alone.Pixels.Width));
Write("GOPR0001.JPG", JpegFile(160, 120, 1));
using (var withJpeg = server.Decode(new DecodeRequest(gpr)))
{
Assert.Equal((DecodeTier.EmbeddedPreview, "managed-sidecar"), (withJpeg!.Tier, withJpeg.Decoder));
Assert.Equal((160, 120, 160, 120), (withJpeg.Pixels.Width, withJpeg.Pixels.Height, withJpeg.SourceWidth, withJpeg.SourceHeight));
}
using (var scaled = server.Decode(new DecodeRequest(gpr, MaxLongEdge: 40, Purpose: DecodePurpose.Thumbnail)))
Assert.Equal(40, scaled!.Pixels.Width);
var probe = new ManagedDecoderProvider().Probe(gpr);
Assert.Equal((DecodeTier.EmbeddedPreview, "managed-sidecar", 160, 120), (probe.Tier, probe.Decoder, probe.Width, probe.Height));
// A companion smaller than the embedded preview is not the better source.
var big = Write("GOPR0002.GPR", Gpr(previewWidth: 320, previewHeight: 240));
Write("GOPR0002.JPG", JpegFile(160, 120, 1));
using (var preview = server.Decode(new DecodeRequest(big)))
Assert.Equal(("managed-preview", 320), (preview!.Decoder, preview.Pixels.Width));
Assert.Equal("managed-preview", new ManagedDecoderProvider().Probe(big).Decoder);
}
[Test]
public void GoProRawDecodesThroughItsJpegWhereTheImportKeptIt()
{
// An import splits sessions per format: the JPEG lives in another sequence folder, under its imported name.
var gpr = Write("GOPR0003.GPR", Gpr(previewWidth: 64, previewHeight: 48));
var elsewhere = Path.Combine(context.CreateTempDirectory("jpeg-sequence"), "2026-09-28_0003.JPG");
File.WriteAllBytes(elsewhere, JpegFile(160, 120, 1));
var server = DecoderFactory.CreateServer();
using (var decoded = server.Decode(new DecodeRequest(gpr, Companion: elsewhere)))
Assert.Equal(("managed-sidecar", 160, 120), (decoded!.Decoder, decoded.SourceWidth, decoded.SourceHeight));
var probe = server.Probe(gpr, ImageFileFormat.Gpr, elsewhere);
Assert.Equal((DecodeTier.EmbeddedPreview, "managed-sidecar", 160, 120), (probe.Tier, probe.Decoder, probe.Width, probe.Height));
// A JPEG that is gone (deleted since) leaves the embedded preview; other formats ignore the companion.
var gone = Path.Combine(_dir, "gone.JPG");
using (var preview = server.Decode(new DecodeRequest(gpr, Companion: gone)))
Assert.Equal(("managed-preview", 64), (preview!.Decoder, preview.Pixels.Width));
Assert.Equal("managed-preview", server.Probe(gpr, ImageFileFormat.Gpr, gone).Decoder);
var jpeg = Write("plain.jpg", JpegFile(64, 48, 1));
using (var plain = server.Decode(new DecodeRequest(jpeg, Companion: elsewhere)))
Assert.Equal(("managed-jpeg", 64), (plain!.Decoder, plain.SourceWidth));
}
[Test]
public void AFileNoProviderCouldReadIsAReadErrorNotAnUndecodableFile()
{
var path = Write("locked.jpg", JpegFile(64, 48, 1));
// Every provider failed to read the file (locked by another program, a network read failed): nothing is known
// about its content, so the caller gets the read error instead of "nothing decodes it".
var unreadable = new ImageDecoder([new ScriptedProvider("a", _ => throw new IOException("sharing violation"))]);
Assert.Throws<IOException>(() => unreadable.Decode(new DecodeRequest(path)));
// One provider read it and found nothing, another could not read it: still unproven.
var mixed = new ImageDecoder([new ScriptedProvider("a", _ => null), new ScriptedProvider("b", _ => throw new IOException("short read"))]);
Assert.Throws<IOException>(() => mixed.Decode(new DecodeRequest(path)));
// A provider that produces pixels wins over one that could not read the file.
var recovered = new ImageDecoder([new ScriptedProvider("a", _ => throw new IOException("busy")), new ManagedDecoderProvider()]);
using (var image = recovered.Decode(new DecodeRequest(path)))
Assert.Equal("managed-jpeg", image!.Decoder);
// Providers that read the file and found it malformed prove it undecodable.
var damaged = new ImageDecoder([new ScriptedProvider("a", _ => throw new InvalidDataException("bad marker"))]);
Assert.Null(damaged.Decode(new DecodeRequest(path)));
Assert.Null(DecoderFactory.CreateServer().Decode(new DecodeRequest(Write("garbage.jpg", new byte[3000]))));
Assert.Throws<FileNotFoundException>(() => DecoderFactory.CreateServer().Decode(new DecodeRequest(Path.Combine(_dir, "vanished.jpg"))));
}
/// <summary>A GoPro GPR as far as Titano reads it: a DNG made by "GoPro" whose only decodable image is a YCbCr JPEG preview.</summary>
private static byte[] Gpr(int previewWidth, int previewHeight)
{
var preview = new IfdSpec().Long(TiffTags.NewSubfileType, 1)
.Long(TiffTags.ImageWidth, (uint)previewWidth).Long(TiffTags.ImageLength, (uint)previewHeight)
.Short(TiffTags.BitsPerSample, 8, 8, 8).Short(TiffTags.Compression, 7)
.Short(TiffTags.PhotometricInterpretation, 6).Strip(JpegFile(previewWidth, previewHeight, 1));
var ifd0 = Fixtures.Ifd0("GoPro", "HERO8 Black", 1)
.Bytes(TiffTags.DngVersion, 1, 4, 0, 0)
.Child(TiffTags.SubIfds, preview);
return TiffFile.Build(ifd0);
}
/// <summary>A Windows-like provider claiming native support for everything but declining every file.</summary>
private sealed class FakeProvider : IImageDecoderProvider
{
@@ -214,4 +332,12 @@ public sealed class ManagedDecoderProviderTests(TestContext context)
return null;
}
}
/// <summary>A JPEG provider whose decode does what the test says (return nothing, or throw).</summary>
private sealed class ScriptedProvider(string name, Func<DecodeRequest, DecodedImage?> decode) : IImageDecoderProvider
{
public string Name => name;
public DecodeTier? TierFor(ImageFileFormat format) => format == ImageFileFormat.Jpeg ? DecodeTier.Native : null;
public DecodedImage? Decode(DecodeRequest request, CancellationToken cancellationToken = default) => decode(request);
}
}
@@ -0,0 +1,125 @@
using Titano.Core.Imaging;
using Titano.Core.Metadata;
using Titano.Core.Metadata.Tiff;
using Titano.Core.Tests.Metadata.Builders;
using Titano.Testing;
using static Titano.Core.Tests.Metadata.MetadataTestHelpers;
namespace Titano.Core.Tests.Metadata;
/// <summary>
/// MakerNote fields of BRIEF §9 beyond identity: the vendor exposure mode (when Exif has no ExposureProgram), the
/// intervalometer hint and the reduced-size RAW flag, from synthetic vendor IFDs.
/// </summary>
public sealed class MakerNoteTests
{
/// <summary>A JPEG whose Exif lacks ExposureProgram and carries <paramref name="makerNote"/> after <paramref name="prefix"/>.</summary>
private static FrameMetadata Jpeg(string make, string model, byte[] prefix, IfdSpec makerNote, bool relativeToTiff = true, bool keepProgram = false)
{
var exif = Fixtures.ExifIfd(identity: false).Embedded(TiffTags.MakerNote, prefix, makerNote, relativeToTiff, littleEndian: true);
if (!keepProgram) exif.Without(TiffTags.ExposureProgram);
var m = Read(new JpegBuilder().Exif(TiffFile.Build(Fixtures.Ifd0(make, model, 1).Child(TiffTags.ExifIfd, exif))).Build(64, 48));
AssertNoFault(m);
return m;
}
/// <summary>A CR2 ("CR" header block) with only IFD0, the Exif IFD and a Canon MakerNote.</summary>
private static FrameMetadata Cr2(ushort[] cameraSettings)
{
var makerNote = new IfdSpec().Short(0x0001, cameraSettings);
var exif = Fixtures.ExifIfd(identity: false).Without(TiffTags.ExposureProgram)
.Embedded(TiffTags.MakerNote, [], makerNote, relativeToTiff: true, littleEndian: true);
var ifd0 = Fixtures.Ifd0("Canon", "Canon EOS 5D Mark IV", 1).Child(TiffTags.ExifIfd, exif);
var m = Read(TiffFile.Build(ifd0, true, headerExtra: [(byte)'C', (byte)'R', 2, 0, 0, 0, 0, 0]), "IMG_0001.CR2");
AssertNoFault(m);
return m;
}
private static ushort[] CanonSettings(ushort exposureMode, ushort sRawQuality) =>
[.. Enumerable.Range(0, 48).Select(i => (ushort)(i switch { 20 => exposureMode, 46 => sRawQuality, _ => 0 }))];
[Theory]
[Case(1, 2)]
[Case(2, 4)]
[Case(3, 3)]
[Case(4, 1)]
[Case(5, 5)]
[Case(7, 1)]
[Case(8, 2)]
public void CanonExposureModeFillsTheExposureProgram(int canonMode, int exposureProgram)
{
var m = Jpeg("Canon", "Canon EOS R6", [], new IfdSpec().Short(0x0001, CanonSettings((ushort)canonMode, 0)));
Assert.Equal(exposureProgram, m.ExposureProgram);
// Not a RAW: the sRAW field says nothing about a JPEG.
Assert.Null(m.RawSize);
}
[Test]
public void CanonEasyModeLeavesTheProgramUnknownAndExifWins()
{
Assert.Null(Jpeg("Canon", "Canon EOS R6", [], new IfdSpec().Short(0x0001, CanonSettings(0, 0))).ExposureProgram);
// The fixture's Exif says aperture priority (3); the MakerNote's manual mode does not override it.
Assert.Equal(3, Jpeg("Canon", "Canon EOS R6", [], new IfdSpec().Short(0x0001, CanonSettings(4, 0)), keepProgram: true).ExposureProgram);
}
[Theory]
[Case(0, RawSize.Full)]
[Case(1, RawSize.Medium)]
[Case(2, RawSize.Small)]
public void CanonSRawQualityGivesTheRawSize(int quality, RawSize expected)
{
var m = Cr2(CanonSettings(3, (ushort)quality));
Assert.Equal(ImageFileFormat.Cr2, m.Format);
Assert.Equal(expected, m.RawSize);
Assert.Equal(3, m.ExposureProgram);
// Bodies whose settings stop before the sRAW field record no size.
Assert.Null(Cr2([.. CanonSettings(3, (ushort)quality).Take(40)]).RawSize);
}
[Test]
public void NikonRawSizeComesFromImageSizeRawOrTheSmallNefCompression()
{
static FrameMetadata Nikon(IfdSpec ifd) => Jpeg("NIKON CORPORATION", "NIKON Z 8", [], ifd);
Assert.Equal(RawSize.Medium, Nikon(new IfdSpec().Short(0x003E, 2)).RawSize);
Assert.Equal(RawSize.Small, Nikon(new IfdSpec().Short(0x003E, 3)).RawSize);
Assert.Equal(RawSize.Full, Nikon(new IfdSpec().Short(0x003E, 1).Short(0x0093, 3)).RawSize);
Assert.Equal(RawSize.Small, Nikon(new IfdSpec().Short(0x0093, 8)).RawSize);
Assert.Null(Nikon(new IfdSpec().Short(0x0093, 3)).RawSize);
// Nikon keeps interval shooting in its encrypted ShotInfo only.
Assert.Null(Nikon(new IfdSpec().Short(0x003E, 1)).IntervalShooting);
}
[Test]
public void OlympusFujifilmAndSonyExposureModes()
{
var olympus = Jpeg("OLYMPUS", "E-M1MarkIII", [.. "OLYMP\0"u8, 1, 0], new IfdSpec().Child(0x2020, new IfdSpec().Short(0x0200, 4)));
Assert.Equal(4, olympus.ExposureProgram);
var fuji = Jpeg("FUJIFILM", "X-T5", [.. "FUJIFILM"u8, 12, 0, 0, 0], new IfdSpec().Short(0x1031, 0x300), relativeToTiff: false);
Assert.Equal(1, fuji.ExposureProgram);
var fujiAperture = Jpeg("FUJIFILM", "X-T5", [.. "FUJIFILM"u8, 12, 0, 0, 0], new IfdSpec().Short(0x1031, 0x100), relativeToTiff: false);
Assert.Equal(3, fujiAperture.ExposureProgram);
var sony = Jpeg("SONY", "ILCE-7M4", [.. "SONY DSC \0\0\0"u8], new IfdSpec().Short(0xB041, 8));
Assert.Equal(4, sony.ExposureProgram);
var sonyAuto = Jpeg("SONY", "ILCE-7M4", [.. "SONY DSC \0\0\0"u8], new IfdSpec().Short(0xB041, 6));
Assert.Null(sonyAuto.ExposureProgram);
}
[Theory]
[Case(1, true)]
[Case(0, false)]
[Case(2, false)]
[Case(3, false)]
public void PanasonicTimerRecordingIsTheIntervalometerHint(int timerRecording, bool expected)
{
var m = Jpeg("Panasonic", "DC-GH6", [.. "Panasonic\0\0\0"u8], new IfdSpec().Short(0x001F, 11).Short(0x0096, (ushort)timerRecording));
Assert.Equal(expected, m.IntervalShooting);
Assert.Equal(1, m.ExposureProgram);
}
[Test]
public void WithoutTheTagsNothingIsGuessed()
{
var m = Jpeg("Panasonic", "DC-GH6", [.. "Panasonic\0\0\0"u8], new IfdSpec().Short(0x001A, 2));
Assert.Equal(((bool?)null, (RawSize?)null, (int?)null), (m.IntervalShooting, m.RawSize, m.ExposureProgram));
}
}
@@ -88,6 +88,60 @@ public sealed class ArchiveJobTests(TestContext context)
Assert.Contains("made 3, reused 3", done.LogTail);
}
[Test]
public async Task AThumbnailPassFlagsFramesNothingDecodesAndClearsThemOnceTheyDecode()
{
await using var fx = await CreateAsync(context);
var files = Photos.WriteSeries(Path.Combine(fx.Paths.Root, "a"), Start, 6);
await fx.ScanAsync();
var a = (await LocationsAsync(fx))[0];
var sequence = (await fx.Db.Sequences.GetAsync(a.Id))!;
var paths = fx.Paths.Sequence(a.Folder);
var original = await File.ReadAllBytesAsync(files[2], fx.Ct);
await File.WriteAllBytesAsync(files[2], new byte[original.Length], fx.Ct);
var result = await fx.Service.Images.BuildThumbnailsAsync(fx.Archive, sequence, false, 0, (_, _) => ValueTask.CompletedTask, fx.Ct);
Assert.Equal((5, 1), (result.Built, result.Undecodable));
var frame = ManifestStore.ReadSequence(paths.ManifestPath).Frames[2];
Assert.Equal((Titano.Core.Imaging.DecodeTier.Unavailable, FrameFlags.Undecodable), (frame.Tier, frame.Flags));
Assert.Equal(FrameFlags.Undecodable, (await fx.Db.Frames.ListBySequenceAsync(a.Id))[2].Flags);
Assert.True((await fx.Db.Sequences.GetAsync(a.Id))!.Status.HasFlag(SequenceStatus.HasWarnings), "the sequence warns at once");
// Restored from a copy: the next pass decodes the frame and clears the flag; the others are reused.
await File.WriteAllBytesAsync(files[2], original, fx.Ct);
result = await fx.Service.Images.BuildThumbnailsAsync(fx.Archive, sequence, false, 0, (_, _) => ValueTask.CompletedTask, fx.Ct);
Assert.Equal((1, 5, 0), (result.Built, result.Reused, result.Undecodable));
frame = ManifestStore.ReadSequence(paths.ManifestPath).Frames[2];
Assert.Equal((Titano.Core.Imaging.DecodeTier.Native, FrameFlags.None), (frame.Tier, frame.Flags));
Assert.Equal(FrameFlags.None, (await fx.Db.Frames.ListBySequenceAsync(a.Id))[2].Flags);
}
[Test]
public async Task AHostWithoutADecoderForTheFormatRecordsTheTierWithoutFlaggingTheFrames()
{
// The fixture's decoder chain is empty: only JPEG decodes here (its decoder is built in), PNG does not.
await using var fx = await CreateAsync(context);
var folder = Path.Combine(fx.Paths.Root, "p");
Directory.CreateDirectory(folder);
using (var image = new Titano.Core.Imaging.ImageBuffer(32, 24))
{
for (var i = 0; i < 3; i++) File.WriteAllBytes(Path.Combine(folder, $"P{i}.png"), Titano.Core.Codecs.Png.PngEncoder.Encode(image));
}
await fx.ScanAsync();
var p = (await LocationsAsync(fx)).Single();
var result = await fx.Service.Images.BuildThumbnailsAsync(fx.Archive, (await fx.Db.Sequences.GetAsync(p.Id))!, false, 0,
(_, _) => ValueTask.CompletedTask, fx.Ct);
// Another host (or a proxy) may still provide the pixels: the tier is recorded, the frames stay renderable.
Assert.Equal(3, result.Undecodable);
var frames = ManifestStore.ReadSequence(fx.Paths.Sequence(p.Folder).ManifestPath).Frames;
Assert.True(frames.All(f => f.Tier == Titano.Core.Imaging.DecodeTier.Unavailable && f.Flags == FrameFlags.None), "tier without flag");
Assert.True((await fx.Db.Frames.ListBySequenceAsync(p.Id)).All(f => f.Flags == FrameFlags.None), "index flags");
Assert.False((await fx.Db.Sequences.GetAsync(p.Id))!.Status.HasFlag(SequenceStatus.HasWarnings), "no warning");
}
[Test]
public async Task AMaintenanceJobResumesAfterItsDoneSteps()
{
@@ -1,9 +1,17 @@
using Titano.Core.Advice;
using Titano.Core.Analysis;
using Titano.Core.Analysis.Deep;
using Titano.Core.Archiving;
using Titano.Core.Codecs.Dng;
using Titano.Core.Codecs.Jpeg;
using Titano.Core.Diagnostics.Synthetic;
using Titano.Core.Imaging;
using Titano.Core.Import;
using Titano.Core.Localization;
using Titano.Core.Metadata;
using Titano.Core.Model;
using Titano.Core.Project;
using Titano.Data.Archiving.Jobs;
using Titano.Data.Processing;
using Titano.Data.Processing.Jobs;
using Titano.Data.Repositories;
@@ -62,6 +70,207 @@ public sealed class AnalysisJobTests(TestContext context)
Assert.Equal(version, (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!.SettingsVersion);
}
[Test]
public async Task LightAnalysisRecordsFormatTiersAndTheAdvisorCapsTheOutputAtThePreviews()
{
await using var fx = await ProcessingFixture.CreateAsync(context);
var sequence = await fx.AddAsync(Flickering(12));
// This host reads the first ten files only through 48×32 embedded previews and cannot decode the last one.
for (var i = 0; i < 10; i++)
fx.Decoder.Tiers[ProcessingFixture.FileName(i)] = new FileTier(ImageFileFormat.Jpeg, DecodeTier.EmbeddedPreview, "test-preview", "test", 48, 32);
fx.Decoder.Tiers[ProcessingFixture.FileName(11)] = new FileTier(ImageFileFormat.Jpeg, DecodeTier.Unavailable, null, "test", 0, 0);
await fx.StartEngineAsync();
var job = await fx.EnqueueAsync(ProcessingJobs.LightAnalysis([sequence.Id]));
await fx.WaitForAsync(job.Id, JobState.Done);
var folder = fx.Folder(sequence);
var sidecar = ManifestStore.ReadSequence(folder.ManifestPath).Frames;
Assert.Equal((DecodeTier.EmbeddedPreview, FrameFlags.PreviewOnly, (int?)48, (int?)32), (sidecar[0].Tier, sidecar[0].Flags, sidecar[0].PreviewW, sidecar[0].PreviewH));
Assert.Equal((DecodeTier.Native, FrameFlags.None), (sidecar[10].Tier, sidecar[10].Flags));
Assert.Equal((DecodeTier.Unavailable, FrameFlags.Undecodable), (sidecar[11].Tier, sidecar[11].Flags));
var rows = await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct);
Assert.Equal((FrameFlags.PreviewOnly, 48, 32), (rows[3].Flags, rows[3].PreviewWidth, rows[3].PreviewHeight));
Assert.Equal(FrameFlags.Undecodable, rows[11].Flags);
var row = (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!;
Assert.Equal(10, row.PreviewOnlyCount);
Assert.GreaterOrEqual(row.WarningCount, 1);
Assert.True(row.Status.HasFlag(SequenceStatus.HasWarnings), "the undecodable frame is a sequence warning");
// The advisor reads the preview size from the index and caps the output there (BRIEF §8.2 tier 2).
var tiers = SequenceContext.FromFrames(rows);
Assert.Equal((10, 48, 32), (tiers.PreviewOnlyCount, tiers.PreviewWidth, tiers.PreviewHeight));
var light = LightAnalyzer.Analyze(rows);
var advice = Advisor.Recommend(light, null, tiers);
Assert.Equal(AdvisorKeys.ResolutionPreview, advice.Find(AdvisorParameters.Resolution)!.ReasonKey);
Assert.Contains(advice.Findings, f => f.Key == FindingKeys.PreviewOnly && Equals(f.Arguments[0], 10));
Assert.Contains(advice.Findings, f => f.Key == DeepFindingKeys.UnreadableFrames && f.Frames.SequenceEqual([11]));
// Probed once: a second pass opens no file for its tier and leaves the sidecar alone.
fx.Decoder.Tiers.Clear();
var written = File.GetLastWriteTimeUtc(folder.ManifestPath);
var again = await fx.EnqueueAsync(ProcessingJobs.LightAnalysis([sequence.Id]));
await fx.WaitForAsync(again.Id, JobState.Done);
Assert.Equal(FrameFlags.PreviewOnly, ManifestStore.ReadSequence(folder.ManifestPath).Frames[0].Flags);
Assert.Equal(written, File.GetLastWriteTimeUtc(folder.ManifestPath));
}
[Test]
public async Task DeepAnalysisFlagsFramesItCannotDecodeAndListsThemOnce()
{
await using var fx = await ProcessingFixture.CreateAsync(context);
var sequence = await fx.AddAsync(Flickering(12));
// Damaged after indexing: the header probe still says JPEG, only decoding finds out.
await File.WriteAllBytesAsync(Path.Combine(fx.Folder(sequence).Folder, ProcessingFixture.FileName(4)), new byte[3000], fx.Ct);
await fx.StartEngineAsync();
var job = await fx.EnqueueAsync(ProcessingJobs.DeepAnalysis([sequence.Id]));
var done = await fx.WaitForAsync(job.Id, JobState.Done);
var sidecar = ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Frames;
Assert.Equal((DecodeTier.Unavailable, FrameFlags.Undecodable), (sidecar[4].Tier, sidecar[4].Flags));
Assert.Equal(DecodeTier.Native, sidecar[5].Tier);
Assert.Equal(FrameFlags.Undecodable, (await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct))[4].Flags);
var report = SequenceAnalyser.ReadReport(fx.Folder(sequence), sequence.FrameCount)!;
var rows = await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct);
var findings = Advisor.Recommend(LightAnalyzer.Analyze(rows), report, SequenceContext.FromFrames(rows)).Findings;
Assert.Count(1, findings.Where(f => f.Key == DeepFindingKeys.UnreadableFrames));
Assert.True((await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!.WarningCount >= 1, "listed in the sequence warnings");
Assert.Equal(JobState.Done, done.State);
}
[Test]
public async Task AnImportedGoProRawDecodesThroughTheJpegItsImportKeptInAnotherSequence()
{
await using var fx = await ProcessingFixture.CreateAsync(context);
// A GoPro card: each GPR (VC-5, without a usable embedded image here) has the camera's full-size JPEG beside it.
// An upload may send the GPRs first: they arrive as two cards here.
var raws = Path.Combine(context.CreateTempDirectory("card"), "DCIM", "100GOPRO");
var jpegs = Path.Combine(context.CreateTempDirectory("card"), "DCIM", "100GOPRO");
Directory.CreateDirectory(raws);
Directory.CreateDirectory(jpegs);
var start = new DateTime(2026, 9, 28, 18, 0, 0);
for (var i = 0; i < 4; i++)
{
var metadata = new FrameMetadata { Make = "GoPro", Model = "HERO12 Black", BodySerial = "C3501", CapturedAt = start.AddSeconds(5 * i) };
using var sensor = new ImageBuffer(64, 48);
File.WriteAllBytes(Path.Combine(raws, $"GOPR{i + 1:0000}.GPR"),
LinearDngWriter.Write(sensor, new LinearDngOptions { Exif = ExifWriter.BuildTiff(metadata), TileSize = 64 }));
using var picture = new ImageBuffer(160, 120);
picture.Plane(1).Fill(0.25f * (i + 1));
File.WriteAllBytes(Path.Combine(jpegs, $"GOPR{i + 1:0000}.JPG"),
JpegEncoder.Encode(picture, new JpegEncodeOptions { App1Segments = [ExifWriter.BuildJpegApp1(metadata)[4..]] }));
}
var service = fx.Archive.Service;
async Task<ImportPlan> ImportAsync(string card)
{
var plan = await service.PlanImportAsync(fx.Archive.Archive.Id, Path.GetDirectoryName(Path.GetDirectoryName(card))!, new ImportOptions(),
cancellationToken: fx.Ct);
await service.Imports.ExecuteAsync(new ImportJobParameters(fx.Archive.Archive.Id, plan, null, true, null), Guid.NewGuid(), 0,
_ => ValueTask.CompletedTask, null, fx.Ct);
return plan;
}
var gprSession = (await ImportAsync(raws)).Sessions.Single();
Assert.Equal(ImageFileFormat.Gpr, gprSession.Format);
var id = await fx.Db.Sequences.FindBySessionKeyAsync(fx.Archive.Archive.Id, gprSession.SessionKey, fx.Ct);
var sequence = (await fx.Db.Sequences.GetAsync(id!.Value, fx.Ct))!;
await fx.StartEngineAsync();
// Alone, a GPR without an embedded preview gives no pixels here, which proves nothing about the file.
var first = await fx.EnqueueAsync(ProcessingJobs.LightAnalysis([sequence.Id]));
await fx.WaitForAsync(first.Id, JobState.Done);
var alone = ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Frames;
Assert.True(alone.All(f => f is { Tier: DecodeTier.Unavailable, Flags: FrameFlags.None, PreviewW: null }), "unavailable, not flagged");
// The JPEGs arrive as a sequence of their own (the import splits per file format, DECISIONS 2026-10-02); the next
// probe finds each GPR's JPEG there, so the output cap is the JPEG's size.
Assert.Equal(ImageFileFormat.Jpeg, (await ImportAsync(jpegs)).Sessions.Single().Format);
var jpegFrame = (await fx.Db.Frames.ListByCaptureRangeAsync(fx.Archive.Archive.Id, ImageFileFormat.Jpeg, start, start.AddMinutes(1), fx.Ct))[0];
Assert.NotEqual(Path.GetDirectoryName(fx.Folder(sequence).File(alone[0].File)), Path.GetDirectoryName(fx.Archive.Paths.FromRelative(jpegFrame.RelativePath)),
"not beside the GPR");
var light = await fx.EnqueueAsync(ProcessingJobs.LightAnalysis([sequence.Id]));
await fx.WaitForAsync(light.Id, JobState.Done);
var sidecar = ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Frames;
Assert.True(sidecar.All(f => f is { Tier: DecodeTier.EmbeddedPreview, Flags: FrameFlags.PreviewOnly, PreviewW: 160, PreviewH: 120 }),
"preview-only at the JPEG's size");
// The deep pass decodes the GPRs through those JPEGs (decoder "managed-sidecar"), never failing a frame.
var deep = await fx.EnqueueAsync(ProcessingJobs.DeepAnalysis([sequence.Id]));
await fx.WaitForAsync(deep.Id, JobState.Done);
var gprs = fx.Decoder.Decoded.Where(d => d.File.EndsWith(".GPR", StringComparison.OrdinalIgnoreCase)).ToList();
Assert.NotEmpty(gprs);
Assert.True(gprs.All(d => d.Decoder == "managed-sidecar"), string.Join(", ", gprs.Select(d => d.Decoder).Distinct()));
Assert.Empty(SequenceAnalyser.ReadReport(fx.Folder(sequence), sequence.FrameCount)!.Issues.Undecodable);
}
[Test]
public async Task DeepAnalysisNeverFlagsFramesThatVanishedOrCouldNotBeRead()
{
await using var fx = await ProcessingFixture.CreateAsync(context);
var sequence = await fx.AddAsync(Flickering(12));
// Deleted after indexing (a verify flags it missing), and held by another program during the pass.
File.Delete(Path.Combine(fx.Folder(sequence).Folder, ProcessingFixture.FileName(3)));
fx.Decoder.Unreadable[ProcessingFixture.FileName(6)] = 0;
await fx.StartEngineAsync();
var job = await fx.EnqueueAsync(ProcessingJobs.DeepAnalysis([sequence.Id]));
await fx.WaitForAsync(job.Id, JobState.Done);
// The pass could not read them, so it lists them as unreadable, but nothing proves the files undecodable.
var report = SequenceAnalyser.ReadReport(fx.Folder(sequence), sequence.FrameCount)!;
Assert.SequenceEqual([3, 6], report.Issues.Undecodable);
var sidecar = ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Frames;
foreach (var index in new[] { 3, 6 })
{
Assert.Equal(FrameFlags.None, sidecar[index].Flags & FrameFlags.Undecodable);
Assert.NotEqual(DecodeTier.Unavailable, sidecar[index].Tier);
}
var rows = await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct);
Assert.True(rows.All(f => (f.Flags & FrameFlags.Undecodable) == 0), "no frame flagged in the index");
var unreadable = Advisor.Recommend(LightAnalyzer.Analyze(rows), report, SequenceContext.FromFrames(rows)).Findings
.Single(f => f.Key == DeepFindingKeys.UnreadableFrames);
Assert.SequenceEqual([3, 6], unreadable.Frames);
// Back in place and readable, the next pass reads both frames.
fx.Decoder.Unreadable.Clear();
await File.WriteAllBytesAsync(Path.Combine(fx.Folder(sequence).Folder, ProcessingFixture.FileName(3)),
await File.ReadAllBytesAsync(Path.Combine(fx.Folder(sequence).Folder, ProcessingFixture.FileName(2)), fx.Ct), fx.Ct);
var again = await fx.EnqueueAsync(ProcessingJobs.DeepAnalysis([sequence.Id]));
await fx.WaitForAsync(again.Id, JobState.Done);
Assert.Empty(SequenceAnalyser.ReadReport(fx.Folder(sequence), sequence.FrameCount)!.Issues.Undecodable);
}
[Test]
public async Task AResumedDeepAnalysisDecodesAgainWhatTheEarlierRunCouldNotRead()
{
await using var fx = await ProcessingFixture.CreateAsync(context);
var sequence = await fx.AddAsync(Flickering());
// The first run cannot read frame 12 (held by another program) and is cancelled later, at frame 26.
fx.Decoder.Unreadable[ProcessingFixture.FileName(11)] = 0;
fx.Decoder.HoldFrame(25);
await fx.StartEngineAsync();
var job = await fx.EnqueueAsync(ProcessingJobs.DeepAnalysis([sequence.Id]));
await fx.Decoder.Holding.Task.WaitAsync(TimeSpan.FromSeconds(60), fx.Ct);
await fx.Engine.CancelAsync(job.Id, fx.Ct);
await fx.WaitForAsync(job.Id, JobState.Cancelled);
// Readable again; the resumed run takes frame 12 from its checkpoint (it is not in the region sample).
fx.Decoder.Unreadable.Clear();
fx.Decoder.Hold = null;
while (fx.Decoder.Requests.TryDequeue(out _))
{
}
await fx.Engine.ResumeAsync(job.Id, fx.Ct);
await fx.WaitForAsync(job.Id, JobState.Done);
Assert.Contains(11, SequenceAnalyser.ReadReport(fx.Folder(sequence), sequence.FrameCount)!.Issues.Undecodable);
// That verdict was a read error: decoding the frame again shows it is fine, so nothing flags it.
Assert.Count(1, fx.Decoder.Requests.Where(r => Path.GetFileName(r.Path) == ProcessingFixture.FileName(11)));
var frame = ManifestStore.ReadSequence(fx.Folder(sequence).ManifestPath).Frames[11];
Assert.Equal((DecodeTier.Native, FrameFlags.None), (frame.Tier, frame.Flags & FrameFlags.Undecodable));
Assert.Equal(FrameFlags.None, (await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct))[11].Flags);
}
[Test]
public async Task DeepAnalysisResumesAfterCancellationWithTheSameReport()
{
@@ -123,18 +123,43 @@ internal sealed class GateDecoder : IImageDecoderProvider
Hold = ProcessingFixture.FileName(index);
}
/// <summary>Tiers <see cref="Probe(string, ImageFileFormat)"/> reports per file name instead of the managed provider's (a
/// host that reads them only as previews, or not at all).</summary>
public ConcurrentDictionary<string, FileTier> Tiers { get; } = new();
/// <summary>Files (by name) whose decodes report the embedded-preview tier from a preview of this oriented size, as
/// a size-limited decode that picked a smaller preview would.</summary>
public ConcurrentDictionary<string, (int Width, int Height)> PreviewDecodes { get; } = new();
/// <summary>Files (by name) that cannot be read: their decodes throw <see cref="IOException"/> (a sharing violation).</summary>
public ConcurrentDictionary<string, byte> Unreadable { get; } = new();
/// <summary>File name and decoder of every decode that produced pixels.</summary>
public ConcurrentQueue<(string File, string Decoder)> Decoded { get; } = new();
public DecodeTier? TierFor(ImageFileFormat format) => _managed.TierFor(format);
public FileTier Probe(string path, ImageFileFormat format) => Probe(path, format, null);
public FileTier Probe(string path, ImageFileFormat format, string? companion) =>
Tiers.TryGetValue(Path.GetFileName(path), out var tier) ? tier : _managed.Probe(path, format, companion);
public DecodedImage? Decode(DecodeRequest request, CancellationToken cancellationToken = default)
{
Requests.Enqueue(request);
if (Hold is { } hold && Path.GetFileName(request.Path) == hold && (HoldPurpose ?? request.Purpose) == request.Purpose
var name = Path.GetFileName(request.Path);
if (Hold is { } hold && name == hold && (HoldPurpose ?? request.Purpose) == request.Purpose
&& (HoldEdge ?? request.MaxLongEdge) == request.MaxLongEdge)
{
Holding.TrySetResult();
cancellationToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(30));
cancellationToken.ThrowIfCancellationRequested();
}
return _managed.Decode(request, cancellationToken);
if (Unreadable.ContainsKey(name)) throw new IOException($"The process cannot access the file '{request.Path}' because it is being used by another process.");
var decoded = _managed.Decode(request, cancellationToken);
if (decoded is null) return null;
Decoded.Enqueue((name, decoded.Decoder));
if (!PreviewDecodes.TryGetValue(name, out var preview)) return decoded;
return new DecodedImage(decoded.Pixels, DecodeTier.EmbeddedPreview, "test-preview", preview.Width, preview.Height);
}
}
@@ -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()
{
@@ -51,6 +51,7 @@ public abstract class CatalogRepositoryTests(TestContext context) : RepositoryTe
FramesVersion = 7,
OwnerUserId = Guid.CreateVersion7(),
WarningCount = 2,
PreviewOnlyCount = 1150,
Tags = ["Sunset", "harbour", "SUNSET"],
};
await db.Sequences.UpsertAsync(sequence, Ct);
@@ -248,6 +249,8 @@ public abstract class CatalogRepositoryTests(TestContext context) : RepositoryTe
Orientation = 6,
PreviewOffset = 1024,
PreviewLength = 65536,
PreviewWidth = 1620,
PreviewHeight = 1080,
MeanLogLuminance = -2.5,
ClipLow = 0.01,
ClipHigh = 0.02,
@@ -307,6 +310,29 @@ public abstract class CatalogRepositoryTests(TestContext context) : RepositoryTe
Assert.Equal(1200, await db.Frames.DeleteBySequenceAsync(sequence.Id, Ct));
}
[Test]
public async Task FrameTiersUpdateInBulkAndSurviveASyncFromTheSidecar()
{
var db = await OpenTitanoAsync();
var archive = TestData.Archive();
await db.Archives.UpsertAsync(archive, Ct);
var sequence = TestData.Sequence(archive.Id);
await db.Sequences.UpsertAsync(sequence, Ct);
// More frames than one batched PostgreSQL statement holds.
const int count = 1205;
var frames = Enumerable.Range(0, count).Select(i => TestData.Frame(sequence.Id, i) with { Flags = FrameFlags.Duplicate }).ToList();
await db.Frames.BulkInsertAsync(frames, Ct);
var tiers = frames.Select(f => new FrameTierFields(f.Id, f.Index % 2 == 0 ? FrameFlags.PreviewOnly : FrameFlags.Undecodable, 1620 + f.Index, 1080)).ToList();
Assert.Equal(count, await db.Frames.UpdateTiersAsync(tiers, Ct));
var read = await Titano.Data.Processing.SequenceFrames.ListAsync(db, sequence.Id, Ct);
Assert.SequenceEqual(tiers.Select(t => (t.Flags, t.PreviewWidth, t.PreviewHeight)), read.Select(f => (f.Flags, f.PreviewWidth, f.PreviewHeight)));
// A sync from the sidecar writes the tier fields like every other one.
await db.Frames.SyncSequenceAsync(sequence.Id, [.. read.Select(f => f with { PreviewWidth = 4, PreviewHeight = 3, Flags = FrameFlags.None })], Ct);
Assert.True((await Titano.Data.Processing.SequenceFrames.ListAsync(db, sequence.Id, Ct)).All(f => (f.Flags, f.PreviewWidth, f.PreviewHeight) == (FrameFlags.None, 4, 3)));
}
[Test]
public async Task RendersKeepTheSequenceCountInStep()
{
@@ -15,6 +15,28 @@ public sealed class SqliteBindingTests(TestContext context) : DatabaseTest(conte
Assert.True(parts[0] > 3 || (parts[0] == 3 && parts[1] >= 31), $"SQLite {SqliteDatabase.LibraryVersion}");
}
[Test]
public async Task CompileOptionsAreProbedOnceAndMatchTheLibrary()
{
await using var database = await OpenDatabaseAsync();
var options = SqliteDatabase.CompileOptions;
// Informational and probed once: the same list on every call, and what any connection reports.
Assert.Same(options, SqliteDatabase.CompileOptions);
await using var session = await database.OpenAsync(Ct);
Assert.SequenceEqual(await session.QueryListAsync("PRAGMA compile_options", [], r => r.GetString(0), Ct), options);
// Linux libraries keep the diagnostics (a Windows build may omit them, which leaves the list empty).
if (!OperatingSystem.IsWindows()) Assert.Contains(options, o => o.StartsWith("THREADSAFE=", StringComparison.Ordinal));
}
[Test]
public void AProbeThatFailsInAnyWayGivesNoOptionsInsteadOfBlockingTheIndex()
{
// A build that returns no statement for the pragma, a column it cannot read, a SQLite error: none escapes.
Assert.Empty(SqliteDatabase.ProbeCompileOptions(() => throw new ArgumentException("No statement in 'PRAGMA compile_options'.")));
Assert.Empty(SqliteDatabase.ProbeCompileOptions(() => throw new InvalidOperationException("Column type 5 is not text.")));
Assert.SequenceEqual(["THREADSAFE=1"], SqliteDatabase.ProbeCompileOptions(() => ["THREADSAFE=1"]));
}
[Test]
public async Task ConnectionsUseTheBriefPragmas()
{
@@ -228,4 +228,41 @@ public sealed class SequenceTests(TestContext context)
using var analysis = await editor.GetAsync($"/api/v1/sequences/{id}/analysis");
Assert.Equal("analysis", (await analysis.ExpectErrorAsync(HttpStatusCode.NotFound, "not_found")).Details);
}
[Test]
public async Task CardsAndFramesCarryTheDecodeTierFields()
{
await using var server = await TestServer.StartAsync(context);
var (editor, _, _) = await server.UserAsync("alberto", "editor");
var first = await Uploads.UploadAsync(editor, Uploads.Photo(1000, 50), "t0.CR3", sessionKey: "t");
await Uploads.UploadAsync(editor, Uploads.Photo(1001, 51), "t1.CR3", sessionKey: "t");
var db = server.Database;
// The follow-up jobs of the upload (thumbnails, proxies, light analysis) rewrite the rows: let them finish first.
for (var waited = 0; waited < 600; waited++)
{
if ((await db.Jobs.ListAsync(Titano.Core.Model.JobState.Queued)).Items.Count == 0
&& (await db.Jobs.ListAsync(Titano.Core.Model.JobState.Running)).Items.Count == 0) break;
await Task.Delay(50, context.Cancellation);
}
// What a light analysis on the server records for CR3s it reads only through their previews.
var frames = await db.Frames.ListBySequenceAsync(first.SequenceId);
await db.Frames.UpdateTiersAsync([.. frames.Select(f => new Titano.Data.Repositories.FrameTierFields(f.Id, Titano.Core.Model.FrameFlags.PreviewOnly, 1620, 1080))]);
var sequence = (await db.Sequences.GetAsync(first.SequenceId))!;
await db.Sequences.UpsertAsync(sequence with { PreviewOnlyCount = 2 });
// The Library cards read the count (the chip), the remote editor the preview size (the output cap).
using var list = await editor.GetAsync("/api/v1/sequences");
await list.ExpectAsync(HttpStatusCode.OK);
Assert.Contains("\"previewOnlyCount\":2", await list.Content.ReadAsStringAsync());
using var listed = await editor.GetAsync("/api/v1/sequences");
Assert.Equal(2, (await listed.ReadAsync(ProtocolJson.Default.PageSequenceDto)).Items.Single(s => s.Id == first.SequenceId).PreviewOnlyCount);
using var page = await editor.GetAsync($"/api/v1/sequences/{first.SequenceId}/frames");
await page.ExpectAsync(HttpStatusCode.OK);
var json = await page.Content.ReadAsStringAsync();
Assert.Contains("\"previewWidth\":1620", json);
Assert.Contains("\"previewHeight\":1080", json);
using var typed = await editor.GetAsync($"/api/v1/sequences/{first.SequenceId}/frames");
var dtos = (await typed.ReadAsync(ProtocolJson.Default.PageFrameDto)).Items;
Assert.True(dtos.All(f => (f.PreviewWidth, f.PreviewHeight, f.Flags) == (1620, 1080, (long)Titano.Core.Model.FrameFlags.PreviewOnly)), "frame DTOs");
}
}