forge
Explore
Log in

Don't you dare go Hollow

Script the oracle EC_TRACE_TPL + per-entry EC_STACK rungs (rung 14) so lane-interbis hand patches survive a rebuild

Browse files at this commit

78968107aeb742fc80c70fc1089f7b5b01f2137aAhmet Kaan GümüşParent: 718eaba
  • chore
    • script the oracle EC_TRACE_TPL + per-entry EC_STACK rungs (rung 14) so lane-interbis hand patches survive a rebuild
Show full message
chore(av1): script the oracle EC_TRACE_TPL + per-entry EC_STACK rungs (rung 14) so lane-interbis hand patches survive a rebuild
scripts/instrument-aom-oracle.shmodified+71 -0
@@ -761,3 +761,74 @@ s = s.replace(anchor, anchor + probe, 1)
761761 open(path, "w").write(s)
762762 print("decodemv rung 13 (EC_MODE_MV + EC_MODE_VAL stack=) instrumented")
763763 PYMV
764+
765+# --- rung 14: temporal-MV (MFMV) ground truth (lane-interbis, scripted by ----
766+# --- lane-refstamp r1) -----------------------------------------------------
767+# lane-interbis patched the live oracle tree BY HAND for its motion-field hunt,
768+# so these two probes lived only in ~/.cache/aom-oracle/src and a rebuild from
769+# this script would have dropped them (class: instrument that lives only in a
770+# build tree -- same reason rung 13 exists).
771+# * EC_TRACE_TPL=1 -> "EC_TPL mi_row=.. mi_col=.. blk=(..,..) mfmv0=(..,..)
772+# rfo=.." (or ".. INVALID") for every temporal candidate `add_tpl_ref_mv`
773+# probes -- the reference's own projected motion field, cell by cell, to
774+# compare against ours (EC_TRACE_TPL on our side).
775+# * the resolved MV STACK itself, one "EC_STACK mi_row=.. mi_col=.. ref=..
776+# i=.. this=(..,..) comp=(..,..) w=.." line per entry, printed under rung
777+# 4's EC_TRACE_MODE right after EC_MODE_VAL (rung 13 only prints the
778+# stack DEPTH).
779+python3 - "$SRC/av1/common/mvref_common.c" <<'PYT'
780+import sys
781+path = sys.argv[1]
782+s = open(path).read()
783+if "EC_TRACE_TPL" in s:
784+ print("mvref_common rung 14 already applied (no-op)")
785+ sys.exit(0)
786+old = " if (prev_frame_mvs->mfmv0.as_int == INVALID_MV) return 0;\n"
787+assert old in s, "add_tpl_ref_mv's INVALID_MV early return moved"
788+new = """ if (prev_frame_mvs->mfmv0.as_int == INVALID_MV) {
789+ if (getenv("EC_TRACE_TPL"))
790+ fprintf(stderr, "EC_TPL mi_row=%d mi_col=%d blk=(%d,%d) INVALID\\n",
791+ mi_row, mi_col, blk_row, blk_col);
792+ return 0;
793+ }
794+ if (getenv("EC_TRACE_TPL"))
795+ fprintf(stderr,
796+ "EC_TPL mi_row=%d mi_col=%d blk=(%d,%d) mfmv0=(%d,%d) rfo=%d\\n",
797+ mi_row, mi_col, blk_row, blk_col, prev_frame_mvs->mfmv0.as_mv.row,
798+ prev_frame_mvs->mfmv0.as_mv.col, prev_frame_mvs->ref_frame_offset);
799+"""
800+s = s.replace(old, new, 1)
801+open(path, "w").write(s)
802+print("mvref_common rung 14 (EC_TPL) instrumented")
803+PYT
804+
805+python3 - "$SRC/av1/decoder/decodemv.c" <<'PYST'
806+import sys
807+path = sys.argv[1]
808+s = open(path).read()
809+if "EC_STACK mi_row" in s:
810+ print("decodemv rung 14 already applied (no-op)")
811+ sys.exit(0)
812+assert "EC_MODE_MV" in s, "rung 14 needs rung 13 (run this script top to bottom)"
813+anchor = """ /* EC_STACK */ (int)dcb->ref_mv_count[av1_ref_frame_type(mbmi->ref_frame)],
814+ (unsigned)r->ec.rng);
815+"""
816+assert s.count(anchor) == 1, "rung 13's EC_MODE_VAL body moved"
817+dump = """ /* EC_INSTRUMENTED lane-interbis: the resolved mv stack itself */
818+ const MV_REFERENCE_FRAME ec_rt = av1_ref_frame_type(mbmi->ref_frame);
819+ for (int ec_i = 0; ec_i < dcb->ref_mv_count[ec_rt]; ec_i++) {
820+ fprintf(stderr,
821+ "EC_STACK mi_row=%d mi_col=%d ref=%d i=%d this=(%d,%d) "
822+ "comp=(%d,%d) w=%d\\n",
823+ ec_xd->mi_row, ec_xd->mi_col, (int)ec_rt, ec_i,
824+ ec_xd->ref_mv_stack[ec_rt][ec_i].this_mv.as_mv.row,
825+ ec_xd->ref_mv_stack[ec_rt][ec_i].this_mv.as_mv.col,
826+ ec_xd->ref_mv_stack[ec_rt][ec_i].comp_mv.as_mv.row,
827+ ec_xd->ref_mv_stack[ec_rt][ec_i].comp_mv.as_mv.col,
828+ ec_xd->weight[ec_rt][ec_i]);
829+ }
830+"""
831+s = s.replace(anchor, anchor + dump, 1)
832+open(path, "w").write(s)
833+print("decodemv rung 14 (per-entry EC_STACK) instrumented")
834+PYST