Skip to content

Commit

Permalink
Adding boolean attribute to temporarily stop decoding JPEGs
Browse files Browse the repository at this point in the history
  • Loading branch information
danilogr committed Mar 4, 2022
1 parent 9595438 commit b526e8b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Runtime/JPEGTurboVideoPlayer/Scripts/JPEGStreamReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public float GetAxisDimension(scaleMeshAxis axis)
[Tooltip("libjpeg-turbo is already fast, but it can run faster! Notice: Faster decoding can causes quality drops")]
public bool FasterDecoding = false;

// adding the possibility to ignore frames when needed
[Tooltip("Stops decoding frames (and updating textures) when this is set to true. Mostly used for debbugging and testing purposes.")]
public bool IgnoreIncomingFrames = false;

// keeps track of how many frames were dropped due to
// not being able to display them
long droppedFrames = 0, decodedFrameErrors = 0, decodedFrames = 0, displayedFrames;
Expand Down Expand Up @@ -251,6 +255,11 @@ public void OnEnable()


onenabletime = DateTime.Now;

if (IgnoreIncomingFrames)
{
Debug.LogWarning(string.Format("[JPEGStreamReceiver@{0}] IgnoreIncomingFrames is set to true! No frames will be decoded!", LogName));
}
}

public void OnDisable()
Expand Down Expand Up @@ -558,6 +567,12 @@ public void DecoderThread()
///
public void NewFrameArrived(byte[] frame)
{
if (IgnoreIncomingFrames)
{
++droppedFrames;
return;
}

if (frame != null)
{
// libjpeg decoder is available?
Expand Down

0 comments on commit b526e8b

Please sign in to comment.