When a decoder requests an IDR frame, don't submit another frame until the IDR frame arrives

This commit is contained in:
Cameron Gutman 2016-02-18 13:23:03 -05:00
parent 8cced32917
commit a8d98284a7
3 changed files with 20 additions and 3 deletions

View File

@ -40,6 +40,7 @@ void destroyVideoDepacketizer(void);
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length);
void queueRtpPacket(PRTP_PACKET rtpPacket, int length);
void stopVideoDepacketizer(void);
void requestDecoderRefresh(void);
void initializeVideoStream(void);
void destroyVideoStream(void);

View File

@ -225,8 +225,8 @@ static void reassembleAvcFrame(int frameNumber) {
freeQueuedDecodeUnit(qdu);
if (ret == DR_NEED_IDR) {
Limelog("Request IDR frame on behalf of DR\n");
requestIdrOnDemand();
Limelog("Requesting IDR frame on behalf of DR\n");
requestDecoderRefresh();
}
}
@ -330,6 +330,22 @@ static void processRtpPayloadSlow(PNV_VIDEO_PACKET videoPacket, PBUFFER_DESC cur
}
}
// Dumps the decode unit queue and ensures the next frame submitted to the decoder will be
// an IDR frame
void requestDecoderRefresh(void) {
// Wait for the next IDR frame
waitingForIdrFrame = 1;
// Flush the decode unit queue and pending state
dropAvcFrameState();
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
freeDecodeUnitList(LbqFlushQueueItems(&decodeUnitQueue));
}
// Request the IDR frame
requestIdrOnDemand();
}
// Return 1 if packet is the first one in the frame
static int isFirstPacket(char flags) {
// Clear the picture data flag

View File

@ -136,7 +136,7 @@ static void DecoderThreadProc(void* context) {
if (ret == DR_NEED_IDR) {
Limelog("Requesting IDR frame on behalf of DR\n");
requestIdrOnDemand();
requestDecoderRefresh();
}
}
}