mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
Wait for an IDR frame after dropping video data due to the decoder being too slow
This commit is contained in:
parent
7ecac185ac
commit
60db0ff775
@ -45,7 +45,13 @@ public class VideoDepacketizer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearAvcFrameState()
|
private void dropAvcFrameState()
|
||||||
|
{
|
||||||
|
waitingForIdrFrame = true;
|
||||||
|
cleanupAvcFrameState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cleanupAvcFrameState()
|
||||||
{
|
{
|
||||||
avcFrameDataChain = null;
|
avcFrameDataChain = null;
|
||||||
avcFrameDataLength = 0;
|
avcFrameDataLength = 0;
|
||||||
@ -81,13 +87,10 @@ public class VideoDepacketizer {
|
|||||||
// Remove existing frames
|
// Remove existing frames
|
||||||
decodedUnits.clearPopulatedObjects();
|
decodedUnits.clearPopulatedObjects();
|
||||||
|
|
||||||
// Try again
|
// Clear frame state and wait for an IDR
|
||||||
du = decodedUnits.pollFreeObject();
|
dropAvcFrameState();
|
||||||
if (du == null) {
|
|
||||||
LimeLog.warning("Video decoder is leaking decode units!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the free DU
|
// Initialize the free DU
|
||||||
du.initialize(DecodeUnit.TYPE_H264, avcFrameDataChain,
|
du.initialize(DecodeUnit.TYPE_H264, avcFrameDataChain,
|
||||||
@ -99,7 +102,7 @@ public class VideoDepacketizer {
|
|||||||
decodedUnits.addPopulatedObject(du);
|
decodedUnits.addPopulatedObject(du);
|
||||||
|
|
||||||
// Clear old state
|
// Clear old state
|
||||||
clearAvcFrameState();
|
cleanupAvcFrameState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +252,7 @@ public class VideoDepacketizer {
|
|||||||
waitingForIdrFrame = true;
|
waitingForIdrFrame = true;
|
||||||
|
|
||||||
// Clear the old state and wait for an IDR
|
// Clear the old state and wait for an IDR
|
||||||
clearAvcFrameState();
|
dropAvcFrameState();
|
||||||
decodingFrame = true;
|
|
||||||
}
|
}
|
||||||
// Look for a non-frame start before a frame start
|
// Look for a non-frame start before a frame start
|
||||||
else if (!firstPacket && !decodingFrame) {
|
else if (!firstPacket && !decodingFrame) {
|
||||||
@ -263,9 +265,8 @@ public class VideoDepacketizer {
|
|||||||
nextFrameNumber = frameIndex + 1;
|
nextFrameNumber = frameIndex + 1;
|
||||||
|
|
||||||
waitingForNextSuccessfulFrame = true;
|
waitingForNextSuccessfulFrame = true;
|
||||||
waitingForIdrFrame = true;
|
|
||||||
|
|
||||||
clearAvcFrameState();
|
dropAvcFrameState();
|
||||||
decodingFrame = false;
|
decodingFrame = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -284,8 +285,7 @@ public class VideoDepacketizer {
|
|||||||
|
|
||||||
// Wait until an IDR frame comes
|
// Wait until an IDR frame comes
|
||||||
waitingForNextSuccessfulFrame = true;
|
waitingForNextSuccessfulFrame = true;
|
||||||
waitingForIdrFrame = true;
|
dropAvcFrameState();
|
||||||
clearAvcFrameState();
|
|
||||||
}
|
}
|
||||||
else if (nextFrameNumber > frameIndex){
|
else if (nextFrameNumber > frameIndex){
|
||||||
// Duplicate packet or FEC dup
|
// Duplicate packet or FEC dup
|
||||||
@ -306,9 +306,8 @@ public class VideoDepacketizer {
|
|||||||
nextFrameNumber = frameIndex + 1;
|
nextFrameNumber = frameIndex + 1;
|
||||||
|
|
||||||
waitingForNextSuccessfulFrame = true;
|
waitingForNextSuccessfulFrame = true;
|
||||||
waitingForIdrFrame = true;
|
|
||||||
|
|
||||||
clearAvcFrameState();
|
dropAvcFrameState();
|
||||||
decodingFrame = false;
|
decodingFrame = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -353,7 +352,7 @@ public class VideoDepacketizer {
|
|||||||
if (waitingForIdrFrame) {
|
if (waitingForIdrFrame) {
|
||||||
LimeLog.warning("Waiting for IDR frame");
|
LimeLog.warning("Waiting for IDR frame");
|
||||||
|
|
||||||
clearAvcFrameState();
|
dropAvcFrameState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user