feat(libwebrtc): implement webrtc::I420Buffer::Create #20049
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20049"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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) threwnot implemented. This PR ports it from M134 (8d78f5de)i420_buffer.cc, withCheckValidDimensionsfromvideo_frame_buffer.ccandAlignedMalloc/AlignedFreefromaligned_malloc.cc.src/I420Buffer.cppnow also carries those two notices. The module exports only this overload;Create(int, int)is not in the export table.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 andref_counted_object.hare the same at M127. Nothing here depends on the standard library's container layouts.operator newfor the object, guestmallocfor the pixels, 64-byte aligned with the start address stored in the 8 bytes before the data, asAlignedMallocdoes. The returned reference count is 1.ToI420,GetI420,GetMappedFrameBuffer,ChromaWidth/ChromaHeight, andCropAndScale, which is still the unimplemented stub and throws.storage_representationreturns"?"using thelibcguest string rules (as inVideoDecoder::GetDecoderInfo). The lastReleasefrees the pixels and the object.RTC_CHECKs (dimensions > 0,stride_y >= width, chroma strides > 0, data size fits inint,mallocsucceeds) throwstd::runtime_errorinstead of aborting, and nothing leaks. A null result throwsstd::invalid_argument. The release-buildRTC_DCHECKs on the chroma strides are left out, as upstream does in release builds.CheckValidDimensionsand thechecked_castarrived 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.Tested
guest_webrtc_i420_buffer_create_create,_virtualsand_invalid(core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp) cover:mallocsize, and plane offsets for even and odd sizes and padded strides;MutableDataY/U/Vexports dispatching through it;AddRef/Release/HasOneRef,ToI420adding a reference,GetMappedFrameBufferrejecting a non-native buffer, and both destructor slots;mallocand a null result, with no leaks;i420_buffer.cc,video_frame_buffer.ccandaligned_malloc.cc, built with Clang 19 + libc++ andNDEBUG, gave identical results to this implementation on 300,000 generated inputs (146,125 accepted, 153,875 rejected, including theINT_MAXdata-size boundary). The comparison covered:mallocsize, alignment and stored header;type, dimensions, chroma dimensions, strides, plane offsets,GetI420,HasOneRef,AddRef/Releasestatus);storage_representation;Release.stride_y == widthfails all three tests, and dropping the+ 1in the V-plane chroma height fails two.ctest -R '[Ww]eb[Rr]tc|[Ii]420|public_headers|export_gap|conventions|progress_report|test_registration|debt': 246/246 passed after rebasing on currentmain. Full suite before the rebase: 5420/5422; the two failures,guest_appcontentandguest_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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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
697092213146fe4a18f44838cb791e39fa32e8d2using the prepared diff and pinned reader; no merged preview was checked.Results
Findings
Blocking
None.
Non-blocking
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, anddocs/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.txtand the surrounding CMake context at the pinned head. No commands or tests were run.Results
Findings
Blocking
None in the requested lines.
Non-blocking
None.
Not verified
This continuation review covers only
core/libs/prx/libwebrtc/CMakeLists.txtlines 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
697092213146fe4a18f44838cb791e39fa32e8d2and nearby CMake context. No commands or tests were run.Results
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-552at the reviewed head; neighboring registration at lines 531-540 and 553-560.Not verified
This continuation reviewed only
core/libs/prx/libwebrtc/CMakeLists.txtlines 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.
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
fb1e179c2742ed7f5166b2340408e8545d379546using the prepared diff and pinned reader. No build or test commands were run.Results
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, anddocs/dev/debt/libwebrtc.md.To get this to a good state
Nothing is required.
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:tools/check_conventions.pypassed;git diff --checkclean.guest_webrtc_i420_buffer_create_testsbuilt cleanly.guest_webrtc_i420_buffer_create_create,guest_webrtc_i420_buffer_create_virtuals,guest_webrtc_i420_buffer_create_invalid):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.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
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:tools/check_conventions.pypassed;git diff --checkclean.guest_webrtc_i420_buffer_create_testsbuilt cleanly.guest_webrtc_i420_buffer_create_create,guest_webrtc_i420_buffer_create_virtuals,guest_webrtc_i420_buffer_create_invalid):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.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
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 throughrepo_read.py. I did not run tests or build commands.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, anddocs/dev/debt/libwebrtc.md; targeted context includedcore/libs/prx/libwebrtc/src/VideoFrameBuffer.cpp,core/libs/prx/libwebrtc/include/GuestString.hpp, andcore/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) anddocs/dev/debt/libwebrtc.md(78), plus the prepared description, commits, manifest, and diff for context.Results
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.
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::Createare 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 onmain. No commands or tests were run in this review; source was inspected with therepo_read.pyreader.Results
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.
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.pyand targeted related ABI definitions and callers.Results
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.
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
45600ce9f9b3eedc2d2953e060829bfc9e033b01using the prepared diff andrepo_read.py; no commands or tests were run.Results
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.jsonwas not available through the reader.To get this to a good state
Nothing is required.