feat(libwebrtc): implement webrtc::I420Buffer::Create #20049

Merged
Krille2004zzz merged 3 commits from upstream-pr/20049 into main 2026-11-21 10:16:47 +00:00
Krille2004zzz commented 2026-11-14 13:52:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Krille2004zzz on 2026-11-14T13:52:50Z.


What

libwebrtc webrtc::I420Buffer::Create(int, int, int, int, int) (_ZN6webrtc10I420Buffer6CreateEiiiii) threw not implemented. This PR ports it from M134 (8d78f5de) i420_buffer.cc, with CheckValidDimensions from video_frame_buffer.cc and AlignedMalloc/AlignedFree from aligned_malloc.cc. src/I420Buffer.cpp now also carries those two notices. The module exports only this overload; Create(int, int) is not in the export table.

  • Layout: Clang 19 + libc++ probes of the real M134 headers give a 48-byte RefCountedObject<I420Buffer>: vtable at 0, width/height at 8/12, strides at 16–24, data at 32, reference count at 40. The vtable dump gives 21 slots (AddRef, Release, two destructors, type, width, height, ToI420, GetI420, CropAndScale, GetMappedFrameBuffer, storage_representation, ChromaWidth/Height, three strides, three planes, HasOneRef). The header and ref_counted_object.h are the same at M127. Nothing here depends on the standard library's container layouts.
  • Create: guest operator new for the object, guest malloc for the pixels, 64-byte aligned with the start address stored in the 8 bytes before the data, as AlignedMalloc does. The returned reference count is 1.
  • Vtable: a host vtable. Slots that already have exports point at them: ToI420, GetI420, GetMappedFrameBuffer, ChromaWidth/ChromaHeight, and CropAndScale, which is still the unimplemented stub and throws. storage_representation returns "?" using the libc guest string rules (as in VideoDecoder::GetDecoderInfo). The last Release frees the pixels and the object.
  • Checks: the RTC_CHECKs (dimensions > 0, stride_y >= width, chroma strides > 0, data size fits in int, malloc succeeds) throw std::runtime_error instead of aborting, and nothing leaks. A null result throws std::invalid_argument. The release-build RTC_DCHECKs on the chroma strides are left out, as upstream does in release builds.
  • Version: CheckValidDimensions and the checked_cast arrived at M133. Up to M132 these inputs are unchecked in release builds, so the reject path assumes a module at M133 or later. Valid inputs behave the same from M127 to M134.
  • Debt: the stub is removed, the libwebrtc unknown-export count drops from 222 to 221, and a debt entry records the layout and that the console's ABI and behaviour are unverified.

Tested

  • New tests: guest_webrtc_i420_buffer_create_create, _virtuals and _invalid (core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp) cover:
    • field values, 64-byte alignment, the stored start address, the malloc size, and plane offsets for even and odd sizes and padded strides;
    • every vtable slot, plus the existing MutableDataY/U/V exports dispatching through it;
    • AddRef/Release/HasOneRef, ToI420 adding a reference, GetMappedFrameBuffer rejecting a non-native buffer, and both destructor slots;
    • each check failure, a failed malloc and a null result, with no leaks;
    • every guest allocation freed.
  • Differential check: upstream i420_buffer.cc, video_frame_buffer.cc and aligned_malloc.cc, built with Clang 19 + libc++ and NDEBUG, gave identical results to this implementation on 300,000 generated inputs (146,125 accepted, 153,875 rejected, including the INT_MAX data-size boundary). The comparison covered:
    • accept or reject;
    • the malloc size, alignment and stored header;
    • all fields and the reference count;
    • each virtual called through the same vtable slot on both objects (type, dimensions, chroma dimensions, strides, plane offsets, GetI420, HasOneRef, AddRef/Release status);
    • storage_representation;
    • leaks after the last Release.
  • Mutation check: rejecting stride_y == width fails all three tests, and dropping the + 1 in the V-plane chroma height fails two.
  • Linux x86-64 (Debian trixie, GCC 14.2, Release): ctest -R '[Ww]eb[Rr]tc|[Ii]420|public_headers|export_gap|conventions|progress_report|test_registration|debt': 246/246 passed after rebasing on current main. Full suite before the rebase: 5420/5422; the two failures, guest_appcontent and guest_http2_transport, have no libwebrtc dependency and their binaries are unchanged by this PR. Not tested on a console, a title or Windows.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • python3 tools/pr_overlap.py: no open PR implements this export. My #20025, #20031, #20036 and #20042 share the debt count line; whichever merges later recounts.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5311914921 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049). Originally posted by [Krille2004zzz](https://github.com/Krille2004zzz) on 2026-11-14T13:52:50Z. --- ### What libwebrtc `webrtc::I420Buffer::Create(int, int, int, int, int)` (`_ZN6webrtc10I420Buffer6CreateEiiiii`) threw `not implemented`. This PR ports it from M134 (8d78f5de) [`i420_buffer.cc`](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/video/i420_buffer.cc), with `CheckValidDimensions` from [`video_frame_buffer.cc`](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/video/video_frame_buffer.cc) and `AlignedMalloc`/`AlignedFree` from [`aligned_malloc.cc`](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/memory/aligned_malloc.cc). `src/I420Buffer.cpp` now also carries those two notices. The module exports only this overload; `Create(int, int)` is not in the export table. - **Layout:** Clang 19 + libc++ probes of the real M134 headers give a 48-byte `RefCountedObject<I420Buffer>`: vtable at 0, width/height at 8/12, strides at 16–24, data at 32, reference count at 40. The vtable dump gives 21 slots (AddRef, Release, two destructors, `type`, `width`, `height`, `ToI420`, `GetI420`, `CropAndScale`, `GetMappedFrameBuffer`, `storage_representation`, `ChromaWidth`/`Height`, three strides, three planes, `HasOneRef`). The header and `ref_counted_object.h` are the same at M127. Nothing here depends on the standard library's container layouts. - **Create:** guest `operator new` for the object, guest `malloc` for the pixels, 64-byte aligned with the start address stored in the 8 bytes before the data, as `AlignedMalloc` does. The returned reference count is 1. - **Vtable:** a host vtable. Slots that already have exports point at them: `ToI420`, `GetI420`, `GetMappedFrameBuffer`, `ChromaWidth`/`ChromaHeight`, and `CropAndScale`, which is still the unimplemented stub and throws. `storage_representation` returns `"?"` using the `libc` guest string rules (as in `VideoDecoder::GetDecoderInfo`). The last `Release` frees the pixels and the object. - **Checks:** the `RTC_CHECK`s (dimensions > 0, `stride_y >= width`, chroma strides > 0, data size fits in `int`, `malloc` succeeds) throw `std::runtime_error` instead of aborting, and nothing leaks. A null result throws `std::invalid_argument`. The release-build `RTC_DCHECK`s on the chroma strides are left out, as upstream does in release builds. - **Version:** `CheckValidDimensions` and the `checked_cast` arrived at M133. Up to M132 these inputs are unchecked in release builds, so the reject path assumes a module at M133 or later. Valid inputs behave the same from M127 to M134. - **Debt:** the stub is removed, the libwebrtc unknown-export count drops from 222 to 221, and a debt entry records the layout and that the console's ABI and behaviour are unverified. ### Tested - **New tests:** `guest_webrtc_i420_buffer_create_create`, `_virtuals` and `_invalid` (`core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp`) cover: - field values, 64-byte alignment, the stored start address, the `malloc` size, and plane offsets for even and odd sizes and padded strides; - every vtable slot, plus the existing `MutableDataY/U/V` exports dispatching through it; - `AddRef`/`Release`/`HasOneRef`, `ToI420` adding a reference, `GetMappedFrameBuffer` rejecting a non-native buffer, and both destructor slots; - each check failure, a failed `malloc` and a null result, with no leaks; - every guest allocation freed. - **Differential check:** upstream `i420_buffer.cc`, `video_frame_buffer.cc` and `aligned_malloc.cc`, built with Clang 19 + libc++ and `NDEBUG`, gave identical results to this implementation on 300,000 generated inputs (146,125 accepted, 153,875 rejected, including the `INT_MAX` data-size boundary). The comparison covered: - accept or reject; - the `malloc` size, alignment and stored header; - all fields and the reference count; - each virtual called through the same vtable slot on both objects (`type`, dimensions, chroma dimensions, strides, plane offsets, `GetI420`, `HasOneRef`, `AddRef`/`Release` status); - `storage_representation`; - leaks after the last `Release`. - **Mutation check:** rejecting `stride_y == width` fails all three tests, and dropping the `+ 1` in the V-plane chroma height fails two. - **Linux x86-64** (Debian trixie, GCC 14.2, Release): `ctest -R '[Ww]eb[Rr]tc|[Ii]420|public_headers|export_gap|conventions|progress_report|test_registration|debt'`: 246/246 passed after rebasing on current `main`. Full suite before the rebase: 5420/5422; the two failures, `guest_appcontent` and `guest_http2_transport`, have no libwebrtc dependency and their binaries are unchanged by this PR. Not tested on a console, a title or Windows. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - **`python3 tools/pr_overlap.py`:** no open PR implements this export. My #20025, #20031, #20036 and #20042 share the debt count line; whichever merges later recounts. ### 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
MarcZX10 commented 2026-11-14 14:07:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T14:07:29Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation and tests provide evidence for the described I420 buffer creation behavior at the pinned head, with console behavior still unverified.

What I ran

No commands were run. I reviewed head 697092213146fe4a18f44838cb791e39fa32e8d2 using the prepared diff and pinned reader; no merged preview was checked.

Results

Check Result Note
Diff and changed lines passed All seven changed files read
Tests and build not run Author-reported checks only
Console behavior not run Author reports it is unverified

Findings

Blocking

None.

Non-blocking

  • The author-reported test coverage and differential comparison are substantial, but I did not rerun them; console ABI and behavior remain unverified as documented.

Not verified

I read all seven changed files: core/libs/prx/libwebrtc/CMakeLists.txt, core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/I420Buffer.hpp, core/libs/prx/libwebrtc/src/I420Buffer.cpp, core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp, and docs/dev/debt/libwebrtc.md. No changed files were excluded. I did not run the reported tests or validate console behavior.

To get this to a good state

Nothing is required. Optional: verify the ABI and behavior on console hardware when available.

Continued review (pass 2)

Nothing blocks this continuation review; the points below are optional.

What I ran

Read the requested added lines 541–552 in core/libs/prx/libwebrtc/CMakeLists.txt and the surrounding CMake context at the pinned head. No commands or tests were run.

Results

Check Result Note
Requested lines and context passed Read at pinned head
Tests not run No tests run in this continuation pass

Findings

Blocking

None in the requested lines.

Non-blocking

None.

Not verified

This continuation review covers only core/libs/prx/libwebrtc/CMakeLists.txt lines 541–552 and their surrounding context. Other changed lines and files, and test behavior, were not reviewed in this pass.

To get this to a good state

Nothing is required.

Continued review (pass 3)

The test registration on the specified lines follows the neighboring libwebrtc test setup; this continuation covers only those lines.

What I ran

Read the change at head 697092213146fe4a18f44838cb791e39fa32e8d2 and nearby CMake context. No commands or tests were run.

Results

Check Result Note
CMake registration review passed Matches neighboring test setup
Build or tests not run No execution in this continuation

Negative control

Not run; this CMake-only continuation did not change code under test.

Findings

Blocking

None in the specified lines.

Non-blocking

None.

Sources

core/libs/prx/libwebrtc/CMakeLists.txt:541-552 at the reviewed head; neighboring registration at lines 531-540 and 553-560.

Not verified

This continuation reviewed only core/libs/prx/libwebrtc/CMakeLists.txt lines 541-552. Other changed files and added lines were not reviewed in this pass; no build, test run, Windows check, or console check was performed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904768066 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049#pullrequestreview-5904768066). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T14:07:29Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation and tests provide evidence for the described I420 buffer creation behavior at the pinned head, with console behavior still unverified. ## What I ran No commands were run. I reviewed head `697092213146fe4a18f44838cb791e39fa32e8d2` using the prepared diff and pinned reader; no merged preview was checked. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | All seven changed files read | | Tests and build | not run | Author-reported checks only | | Console behavior | not run | Author reports it is unverified | ## Findings ### Blocking None. ### Non-blocking - The author-reported test coverage and differential comparison are substantial, but I did not rerun them; console ABI and behavior remain unverified as documented. ## Not verified I read all seven changed files: `core/libs/prx/libwebrtc/CMakeLists.txt`, `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/I420Buffer.hpp`, `core/libs/prx/libwebrtc/src/I420Buffer.cpp`, `core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp`, and `docs/dev/debt/libwebrtc.md`. No changed files were excluded. I did not run the reported tests or validate console behavior. ## To get this to a good state Nothing is required. Optional: verify the ABI and behavior on console hardware when available. ## Continued review (pass 2) Nothing blocks this continuation review; the points below are optional. ## What I ran Read the requested added lines 541–552 in `core/libs/prx/libwebrtc/CMakeLists.txt` and the surrounding CMake context at the pinned head. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Requested lines and context | passed | Read at pinned head | | Tests | not run | No tests run in this continuation pass | ## Findings ### Blocking None in the requested lines. ### Non-blocking None. ## Not verified This continuation review covers only `core/libs/prx/libwebrtc/CMakeLists.txt` lines 541–552 and their surrounding context. Other changed lines and files, and test behavior, were not reviewed in this pass. ## To get this to a good state Nothing is required. ## Continued review (pass 3) The test registration on the specified lines follows the neighboring libwebrtc test setup; this continuation covers only those lines. ## What I ran Read the change at head `697092213146fe4a18f44838cb791e39fa32e8d2` and nearby CMake context. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | CMake registration review | passed | Matches neighboring test setup | | Build or tests | not run | No execution in this continuation | ## Negative control Not run; this CMake-only continuation did not change code under test. ## Findings ### Blocking None in the specified lines. ### Non-blocking None. ## Sources `core/libs/prx/libwebrtc/CMakeLists.txt:541-552` at the reviewed head; neighboring registration at lines 531-540 and 553-560. ## Not verified This continuation reviewed only `core/libs/prx/libwebrtc/CMakeLists.txt` lines 541-552. Other changed files and added lines were not reviewed in this pass; no build, test run, Windows check, or console check was performed. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-14 14:54:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T14:54:22Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and added tests look consistent with the stated M134 behavior, but I did not run the checks reported by the author.

What I ran

Reviewed head fb1e179c2742ed7f5166b2340408e8545d379546 using the prepared diff and pinned reader. No build or test commands were run.

Results

Check Result Note
Diff and changed code review passed Seven changed files inspected
Build and test suite not run Reported results are author supplied
Console and Windows behavior not run Not verified in this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

Console ABI and behavior, Windows execution, and the reported automated test results were not independently verified. The reader showed every changed file as included in the review bundle, and I read the changed code and relevant changed regions. I did not inspect unaffected callers or the full unchanged portions of Export.cpp, Api.hpp, CMakeLists.txt, and docs/dev/debt/libwebrtc.md.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5905101589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049#pullrequestreview-5905101589). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T14:54:22Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and added tests look consistent with the stated M134 behavior, but I did not run the checks reported by the author. ## What I ran Reviewed head `fb1e179c2742ed7f5166b2340408e8545d379546` using the prepared diff and pinned reader. No build or test commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code review | passed | Seven changed files inspected | | Build and test suite | not run | Reported results are author supplied | | Console and Windows behavior | not run | Not verified in this review | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Console ABI and behavior, Windows execution, and the reported automated test results were not independently verified. The reader showed every changed file as included in the review bundle, and I read the changed code and relevant changed regions. I did not inspect unaffected callers or the full unchanged portions of `Export.cpp`, `Api.hpp`, `CMakeLists.txt`, and `docs/dev/debt/libwebrtc.md`. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-14 15:38:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T15:38:50Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against c7dd405f03:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_i420_buffer_create_tests built cleanly.
  • CTest (guest_webrtc_i420_buffer_create_create, guest_webrtc_i420_buffer_create_virtuals, guest_webrtc_i420_buffer_create_invalid):
    1/3 Test #5136: guest_webrtc_i420_buffer_create_virtuals ...   Passed    0.02 sec
    2/3 Test #5135: guest_webrtc_i420_buffer_create_create .....   Passed    0.04 sec
    3/3 Test #5137: guest_webrtc_i420_buffer_create_invalid ....   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 3
    
  • Negative control: with core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/I420Buffer.hpp, core/libs/prx/libwebrtc/src/I420Buffer.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified _ZN6webrtc10I420Buffer6CreateEiiiii_nid_postfix checks for a null result pointer (throwing std::invalid_argument) and guarantees exception safety by releasing storage via _ZdlPv_nid_postfix if AlignedMalloc or I420DataSize throws.
    • core/libs/prx/libwebrtc/src/I420Buffer.cpp: Audited I420DataSize calculation 'strideY * h + (strideU + strideV) * ((h + 1) / 2)' in 64 bits, confirming no signed integer overflow can occur across any 32-bit positive inputs and that values exceeding INT_MAX or non-positive dimensions/strides trigger std::runtime_error.
    • core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified AlignedMalloc and AlignedFree 64-byte alignment arithmetic, confirming that the stored start pointer at 'aligned - sizeof(uintptr_t)' remains within the allocated block and correctly restores the original allocation pointer for free_nid_postfix.
    • core/libs/prx/libwebrtc/src/I420Buffer.cpp: Checked reference counting operations (relaxed fetch_add in AddRef, acq_rel fetch_sub in Release, and acquire load in HasOneRef), verifying that destruction (Destroy_nid_no_patch and Delete_nid_no_patch) executes only when the reference count drops to 0.
    • core/libs/prx/libwebrtc/include/I420Buffer.hpp: Confirmed WebRtcRefCountedI420Buffer layout and member offsets (sizeof 48, offsetof refCount at 40) maintain LP64 and LLP64 portability and match the documented debt specifications.
    • core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp: Verified test coverage across create, virtuals, and invalid cases, confirming all 21 vtable slots are exercised behaviorally without import thunk address comparisons on Windows, and memory failure paths confirm zero leaks.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5905473531 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049#pullrequestreview-5905473531). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T15:38:50Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `c7dd405f03`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_i420_buffer_create_tests` built cleanly. - **CTest** (`guest_webrtc_i420_buffer_create_create`, `guest_webrtc_i420_buffer_create_virtuals`, `guest_webrtc_i420_buffer_create_invalid`): ``` 1/3 Test #5136: guest_webrtc_i420_buffer_create_virtuals ... Passed 0.02 sec 2/3 Test #5135: guest_webrtc_i420_buffer_create_create ..... Passed 0.04 sec 3/3 Test #5137: guest_webrtc_i420_buffer_create_invalid .... Passed 0.02 sec 100% tests passed, 0 tests failed out of 3 ``` - **Negative control**: with `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/I420Buffer.hpp`, `core/libs/prx/libwebrtc/src/I420Buffer.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified _ZN6webrtc10I420Buffer6CreateEiiiii_nid_postfix checks for a null result pointer (throwing std::invalid_argument) and guarantees exception safety by releasing storage via _ZdlPv_nid_postfix if AlignedMalloc or I420DataSize throws. - core/libs/prx/libwebrtc/src/I420Buffer.cpp: Audited I420DataSize calculation 'strideY * h + (strideU + strideV) * ((h + 1) / 2)' in 64 bits, confirming no signed integer overflow can occur across any 32-bit positive inputs and that values exceeding INT_MAX or non-positive dimensions/strides trigger std::runtime_error. - core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified AlignedMalloc and AlignedFree 64-byte alignment arithmetic, confirming that the stored start pointer at 'aligned - sizeof(uintptr_t)' remains within the allocated block and correctly restores the original allocation pointer for free_nid_postfix. - core/libs/prx/libwebrtc/src/I420Buffer.cpp: Checked reference counting operations (relaxed fetch_add in AddRef, acq_rel fetch_sub in Release, and acquire load in HasOneRef), verifying that destruction (Destroy_nid_no_patch and Delete_nid_no_patch) executes only when the reference count drops to 0. - core/libs/prx/libwebrtc/include/I420Buffer.hpp: Confirmed WebRtcRefCountedI420Buffer layout and member offsets (sizeof 48, offsetof refCount at 40) maintain LP64 and LLP64 portability and match the documented debt specifications. - core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp: Verified test coverage across create, virtuals, and invalid cases, confirming all 21 vtable slots are exercised behaviorally without import thunk address comparisons on Windows, and memory failure paths confirm zero leaks. - Note: the AI-assisted checkbox can stay. Looks Good To Me
PrivacyOnion commented 2026-11-14 17:09:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T17:09:52Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0a0180bdad:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_i420_buffer_create_tests built cleanly.
  • CTest (guest_webrtc_i420_buffer_create_create, guest_webrtc_i420_buffer_create_virtuals, guest_webrtc_i420_buffer_create_invalid):
    1/3 Test #5146: guest_webrtc_i420_buffer_create_invalid ....   Passed    0.01 sec
    2/3 Test #5144: guest_webrtc_i420_buffer_create_create .....   Passed    0.01 sec
    3/3 Test #5145: guest_webrtc_i420_buffer_create_virtuals ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 3
    
  • Negative control: with core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/I420Buffer.hpp, core/libs/prx/libwebrtc/src/I420Buffer.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified _ZN6webrtc10I420Buffer6CreateEiiiii_nid_postfix validates result != nullptr throwing std::invalid_argument and cleans up storage via _ZdlPv_nid_postfix if AlignedMalloc throws.
    • core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified I420DataSize validates positive dimensions and strides (width <= 0, height <= 0, strideY < width, strideU <= 0, strideV <= 0) and computes total size in 64-bit signed integer arithmetic before validating against std::numeric_limitsstd::int32_t::max().
    • core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified AlignedMalloc and AlignedFree implement 64-byte alignment, storing the guest malloc allocation pointer in the header preceding the aligned block and properly freeing it on destruction.
    • core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified RefCountedI420BufferVtable slot dispatch and memory ordering, confirming AddRef uses relaxed order, Release uses acq_rel order returning DroppedLastRef (0) or OtherRefsRemained (1), HasOneRef uses acquire order, and plane pointers match YUV420 offsets.
    • core/libs/prx/libwebrtc/include/I420Buffer.hpp: Verified WebRtcI420Buffer (40 bytes) and WebRtcRefCountedI420Buffer (48 bytes) static_assert assertions for size and member offsets on 64-bit architectures.
    • core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp: Verified test coverage across TestCreate, TestVirtuals, and TestInvalid, including heap tracking through ApplicationHeapRegister_nid_no_patch and functional virtual checks avoiding Windows import thunk address comparisons.
    • AGENTS.md & docs/dev/debt/libwebrtc.md: Verified strict compliance with conventions: zero comments in code, Conventional Commit title, debt entry updated with unknown export count reduced from 202 to 201, and CMake test registration configured for Linux and Windows.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5906015772 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049#pullrequestreview-5906015772). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T17:09:52Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0a0180bdad`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_i420_buffer_create_tests` built cleanly. - **CTest** (`guest_webrtc_i420_buffer_create_create`, `guest_webrtc_i420_buffer_create_virtuals`, `guest_webrtc_i420_buffer_create_invalid`): ``` 1/3 Test #5146: guest_webrtc_i420_buffer_create_invalid .... Passed 0.01 sec 2/3 Test #5144: guest_webrtc_i420_buffer_create_create ..... Passed 0.01 sec 3/3 Test #5145: guest_webrtc_i420_buffer_create_virtuals ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 3 ``` - **Negative control**: with `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/I420Buffer.hpp`, `core/libs/prx/libwebrtc/src/I420Buffer.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified _ZN6webrtc10I420Buffer6CreateEiiiii_nid_postfix validates result != nullptr throwing std::invalid_argument and cleans up storage via _ZdlPv_nid_postfix if AlignedMalloc throws. - core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified I420DataSize validates positive dimensions and strides (width <= 0, height <= 0, strideY < width, strideU <= 0, strideV <= 0) and computes total size in 64-bit signed integer arithmetic before validating against std::numeric_limits<std::int32_t>::max(). - core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified AlignedMalloc and AlignedFree implement 64-byte alignment, storing the guest malloc allocation pointer in the header preceding the aligned block and properly freeing it on destruction. - core/libs/prx/libwebrtc/src/I420Buffer.cpp: Verified RefCountedI420BufferVtable slot dispatch and memory ordering, confirming AddRef uses relaxed order, Release uses acq_rel order returning DroppedLastRef (0) or OtherRefsRemained (1), HasOneRef uses acquire order, and plane pointers match YUV420 offsets. - core/libs/prx/libwebrtc/include/I420Buffer.hpp: Verified WebRtcI420Buffer (40 bytes) and WebRtcRefCountedI420Buffer (48 bytes) static_assert assertions for size and member offsets on 64-bit architectures. - core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp: Verified test coverage across TestCreate, TestVirtuals, and TestInvalid, including heap tracking through ApplicationHeapRegister_nid_no_patch and functional virtual checks avoiding Windows import thunk address comparisons. - AGENTS.md & docs/dev/debt/libwebrtc.md: Verified strict compliance with conventions: zero comments in code, Conventional Commit title, debt entry updated with unknown export count reduced from 202 to 201, and CMake test registration configured for Linux and Windows. - Note: the AI-assisted checkbox can stay. Looks Good To Me
MarcZX10 commented 2026-11-14 17:18:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T17:18:35Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the host ABI and console behavior remain unverified as documented.

What I ran

Reviewed head 0a0180bdad82c2a15b8aedd7cdc203fda54c1191. I read the prepared description, commits, manifest and diff, plus every changed line and targeted allocator, string, and video-frame helper context through repo_read.py. I did not run tests or build commands.

Results

Check Result Note
Diff and changed lines passed All changed files read
Targeted source context passed Allocation and dispatch helpers reviewed
Tests and build not run Author reports Linux test results

Findings

Blocking

None.

Non-blocking

None.

Not verified

Console ABI and behavior, Windows, and title behavior were not verified. I did not independently reproduce the author-reported tests or differential check. Files read: core/libs/prx/libwebrtc/CMakeLists.txt, core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/I420Buffer.hpp, core/libs/prx/libwebrtc/src/I420Buffer.cpp, core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp, and docs/dev/debt/libwebrtc.md; targeted context included core/libs/prx/libwebrtc/src/VideoFrameBuffer.cpp, core/libs/prx/libwebrtc/include/GuestString.hpp, and core/libs/prx/libc/src/StdioExtras.cpp. No changed files were excluded from reading.

To get this to a good state

Nothing is required.

Continued review (pass 2)

The added test source and debt entry were reviewed; no verified defect was found in these lines.

What I ran

No commands were run. Read the added lines of core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp (1–222) and docs/dev/debt/libwebrtc.md (78), plus the prepared description, commits, manifest, and diff for context.

Results

Check Result Note
Added test source review passed Assertions and cleanup paths inspected
Debt entry review passed Entry matches stated assumptions
Tests not run Continuation review only

Findings

Blocking

None.

Non-blocking

None.

Not verified

Tests, runtime behavior, and other changed lines were not verified in this continuation pass. The requested added lines were read; other files listed in the manifest were not reread.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5906050225 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049#pullrequestreview-5906050225). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T17:18:35Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the host ABI and console behavior remain unverified as documented. ## What I ran Reviewed head `0a0180bdad82c2a15b8aedd7cdc203fda54c1191`. I read the prepared description, commits, manifest and diff, plus every changed line and targeted allocator, string, and video-frame helper context through `repo_read.py`. I did not run tests or build commands. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | All changed files read | | Targeted source context | passed | Allocation and dispatch helpers reviewed | | Tests and build | not run | Author reports Linux test results | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Console ABI and behavior, Windows, and title behavior were not verified. I did not independently reproduce the author-reported tests or differential check. Files read: `core/libs/prx/libwebrtc/CMakeLists.txt`, `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/I420Buffer.hpp`, `core/libs/prx/libwebrtc/src/I420Buffer.cpp`, `core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp`, and `docs/dev/debt/libwebrtc.md`; targeted context included `core/libs/prx/libwebrtc/src/VideoFrameBuffer.cpp`, `core/libs/prx/libwebrtc/include/GuestString.hpp`, and `core/libs/prx/libc/src/StdioExtras.cpp`. No changed files were excluded from reading. ## To get this to a good state Nothing is required. ## Continued review (pass 2) The added test source and debt entry were reviewed; no verified defect was found in these lines. ## What I ran No commands were run. Read the added lines of `core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp` (1–222) and `docs/dev/debt/libwebrtc.md` (78), plus the prepared description, commits, manifest, and diff for context. ## Results | Check | Result | Note | |---|---|---| | Added test source review | passed | Assertions and cleanup paths inspected | | Debt entry review | passed | Entry matches stated assumptions | | Tests | not run | Continuation review only | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Tests, runtime behavior, and other changed lines were not verified in this continuation pass. The requested added lines were read; other files listed in the manifest were not reread. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-14 19:52:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T19:52:06Z.

Review: APPROVED


Reviewed — looks good

The implementation and tests for I420Buffer::Create are coherent at the reviewed head; the author reports passing Linux checks, but I did not run them here, and console behavior remains unverified.

What I ran

Reviewed head e580ad44457e367a8ee5e14afba64f3d9644ebeb, based on main. No commands or tests were run in this review; source was inspected with the repo_read.py reader.

Results

Check Result Note
Diff and changed sources passed Reviewed all seven changed files
Tests not run Results in the PR description are author-reported
Console behavior not run Description says console and title behavior are unverified

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the reported Linux tests, differential check, mutation check, or conventions check. Console, title, and Windows behavior were not verified. No files were excluded; all seven changed files listed in the manifest were read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5906798970 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049#pullrequestreview-5906798970). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T19:52:06Z. **Review:** APPROVED --- # Reviewed — looks good The implementation and tests for `I420Buffer::Create` are coherent at the reviewed head; the author reports passing Linux checks, but I did not run them here, and console behavior remains unverified. ## What I ran Reviewed head `e580ad44457e367a8ee5e14afba64f3d9644ebeb`, based on `main`. No commands or tests were run in this review; source was inspected with the `repo_read.py` reader. ## Results | Check | Result | Note | |---|---|---| | Diff and changed sources | passed | Reviewed all seven changed files | | Tests | not run | Results in the PR description are author-reported | | Console behavior | not run | Description says console and title behavior are unverified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the reported Linux tests, differential check, mutation check, or conventions check. Console, title, and Windows behavior were not verified. No files were excluded; all seven changed files listed in the manifest were read. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-14 22:04:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T22:04:53Z.

Review: APPROVED


Reviewed — looks good

The implementation and all seven changed files were reviewed at head 193c7523511506f20774a7afbcda8975081c463d; no verified blocking defect was found, and the author-reported checks were not run here.

What I ran

No commands or tests were run. I read the prepared description, commits, manifest and diff, plus all seven changed files through repo_read.py and targeted related ABI definitions and callers.

Results

Check Result Note
Changed-file review passed Seven of seven reviewed
Reported test suite not run Results are author-reported
Console and Windows behavior not run Not verified here

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported differential and mutation checks, Linux test suite, and convention checks were not independently run. Console/title behavior and Windows behavior remain unverified. Files excluded by rule: none reported in files.json (not provided as a separate prepared artifact); the manifest lists all seven changed files as included.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5907377475 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049#pullrequestreview-5907377475). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T22:04:53Z. **Review:** APPROVED --- # Reviewed — looks good The implementation and all seven changed files were reviewed at head `193c7523511506f20774a7afbcda8975081c463d`; no verified blocking defect was found, and the author-reported checks were not run here. ## What I ran No commands or tests were run. I read the prepared description, commits, manifest and diff, plus all seven changed files through `repo_read.py` and targeted related ABI definitions and callers. ## Results | Check | Result | Note | |---|---|---| | Changed-file review | passed | Seven of seven reviewed | | Reported test suite | not run | Results are author-reported | | Console and Windows behavior | not run | Not verified here | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The author-reported differential and mutation checks, Linux test suite, and convention checks were not independently run. Console/title behavior and Windows behavior remain unverified. Files excluded by rule: none reported in `files.json` (not provided as a separate prepared artifact); the manifest lists all seven changed files as included. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-15 05:49:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T05:49:43Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation and added tests were inspected at the pinned head; no concrete blocking defect was verified, but the reported checks were not rerun here.

What I ran

Reviewed head 45600ce9f9b3eedc2d2953e060829bfc9e033b01 using the prepared diff and repo_read.py; no commands or tests were run.

Results

Check Result Note
Source review passed Changed implementation and test code inspected
Reported test suite not run Results in the PR description were not independently verified
Console and title behavior not run Not verified by this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

Tests and differential checks reported in the PR description were not rerun. Console, title, and Windows behavior remain unverified. The review artifacts list seven changed files; their relevant diffs were inspected, including the implementation, tests, declarations, build registration, export removal, and debt-count update. files.json was not available through the reader.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5909327552 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20049#pullrequestreview-5909327552). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-15T05:49:43Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation and added tests were inspected at the pinned head; no concrete blocking defect was verified, but the reported checks were not rerun here. ## What I ran Reviewed head `45600ce9f9b3eedc2d2953e060829bfc9e033b01` using the prepared diff and `repo_read.py`; no commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed implementation and test code inspected | | Reported test suite | not run | Results in the PR description were not independently verified | | Console and title behavior | not run | Not verified by this review | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Tests and differential checks reported in the PR description were not rerun. Console, title, and Windows behavior remain unverified. The review artifacts list seven changed files; their relevant diffs were inspected, including the implementation, tests, declarations, build registration, export removal, and debt-count update. `files.json` was not available through the reader. ## To get this to a good state Nothing is required.
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!20049
No description provided.