Stage 2 PR-A2: per-MB inspection callback wiring + invariant checks #14
Reference in New Issue
Block a user
Delete Branch "noether/tools-h264-callback-wiring"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Validates marfrit-packages patch 0016 (PR #106, merged) end-to-end against the
daedalus_decode_h264CLI. Callback fires once per macroblock in coded order; this PR checks the count + uniqueness invariants without yet driving daedalus-decoder differently — that's PR-A3.Infrastructure landed
CMake: new
DAEDALUS_FFMPEG_PREFIXoption pointing at a private FFmpeg install carrying patch 0016. When set, the CLI links against it (static.a's from$prefix/lib) andDAEDALUS_HAVE_H264_MB_INSPECT_CBis compiled in. When unset, the CLI falls back to pkg-config'd system FFmpeg and behaves as PR-A1b did (identity-passthrough only).Opaqueness: the
H264Contextstruct stays forward-declared in the CLI — its real definition lives in libavcodec's internalh264dec.h, not installed. Real per-MB state extraction (sl->mbcoeffs, mb_type, intra modes, deblock params) lands in PR-A3 alongside an internal-header include path.Callback work: assert
(mb_x, mb_y)∈ coded grid → mark seen in per-frame bitmap → count invocations. At end-of-frame: assert seen-count ==mb_w*mb_h, 0 duplicates, 0 OOB.Init timing: callbacks fire from inside
avcodec_send_packet, before the firstreceive_frameever returns. So the per-frame bitmap MUST be allocated before the firstsend_packet, not lazy-on-first-frame (which would miss all of frame 0). Dims come fromcodecpar->width/heightrounded up to 16-mod (H.264 codes 1080 display as 1088 coded).Order check considered + dropped: libavcodec uses MB-level threading in some configs so callbacks fire out of strict raster order. The contract is "each MB exactly once", not "in raster order"; the bitmap check captures that.
Result on hertz (Pi 5, patched FFmpeg at /tmp/ffmpeg-inspect-prefix)
Identity-passthrough still PASSES — the callback path is additive, doesn't break PR-A1b semantics.
Followups
libavcodec/h264dec.hvia-I/path/to/ffmpeg/srcto accessH264Contextinternals; extractsl->mbcoefficients in the callback; computeP = pre-deblock pixels - IDCT(C)using a transcribed C reference; feeddaedalus_decoderwith REAL(P, C, edges). Useavctx->skip_loop_filter = AVDISCARD_ALLso libavcodec's output is pre-deblock and the subtraction is exact.