Postdeblock oracle rung -- EC_AV1_POSTDEBLOCK_DUMP
Browse files at this commit894d3a5eb7ef88dd5722d6c3d13fbca43b2c74a5Parent: 92a3a37- feat
- postdeblock oracle rung -- EC_AV1_POSTDEBLOCK_DUMP
1 changed file +57 -0
scripts/instrument-aom-oracle.shmodified+57 -0
| @@ -27,6 +27,14 @@ | ||
| 27 | 27 | # the key-frame path has no traced symbol at all between the partition |
| 28 | 28 | # read and the first coefficient block, which is precisely the gap a |
| 29 | 29 | # 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). | |
| 30 | 38 | # |
| 31 | 39 | # Idempotent: re-running is a no-op. Rebuild afterwards with |
| 32 | 40 | # ninja -C ~/.cache/aom-oracle/build aomdec |
| @@ -263,3 +271,52 @@ s = s.replace(old, new, 1) | ||
| 263 | 271 | open(path, "w").write(s) |
| 264 | 272 | print("intra mode-info instrumented") |
| 265 | 273 | 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 |