feat(libwebrtc): implement I420BufferInterface::ChromaWidth and ChromaHeight #16893

Merged
AlexWhitehouse merged 1 commit from upstream-pr/16893 into main 2026-11-11 15:28:52 +00:00
AlexWhitehouse commented 2026-11-07 20:52:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-07T20:52:39Z.


What

Two libwebrtc exports threw ..._nid_postfix not implemented:

  • webrtc::I420BufferInterface::ChromaWidth() const (_ZNK6webrtc19I420BufferInterface11ChromaWidthEv, NID mAGSZ23UvZA);
  • ChromaHeight() const (_ZNK6webrtc19I420BufferInterface12ChromaHeightEv, NID 2j1-2M0bVZU).

This PR implements them from video_frame_buffer.cc at M134 (8d78f5de), identical at M127 (e0b28a6a). They are (width() + 1) / 2 and (height() + 1) / 2.

  • width() and height() are virtual calls on the guest buffer, at vtable slots 5 and 6 from the address point. The slots come from a GCC -fdump-lang-class of the M134 header, and are the slots my merged #15766 (VideoFrame width/height) already calls. They are called through the guest's System V ABI (APS5_VABI).
  • A dimension of INT_MAX would overflow dimension + 1, which is undefined behaviour upstream, so it throws. So does a null buffer, vtable or slot.
  • The new I420BufferChroma.cpp starts with video_frame_buffer.cc's notice.

The libwebrtc unknown-export count drops by 2 (260 to 258 on current main, after the rebase onto 6dc91ffb0c).

Tested

  • New tests: guest_webrtc_i420_chroma_width and guest_webrtc_i420_chroma_height use a synthetic guest vtable with different width and height callbacks. They cover:
    • dimensions 0, 1, 2, 3, 1919 and 1081;
    • the receiver passed to the callbacks;
    • repeated calls after the dimensions change;
    • the INT_MAX and null throws.
  • Linux x86-64 (Ubuntu 26.04, GCC 15, Release):
    • on main, both fail with ..._nid_postfix not implemented;
    • with this PR, both pass, as do guest_webrtc_video_frame_dimensions and public_headers.
    • after the rebase, all 51 libwebrtc tests pass at 0ea12aed1d, including guest_webrtc_trivial_returns from #15609 and the merged SentPacket and EchoCanceller3Config tests.
  • Windows 11: (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): all 37 libwebrtc tests pass at 6f2286e582, the two new ones and guest_webrtc_video_frame_dimensions included, with no compiler warnings in the changed files.
  • Mutation check: swapping slots 5 and 6 fails both tests at the asymmetric 1919×1081 case.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • python3 tools/pr_overlap.py: no other PR implements these exports.
    • #15609, which changed the GetI420 stub right after them in Export.cpp and Api.hpp, is now on main; this PR is rebased onto it and keeps its GetI420.
    • #15277 (I420Buffer mutable data, which adds src/I420Buffer.cpp) is now on main; this PR is rebased onto it.
    • My #16870 shares CMake insertion points and the count line, so whichever merges second recounts; my #16381, #16485, #16850 and #16894 are now on main.
    • #15189, #15197, #15262–#15265, #15270, #15271 and #15274–#15276 are now on main.
    • #14212 (debt entry layout and count totals) and #16419 (rate bucket test) share files but implement no exports, and #15927 is now on main; none of the listed PRs changes ChromaWidth or ChromaHeight.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5205740996 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16893). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-07T20:52:39Z. --- ### What Two libwebrtc exports threw `..._nid_postfix not implemented`: - `webrtc::I420BufferInterface::ChromaWidth() const` (`_ZNK6webrtc19I420BufferInterface11ChromaWidthEv`, NID `mAGSZ23UvZA`); - `ChromaHeight() const` (`_ZNK6webrtc19I420BufferInterface12ChromaHeightEv`, NID `2j1-2M0bVZU`). This PR implements them from [`video_frame_buffer.cc`](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/video/video_frame_buffer.cc) at M134 (8d78f5de), identical at M127 (e0b28a6a). They are `(width() + 1) / 2` and `(height() + 1) / 2`. - `width()` and `height()` are virtual calls on the guest buffer, at vtable slots 5 and 6 from the address point. The slots come from a GCC `-fdump-lang-class` of the M134 header, and are the slots my merged #15766 (`VideoFrame` width/height) already calls. They are called through the guest's System V ABI (`APS5_VABI`). - A dimension of `INT_MAX` would overflow `dimension + 1`, which is undefined behaviour upstream, so it throws. So does a null buffer, vtable or slot. - The new `I420BufferChroma.cpp` starts with `video_frame_buffer.cc`'s notice. The libwebrtc unknown-export count drops by 2 (260 to 258 on current `main`, after the rebase onto 6dc91ffb0c). ### Tested - **New tests:** `guest_webrtc_i420_chroma_width` and `guest_webrtc_i420_chroma_height` use a synthetic guest vtable with different width and height callbacks. They cover: - dimensions 0, 1, 2, 3, 1919 and 1081; - the receiver passed to the callbacks; - repeated calls after the dimensions change; - the `INT_MAX` and null throws. - **Linux x86-64** (Ubuntu 26.04, GCC 15, Release): - on `main`, both fail with `..._nid_postfix not implemented`; - with this PR, both pass, as do `guest_webrtc_video_frame_dimensions` and `public_headers`. - after the rebase, all 51 libwebrtc tests pass at 0ea12aed1d, including `guest_webrtc_trivial_returns` from #15609 and the merged SentPacket and EchoCanceller3Config tests. - **Windows 11:** (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): all 37 libwebrtc tests pass at 6f2286e582, the two new ones and `guest_webrtc_video_frame_dimensions` included, with no compiler warnings in the changed files. - **Mutation check:** swapping slots 5 and 6 fails both tests at the asymmetric 1919×1081 case. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - **`python3 tools/pr_overlap.py`:** no other PR implements these exports. - #15609, which changed the `GetI420` stub right after them in `Export.cpp` and `Api.hpp`, is now on `main`; this PR is rebased onto it and keeps its `GetI420`. - #15277 (`I420Buffer` mutable data, which adds `src/I420Buffer.cpp`) is now on `main`; this PR is rebased onto it. - My #16870 shares CMake insertion points and the count line, so whichever merges second recounts; my #16381, #16485, #16850 and #16894 are now on `main`. - #15189, #15197, #15262–#15265, #15270, #15271 and #15274–#15276 are now on `main`. - #14212 (debt entry layout and count totals) and #16419 (rate bucket test) share files but implement no exports, and #15927 is now on `main`; none of the listed PRs changes `ChromaWidth` or `ChromaHeight`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabichuuuuu commented 2026-11-07 22:13:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T22:13:34Z.

Review: COMMENTED


Read 5193e17be2 against main.

(width() + 1) / 2 and (height() + 1) / 2 match video_frame_buffer.cc at both 8d78f5de and e0b28a6a. Slots 5 and 6 follow RefCountInterface's AddRef, Release and the two destructor entries, then type, width and height in VideoFrameBuffer at both revisions; with single inheritance the vptr stays at offset 0, the same dispatch as VideoFrameDimensions.cpp. The test's expected values for negative inputs, INT_MIN and INT_MAX - 1 follow C++ truncating division, and the tests can't build on main, where the stubs take no arguments.

Count line. The diff's 296 to 294 matches main, but the PR body still says 300 to 298, and #16850 changes the same line to 294, so whichever merges second should say 292.

Not run here; this is from reading the code.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5815240666 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16893#pullrequestreview-5815240666). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T22:13:34Z. **Review:** COMMENTED --- Read `5193e17be2` against `main`. `(width() + 1) / 2` and `(height() + 1) / 2` match `video_frame_buffer.cc` at both `8d78f5de` and `e0b28a6a`. Slots 5 and 6 follow `RefCountInterface`'s `AddRef`, `Release` and the two destructor entries, then `type`, `width` and `height` in `VideoFrameBuffer` at both revisions; with single inheritance the vptr stays at offset 0, the same dispatch as `VideoFrameDimensions.cpp`. The test's expected values for negative inputs, `INT_MIN` and `INT_MAX - 1` follow C++ truncating division, and the tests can't build on `main`, where the stubs take no arguments. **Count line.** The diff's 296 to 294 matches `main`, but the PR body still says 300 to 298, and #16850 changes the same line to 294, so whichever merges second should say 292. Not run here; this is from reading the code. AI-assisted: yes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!16893
No description provided.