forge
Explore
Log in

Don't you dare go Hollow

Pre-deblock full-buffer oracle rung -- EC_AV1_PREFILT_WIDE_DUMP

Browse files at this commit

e0104c45fd9db52ef3cac914ba05d960d154d513Ahmet Kaan GümüşParent: 894d3a5
  • feat
    • pre-deblock full-buffer oracle rung -- EC_AV1_PREFILT_WIDE_DUMP
Show full message
feat(av1): pre-deblock full-buffer oracle rung -- EC_AV1_PREFILT_WIDE_DUMP

Rung 7: same anchor as the existing EC_AV1_PREFILT_DUMP (before loop
filter/CDEF/superres), but dumps y_width/y_height (full aligned buffer)
instead of y_crop_width/y_crop_height, so the margin region [FrameWidth,
true mi-aligned width) is visible pre-deblock too -- separates a
reconstruction bug in the margin from a deblock bug in the margin.
Additive/new env var; the existing EC_AV1_PREFILT_DUMP rung other lanes
already use is untouched. Rebuilt and verified clean.
scripts/instrument-aom-oracle.shmodified+71 -14
@@ -28,13 +28,16 @@
2828 # read and the first coefficient block, which is precisely the gap a
2929 # rect-strip desync hides in.
3030 # 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).
31+# V, full ALIGNED-buffer rows (y_width/y_height, not y_crop_width --
32+# cm->cur_frame->buf at this point is still the pre-superres buffer,
33+# but its aligned width already extends past FrameWidth out to the
34+# mi-aligned true width, which is exactly the margin content we need).
35+# Written right after av1_loop_filter_frame_mt returns and before
36+# CDEF/superres run -- ground truth for the post-deblock, pre-superres
37+# row content over frame_width..true_width that decode.rs stashes as
38+# its superres margin (lane-superres r5: hand-tracing the arithmetic
39+# could only prove our own self-consistency, not correctness against
40+# libaom).
3841 #
3942 # Idempotent: re-running is a no-op. Rebuild afterwards with
4043 # ninja -C ~/.cache/aom-oracle/build aomdec
@@ -299,16 +302,20 @@ dump = """
299302 FILE *ec_f = fopen(ec_path, "wb");
300303 if (ec_f) {
301304 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+ /* Dump the FULL aligned buffer (y_width/y_height), not the
306+ * crop_width/crop_height (== FrameWidth/FrameHeight): the
307+ * superres margin (columns [FrameWidth, true mi-aligned width))
308+ * only exists in the aligned buffer -- lane-superres r5. */
309+ for (int ec_r = 0; ec_r < ec_b->y_height; ++ec_r)
310+ fwrite(ec_b->y_buffer + ec_r * ec_b->y_stride, 1, ec_b->y_width,
311+ ec_f);
305312 if (num_planes > 1) {
306- for (int ec_r = 0; ec_r < ec_b->uv_crop_height; ++ec_r)
313+ for (int ec_r = 0; ec_r < ec_b->uv_height; ++ec_r)
307314 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)
315+ ec_b->uv_width, ec_f);
316+ for (int ec_r = 0; ec_r < ec_b->uv_height; ++ec_r)
310317 fwrite(ec_b->v_buffer + ec_r * ec_b->uv_stride, 1,
311- ec_b->uv_crop_width, ec_f);
318+ ec_b->uv_width, ec_f);
312319 }
313320 fclose(ec_f);
314321 }
@@ -320,3 +327,53 @@ s = s.replace(anchor, anchor + dump, 1)
320327 open(path, "w").write(s)
321328 print("postdeblock dump instrumented")
322329 PYD
330+
331+# --- rung 7: pre-deblock, FULL aligned-buffer row dump (lane-superres r5) -
332+# EC_AV1_PREFILT_DUMP (rung 1) is used by other lanes at its existing
333+# y_crop_width/y_crop_height shape -- left untouched. This adds a second,
334+# additive env var at the SAME anchor (pre-loop-filter) but dumping the full
335+# y_width/y_height aligned buffer, so a margin-region reconstruction bug can
336+# be told apart from a margin-region deblock bug.
337+python3 - "$F" <<'PYW'
338+import sys
339+path = sys.argv[1]
340+s = open(path).read()
341+if "EC_INSTRUMENTED_PREFILT_WIDE" in s:
342+ print("prefilt-wide dump already instrumented (no-op)")
343+ sys.exit(0)
344+
345+anchor = """ av1_alloc_cdef_buffers(cm, &pbi->cdef_worker, &pbi->cdef_sync,
346+ pbi->num_workers, 1);"""
347+dump = """ /* EC_INSTRUMENTED_PREFILT_WIDE */
348+ {
349+ const char *ec_dump = getenv("EC_AV1_PREFILT_WIDE_DUMP");
350+ if (ec_dump) {
351+ static int ec_prefilt_wide_idx = 0;
352+ char ec_path[1024];
353+ snprintf(ec_path, sizeof(ec_path), "%s.f%d", ec_dump,
354+ ec_prefilt_wide_idx++);
355+ FILE *ec_f = fopen(ec_path, "wb");
356+ if (ec_f) {
357+ const YV12_BUFFER_CONFIG *ec_b = &cm->cur_frame->buf;
358+ for (int ec_r = 0; ec_r < ec_b->y_height; ++ec_r)
359+ fwrite(ec_b->y_buffer + ec_r * ec_b->y_stride, 1, ec_b->y_width,
360+ ec_f);
361+ if (num_planes > 1) {
362+ for (int ec_r = 0; ec_r < ec_b->uv_height; ++ec_r)
363+ fwrite(ec_b->u_buffer + ec_r * ec_b->uv_stride, 1,
364+ ec_b->uv_width, ec_f);
365+ for (int ec_r = 0; ec_r < ec_b->uv_height; ++ec_r)
366+ fwrite(ec_b->v_buffer + ec_r * ec_b->uv_stride, 1,
367+ ec_b->uv_width, ec_f);
368+ }
369+ fclose(ec_f);
370+ }
371+ }
372+ }
373+
374+"""
375+assert anchor in s, "cdef alloc anchor moved"
376+s = s.replace(anchor, dump + anchor, 1)
377+open(path, "w").write(s)
378+print("prefilt-wide dump instrumented")
379+PYW