Skip to content

Commit b526e8b

Browse files
committed
Adding boolean attribute to temporarily stop decoding JPEGs
1 parent 9595438 commit b526e8b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Runtime/JPEGTurboVideoPlayer/Scripts/JPEGStreamReceiver.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ public float GetAxisDimension(scaleMeshAxis axis)
146146
[Tooltip("libjpeg-turbo is already fast, but it can run faster! Notice: Faster decoding can causes quality drops")]
147147
public bool FasterDecoding = false;
148148

149+
// adding the possibility to ignore frames when needed
150+
[Tooltip("Stops decoding frames (and updating textures) when this is set to true. Mostly used for debbugging and testing purposes.")]
151+
public bool IgnoreIncomingFrames = false;
152+
149153
// keeps track of how many frames were dropped due to
150154
// not being able to display them
151155
long droppedFrames = 0, decodedFrameErrors = 0, decodedFrames = 0, displayedFrames;
@@ -251,6 +255,11 @@ public void OnEnable()
251255

252256

253257
onenabletime = DateTime.Now;
258+
259+
if (IgnoreIncomingFrames)
260+
{
261+
Debug.LogWarning(string.Format("[JPEGStreamReceiver@{0}] IgnoreIncomingFrames is set to true! No frames will be decoded!", LogName));
262+
}
254263
}
255264

256265
public void OnDisable()
@@ -558,6 +567,12 @@ public void DecoderThread()
558567
///
559568
public void NewFrameArrived(byte[] frame)
560569
{
570+
if (IgnoreIncomingFrames)
571+
{
572+
++droppedFrames;
573+
return;
574+
}
575+
561576
if (frame != null)
562577
{
563578
// libjpeg decoder is available?

0 commit comments

Comments
 (0)