Ensure the next frame after a DU drop is always an IDR frame

On RFI-capable decoders, this would sometimes be a P-frame
This commit is contained in:
Cameron Gutman
2022-10-02 21:12:01 -05:00
parent 3ae777f973
commit 795e3f644a

View File

@@ -397,18 +397,19 @@ static void reassembleFrame(int frameNumber) {
if (LbqOfferQueueItem(&decodeUnitQueue, qdu, &qdu->entry) == LBQ_BOUND_EXCEEDED) { if (LbqOfferQueueItem(&decodeUnitQueue, qdu, &qdu->entry) == LBQ_BOUND_EXCEEDED) {
Limelog("Video decode unit queue overflow\n"); Limelog("Video decode unit queue overflow\n");
// Clear frame state and wait for an IDR // Clear NAL state for the frame that we failed to enqueue
nalChainHead = qdu->decodeUnit.bufferList; nalChainHead = qdu->decodeUnit.bufferList;
nalChainDataLength = qdu->decodeUnit.fullLength; nalChainDataLength = qdu->decodeUnit.fullLength;
dropFrameState(); dropFrameState();
// Free the DU // Free the DU we were going to queue
free(qdu); free(qdu);
// Flush the decode unit queue // Free all frames in the decode unit queue
freeDecodeUnitList(LbqFlushQueueItems(&decodeUnitQueue)); freeDecodeUnitList(LbqFlushQueueItems(&decodeUnitQueue));
// FIXME: Get proper bounds to use reference frame invalidation // Request an IDR frame to recover (RFI recovery is not supported here)
waitingForIdrFrame = true;
requestIdrOnDemand(); requestIdrOnDemand();
return; return;
} }
@@ -423,6 +424,9 @@ static void reassembleFrame(int frameNumber) {
// Clear frame drops // Clear frame drops
consecutiveFrameDrops = 0; consecutiveFrameDrops = 0;
// Move the start of our (potential) RFI window to the next frame
startFrameNumber = nextFrameNumber;
} }
} }
} }
@@ -826,8 +830,6 @@ static void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length,
} }
reassembleFrame(frameIndex); reassembleFrame(frameIndex);
startFrameNumber = nextFrameNumber;
} }
} }