Restores the previously shelved decoder/player hardening and extends it:
1. Startup keyframe gating (video_decoder): after (re)start the decoder
joins the stream mid-GOP; frames referencing unseen pictures render as
green/blocky concealment garbage. Drop everything until the first IDR
(300-frame safety valve so unmarked streams can't blank forever).
2. NEW - corruption re-arm: on lossy links (Wi-Fi cameras) dropped slices
surface as "First slice in a frame missing" / "Could not find ref with
POC n" and FFmpeg marks the output via AVFrame::decode_error_flags.
Re-arm the keyframe gate and drop the rest of the GOP so the display
holds the last clean frame instead of showing concealment artifacts;
corrupt drops count toward the safety valve.
3. libyuv NV12->BGR conversion (video_player): honors NVDEC/D3D11VA padded
strides (1080->1088 rows) that cv::cvtColorTwoPlane mishandled (green
cast + striped noise), picks BT.601/709/2020 coefficients from the
frame's signalled colorspace, and is ~3-5x faster than sws_scale.
Verified live against an RTSP HEVC camera (NVDEC path): steady frame flow,
no regressions on the clean-stream path.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Thread-local staging Mat (video_player.cpp:1400-1407) — single biggest win. Eliminates the 12 MB per-call malloc/free cycle.
Contiguous get_buffer2 allocator (video_decoder.cpp:35-102) — keeps the 3 bulk memcpys cache-friendly. Would also enable FAST/zero-copy for resolutions where visible_h % 64 == 0.
SW-decoder thread config (video_decoder.cpp:528-540) — thread_count=0, thread_type=FRAME|SLICE. FRAME is downgraded to SLICE-only by AV_CODEC_FLAG_LOW_DELAY, but decode throughput is sufficient for your input rate.
SetTargetFPS(100) delivery throttle (already there) — caps onVideoFrame post-decode work at 10 FPS. Keeps the caller path warm-cached.
Instrumentation — [MEDIA_DecInit] / [MEDIA_Convert] / [MEDIA_SWDec] / [MEDIA_Timing] / [MEDIA_JpegTiming] — always-on regression detector, zero cost when ANSCORE_DEBUGVIEW=OFF.