fix(imaging): record decode tiers per frame and keep undecodable frames out of renders

BRIEF §8.2 tiers 2 and 3 had no writer: PreviewOnly and Undecodable were never set,
so the advisor could not cap the output at the preview size and one unreadable frame
failed a whole render.

- ImageDecoder.Probe names a file's tier without decoding it (JPEG, PNG and TIFF
  without opening the file); the light analysis probes frames whose tier is unknown,
  and the deep analysis, renders from originals and thumbnail/proxy passes record
  what decoding actually found (FrameTiers). Sidecar frames gain "tier", "previewW"
  and "previewH"; the index gains frames.preview_width/height and
  sequences.preview_only_count (migration 0005, SQLite and PostgreSQL).
- SequenceContext takes the preview size from preview-only frames, so the advisor's
  output cap applies; the light analysis reports format tiers (preview-only frames as
  information, undecodable ones as a warning under the deep analysis' key, listed
  once); a sequence that gains undecodable frames warns at once.
- Only a file in a format the host decodes natively is flagged undecodable; files
  beyond the host's decoders keep their tier without the flag, so render nodes and
  proxies can still supply them.
- A frame that stops decoding during a render is replaced by its nearest planned
  neighbour and logged instead of failing the job; the render fails only when no
  planned frame decodes.
- The Library card shows a preview-only chip with the count (local and server
  sequences: SequenceDto.PreviewOnlyCount, FrameDto preview size).
- GoPro GPR decodes through the JPEG the camera writes beside it when that is larger
  than the embedded preview (BRIEF §8.1).
- Thumbnails use a stored embedded preview only when it reaches 320 px; a smaller one
  sends the frame through the host's decoders instead (BRIEF §8.5).

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 09:58:36 +00:00
1 parent 61d913baa9
commit 4d321a84b0
48 files changed
+1132 -87

No files matched your search

+5 -2
View File
@@ -16,14 +16,17 @@ public static class Advisor
{
/// <summary>
/// Recommendations for every parameter the rules cover (see <see cref="AdvisorRules"/>), in section order, plus
/// every finding of both analyses. Without a deep report, pixel-based parameters get missing-data recommendations.
/// every finding of both analyses; a finding both report (frames that cannot be decoded: the light analysis reads
/// the flags the deep pass recorded) is listed once, as the light analysis has it. Without a deep report,
/// pixel-based parameters get missing-data recommendations.
/// </summary>
public static AdvisorResult Recommend(LightAnalysisReport light, DeepAnalysisReport? deep, SequenceContext context)
{
ArgumentNullException.ThrowIfNull(light);
ArgumentNullException.ThrowIfNull(context);
var findings = new List<Finding>(light.Findings);
if (deep is not null) findings.AddRange(deep.Findings.Select(f => f.ToFinding()));
var lightKeys = light.Findings.Select(f => f.Key).ToHashSet(StringComparer.Ordinal);
if (deep is not null) findings.AddRange(deep.Findings.Select(f => f.ToFinding()).Where(f => !lightKeys.Contains(f.Key)));
return new AdvisorResult(new AdvisorRules(light, deep, context).Run(), findings);
}
+14 -3
View File
@@ -143,27 +143,38 @@ public sealed record SequenceContext
/// <summary>Wanted video length ("fit to N seconds"), when the user set one.</summary>
public double? TargetDurationSeconds { get; init; }
/// <summary>Context from the archive's frame rows: count, dominant oriented size, preview-only count, median shutter time.</summary>
/// <summary>
/// Context from the archive's frame rows: count, dominant oriented size, preview-only count with the dominant oriented
/// size of those frames' previews, median shutter time.
/// </summary>
public static SequenceContext FromFrames(IReadOnlyList<Frame> frames, IReadOnlyList<EncoderCapability>? codecs = null)
{
ArgumentNullException.ThrowIfNull(frames);
var sizes = new Dictionary<(int, int), int>();
var previews = new Dictionary<(int, int), int>();
var exposures = new List<double>();
var previewOnly = 0;
foreach (var f in frames)
{
var size = f.Orientation is >= 5 and <= 8 ? (f.Height, f.Width) : (f.Width, f.Height);
var rotated = f.Orientation is >= 5 and <= 8;
var size = rotated ? (f.Height, f.Width) : (f.Width, f.Height);
if (size.Item1 > 0 && size.Item2 > 0) sizes[size] = sizes.GetValueOrDefault(size) + 1;
if (f.ExposureTime is > 0 and var t) exposures.Add(t);
if ((f.Flags & FrameFlags.PreviewOnly) != 0) previewOnly++;
if ((f.Flags & FrameFlags.PreviewOnly) == 0) continue;
previewOnly++;
var preview = rotated ? (f.PreviewHeight, f.PreviewWidth) : (f.PreviewWidth, f.PreviewHeight);
if (preview.Item1 > 0 && preview.Item2 > 0) previews[preview] = previews.GetValueOrDefault(preview) + 1;
}
var (width, height) = sizes.Count > 0 ? sizes.MaxBy(kv => kv.Value).Key : (0, 0);
var (previewWidth, previewHeight) = previews.Count > 0 ? previews.MaxBy(kv => kv.Value).Key : (0, 0);
return new SequenceContext
{
FrameCount = frames.Count,
SourceWidth = width,
SourceHeight = height,
PreviewOnlyCount = previewOnly,
PreviewWidth = previewWidth,
PreviewHeight = previewHeight,
MedianExposureSeconds = exposures.Count > 0 ? Statistics.Median(exposures.ToArray()) : null,
Codecs = codecs ?? [],
};