video_decoder: av_log bridge — corruption detection for hwaccel decode
The corruption re-arm added in 6344062 keyed off AVFrame::decode_error_flags,
but the HEVC decoder on the hwaccel (NVDEC) path never sets it: 120 s of live
Wi-Fi packet loss produced 10+ "First slice in a frame missing" / "Could not
find ref with POC n" log bursts with decode_error_flags == 0 on every frame,
so the keyframe gate never fired.
Bridge: install a process-wide av_log callback (chains to
av_log_default_callback) that maps the logging AVCodecContext back to its
CVideoDecoder and latches a per-decoder m_bCorruptSeen flag on AV_LOG_ERROR
messages. readFrame() consumes the latch alongside decode_error_flags to
re-arm the keyframe gate. With hwaccel the decoder is single-threaded, so
the logging context is exactly our AVCodecContext; SW frame-threaded paths
log from per-thread clones but set decode_error_flags instead, which the
existing check covers.
Registered after avcodec_open2, unregistered in uninit() before the context
is freed. Map lookup only on error-level messages (rare). Also promote the
gate-arm message to log_print(HT_LOG_WARN) for console visibility.
Clean-path verified live: 6105 frames / 5 min NVDEC RTSP with zero errors
and no regressions. Loss-path verification pending a naturally lossy window.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -173,6 +173,11 @@ private:
|
||||
// keyframe can't blank the display forever.
|
||||
std::atomic<bool> m_bWaitKeyframe{ true }; // true until first IDR after (re)start
|
||||
int m_nKeyframeWaitCount{ 0 }; // frames dropped while waiting
|
||||
// Latched by the av_log bridge (video_decoder.cpp) when FFmpeg logs a decode
|
||||
// error for this decoder's AVCodecContext. Needed because hwaccel (NVDEC)
|
||||
// decode does NOT set AVFrame::decode_error_flags on slice loss — the log
|
||||
// is the only corruption signal on that path. Consumed by readFrame().
|
||||
std::atomic<bool> m_bCorruptSeen{ false };
|
||||
int m_hwGpuIndex; // GPU index assigned by HWDecoderPool (-1 = legacy)
|
||||
AVFrame* m_pCudaHWFrame; // Cloned CUDA HW frame (device ptrs) for inference
|
||||
const AVCodec* m_pCodec;
|
||||
|
||||
Reference in New Issue
Block a user