feat(libwebrtc): implement the EncodedImage constructor and destructor and EncodedImageBuffer::Create #20042

Merged
Krille2004zzz merged 3 commits from upstream-pr/20042 into main 2026-11-14 16:25:17 +00:00
Krille2004zzz commented 2026-11-14 13:21:34 +00:00 (Migrated from github.com)

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


What

libwebrtc webrtc::EncodedImage::EncodedImage() (_ZN6webrtc12EncodedImageC1Ev), webrtc::EncodedImage::~EncodedImage() (_ZN6webrtc12EncodedImageD1Ev) and webrtc::EncodedImageBuffer::Create(const uint8_t*, size_t) (_ZN6webrtc18EncodedImageBuffer6CreateEPKhm) threw not implemented. This PR ports them from M134 (8d78f5de) encoded_image.cc and encoded_image.h, with the reference counting from ref_counted_object.h and the rtc::Buffer constructor from buffer.h. The new src/EncodedImage.cpp starts with their notices. The copy and move constructors and assignments are not exported, so they are left out.

  • Layout: Clang 19 + libc++ probes of the real M134 headers give a 344-byte object: Timing at 40, the std::optional<VideoPlayoutDelay> at 112, the buffer scoped_refptr at 136, size_ at 144, std::map<int, size_t> at 200, std::optional<ColorSpace> at 224, RtpPacketInfos at 304 and the corruption-detection settings at 320. RefCountedObject<EncodedImageBuffer> is 40 bytes: vtable, rtc::Buffer at 8, count at 32. encoded_image.cc is the same in M132, M133 and M134, and the header is the same in M133. M132 has no corruption_detection_filter_settings_, which would make the object 320 bytes. The module is at least M132, since it exports BuiltinAudioProcessingBuilder::Build, but its exact revision isn't known. Like #20031 and #20036, this assumes the module's standard library is libc++.

  • Constructor: writes the upstream defaults: kVideoFrameDelta, qp_ −1, timing flags kInvalid, retransmission_allowed_ true, an empty map whose begin node points at its own end node, and everything else zero or not set.

  • Destructor: follows upstream's member order:

    • drops a reference to RtpPacketInfos::Data, and on the last one frees each entry's CSRC vector, the entry vector and the data;
    • frees every map node;
    • releases the buffer through guest vtable slot 1 (Release), so a buffer the title implements itself is released by its own code.

    Before anything is freed, it checks the map's node count and begin node and the bounds of the vectors. A null object, a malformed vector or map, or a buffer without a Release slot throws.

  • EncodedImageBuffer::Create: allocates the 40-byte object with guest operator new and the copy of the bytes with operator new[], with capacity equal to size and no array when size is 0. If the array allocation fails, the object is freed. It returns the reference through the hidden result pointer with count 1. The host vtable follows Clang's dump: AddRef, Release, complete and deleting destructors, both data(), size(), HasOneRef. A null result, or null data with a non-zero size, throws.

  • Debt: the three stubs are removed, the libwebrtc unknown-export count drops from 222 to 219, and a debt entry records the layout, the M132 difference and that nothing has been checked on the console.

Tested

  • New tests: guest_webrtc_encoded_image_default, _buffer and _destructor (core/libs/prx/libwebrtc/tests/EncodedImage.cpp) cover:
    • every default field;
    • Create's copy, every vtable slot, shared references, zero-size and allocation-failure paths;
    • destroying an image with our own buffer and with a title's buffer, with shared and unshared buffers and packet infos, and with a 4-node map;
    • malformed vectors, map counts, a map cycle, a broken vtable and null arguments;
    • every guest allocation freed.
  • Differential check: a Clang 19 + libc++ program linked the real M134 encoded_image.cc, rtp_packet_info.cc and color_space.cc with this implementation:
    • the constructed bytes match upstream's exactly, apart from the map's self-pointer;
    • on 100,000 randomly filled upstream objects (75,036 with data, 73,126 with layer sizes, 50,043 with packet infos, 37,568 holding shared references), this destructor freed the same number of blocks and bytes as upstream's, and left the shared references and their counts the same;
    • on 20,000 buffers, Create matched upstream in allocation sizes, fields and virtual calls, and upstream EncodedImage copies released these buffers with no leak.
  • Mutation check: each of these breaks both the differential check and a test: skipping the CSRC frees, using the wrong last-reference threshold, defaulting qp_ to 0, and a wrong buffer capacity.
  • Linux x86-64 (Debian trixie, GCC 14.2, Release): ctest -R '[Ww]eb[Rr]tc|[Nn]ack|[Ee]ncoded|[Ii]420|public_headers|export_gap|conventions|progress_report|test_registration|debt': 249/249 passed. 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 these exports. #17009, #17722, #18495, #18503 and #18798 couldn't be compared automatically, so I compared them by hand: they implement other functions and only share the libwebrtc files. My #20025, #20031 and #20036 change the same debt count line, so whichever merges later needs a recount.

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:5311645965 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20042). Originally posted by [Krille2004zzz](https://github.com/Krille2004zzz) on 2026-11-14T13:21:34Z. --- ### What libwebrtc `webrtc::EncodedImage::EncodedImage()` (`_ZN6webrtc12EncodedImageC1Ev`), `webrtc::EncodedImage::~EncodedImage()` (`_ZN6webrtc12EncodedImageD1Ev`) and `webrtc::EncodedImageBuffer::Create(const uint8_t*, size_t)` (`_ZN6webrtc18EncodedImageBuffer6CreateEPKhm`) threw `not implemented`. This PR ports them from M134 (8d78f5de) [`encoded_image.cc`](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/video/encoded_image.cc) and [`encoded_image.h`](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/video/encoded_image.h), with the reference counting from `ref_counted_object.h` and the `rtc::Buffer` constructor from `buffer.h`. The new `src/EncodedImage.cpp` starts with their notices. The copy and move constructors and assignments are not exported, so they are left out. - **Layout:** Clang 19 + libc++ probes of the real M134 headers give a 344-byte object: `Timing` at 40, the `std::optional<VideoPlayoutDelay>` at 112, the buffer `scoped_refptr` at 136, `size_` at 144, `std::map<int, size_t>` at 200, `std::optional<ColorSpace>` at 224, `RtpPacketInfos` at 304 and the corruption-detection settings at 320. `RefCountedObject<EncodedImageBuffer>` is 40 bytes: vtable, `rtc::Buffer` at 8, count at 32. `encoded_image.cc` is the same in M132, M133 and M134, and the header is the same in M133. M132 has no `corruption_detection_filter_settings_`, which would make the object 320 bytes. The module is at least M132, since it exports `BuiltinAudioProcessingBuilder::Build`, but its exact revision isn't known. Like #20031 and #20036, this assumes the module's standard library is libc++. - **Constructor:** writes the upstream defaults: `kVideoFrameDelta`, `qp_` −1, timing flags `kInvalid`, `retransmission_allowed_` true, an empty map whose begin node points at its own end node, and everything else zero or not set. - **Destructor:** follows upstream's member order: - drops a reference to `RtpPacketInfos::Data`, and on the last one frees each entry's CSRC vector, the entry vector and the data; - frees every map node; - releases the buffer through guest vtable slot 1 (`Release`), so a buffer the title implements itself is released by its own code. Before anything is freed, it checks the map's node count and begin node and the bounds of the vectors. A null object, a malformed vector or map, or a buffer without a `Release` slot throws. - **`EncodedImageBuffer::Create`:** allocates the 40-byte object with guest `operator new` and the copy of the bytes with `operator new[]`, with capacity equal to size and no array when size is 0. If the array allocation fails, the object is freed. It returns the reference through the hidden result pointer with count 1. The host vtable follows Clang's dump: `AddRef`, `Release`, complete and deleting destructors, both `data()`, `size()`, `HasOneRef`. A null result, or null data with a non-zero size, throws. - **Debt:** the three stubs are removed, the libwebrtc unknown-export count drops from 222 to 219, and a debt entry records the layout, the M132 difference and that nothing has been checked on the console. ### Tested - **New tests:** `guest_webrtc_encoded_image_default`, `_buffer` and `_destructor` (`core/libs/prx/libwebrtc/tests/EncodedImage.cpp`) cover: - every default field; - `Create`'s copy, every vtable slot, shared references, zero-size and allocation-failure paths; - destroying an image with our own buffer and with a title's buffer, with shared and unshared buffers and packet infos, and with a 4-node map; - malformed vectors, map counts, a map cycle, a broken vtable and null arguments; - every guest allocation freed. - **Differential check:** a Clang 19 + libc++ program linked the real M134 `encoded_image.cc`, `rtp_packet_info.cc` and `color_space.cc` with this implementation: - the constructed bytes match upstream's exactly, apart from the map's self-pointer; - on 100,000 randomly filled upstream objects (75,036 with data, 73,126 with layer sizes, 50,043 with packet infos, 37,568 holding shared references), this destructor freed the same number of blocks and bytes as upstream's, and left the shared references and their counts the same; - on 20,000 buffers, `Create` matched upstream in allocation sizes, fields and virtual calls, and upstream `EncodedImage` copies released these buffers with no leak. - **Mutation check:** each of these breaks both the differential check and a test: skipping the CSRC frees, using the wrong last-reference threshold, defaulting `qp_` to 0, and a wrong buffer capacity. - **Linux x86-64** (Debian trixie, GCC 14.2, Release): `ctest -R '[Ww]eb[Rr]tc|[Nn]ack|[Ee]ncoded|[Ii]420|public_headers|export_gap|conventions|progress_report|test_registration|debt'`: 249/249 passed. 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 these exports. #17009, #17722, #18495, #18503 and #18798 couldn't be compared automatically, so I compared them by hand: they implement other functions and only share the libwebrtc files. My #20025, #20031 and #20036 change the same debt count line, so whichever merges later needs a recount. ### 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 13:33:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T13:33:46Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing in the inspected code establishes a verified defect; the implementation is plausible, but material ABI and console behavior remain unverified.

What I ran

Reviewed head 931b759201b4fd75e5d0d78c3343930084634405. No tests or builds were run; author-reported checks are not treated as checks performed here. Read description.md, commits.md, manifest.json, diff.patch, and all seven changed files listed as included in the manifest. files.json was unavailable through the reader; the file listing confirmed the changed-file set. Targeted context read: Buffer.hpp, StdioExtras.cpp, Api.hpp, and the relevant CMake test-registration section. Searched for the guest-memory helper and matching export stubs; the helper implementation was not located.

Results

Check Result Note
Source review passed Included changed files read
Build and tests not run Linux results supplied by author
Console ABI not run Description reports no console check

Findings

Blocking

None.

Non-blocking

None.

Not verified

The review-folder exclusion report was not available. Console ABI and behavior, title behavior, Windows behavior, the implementation of GuestCopyIn_nid_no_patch, and the author-reported test and differential runs were not independently verified. No claims are made about excluded files.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904542996 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20042#pullrequestreview-5904542996). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T13:33:46Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing in the inspected code establishes a verified defect; the implementation is plausible, but material ABI and console behavior remain unverified. ## What I ran Reviewed head `931b759201b4fd75e5d0d78c3343930084634405`. No tests or builds were run; author-reported checks are not treated as checks performed here. Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and all seven changed files listed as included in the manifest. `files.json` was unavailable through the reader; the file listing confirmed the changed-file set. Targeted context read: `Buffer.hpp`, `StdioExtras.cpp`, `Api.hpp`, and the relevant CMake test-registration section. Searched for the guest-memory helper and matching export stubs; the helper implementation was not located. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Included changed files read | | Build and tests | not run | Linux results supplied by author | | Console ABI | not run | Description reports no console check | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The review-folder exclusion report was not available. Console ABI and behavior, title behavior, Windows behavior, the implementation of `GuestCopyIn_nid_no_patch`, and the author-reported test and differential runs were not independently verified. No claims are made about excluded files. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-14 13:43:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T13:43:02Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_encoded_image_tests built cleanly.
  • CTest (guest_webrtc_encoded_image_default, guest_webrtc_encoded_image_buffer, guest_webrtc_encoded_image_destructor):
    1/3 Test #5141: guest_webrtc_encoded_image_default ......   Passed    0.00 sec
    2/3 Test #5142: guest_webrtc_encoded_image_buffer .......   Passed    0.01 sec
    3/3 Test #5143: guest_webrtc_encoded_image_destructor ...   Passed    0.00 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 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/EncodedImage.cpp: Verified that _ZN6webrtc18EncodedImageBuffer6CreateEPKhm_nid_postfix validates input arguments (!result and !data && size > 0 throw std::invalid_argument), handles zero-sized buffers (data == nullptr, size == 0) without invoking std::memcpy, sets capacity and size properly, and cleans up storage if array allocation throws.
    • core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified BufferVtable layout and intrusive atomic reference counting in AddRefBuffer_nid_no_patch, ReleaseBuffer_nid_no_patch, and BufferHasOneRef_nid_no_patch, ensuring correct std::memory_order_acq_rel on decrement and properly paired deallocations via _ZdaPv_nid_postfix and _ZdlPv_nid_postfix.
    • core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified _ZN6webrtc12EncodedImageC1Ev_nid_postfix initializes all 344 bytes of WebRtcEncodedImage, setting defaults (kVideoFrameDelta = 4, qp = -1, timing flags 0xff, retransmissionAllowed = true, and beginNode = EndNode(spatialLayerFrameSizeBytes)).
    • core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified _ZN6webrtc12EncodedImageD1Ev_nid_postfix performs orderly cleanup, releasing packetInfos with bounds validation on CSRC and entry vectors, collecting and deleting spatialLayerFrameSizeBytes nodes with cycle/size checks, and dispatching buffer release through guest vtable slot 1 (ReleaseSlot = 1).
    • core/libs/prx/libwebrtc/include/EncodedImage.hpp: Verified struct alignments, member offsets, and size guarantees across LP64 and LLP64 platforms matching upstream Clang 19 libc++ M134 layouts, including static assertions for WebRtcEncodedImage (344 bytes) and WebRtcEncodedImageBuffer (40 bytes).
    • docs/dev/debt/libwebrtc.md and repository conventions: Verified compliance with AGENTS.md rules, with no forbidden code comments, updated unknown export debt counters (222 to 219), and full unit test coverage in core/libs/prx/libwebrtc/tests/EncodedImage.cpp tracking all allocations and deallocations.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904577077 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20042#pullrequestreview-5904577077). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T13:43:02Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `931b759201`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_encoded_image_tests` built cleanly. - **CTest** (`guest_webrtc_encoded_image_default`, `guest_webrtc_encoded_image_buffer`, `guest_webrtc_encoded_image_destructor`): ``` 1/3 Test #5141: guest_webrtc_encoded_image_default ...... Passed 0.00 sec 2/3 Test #5142: guest_webrtc_encoded_image_buffer ....... Passed 0.01 sec 3/3 Test #5143: guest_webrtc_encoded_image_destructor ... Passed 0.00 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` 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/EncodedImage.cpp: Verified that _ZN6webrtc18EncodedImageBuffer6CreateEPKhm_nid_postfix validates input arguments (!result and !data && size > 0 throw std::invalid_argument), handles zero-sized buffers (data == nullptr, size == 0) without invoking std::memcpy, sets capacity and size properly, and cleans up storage if array allocation throws. - core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified BufferVtable layout and intrusive atomic reference counting in AddRefBuffer_nid_no_patch, ReleaseBuffer_nid_no_patch, and BufferHasOneRef_nid_no_patch, ensuring correct std::memory_order_acq_rel on decrement and properly paired deallocations via _ZdaPv_nid_postfix and _ZdlPv_nid_postfix. - core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified _ZN6webrtc12EncodedImageC1Ev_nid_postfix initializes all 344 bytes of WebRtcEncodedImage, setting defaults (kVideoFrameDelta = 4, qp = -1, timing flags 0xff, retransmissionAllowed = true, and beginNode = EndNode(spatialLayerFrameSizeBytes)). - core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified _ZN6webrtc12EncodedImageD1Ev_nid_postfix performs orderly cleanup, releasing packetInfos with bounds validation on CSRC and entry vectors, collecting and deleting spatialLayerFrameSizeBytes nodes with cycle/size checks, and dispatching buffer release through guest vtable slot 1 (ReleaseSlot = 1). - core/libs/prx/libwebrtc/include/EncodedImage.hpp: Verified struct alignments, member offsets, and size guarantees across LP64 and LLP64 platforms matching upstream Clang 19 libc++ M134 layouts, including static assertions for WebRtcEncodedImage (344 bytes) and WebRtcEncodedImageBuffer (40 bytes). - docs/dev/debt/libwebrtc.md and repository conventions: Verified compliance with AGENTS.md rules, with no forbidden code comments, updated unknown export debt counters (222 to 219), and full unit test coverage in core/libs/prx/libwebrtc/tests/EncodedImage.cpp tracking all allocations and deallocations. - Note: the AI-assisted checkbox can stay. Looks Good To Me
MarcZX10 commented 2026-11-14 15:07:00 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed — no blocking findings

Nothing in the inspected changes blocks merging; however, the target module revision and console ABI remain unverified.

What I ran

Reviewed head b2237ab5c776001a80e8bfadae9f008dc18634fe using the prepared review artifacts and pinned repository reader. No commands or tests were run by me.

Results

Check Result Note
Changed code review passed Inspected implementation, declarations, tests, and debt update
Programmatic checks not run Test results in the PR description are author reported
Console ABI not run No console verification reported

Findings

Blocking

None.

Non-blocking

  • The implementation assumes the title module's EncodedImage layout matches the M134 layout, while the PR notes that the module's exact WebRTC revision is unknown. Confirm the layout against the console module when possible.

Not verified

Did not run tests, inspect a merged preview, or verify behavior on console, title, Windows, or other host environments. The implementation's compatibility with the module's actual revision remains uncertain. The PR reports Linux x86-64 tests and differential checks, but these were not run by me.

To get this to a good state

Nothing is required. Optional: confirm the object layout and ABI against the target console module.

Files read

review/description.md, review/commits.md, review/manifest.json, review/diff.patch, core/libs/prx/libwebrtc/include/EncodedImage.hpp (requested lines were outside the file), and core/libs/prx/libwebrtc/tests/EncodedImage.cpp (search results only).

Files excluded

No excluded files were identified by the manifest search; manifest completeness was not checked beyond the first 200 lines.

Continued review (pass 2)

This continuation reviewed the listed added lines at head b2237ab5c776001a80e8bfadae9f008dc18634fe; I found no verified blocking defect in them. This draft covers only this continuation pass and does not repeat earlier findings.

What I ran

  • Read the requested ranges in core/libs/prx/libwebrtc/CMakeLists.txt, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/EncodedImage.hpp, core/libs/prx/libwebrtc/src/EncodedImage.cpp, core/libs/prx/libwebrtc/tests/EncodedImage.cpp, and docs/dev/debt/libwebrtc.md.
  • No commands or tests were run in this continuation pass.

Results

Check Result Note
Requested code review passed Listed added lines and surrounding implementation read
Tests not run This continuation was a source review

Findings

Blocking

None in the lines reviewed in this continuation.

Non-blocking

None.

Not verified

  • This is a continuation-only review, not a complete review of every changed file or added line in the PR. The preceding review's findings and overall disposition are not included here.
  • No runtime test, console behavior, or new test execution was verified in this pass.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5905215399 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20042#pullrequestreview-5905215399). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T15:07:00Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing in the inspected changes blocks merging; however, the target module revision and console ABI remain unverified. ## What I ran Reviewed head `b2237ab5c776001a80e8bfadae9f008dc18634fe` using the prepared review artifacts and pinned repository reader. No commands or tests were run by me. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Inspected implementation, declarations, tests, and debt update | | Programmatic checks | not run | Test results in the PR description are author reported | | Console ABI | not run | No console verification reported | ## Findings ### Blocking None. ### Non-blocking - The implementation assumes the title module's EncodedImage layout matches the M134 layout, while the PR notes that the module's exact WebRTC revision is unknown. Confirm the layout against the console module when possible. ## Not verified Did not run tests, inspect a merged preview, or verify behavior on console, title, Windows, or other host environments. The implementation's compatibility with the module's actual revision remains uncertain. The PR reports Linux x86-64 tests and differential checks, but these were not run by me. ## To get this to a good state Nothing is required. Optional: confirm the object layout and ABI against the target console module. ## Files read `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`, `core/libs/prx/libwebrtc/include/EncodedImage.hpp` (requested lines were outside the file), and `core/libs/prx/libwebrtc/tests/EncodedImage.cpp` (search results only). ## Files excluded No excluded files were identified by the manifest search; manifest completeness was not checked beyond the first 200 lines. ## Continued review (pass 2) This continuation reviewed the listed added lines at head `b2237ab5c776001a80e8bfadae9f008dc18634fe`; I found no verified blocking defect in them. This draft covers only this continuation pass and does not repeat earlier findings. ## What I ran - Read the requested ranges in `core/libs/prx/libwebrtc/CMakeLists.txt`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/EncodedImage.hpp`, `core/libs/prx/libwebrtc/src/EncodedImage.cpp`, `core/libs/prx/libwebrtc/tests/EncodedImage.cpp`, and `docs/dev/debt/libwebrtc.md`. - No commands or tests were run in this continuation pass. ## Results | Check | Result | Note | |---|---|---| | Requested code review | passed | Listed added lines and surrounding implementation read | | Tests | not run | This continuation was a source review | ## Findings ### Blocking None in the lines reviewed in this continuation. ### Non-blocking None. ## Not verified - This is a continuation-only review, not a complete review of every changed file or added line in the PR. The preceding review's findings and overall disposition are not included here. - No runtime test, console behavior, or new test execution was verified in this pass. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-14 15:31:41 +00:00 (Migrated from github.com)

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

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_encoded_image_tests built cleanly.
  • CTest (guest_webrtc_encoded_image_default, guest_webrtc_encoded_image_buffer, guest_webrtc_encoded_image_destructor):
    1/3 Test #5149: guest_webrtc_encoded_image_default ......   Passed    0.02 sec
    2/3 Test #5150: guest_webrtc_encoded_image_buffer .......   Passed    0.03 sec
    3/3 Test #5151: guest_webrtc_encoded_image_destructor ...   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 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/EncodedImage.cpp: Verified _ZN6webrtc18EncodedImageBuffer6CreateEPKhm_nid_postfix properly validates result != nullptr and (data != nullptr || size == 0), safely copies data into the allocated buffer without calling std::memcpy on null zero-sized buffers, and correctly frees intermediate storage on allocation failure.
    • core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified _ZN6webrtc12EncodedImageC1Ev_nid_postfix initializes all 344 bytes to upstream WebRTC defaults (kVideoFrameDelta=4, qp=-1, timing flags=0xff, retransmissionAllowed=true, empty spatialLayerFrameSizeBytes begin node pointing to root) matching all field offsets.
    • core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified _ZN6webrtc12EncodedImageD1Ev_nid_postfix checks null arguments, validates RtpPacketInfos and CSRC vector bounds/alignments via Count before deallocating with _ZdlPv_nid_postfix, properly decrements reference counts with acq_rel ordering, and safely collects and frees spatial layer size map nodes.
    • core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified ReleaseEncodedData uses GuestCopyIn_nid_no_patch to check buffer virtual table slot 1 (Release) and throws std::invalid_argument if the buffer vtable pointer or Release slot is null.
    • core/libs/prx/libwebrtc/include/EncodedImage.hpp: Verified all struct layouts, alignments, and member offsets across WebRtcEncodedImage (344 bytes), WebRtcEncodedImageBuffer (40 bytes), WebRtcRtpPacketInfosData (32 bytes), and WebRtcEncodedImageMap (24 bytes) via static assertions matching LP64 and LLP64 requirements.
    • core/libs/prx/libwebrtc/tests/EncodedImage.cpp & CMakeLists.txt: Verified tests (default, buffer, destructor) thoroughly cover zero-size buffer allocation, allocation failure rollback, shared reference counting, virtual table slots, and cycle detection in spatial layer maps.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5905425508 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20042#pullrequestreview-5905425508). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T15:31:41Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `dbafc970f8`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_encoded_image_tests` built cleanly. - **CTest** (`guest_webrtc_encoded_image_default`, `guest_webrtc_encoded_image_buffer`, `guest_webrtc_encoded_image_destructor`): ``` 1/3 Test #5149: guest_webrtc_encoded_image_default ...... Passed 0.02 sec 2/3 Test #5150: guest_webrtc_encoded_image_buffer ....... Passed 0.03 sec 3/3 Test #5151: guest_webrtc_encoded_image_destructor ... 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` 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/EncodedImage.cpp: Verified _ZN6webrtc18EncodedImageBuffer6CreateEPKhm_nid_postfix properly validates result != nullptr and (data != nullptr || size == 0), safely copies data into the allocated buffer without calling std::memcpy on null zero-sized buffers, and correctly frees intermediate storage on allocation failure. - core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified _ZN6webrtc12EncodedImageC1Ev_nid_postfix initializes all 344 bytes to upstream WebRTC defaults (kVideoFrameDelta=4, qp=-1, timing flags=0xff, retransmissionAllowed=true, empty spatialLayerFrameSizeBytes begin node pointing to root) matching all field offsets. - core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified _ZN6webrtc12EncodedImageD1Ev_nid_postfix checks null arguments, validates RtpPacketInfos and CSRC vector bounds/alignments via Count before deallocating with _ZdlPv_nid_postfix, properly decrements reference counts with acq_rel ordering, and safely collects and frees spatial layer size map nodes. - core/libs/prx/libwebrtc/src/EncodedImage.cpp: Verified ReleaseEncodedData uses GuestCopyIn_nid_no_patch to check buffer virtual table slot 1 (Release) and throws std::invalid_argument if the buffer vtable pointer or Release slot is null. - core/libs/prx/libwebrtc/include/EncodedImage.hpp: Verified all struct layouts, alignments, and member offsets across WebRtcEncodedImage (344 bytes), WebRtcEncodedImageBuffer (40 bytes), WebRtcRtpPacketInfosData (32 bytes), and WebRtcEncodedImageMap (24 bytes) via static assertions matching LP64 and LLP64 requirements. - core/libs/prx/libwebrtc/tests/EncodedImage.cpp & CMakeLists.txt: Verified tests (default, buffer, destructor) thoroughly cover zero-size buffer allocation, allocation failure rollback, shared reference counting, virtual table slots, and cycle detection in spatial layer maps. - Note: the AI-assisted checkbox can stay. Looks Good To Me
PrivacyOnion commented 2026-11-14 16:24:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T16:24:32Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_encoded_image_tests built cleanly.
  • CTest (guest_webrtc_encoded_image_default, guest_webrtc_encoded_image_buffer, guest_webrtc_encoded_image_destructor):
    1/3 Test #5155: guest_webrtc_encoded_image_default ......   Passed    0.02 sec
    2/3 Test #5157: guest_webrtc_encoded_image_destructor ...   Passed    0.03 sec
    3/3 Test #5156: guest_webrtc_encoded_image_buffer .......   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 reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified memory safety and exception unwinding in EncodedImageBuffer::Create (core/libs/prx/libwebrtc/src/EncodedImage.cpp): validates !result and (!data && size > 0), properly frees storage via _ZdlPv_nid_postfix if array allocation throws, and correctly handles size == 0 boundary conditions.
    • Verified reference counting and vtable dispatch for WebRtcEncodedImageBuffer (core/libs/prx/libwebrtc/src/EncodedImage.cpp): AddRef and Release use proper atomic memory orders (relaxed and acq_rel) returning RefCountReleaseStatus constants (DroppedLastRef / OtherRefsRemained), matching upstream WebRTC and Itanium ABI vtable layouts.
    • Verified default initialization in _ZN6webrtc12EncodedImageC1Ev_nid_postfix (core/libs/prx/libwebrtc/src/EncodedImage.cpp): validates non-null pointer, zero-initializes the 344-byte structure, and assigns upstream defaults (frameType = 4 / kVideoFrameDelta, qp = -1, timing.flags = 0xff, spatialLayerFrameSizeBytes sentinel, retransmissionAllowed = true).
    • Verified destructor cleanup order and validation in _ZN6webrtc12EncodedImageD1Ev_nid_postfix (core/libs/prx/libwebrtc/src/EncodedImage.cpp): ensures rigorous bounds/alignment validation via Count(), prevents double-frees or map cycles in CollectNodes(), releases packet info CSRC arrays, and safely invokes guest virtual Release on encodedData.
    • Verified struct layouts and ABI offsets in EncodedImage.hpp (core/libs/prx/libwebrtc/include/EncodedImage.hpp): confirmed 344-byte sizeof for WebRtcEncodedImage, 40-byte buffer layout, 8-byte alignment, and strict offsetof assertions across LP64 and LLP64 platforms.
    • Verified test coverage in core/libs/prx/libwebrtc/tests/EncodedImage.cpp: validated test cases for default fields, buffer allocation and failure paths, shared references, guest release slots, cycle detection, and confirmed complete memory leak accounting (allocated == freed).
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5905779609 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20042#pullrequestreview-5905779609). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T16:24:32Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `2804f3b03c`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_encoded_image_tests` built cleanly. - **CTest** (`guest_webrtc_encoded_image_default`, `guest_webrtc_encoded_image_buffer`, `guest_webrtc_encoded_image_destructor`): ``` 1/3 Test #5155: guest_webrtc_encoded_image_default ...... Passed 0.02 sec 2/3 Test #5157: guest_webrtc_encoded_image_destructor ... Passed 0.03 sec 3/3 Test #5156: guest_webrtc_encoded_image_buffer ....... 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` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified memory safety and exception unwinding in EncodedImageBuffer::Create (core/libs/prx/libwebrtc/src/EncodedImage.cpp): validates !result and (!data && size > 0), properly frees storage via _ZdlPv_nid_postfix if array allocation throws, and correctly handles size == 0 boundary conditions. - Verified reference counting and vtable dispatch for WebRtcEncodedImageBuffer (core/libs/prx/libwebrtc/src/EncodedImage.cpp): AddRef and Release use proper atomic memory orders (relaxed and acq_rel) returning RefCountReleaseStatus constants (DroppedLastRef / OtherRefsRemained), matching upstream WebRTC and Itanium ABI vtable layouts. - Verified default initialization in _ZN6webrtc12EncodedImageC1Ev_nid_postfix (core/libs/prx/libwebrtc/src/EncodedImage.cpp): validates non-null pointer, zero-initializes the 344-byte structure, and assigns upstream defaults (frameType = 4 / kVideoFrameDelta, qp = -1, timing.flags = 0xff, spatialLayerFrameSizeBytes sentinel, retransmissionAllowed = true). - Verified destructor cleanup order and validation in _ZN6webrtc12EncodedImageD1Ev_nid_postfix (core/libs/prx/libwebrtc/src/EncodedImage.cpp): ensures rigorous bounds/alignment validation via Count(), prevents double-frees or map cycles in CollectNodes(), releases packet info CSRC arrays, and safely invokes guest virtual Release on encodedData. - Verified struct layouts and ABI offsets in EncodedImage.hpp (core/libs/prx/libwebrtc/include/EncodedImage.hpp): confirmed 344-byte sizeof for WebRtcEncodedImage, 40-byte buffer layout, 8-byte alignment, and strict offsetof assertions across LP64 and LLP64 platforms. - Verified test coverage in core/libs/prx/libwebrtc/tests/EncodedImage.cpp: validated test cases for default fields, buffer allocation and failure paths, shared references, guest release slots, cycle detection, and confirmed complete memory leak accounting (allocated == freed). - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!20042
No description provided.