Print the frame number if decoding fails

This commit is contained in:
Cameron Gutman
2022-10-04 23:38:54 -05:00
parent 9e8a4cab7b
commit bc68aad67b
3 changed files with 25 additions and 17 deletions
+14 -6
View File
@@ -1054,15 +1054,16 @@ void FFmpegVideoDecoder::decoderThreadProc()
frame->pkt_dts = SDL_GetTicks(); frame->pkt_dts = SDL_GetTicks();
if (!m_FrameInfoQueue.isEmpty()) { if (!m_FrameInfoQueue.isEmpty()) {
FrameInfoTuple infoTuple = m_FrameInfoQueue.dequeue(); // Data buffers in the DU are not valid here!
DECODE_UNIT du = m_FrameInfoQueue.dequeue();
// Count time in avcodec_send_packet() and avcodec_receive_frame() // Count time in avcodec_send_packet() and avcodec_receive_frame()
// as time spent decoding. Also count time spent in the decode unit // as time spent decoding. Also count time spent in the decode unit
// queue because that's directly caused by decoder latency. // queue because that's directly caused by decoder latency.
m_ActiveWndVideoStats.totalDecodeTime += LiGetMillis() - infoTuple.enqueueTimeMs; m_ActiveWndVideoStats.totalDecodeTime += LiGetMillis() - du.enqueueTimeMs;
// Store the presentation time // Store the presentation time
frame->pts = infoTuple.presentationTimeMs; frame->pts = du.presentationTimeMs;
} }
m_ActiveWndVideoStats.decodedFrames++; m_ActiveWndVideoStats.decodedFrames++;
@@ -1087,9 +1088,14 @@ void FFmpegVideoDecoder::decoderThreadProc()
} }
else { else {
char errorstring[512]; char errorstring[512];
// FIXME: Should we pop an entry off m_FrameInfoQueue here?
av_strerror(err, errorstring, sizeof(errorstring)); av_strerror(err, errorstring, sizeof(errorstring));
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"avcodec_receive_frame() failed: %s", errorstring); "avcodec_receive_frame() failed: %s (frame %d)",
errorstring,
!m_FrameInfoQueue.isEmpty() ? m_FrameInfoQueue.head().frameNumber : -1);
if (++m_ConsecutiveFailedDecodes == FAILED_DECODES_RESET_THRESHOLD) { if (++m_ConsecutiveFailedDecodes == FAILED_DECODES_RESET_THRESHOLD) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@@ -1197,7 +1203,9 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
char errorstring[512]; char errorstring[512];
av_strerror(err, errorstring, sizeof(errorstring)); av_strerror(err, errorstring, sizeof(errorstring));
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"avcodec_send_packet() failed: %s", errorstring); "avcodec_send_packet() failed: %s (frame %d)",
errorstring,
du->frameNumber);
// If we've failed a bunch of decodes in a row, the decoder/renderer is // If we've failed a bunch of decodes in a row, the decoder/renderer is
// clearly unhealthy, so let's generate a synthetic reset event to trigger // clearly unhealthy, so let's generate a synthetic reset event to trigger
@@ -1217,7 +1225,7 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
return DR_NEED_IDR; return DR_NEED_IDR;
} }
m_FrameInfoQueue.enqueue({ du->enqueueTimeMs, du->presentationTimeMs}); m_FrameInfoQueue.enqueue(*du);
m_FramesIn++; m_FramesIn++;
return DR_OK; return DR_OK;
+2 -5
View File
@@ -84,11 +84,8 @@ private:
SDL_Thread* m_DecoderThread; SDL_Thread* m_DecoderThread;
SDL_atomic_t m_DecoderThreadShouldQuit; SDL_atomic_t m_DecoderThreadShouldQuit;
typedef struct { // Data buffers in the queued DU are not valid
uint64_t enqueueTimeMs; QQueue<DECODE_UNIT> m_FrameInfoQueue;
uint32_t presentationTimeMs;
} FrameInfoTuple;
QQueue<FrameInfoTuple> m_FrameInfoQueue;
static const uint8_t k_H264TestFrame[]; static const uint8_t k_H264TestFrame[];
static const uint8_t k_HEVCMainTestFrame[]; static const uint8_t k_HEVCMainTestFrame[];
+9 -6
View File
@@ -123,8 +123,9 @@ SLVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
err = SLVideo_BeginFrame(m_VideoStream, du->fullLength); err = SLVideo_BeginFrame(m_VideoStream, du->fullLength);
if (err < 0) { if (err < 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"SLVideo_BeginFrame() failed: %d", "SLVideo_BeginFrame() failed: %d (frame %d)",
err); err,
du->frameNumber);
// Need an IDR frame to resync // Need an IDR frame to resync
return DR_NEED_IDR; return DR_NEED_IDR;
@@ -137,8 +138,9 @@ SLVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
entry->length); entry->length);
if (err < 0) { if (err < 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"SLVideo_WriteFrameData() failed: %d", "SLVideo_WriteFrameData() failed: %d (frame %d)",
err); err,
du->frameNumber);
// Need an IDR frame to resync // Need an IDR frame to resync
return DR_NEED_IDR; return DR_NEED_IDR;
@@ -150,8 +152,9 @@ SLVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
err = SLVideo_SubmitFrame(m_VideoStream); err = SLVideo_SubmitFrame(m_VideoStream);
if (err < 0) { if (err < 0) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"SLVideo_SubmitFrame() failed: %d", "SLVideo_SubmitFrame() failed: %d (frame %d)",
err); err,
du->frameNumber);
// Need an IDR frame to resync // Need an IDR frame to resync
return DR_NEED_IDR; return DR_NEED_IDR;