Pre-deblock full-buffer oracle rung -- EC_AV1_PREFILT_WIDE_DUMP
Browse files at this commite0104c45fd9db52ef3cac914ba05d960d154d513Parent: 894d3a5- feat
- pre-deblock full-buffer oracle rung -- EC_AV1_PREFILT_WIDE_DUMP
1 changed file +71 -14
- scripts/instrument-aom-oracle.sh +71 -14
scripts/instrument-aom-oracle.shmodified+71 -14
| @@ -28,13 +28,16 @@ | |||
| 28 | # read and the first coefficient block, which is precisely the gap a | 28 | # read and the first coefficient block, which is precisely the gap a |
| 29 | # rect-strip desync hides in. | 29 | # rect-strip desync hides in. |
| 30 | # EC_AV1_POSTDEBLOCK_DUMP=<prefix> -> <prefix>.f<N> per frame, Y then U then | 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 | 31 | +# V, full ALIGNED-buffer rows (y_width/y_height, not y_crop_width -- |
| 32 | -# the pre-superres, frame_width-wide buffer). Written right after | 32 | +# cm->cur_frame->buf at this point is still the pre-superres buffer, |
| 33 | -# av1_loop_filter_frame_mt returns and before CDEF/superres run -- | 33 | +# but its aligned width already extends past FrameWidth out to the |
| 34 | -# ground truth for the post-deblock, pre-superres row content over | 34 | +# mi-aligned true width, which is exactly the margin content we need). |
| 35 | -# frame_width..true_width that decode.rs stashes as its superres | 35 | +# Written right after av1_loop_filter_frame_mt returns and before |
| 36 | -# margin (lane-superres r5: hand-tracing the arithmetic could only | 36 | +# CDEF/superres run -- ground truth for the post-deblock, pre-superres |
| 37 | -# prove our own self-consistency, not correctness against libaom). | 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). | ||
| 38 | # | 41 | # |
| 39 | # Idempotent: re-running is a no-op. Rebuild afterwards with | 42 | # Idempotent: re-running is a no-op. Rebuild afterwards with |
| 40 | # ninja -C ~/.cache/aom-oracle/build aomdec | 43 | # ninja -C ~/.cache/aom-oracle/build aomdec |
| @@ -299,16 +302,20 @@ dump = """ | |||
| 299 | FILE *ec_f = fopen(ec_path, "wb"); | 302 | FILE *ec_f = fopen(ec_path, "wb"); |
| 300 | if (ec_f) { | 303 | if (ec_f) { |
| 301 | const YV12_BUFFER_CONFIG *ec_b = &cm->cur_frame->buf; | 304 | 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) | 305 | + /* Dump the FULL aligned buffer (y_width/y_height), not the |
| 303 | - fwrite(ec_b->y_buffer + ec_r * ec_b->y_stride, 1, | 306 | + * crop_width/crop_height (== FrameWidth/FrameHeight): the |
| 304 | - ec_b->y_crop_width, ec_f); | 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); | ||
| 305 | if (num_planes > 1) { | 312 | 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) |
| 307 | fwrite(ec_b->u_buffer + ec_r * ec_b->uv_stride, 1, | 314 | fwrite(ec_b->u_buffer + ec_r * ec_b->uv_stride, 1, |
| 308 | - ec_b->uv_crop_width, ec_f); | 315 | + ec_b->uv_width, ec_f); |
| 309 | - for (int ec_r = 0; ec_r < ec_b->uv_crop_height; ++ec_r) | 316 | + for (int ec_r = 0; ec_r < ec_b->uv_height; ++ec_r) |
| 310 | fwrite(ec_b->v_buffer + ec_r * ec_b->uv_stride, 1, | 317 | 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); |
| 312 | } | 319 | } |
| 313 | fclose(ec_f); | 320 | fclose(ec_f); |
| 314 | } | 321 | } |
| @@ -320,3 +327,53 @@ s = s.replace(anchor, anchor + dump, 1) | |||
| 320 | open(path, "w").write(s) | 327 | open(path, "w").write(s) |
| 321 | print("postdeblock dump instrumented") | 328 | print("postdeblock dump instrumented") |
| 322 | PYD | 329 | 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 | ||