)]}'
{
  "commit": "8695b3ebac9d0c12c0fc9626d2692d51544d8f67",
  "tree": "4b2a5615e16222d3700dba30d460fd12cbbabf21",
  "parents": [
    "c8db5b2007925bc8044aec0546aa9296bce2c5b9"
  ],
  "author": {
    "name": "Chris Davis",
    "email": "chrdavis@microsoft.com",
    "time": "Mon Jun 08 08:19:23 2026 -0700"
  },
  "committer": {
    "name": "James Zern",
    "email": "jzern@google.com",
    "time": "Thu Jun 11 20:54:41 2026 -0700"
  },
  "message": "Make AV1 wedge tables const so they are in .rdata\n\nPrecompute libaom\u0027s AV1 compound-prediction wedge masks and inter-intra\nsmooth blending masks at codegen time, store them as `const` data, and\nremove the runtime initialization path. This lets the tables live in\n`.rdata` and be COW-shared across processes instead of being lazily\npopulated into writable `.data` and giving every process its own private\ncopy.\n\n`av1/common/reconinter.c` previously declared several large writable\nbuffers:\n\n - `wedge_mask_obl`            — ~48 KB\n - `wedge_mask_buf`            — 128 KB\n - `smooth_interintra_mask_buf` — ~88 KB\n - `wedge_masks`               — pointer table\n\nThey were filled lazily by `av1_init_wedge_masks()` (via `aom_once`) the\nfirst time the decoder/encoder ran. Because the buffers were writable,\nevery process that touched AV1 inter-prediction got its own private COW\ncopy of ~250+ KB of identical data.\n\n1. **New codegen tool** `tools/gen_wedge_masks_data.py` reproduces the\nexact logic of `init_wedge_master_masks()`, `init_wedge_masks()`, and\n`init_smooth_interintra_masks()` and emits a header fragment.\n 2. **New generated file** `av1/common/wedge_masks_data.inc` is included by `reconinter.c` and provides `static const` definitions of `wedge_mask_buf`, `smooth_interintra_mask_buf`, and `wedge_masks`.\n 3. **`wedge_masks` now stores `uint32_t` byte offsets** into `wedge_mask_buf` instead of raw `uint8_t *` pointers. This avoids loader base-relocations that would otherwise dirty the `.rdata` page on load and defeat the sharing goal. `uint16_t` is too small (the largest emitted offset exceeds 65 KiB).\n 4. **`wedge_signflip_lookup` and `ii_size_scales`** are now `const`.\n 5. **`av1_init_wedge_masks()` is now a no-op** but kept exported because `decoder.c`, `encoder.c`, and unit tests still call it. The unused `\u003caom_ports/aom_once.h\u003e` include, master tables, `shift_copy`, `get_wedge_mask_inplace`, and the three `init_*_masks` helpers are removed.\n 6. **`av1_get_contiguous_soft_mask()`** is now a non-inline function in `reconinter.c` (forward-declared in `reconinter.h`) that resolves a mask address by adding the stored offset to `wedge_mask_buf`. Moving it out of the header lets `wedge_mask_buf` stay `static const` to its translation unit.\n 7. `ii_weights1d`, `ii_size_scales`, and `build_smooth_interintra_mask()` are wrapped in `#if CONFIG_AV1_HIGHBITDEPTH` since they are only used by the highbd path now that the lowbd init code is gone.\n\nRoughly **~220 KB** of writable `.data` per process is moved into\nshareable `.rdata`.\n\n`wedge_masks_data.inc` is generated, not hand-written. If any of the\nupstream inputs change (master tables, wedge codebooks, `BLOCK_SIZE`\nenum, `ii_weights1d`, mask sizes), regenerate it with:\n\npython3 source/libaom/tools/gen_wedge_masks_data.py\n    --output source/libaom/av1/common/wedge_masks_data.inc\n\nA header comment in both the script and the `.inc` documents this\ncontract.\n\n - No bitstream or pixel-output change. The generated tables are bit-identical\n   to what `init_all_wedge_masks()` produced (the Python mirrors the C exactly).\n - `av1_init_wedge_masks()` is preserved as a no-op so existing callers and\n   third-party consumers keep building/linking unchanged.\n - The `wedge_params_type::masks` field type change (`uint8_t *` → `uint32_t`)\n   and `signflip` becoming `const` are internal to libaom — no external API\n   consumer in our tree references these fields directly. Verified via grep.\n\nBug: 520656240\nChange-Id: I788cf0e29ee5f14b307de58deadace66d8327a05\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3670e80b1b837074811ce995528d0ddaeb72ce52",
      "old_mode": 33188,
      "old_path": "av1/av1.cmake",
      "new_id": "19bb1a7ca0e1b6aa976b0be10c898a2740b1302b",
      "new_mode": 33188,
      "new_path": "av1/av1.cmake"
    },
    {
      "type": "modify",
      "old_id": "6c220c5034be7eac334df3a0cbdfc3e415470ea8",
      "old_mode": 33188,
      "old_path": "av1/common/reconinter.c",
      "new_id": "edac3bd3ba56558577b3ba465220f7c88810a7a6",
      "new_mode": 33188,
      "new_path": "av1/common/reconinter.c"
    },
    {
      "type": "modify",
      "old_id": "0a33c9348fedf3df88d239b5268a56c946dd94d5",
      "old_mode": 33188,
      "old_path": "av1/common/reconinter.h",
      "new_id": "e32cc3e06c5e6bf55efe56ffabf2a8ed08415f0f",
      "new_mode": 33188,
      "new_path": "av1/common/reconinter.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "f3af453191702d92f62cedce47ed009a35d17180",
      "new_mode": 33188,
      "new_path": "av1/common/wedge_masks_data.inc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "fd151bae7414f129bfd4a26c554ea0258e0287f9",
      "new_mode": 33188,
      "new_path": "tools/gen_wedge_masks_data.py"
    }
  ]
}
