Skip to content

Conversation

@meesoft
Copy link
Owner

@meesoft meesoft commented Dec 29, 2025

Summary by CodeRabbit

  • New Features

    • Improved time-based frame averaging and conditional local processing for faster speed-up scenarios
    • Enhanced video file naming to include a "stabilized" postfix when stabilization is active
  • Bug Fixes

    • Enforced minimum frame-combine count and refreshed processing args on changes
    • Adjusted stabilization behavior to skip scaling for Zoom effects
    • Prevented premature reads of processed frames by checking readiness before retrieval

✏️ Tip: You can customize this high-level summary in your review settings.

@meesoft meesoft force-pushed the features/TimeCompressionAverage branch from bd51fc5 to 7ff5d0a Compare January 1, 2026 16:19
@meesoft meesoft marked this pull request as ready for review January 3, 2026 14:10
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Walkthrough

Adds IsResultReady to CombineFramesOperationBase, introduces TimeCompressionAverageOperation for time-based averaging, and updates VideoTransformCommands to choose the new operation and refine stabilization/filtering and process-argument refresh logic.

Changes

Cohort / File(s) Summary
Base class property
PhotoLocator/BitmapOperations/CombineFramesOperationBase.cs
Added public virtual bool IsResultReady => _accumulatorPixels is not null; to expose when an accumulated result is available.
New frame averaging operation
PhotoLocator/BitmapOperations/TimeCompressionAverageOperation.cs
Added internal sealed TimeCompressionAverageOperation : CombineFramesOperationBase that accumulates frames, tracks collected frames, resets when target is reached, and returns scaling = 1.0 / number of frames.
Video processing command updates
PhotoLocator/VideoTransformCommands.cs
Property setters updated: SelectedEffect now calls UpdateStabilizeArgs(), CombineFramesMode/CombineFramesCount call UpdateProcessArgs() (count clamped >=1). Added SpeedupByEqualsCombineFramesCount. UpdateStabilizeArgs()/UpdateProcessArgs() skip scaling/fps filtering for Zoom in certain cases. RunLocalFrameProcessingAsync may use TimeCompressionAverageOperation for specific speed-up cases and checks IsResultReady before reading results. Save postfix logic updated to include stabilization suffix when active.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Time slice photo and video #45 — Adjusts CombineFrames pipeline and VideoTransformCommands processing paths that this PR extends with time-compression averaging selection.
  • Reverse video effect #54 — Alters VideoTransformCommands effect/stabilization logic and Zoom special-casing, overlapping changes to stabilization/filter construction.
  • Improve dark frame handling #53 — Modifies CombineFramesOperationBase internals that the new TimeCompressionAverageOperation depends on.

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Time Compression Average' directly corresponds to the main change: introducing TimeCompressionAverageOperation class that performs time-based frame averaging.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch features/TimeCompressionAverage

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 206dc2f and 1481069.

📒 Files selected for processing (1)
  • PhotoLocator/BitmapOperations/TimeCompressionAverageOperation.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • PhotoLocator/BitmapOperations/TimeCompressionAverageOperation.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (csharp)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
PhotoLocator/BitmapOperations/TimeCompressionAverageOperation.cs (1)

21-21: Consider using exact equality check.

The condition uses >= but _collectedFrames is always incremented by 1 and should never exceed _numberOfFramesToAverage. While >= provides defensive programming, using == would make the intent clearer and catch logic errors faster.

🔎 Proposed change
-if (_collectedFrames >= _numberOfFramesToAverage)
+if (_collectedFrames == _numberOfFramesToAverage)
PhotoLocator/VideoTransformCommands.cs (1)

701-702: LGTM!

The conditional logic correctly skips the setpts filter when using time compression averaging, since the speedup is inherent in the operation (every N frames → 1 output frame). This aligns with the operation selection logic at lines 1089-1091.

Optional: Consider extending optimization to other combine modes.

The time compression optimization is currently only applied to RollingAverage mode (lines 1089-1091, 701). Could FadingAverage and FadingMax also benefit from similar optimization when SpeedupByEqualsCombineFramesCount?

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b56221a and 206dc2f.

📒 Files selected for processing (3)
  • PhotoLocator/BitmapOperations/CombineFramesOperationBase.cs
  • PhotoLocator/BitmapOperations/TimeCompressionAverageOperation.cs
  • PhotoLocator/VideoTransformCommands.cs
🧰 Additional context used
🧬 Code graph analysis (1)
PhotoLocator/VideoTransformCommands.cs (5)
PhotoLocator/RenameWindow.xaml.cs (1)
  • SetProperty (76-83)
PhotoLocator/SlideShowWindow.xaml.cs (1)
  • SetProperty (70-77)
PhotoLocator/MainViewModel.cs (1)
  • SetProperty (57-64)
PhotoLocator/BitmapOperations/TimeCompressionAverageOperation.cs (2)
  • TimeCompressionAverageOperation (6-36)
  • TimeCompressionAverageOperation (11-15)
PhotoLocator/BitmapOperations/RollingAverageOperation.cs (2)
  • RollingAverageOperation (8-36)
  • RollingAverageOperation (13-18)
🔇 Additional comments (11)
PhotoLocator/BitmapOperations/CombineFramesOperationBase.cs (1)

62-63: LGTM!

The IsResultReady property cleanly exposes readiness state without leaking internal implementation details. The virtual modifier appropriately allows derived classes like TimeCompressionAverageOperation to provide custom readiness logic.

PhotoLocator/BitmapOperations/TimeCompressionAverageOperation.cs (3)

17-17: LGTM!

The override correctly implements the readiness check for time compression averaging. The result is only ready after collecting exactly the target number of frames, which properly coordinates with the processing pipeline in VideoTransformCommands.cs (lines 1104-1105).


32-35: LGTM!

The scaling factor correctly implements averaging. Ensure the constructor validation (flagged earlier) is added to prevent division by zero.


24-24: No action needed. The project targets .NET 10.0 (net10.0-windows), which is well beyond .NET 5.0 where the single-parameter Array.Clear overload was introduced. The code is correct and compatible with the target framework.

PhotoLocator/VideoTransformCommands.cs (7)

269-269: LGTM!

Adding UpdateStabilizeArgs() when the effect changes ensures that effect-specific stabilization adjustments (like skipping scaling for the Zoom effect at line 670) are applied correctly.


408-412: LGTM!

The clamping of CombineFramesCount to a minimum of 1 is good defensive programming that prevents invalid configurations and aligns with the requirements of TimeCompressionAverageOperation.


670-670: LGTM!

The Zoom effect handling is consistent across both UpdateStabilizeArgs() and UpdateProcessArgs(). Skipping manual scaling and FPS filtering when Zoom is selected is correct since the Zoom effect (line 236) manages these parameters internally.

Also applies to: 688-688, 703-703


1089-1091: LGTM!

The conditional selection between TimeCompressionAverageOperation and RollingAverageOperation is well-designed. Using time compression when the speedup factor matches the combine frames count is more efficient than maintaining a rolling window.


1104-1105: LGTM!

The IsResultReady check is essential for coordinating with TimeCompressionAverageOperation, which only produces a result after collecting all target frames. This correctly implements the time compression behavior by skipping intermediate frames.


1125-1126: LGTM!

The helper property cleanly encapsulates the speedup comparison logic and is used consistently throughout the file (lines 701, 1089). The TryParse approach gracefully handles invalid input.


1142-1144: LGTM!

The postfix naming logic now explicitly includes IsStabilizeChecked with the SmoothFrames parameter, providing clearer output file naming. The fallback to line 1144 still handles registration-only cases.

Comment on lines +11 to +15
public TimeCompressionAverageOperation(int numberOfFramesToAverage, string? darkFramePath, CombineFramesRegistration? registrationSettings, CancellationToken ct)
: base(darkFramePath, registrationSettings?.ToCombineFramesRegistrationBase(RegistrationOperation.Borders.Mirror), ct)
{
_numberOfFramesToAverage = numberOfFramesToAverage;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Validate numberOfFramesToAverage parameter.

The constructor doesn't validate that numberOfFramesToAverage is positive. If it's zero or negative, this will cause issues:

  • Zero would cause division by zero in GetResultScaling() (line 34)
  • Zero or negative values would break the readiness logic in IsResultReady (line 17)
🔎 Proposed fix
 public TimeCompressionAverageOperation(int numberOfFramesToAverage, string? darkFramePath, CombineFramesRegistration? registrationSettings, CancellationToken ct) 
     : base(darkFramePath, registrationSettings?.ToCombineFramesRegistrationBase(RegistrationOperation.Borders.Mirror), ct)
 {
+    if (numberOfFramesToAverage <= 0)
+        throw new ArgumentOutOfRangeException(nameof(numberOfFramesToAverage), "Must be greater than zero");
     _numberOfFramesToAverage = numberOfFramesToAverage;
 }
🤖 Prompt for AI Agents
In PhotoLocator/BitmapOperations/TimeCompressionAverageOperation.cs around lines
11 to 15, the constructor does not validate numberOfFramesToAverage allowing
zero or negative values which will lead to division by zero and incorrect
readiness logic; fix by validating that numberOfFramesToAverage is > 0 at the
start of the constructor and throw an ArgumentOutOfRangeException (or
ArgumentException) with the parameter name if the check fails, and only assign
_numberOfFramesToAverage after the validation.

@meesoft meesoft merged commit 652f5ea into main Jan 3, 2026
5 checks passed
@meesoft meesoft deleted the features/TimeCompressionAverage branch January 3, 2026 15:40
@coderabbitai coderabbitai bot mentioned this pull request Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants