Browse Source

fix: improve speed of motion graphics element compositing (#2922)

* fix: improve speed of motion graphics element compositing

* update changelog
pull/2923/head
Jason Dove 2 months ago committed by GitHub
parent
commit
dca93717a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 21
      ErsatzTV.Infrastructure/Streaming/Graphics/Motion/MotionElement.cs

1
CHANGELOG.md

@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Use configured ffmpeg path for motion and subtitle graphics elements
- Previously, these elements required ffmpeg to be on PATH
- Fix erroneous warning `Unable to locate MPEG-TS Script in folder Default` on installations with case-sensitive file systems
- Improve speed of motion graphics element compositing
## [26.5.1] - 2026-05-08
### Fixed

21
ErsatzTV.Infrastructure/Streaming/Graphics/Motion/MotionElement.cs

@ -25,7 +25,6 @@ public class MotionElement( @@ -25,7 +25,6 @@ public class MotionElement(
private int _frameSize;
private PipeReader _pipeReader;
private SKPointI _point;
private SKBitmap _canvasBitmap;
private SKBitmap _motionFrameBitmap;
private TimeSpan _startTime;
private TimeSpan _endTime;
@ -55,7 +54,6 @@ public class MotionElement( @@ -55,7 +54,6 @@ public class MotionElement(
_cancellationTokenSource?.Dispose();
_canvasBitmap?.Dispose();
_motionFrameBitmap?.Dispose();
}
@ -119,12 +117,6 @@ public class MotionElement( @@ -119,12 +117,6 @@ public class MotionElement(
_frameSize = targetSize.Width * targetSize.Height * 4;
_canvasBitmap = new SKBitmap(
context.FrameSize.Width,
context.FrameSize.Height,
SKColorType.Bgra8888,
SKAlphaType.Unpremul);
_motionFrameBitmap = new SKBitmap(
targetSize.Width,
targetSize.Height,
@ -235,7 +227,7 @@ public class MotionElement( @@ -235,7 +227,7 @@ public class MotionElement(
{
if (contentTime <= _endTime)
{
return new PreparedElementImage(_canvasBitmap, SKPointI.Empty, 1.0f, ZIndex, false);
return new PreparedElementImage(_motionFrameBitmap, _point, 1.0f, ZIndex, false);
}
_state = MotionElementState.Finished;
@ -260,18 +252,11 @@ public class MotionElement( @@ -260,18 +252,11 @@ public class MotionElement(
sequence.CopyTo(pixmap.GetPixelSpan());
}
_canvasBitmap.Erase(SKColors.Transparent);
using (var canvas = new SKCanvas(_canvasBitmap))
{
canvas.DrawBitmap(_motionFrameBitmap, _point);
}
// mark this frame as consumed
consumed = sequence.End;
// we are done, return the frame
return new PreparedElementImage(_canvasBitmap, SKPointI.Empty, 1.0f, ZIndex, false);
return new PreparedElementImage(_motionFrameBitmap, _point, 1.0f, ZIndex, false);
}
if (readResult.IsCompleted)
@ -281,7 +266,7 @@ public class MotionElement( @@ -281,7 +266,7 @@ public class MotionElement(
if (motionElement.EndBehavior is MotionEndBehavior.Hold)
{
_state = MotionElementState.Holding;
return new PreparedElementImage(_canvasBitmap, SKPointI.Empty, 1.0f, ZIndex, false);
return new PreparedElementImage(_motionFrameBitmap, _point, 1.0f, ZIndex, false);
}
else
{

Loading…
Cancel
Save