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
@@ -16,14 +16,32 @@ 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. Frames that cannot be decoded are reported by both (the light analysis reads the
|
||||
/// undecodable flags, the deep pass also counts missing and corrupt files and those beyond this host's decoders):
|
||||
/// they are listed once, over the union of both lists, at the higher severity. 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()));
|
||||
foreach (var finding in deep?.Findings.Select(f => f.ToFinding()) ?? [])
|
||||
{
|
||||
var shared = finding.Key == DeepFindingKeys.UnreadableFrames ? findings.FindIndex(f => f.Key == finding.Key) : -1;
|
||||
if (shared < 0)
|
||||
{
|
||||
findings.Add(finding);
|
||||
continue;
|
||||
}
|
||||
var unreadable = light.UndecodableFrames.Union(deep!.Issues.Undecodable).Order().ToList();
|
||||
findings[shared] = findings[shared] with
|
||||
{
|
||||
Severity = (FindingSeverity)int.Max((int)findings[shared].Severity, (int)finding.Severity),
|
||||
Arguments = [unreadable.Count],
|
||||
Frames = [.. unreadable.Take(Finding.MaxFrames)],
|
||||
};
|
||||
}
|
||||
return new AdvisorResult(new AdvisorRules(light, deep, context).Run(), findings);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public static class AdvisorKeys
|
||||
|
||||
public static string TimingSessions { get; } = LocKey("Advisor.Reason.Timing.Sessions");
|
||||
public static string TimingIrregular { get; } = LocKey("Advisor.Reason.Timing.Irregular");
|
||||
public static string TimingIntervalometer { get; } = LocKey("Advisor.Reason.Timing.Intervalometer");
|
||||
public static string TimingSparseGapsSmooth { get; } = LocKey("Advisor.Reason.Timing.SparseGapsSmooth");
|
||||
public static string TimingSparseGaps { get; } = LocKey("Advisor.Reason.Timing.SparseGaps");
|
||||
public static string TimingManyGaps { get; } = LocKey("Advisor.Reason.Timing.ManyGaps");
|
||||
|
||||
@@ -185,11 +185,13 @@ internal sealed class AdvisorRules
|
||||
|
||||
/// <summary>
|
||||
/// Timing mode, in order: several capture sessions (pauses ≥ the session gap) → Adaptive; jitter above 10 % of the
|
||||
/// median interval → Adaptive; gaps that are sparse (≤ 2 % of intervals, each ≤ 10 × median) with smooth measured
|
||||
/// motion (95th percentile ≤ 1 % of the long edge per frame) → Interpolated, or Constant when motion is unknown or
|
||||
/// fast; denser gaps → Adaptive; otherwise Constant. Frame rate, in order: "fit to N s" target → the standard rate
|
||||
/// nearest frames/N; under 240 frames → 24 (clip ≥ 10 s); over 10 min at 30 fps → 60; several sessions → 30; fast
|
||||
/// motion (≥ 1 % of the long edge per frame) → 24; measured moderate motion (≥ 0.2 %) → 24; otherwise 30.
|
||||
/// median interval → Adaptive; gaps in a sequence the camera's own intervalometer shot (most frames carry its
|
||||
/// MakerNote hint), so its pauses were deliberate → Adaptive; gaps that are sparse (≤ 2 % of intervals, each ≤ 10 ×
|
||||
/// median) with smooth measured motion (95th percentile ≤ 1 % of the long edge per frame) → Interpolated, or Constant
|
||||
/// when motion is unknown or fast; denser gaps → Adaptive; otherwise Constant. Frame rate, in order: "fit to N s"
|
||||
/// target → the standard rate nearest frames/N; under 240 frames → 24 (clip ≥ 10 s); over 10 min at 30 fps → 60;
|
||||
/// several sessions → 30; fast motion (≥ 1 % of the long edge per frame) → 24; measured moderate motion (≥ 0.2 %) →
|
||||
/// 24; otherwise 30.
|
||||
/// </summary>
|
||||
private void Timing()
|
||||
{
|
||||
@@ -222,6 +224,11 @@ internal sealed class AdvisorRules
|
||||
_timing = TimingMode.Adaptive;
|
||||
Add(section, parameter, _timing, 0.7, AdvisorKeys.TimingIrregular, R(jitter, 2), R(median, 2));
|
||||
}
|
||||
else if (gaps.Count > 0 && 2 * _light.IntervalometerFrames > _light.FrameCount)
|
||||
{
|
||||
_timing = TimingMode.Adaptive;
|
||||
Add(section, parameter, _timing, 0.8, AdvisorKeys.TimingIntervalometer, gaps.Count);
|
||||
}
|
||||
else if (gaps.Count > 0)
|
||||
{
|
||||
var sparse = gaps.Count <= double.Max(1, 0.02 * _light.Intervals.Count) && gaps.All(g => g.Seconds <= 10 * median);
|
||||
|
||||
@@ -144,27 +144,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 ?? [],
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user