Charge decoders for time spent holding on to frames
This commit is contained in:
parent
f0119b1231
commit
4794f44a6d
2 changed files with 14 additions and 0 deletions
|
|
@ -104,6 +104,8 @@ FFmpegVideoDecoder::FFmpegVideoDecoder(bool testOnly)
|
|||
m_FrontendRenderer(nullptr),
|
||||
m_ConsecutiveFailedDecodes(0),
|
||||
m_Pacer(nullptr),
|
||||
m_FramesIn(0),
|
||||
m_FramesOut(0),
|
||||
m_LastFrameNumber(0),
|
||||
m_StreamFps(0),
|
||||
m_VideoFormat(0),
|
||||
|
|
@ -864,6 +866,8 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
|||
return DR_NEED_IDR;
|
||||
}
|
||||
|
||||
m_FramesIn++;
|
||||
|
||||
AVFrame* frame = av_frame_alloc();
|
||||
if (!frame) {
|
||||
// Failed to allocate a frame but we did submit,
|
||||
|
|
@ -875,6 +879,8 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
|||
|
||||
err = avcodec_receive_frame(m_VideoDecoderCtx, frame);
|
||||
if (err == 0) {
|
||||
m_FramesOut++;
|
||||
|
||||
// Reset failed decodes count if we reached this far
|
||||
m_ConsecutiveFailedDecodes = 0;
|
||||
|
||||
|
|
@ -890,6 +896,11 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
|||
// Count time in avcodec_send_packet() and avcodec_receive_frame()
|
||||
// as time spent decoding
|
||||
m_ActiveWndVideoStats.totalDecodeTime += SDL_GetTicks() - beforeDecode;
|
||||
|
||||
// Also count the frame-to-frame delay if the decoder is delaying frames
|
||||
// until a subsequent frame is submitted.
|
||||
m_ActiveWndVideoStats.totalDecodeTime += (m_FramesIn - m_FramesOut) * (1000 / m_StreamFps);
|
||||
|
||||
m_ActiveWndVideoStats.decodedFrames++;
|
||||
|
||||
// Queue the frame for rendering (or render now if pacer is disabled)
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ private:
|
|||
VIDEO_STATS m_LastWndVideoStats;
|
||||
VIDEO_STATS m_GlobalVideoStats;
|
||||
|
||||
int m_FramesIn;
|
||||
int m_FramesOut;
|
||||
|
||||
int m_LastFrameNumber;
|
||||
int m_StreamFps;
|
||||
int m_VideoFormat;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue