forge
Explore
Log in

Don't you dare go Hollow

Postdeblock oracle rung -- EC_AV1_POSTDEBLOCK_DUMP

Browse files at this commit

894d3a5eb7ef88dd5722d6c3d13fbca43b2c74a5Ahmet Kaan GümüşParent: 92a3a37
  • feat
    • postdeblock oracle rung -- EC_AV1_POSTDEBLOCK_DUMP
Show full message
feat(av1): postdeblock oracle rung -- EC_AV1_POSTDEBLOCK_DUMP

Add rung 6 to instrument-aom-oracle.sh: dumps cm->cur_frame->buf right
after av1_loop_filter_frame_mt returns and before CDEF/superres run,
same shape as EC_AV1_PREFILT_DUMP (full coded-width rows, Y/U/V, one
file per frame). Rebuilt and verified with ninja -C
~/.cache/aom-oracle/build aomdec -- clean.

This is the ground truth r4 identified as missing: post-deblock,
pre-superres row content over frame_width..true_width, to compare
against decode.rs's stashed superres margin at the failing row
(frame 2, rows 17/18, output col 62 -- 2/4096 luma pixels off by 1).
scripts/instrument-aom-oracle.shmodified+57 -0
@@ -27,6 +27,14 @@
2727 # the key-frame path has no traced symbol at all between the partition
2828 # read and the first coefficient block, which is precisely the gap a
2929 # rect-strip desync hides in.
30+# EC_AV1_POSTDEBLOCK_DUMP=<prefix> -> <prefix>.f<N> per frame, Y then U then
31+# V, full coded-width rows (cm->cur_frame->buf at this point is still
32+# the pre-superres, frame_width-wide buffer). Written right after
33+# av1_loop_filter_frame_mt returns and before CDEF/superres run --
34+# ground truth for the post-deblock, pre-superres row content over
35+# frame_width..true_width that decode.rs stashes as its superres
36+# margin (lane-superres r5: hand-tracing the arithmetic could only
37+# prove our own self-consistency, not correctness against libaom).
3038 #
3139 # Idempotent: re-running is a no-op. Rebuild afterwards with
3240 # ninja -C ~/.cache/aom-oracle/build aomdec
@@ -263,3 +271,52 @@ s = s.replace(old, new, 1)
263271 open(path, "w").write(s)
264272 print("intra mode-info instrumented")
265273 PYI
274+
275+# --- rung 6: post-deblock, pre-superres row dump ------------------------
276+python3 - "$F" <<'PYD'
277+import sys
278+path = sys.argv[1]
279+s = open(path).read()
280+if "EC_INSTRUMENTED_POSTDEBLOCK" in s:
281+ print("postdeblock dump already instrumented (no-op)")
282+ sys.exit(0)
283+
284+anchor = """ if (cm->lf.filter_level[0] || cm->lf.filter_level[1]) {
285+ av1_loop_filter_frame_mt(&cm->cur_frame->buf, cm, &pbi->dcb.xd, 0,
286+ num_planes, 0, pbi->tile_workers,
287+ pbi->num_workers, &pbi->lf_row_sync, 0);
288+ }
289+"""
290+dump = """
291+ /* EC_INSTRUMENTED_POSTDEBLOCK */
292+ {
293+ const char *ec_dump = getenv("EC_AV1_POSTDEBLOCK_DUMP");
294+ if (ec_dump) {
295+ static int ec_postdeblock_idx = 0;
296+ char ec_path[1024];
297+ snprintf(ec_path, sizeof(ec_path), "%s.f%d", ec_dump,
298+ ec_postdeblock_idx++);
299+ FILE *ec_f = fopen(ec_path, "wb");
300+ if (ec_f) {
301+ const YV12_BUFFER_CONFIG *ec_b = &cm->cur_frame->buf;
302+ for (int ec_r = 0; ec_r < ec_b->y_crop_height; ++ec_r)
303+ fwrite(ec_b->y_buffer + ec_r * ec_b->y_stride, 1,
304+ ec_b->y_crop_width, ec_f);
305+ if (num_planes > 1) {
306+ for (int ec_r = 0; ec_r < ec_b->uv_crop_height; ++ec_r)
307+ fwrite(ec_b->u_buffer + ec_r * ec_b->uv_stride, 1,
308+ ec_b->uv_crop_width, ec_f);
309+ for (int ec_r = 0; ec_r < ec_b->uv_crop_height; ++ec_r)
310+ fwrite(ec_b->v_buffer + ec_r * ec_b->uv_stride, 1,
311+ ec_b->uv_crop_width, ec_f);
312+ }
313+ fclose(ec_f);
314+ }
315+ }
316+ }
317+"""
318+assert anchor in s, "loop filter call anchor moved"
319+s = s.replace(anchor, anchor + dump, 1)
320+open(path, "w").write(s)
321+print("postdeblock dump instrumented")
322+PYD