Repository navigation
Conversation
Add libyuv as the 3rdparty/libyuv submodule at the revision WebRTC M134 pins, build its scaler from source, and implement webrtc::VideoFrameBuffer::CropAndScale from video_frame_buffer.cc and I420Buffer::CropAndScaleFrom. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against b205cff00c:
- Conventions:
tools/check_conventions.pypassed. - Build:
CMakeLists.txtfailed to build.-- Configuring done (4.6s) CMake Error at core/libs/CMakeLists.txt:244 (add_library): Cannot find source file: 3rdparty/libyuv/source/cpu_id.cc CMake Error at core/libs/CMakeLists.txt:244 (add_library): No SOURCES given to target: webrtc_yuv CMake Generate step failed. Build files cannot be regenerated correctly.
Requesting changes for the points above.
mihiii1337
left a comment
There was a problem hiding this comment.
The crop rectangle guard uses the signed cropHeight, but negative heights are intentionally accepted and libyuv immediately negates them to obtain the row count before scaling. An inverted crop whose magnitude extends past the bottom of the source can therefore pass the current check even though the scaler consumes more rows than the validated rectangle.
Please validate offsetY + magnitude(cropHeight) in a wide integer before any plane-pointer calculation or scaler call, while preserving the original signed height when calling libyuv so valid vertical inversion still works. The regression should prove that a valid inverted crop reaches the scaler, while an oversized inverted extent throws the existing invalid_argument with the result/reference state unchanged and no scaler invocation.
Verification at b205cff00c49eeb1e4390d4e57383efa8d39e260 was deliberately memory-safe: a fail-closed scaler stand-in counted dispatches and never read image planes. The exact PR guard forwarded both the valid inverted crop and the oversized extent (exit 7); the magnitude-based control forwarded only the valid case (exit 0). Pinned libyuv's ScalePlane confirms the negative-height inversion, and the targeted pinned-libyuv build plus existing positive pixel subset passed. I did not execute an out-of-bounds read. The full standalone suite was not claimed because the reused older libc hit an unwind limitation. Conventions and merge preview passed; hosted release-tools and portability checks are green, with Windows still running. No GPU test was run.
AI-assisted: yes.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — changes requested
Changes are required before merge: reject invalid crop dimensions before using them to create the destination buffer.
What I ran
Reviewed head b205cff00c49eeb1e4390d4e57383efa8d39e260 and the prepared diff. No build or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | Implementation and targeted callers inspected |
| Build and tests | not run | Author reports results; not independently run |
Findings
Blocking
core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cpp:105: The destination is created before validating the crop. In particular,cropHeight == INT_MINpasses the current upper-bound and negative-offset checks, but libyuv negates negative source height when setting up vertical scaling; negatingINT_MINoverflows. This can invoke undefined behavior for an input the implementation otherwise accepts. Validate crop dimensions before destination creation, rejectingINT_MIN(and any other unsupported dimension) while preserving intentionally supported negative-height flips.
Non-blocking
None.
Not verified
The submodule entry is present, but its checkout contents were excluded because it is not plain text; its source files, LICENSE, and PATENTS were not inspected. Console behavior and the author-reported build and test runs were not independently verified. The remaining changed files listed in the manifest were not read: core/libs/prx/libwebrtc/tests/VideoFrameBufferCropAndScale.cpp, core/libs/prx/libwebrtc/Export.cpp, and core/libs/prx/libwebrtc/include/Api.hpp were partially reviewed through the diff where relevant; other changed-file text and tests were not fully verified.
To get this to a good state
Reject the INT_MIN crop height before destination creation and add a regression test that confirms it is refused without allocation or changing the result pointer. Then rerun the crop-and-scale and library test suites.
Progress report (6bc2a88 → d3a8483)📈 System libraries: 45.87% (+0.0025%, +1 implemented function) ✅ 1 implemented
Changed libraries (implemented exports)
|
…me-buffer-crop-and-scale
A negative crop height passed the rectangle check whatever its size, and libyuv then read that many rows from the row offset. Compare offsetY plus the magnitude of the height, in 64 bits, with the buffer height, which also keeps INT_MIN away from libyuv. Stop the configuration with an instruction when the libyuv submodule is not initialized. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks for the three reviews. @mihiii1337, @MarcZX10 — negative crop heights. You are both right that the rectangle check let a flipped crop through whatever its size: Added to the test:
Without the fix the eight refusals fail; four of the 65 negative controls are about this check (magnitude dropped, negated in On the order, @MarcZX10: the destination is still created before the rectangle is checked, because that is upstream's order ( @PrivacyOnion — the configure failure. |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 7f04c46d8e:
- Conventions:
tools/check_conventions.pypassed. - Build:
CMakeLists.txtfailed to build.-- Building with GNU 13.3.0 on Linux-6.8.0-71-generic -- Performing Test COMPILER_SUPPORTS_Wformat=2 -- Performing Test COMPILER_SUPPORTS_Wformat=2 - Success -- QJS_BUILD_LIBC: OFF -- USING O3 CMake Error at core/libs/CMakeLists.txt:245 (message): libyuv: 3rdparty/libyuv/source/scale.cc is missing; initialize the submodule with git submodule update --init 3rdparty/libyuv -- Configuring incomplete, errors occurred!
Requesting changes for the points above.
|
@ToRaNek the crop validation has two memory-safety gaps that both reviewers measured, and they are the blockers here:
PrivacyOnion's Linux build stopped at configure with "Cannot find source file 3rdparty/libyuv/source/cpu_id.cc"; that run may not have had the submodule checked out. Please confirm that webrtc_yuv configures with the pinned libyuv commit (10592b60c0) in a fresh recursive checkout and that the ten source files listed in core/libs/CMakeLists.txt:244 exist at that commit. |
mihiii1337
left a comment
There was a problem hiding this comment.
Re-reviewed fix head 7f04c46d8e08e1ed9cf0be31dd999cd5c494e559. This resolves my negative-height boundary finding. The implementation promotes cropHeight to int64_t before negation, validates magnitude + offsetY against the converted I420 source height before any plane offset or I420Scale, and preserves the original signed height when calling libyuv so valid vertical inversion still works (including the INT_MIN conversion boundary).
The positive inverted-window fixture reads all three Y/U/V planes backward. Eight refusal cases now verify invalid_argument, unchanged result pointer/reference count and allocation balance; three accepted boundary controls remain. The result is assigned only after a successful scale, and temporary RAII references unwind on rejection.
The pinned libyuv Gitlink is unchanged and the official remote contains the required scale/cpu/header sources at that exact commit. The reported Linux configure failure was a locally uninitialized submodule, not a compiler result. The prior exact-topic Windows job built the libyuv objects and ran guest_webrtc_crop_and_scale successfully; new portability/release-tools checks are green and the replacement workflow is starting. I deliberately did not execute any out-of-bounds access or GPU test.
AI-assisted: yes.
mihiii1337
left a comment
There was a problem hiding this comment.
I need to supersede my approval after the continuing boundary audit found one separate blocker in the same input-validation path. The negative cropHeight issue is fixed, but the destination chroma stride is still computed as (scaledWidth + 1) / 2 in signed int before I420Buffer::Create validates dimensions. For a valid int input of INT_MAX, the addition itself overflows; the later size/dimension rejection cannot make that expression defined.
Please validate the destination dimensions before deriving strides and compute the ceil-half width without signed overflow (for example in int64_t, with a checked conversion, or scaledWidth / 2 + scaledWidth % 2 after proving it positive). Add a boundary regression showing the largest input is rejected deterministically with the result pointer/reference/allocation state unchanged and no allocator/scaler call.
This is a source-level arithmetic finding at VideoFrameBufferCropAndScale.cpp:105; I did not execute the undefined expression or any out-of-bounds access. The prior review's evidence for the corrected inverted-crop extent remains valid and does not need to be redone.
AI-assisted: yes.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head 7f04c46d8e08e1ed9cf0be31dd999cd5c494e559 against main using the prepared diff and repo_read.py. No commands or tests were run independently.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | Implementation, build wiring, tests, and packaging changes inspected |
| Tests | not run | Results in the description are author-reported |
| Submodule contents | not run | Gitlink is visible; target contents were unavailable as text |
Negative control
Not run independently. The description reports 65 single-change negative controls, each failing the new test.
Findings
Blocking
None.
Non-blocking
- Console behavior and the console’s libyuv revision remain unverified, as recorded in the change’s debt entry.
Sources
Reviewed the prepared diff and changed source at the pinned head, including core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cpp, core/libs/CMakeLists.txt, core/libs/prx/libwebrtc/CMakeLists.txt, and the changed tests and release packaging code.
Not verified
3rdparty/libyuvis a changed gitlink and its checked-out contents were unavailable as text; only its pinned commit shown in the diff was reviewed.- Tests and build checks were not run independently. Linux, macOS, and console behavior were not verified.
To get this to a good state
Nothing is required. Optional: verify the pinned submodule contents and console behavior when available.
(scaledWidth + 1) / 2 overflowed for INT_MAX before I420Buffer::Create could refuse the size. Compute the chroma stride as scaledWidth / 2 + scaledWidth % 2. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@mihiii1337 — the chroma stride. Right again: @PrivacyOnion — the configure step. The run on then the usual configure, and |
|
@ToRaNek the crop extent fix is in, and mihiii1337 confirmed the libyuv checkout failure was only an uninitialised submodule on that reviewer's side. One blocker is left, in the same function. VideoFrameBufferCropAndScale.cpp:104-105 still calls I420Buffer::Create with |
mihiii1337
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 9e711745aed1a8dc7101bfd642da9e8a9f0dd201. The new ceil-half expression is defined for every int, but the requested validation order is not fixed yet: line 106 still enters I420Buffer::Create before validating either the destination dimensions or the source rectangle. Create allocates the ref-counted object shell before I420DataSize rejects the dimensions, so the current allocation-balance assertion does not establish the maintainer-requested zero allocator call; the boundary cases also still expect runtime_error rather than the requested invalid_argument.
Continuing the same source-only boundary audit found one separate lower-bound gap at line 114, described inline. Please validate the destination dimensions/size before Create, and reject non-positive crop widths before plane calculation or scaler dispatch. A fail-closed scaler/allocator counter can cover both without executing an invalid expression.
I inspected the exact PR source, I420Buffer::Create, the test fixture, and pinned libyuv scale.cc. I did not execute undefined arithmetic, an out-of-bounds access, or a GPU test.
AI-assisted: yes.
| const std::int64_t sourceWidth = Call<std::int32_t>(source.object, WidthSlot); | ||
| const std::int64_t sourceHeight = Call<std::int32_t>(source.object, HeightSlot); | ||
| const std::int64_t rows = cropHeight < 0 ? -std::int64_t{cropHeight} : std::int64_t{cropHeight}; | ||
| if (std::int64_t{cropWidth} + offsetX > sourceWidth || rows + offsetY > sourceHeight || offsetX < 0 || offsetY < 0) |
There was a problem hiding this comment.
cropWidth has no lower bound here. Zero and negative widths pass this rectangle check; pinned libyuv computes SUBSAMPLE(src_width, 1, 1) before its src_width <= 0 guard, and that macro negates a negative input. Thus INT_MIN reaches a signed negation before rejection. For ordinary non-positive widths libyuv returns -1, but this wrapper ignores the return value and publishes the destination as if scaling succeeded. Please reject cropWidth <= 0 before plane calculation/dispatch (while preserving the intentional negative-height flip) and add a fail-closed regression proving no scaler call. Source: https://chromium.googlesource.com/libyuv/libyuv/+/10592b60c0b2c33210b7752454253dc2625b4305/source/scale.cc#2333
AI-assisted: yes.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this change; the implementation and its changed call sites are supported by the inspected code, with the libyuv submodule contents and console behavior not verified.
What I ran
Reviewed head 9e711745aed1a8dc7101bfd642da9e8a9f0dd201 using the prepared diff and repository reader. No build or tests were run during this review; results reported in the PR description are author-reported.
Results
| Check | Result | Note |
|---|---|---|
| Changed implementation and integration | passed | Inspected the implementation, build wiring, export, and tests |
| Build and tests in this review | not run | PR description reports successful runs |
| libyuv submodule and console behavior | not run | Submodule content is unavailable in the review materials |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The changed text files were read, including the implementation, tests, build and packaging changes, debt entry, and .gitmodules. The 3rdparty/libyuv submodule pointer was present in the diff, but its checked-out source and license files were excluded as unsupported; their contents were not verified. No tests were run during this review, and no console behavior was verified. The PR description reports Windows/MinGW test runs and explicitly says console behavior is untested.
To get this to a good state
Nothing is required.
Sources
The changed implementation and its associated tests are in VideoFrameBufferCropAndScale.cpp at the reviewed commit and its test at the reviewed commit.
|
@ToRaNek, the earlier findings (inverted-crop magnitude, INT_MIN, the (w+1)/2 overflow, the submodule message) look fixed on 9e71174, and the I420Scale call with kFilterBox and the even-ised offsets match WebRTC's CropAndScaleFrom. One bug is left: A crop width of 0 or below, or a crop height of 0, passes the bounds guard, but libyuv's I420Scale returns -1 for those (crop width 0, crop width -4 and a destination width 0 all do). The PR ignores the return value, so the call reports success with a buffer whose planes were never written and the guest then reads allocator contents. TestInvalid explicitly accepts the {0,0,0,6} and {0,0,8,0} cases. Please throw std::invalid_argument when I420Scale returns non-zero (the target reference frees the buffer), and move those two cases into the rejected list in TestInvalid. Smaller points: the libwebrtc.md I420Buffer::Create entry still says "CropAndScale throws", and the new fragment has no "Closes when". Also for the maintainers, not for you to change: this adds a new third-party submodule (3rdparty/libyuv, pinned 10592b60, built as webrtc_yuv with GCC/clang-only row_gcc/scale_gcc sources, so MSVC would not build it). |
|
One detail on the proposed remedy: checking Pinned source: https://chromium.googlesource.com/libyuv/libyuv/+/10592b60c0b2c33210b7752454253dc2625b4305/source/scale.cc#2333 I verified this from source only and did not execute the invalid expression. AI-assisted: yes. |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9e711745ae:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_webrtc_crop_and_scale_tests,guest_webrtc_i420_buffer_create_testsbuilt cleanly. - CTest (
guest_webrtc_i420_buffer_create_create,guest_webrtc_i420_buffer_create_virtuals,guest_webrtc_i420_buffer_create_invalid,guest_webrtc_crop_and_scale):1/4 Test #6363: guest_webrtc_i420_buffer_create_virtuals ... Passed 0.03 sec 2/4 Test #6362: guest_webrtc_i420_buffer_create_create ..... Passed 0.04 sec 3/4 Test #6364: guest_webrtc_i420_buffer_create_invalid .... Passed 0.03 sec 4/4 Test #6365: guest_webrtc_crop_and_scale ................ Passed 0.07 sec 100% tests passed, 0 tests failed out of 4 - Negative control: with
core/libs/prx/libwebrtc/Export.cpp,core/libs/prx/libwebrtc/include/Api.hpp,core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/4 Test #6365: guest_webrtc_crop_and_scale ................***Failed 0.02 sec 2/4 Test #6362: guest_webrtc_i420_buffer_create_create ..... Passed 0.04 sec 3/4 Test #6364: guest_webrtc_i420_buffer_create_invalid .... Passed 0.05 sec 4/4 Test #6363: guest_webrtc_i420_buffer_create_virtuals ...***Failed 0.03 sec 50% tests passed, 2 tests failed out of 4 - Code reading:
- Verified VideoFrameBufferCropAndScale.cpp:108-118 crop rectangle validation: checks offsetX < 0, offsetY < 0, int64_t(cropWidth) + offsetX > sourceWidth, and rows + offsetY > sourceHeight with rows = (cropHeight < 0 ? -int64_t(cropHeight) : int64_t(cropHeight)), properly handling INT_MIN and signed negative heights.
- Verified VideoFrameBufferCropAndScale.cpp:104 chromaStride computation scaledWidth / 2 + scaledWidth % 2 to prevent integer overflow for INT_MAX.
- Verified VideoFrameBufferCropAndScale.cpp:103-107 I420Buffer::Create allocation lifecycle and RAII target/source cleanup with Reference struct releasing COM-style refcount on exception or error.
- Verified VideoFrameBufferCropAndScale.cpp:119-122 chroma offset alignment uvOffsetX = offsetX / 2; uvOffsetY = offsetY / 2; offsetX = uvOffsetX * 2; offsetY = uvOffsetY * 2 matching upstream WebRTC CropAndScaleFrom.
- Verified CMakeLists.txt and .gitmodules submodule integration for 3rdparty/libyuv at pinned revision 10592b60 matching WebRTC M134 DEPS and package_release.py license packaging.
- Verified AGENTS.md compliance, license headers, technical debt fragment in docs/dev/debt/changes/, and comprehensive test coverage in VideoFrameBufferCropAndScale.cpp.
Looks Good To Me
|
Agreed with Dean's latest scoping: I withdraw the pre- My AI-assisted: yes. |
…me-buffer-crop-and-scale
Refuse a scaled size no I420 buffer holds and a crop size libyuv does not accept (width below 1, height 0, either above 32768) before the buffer is converted, and the rectangle and null planes before the destination is created, so a refused call allocates nothing. Throw when libyuv reports a failure instead of returning the buffer unscaled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@mihiii1337 thanks, I had missed your 08:53 review while answering the others. Both points are taken in Validation before any allocation. The function now checks every argument first and creates the destination last:
Everything refused in 1 to 3 throws Crop width. You are right about Regression. The test heap now counts allocator calls, not only live blocks:
89 negative controls, each rebuilt and run: all make the test fail. The one thing I cannot exercise is the branch after a libyuv failure, since every input that makes it fail is now refused beforehand. The description and the debt entry say what is refused and how that differs from upstream. |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against d3a8483c27:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_webrtc_crop_and_scale_tests,guest_webrtc_i420_buffer_create_testsbuilt cleanly. - CTest (
guest_webrtc_i420_buffer_create_create,guest_webrtc_i420_buffer_create_virtuals,guest_webrtc_i420_buffer_create_invalid,guest_webrtc_crop_and_scale):1/4 Test #6367: guest_webrtc_i420_buffer_create_create ..... Passed 0.05 sec 2/4 Test #6370: guest_webrtc_crop_and_scale ................ Passed 0.08 sec 3/4 Test #6369: guest_webrtc_i420_buffer_create_invalid .... Passed 0.03 sec 4/4 Test #6368: guest_webrtc_i420_buffer_create_virtuals ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 4 - Negative control: with
core/libs/prx/libwebrtc/Export.cpp,core/libs/prx/libwebrtc/include/Api.hpp,core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/4 Test #6370: guest_webrtc_crop_and_scale ................***Failed 0.02 sec 2/4 Test #6367: guest_webrtc_i420_buffer_create_create ..... Passed 0.05 sec 3/4 Test #6369: guest_webrtc_i420_buffer_create_invalid .... Passed 0.05 sec 4/4 Test #6368: guest_webrtc_i420_buffer_create_virtuals ...***Failed 0.03 sec 50% tests passed, 2 tests failed out of 4 - Code reading:
- Checked core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cpp:103-108 parameter and dimension validation for result, buffer, vtable, scaledWidth/scaledHeight <= 0, and 64-bit plane overflow guard against INT_MAX
- Checked core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cpp:109-111 scaler limits against cropWidth <= 0, rows == 0 (cropHeight == 0), cropWidth > 32768, rows > 32768, and negative height rows computation handling INT_MIN safely without signed overflow
- Checked core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cpp:112-127 ToI420 conversion, source bounds checking (cropWidth + offsetX > sourceWidth, rows + offsetY > sourceHeight, negative offsets), even offset chroma plane alignment, and null plane pointer checks
- Checked core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cpp:138-149 libyuv::I420Scale invocation return code check, RAII reference management via struct Reference preventing leaks on thrown exceptions, and result publishing only on success
- Checked CMakeLists.txt, .gitmodules, docs/dev/debt/changes fragment, and package_release.py license packaging for compliance with AGENTS.md conventions
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The changed implementation and build/package integration were inspected at head d3a8483c274de7c7bdbf2fdb16568658d736170f; no concrete blocking defect was verified, but tests were not run and the libyuv submodule contents were unavailable for review.
What I ran
No commands or tests were run. I read the prepared description, commits, diff, manifest, review README, and targeted source ranges at the pinned head. The changed files inspected were .gitmodules, 3rdparty/libyuv (submodule pointer only), core/libs/CMakeLists.txt, core/libs/prx/libwebrtc/CMakeLists.txt, core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/src/VideoFrameBufferCropAndScale.cpp, core/libs/prx/libwebrtc/src/I420Buffer.cpp, core/libs/prx/libwebrtc/tests/I420BufferCreate.cpp (diff), core/libs/prx/libwebrtc/tests/VideoFrameBufferCropAndScale.cpp (diff and selected ranges), docs/dev/debt/changes/feat-webrtc-video-frame-buffer-crop-and-scale.md, tools/package_release.py, and tools/tests/test_package_release.py (diff). 3rdparty/libyuv was excluded because its text was unavailable.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | No verified blocking defect |
| Tests | not run | Author-reported results were not rerun |
| Submodule review | not run | Pointer inspected; contents unavailable |
Findings
Blocking
None verified.
Non-blocking
No additional comments.
Not verified
The libyuv source and license files at the submodule revision, console behavior, and author-reported build and test results were not independently verified. Some changed test-file ranges were not read in full.
To get this to a good state
Nothing is required. The implementation has extensive author-reported tests, but those results were not rerun during this review.
mihiii1337
left a comment
There was a problem hiding this comment.
Re-reviewed exact head d3a8483c274de7c7bdbf2fdb16568658d736170f. This supersedes my earlier change request.
The remaining scaler-input/result blockers are fixed: non-positive crop widths and zero crop heights (including the INT_MIN paths) are rejected before conversion or allocation; destination plane sizing is checked in 64 bits before Create; source extent and null planes are checked before dispatch; and the result is published only after I420Scale returns success. Temporary references remain RAII-managed. As clarified earlier, I do not retain the allocation order as a separate blocker.
My exact-head source and test syntax checks, diff/merge checks, and conventions check passed. PrivacyOnion independently built and passed the four focused WebRTC tests on Linux with a negative control. The exact-head hosted Windows job is now green: it built and passed guest_webrtc_crop_and_scale, and completed 5,648 executed tests with zero failures. The Windows relinker, Linux/macOS relinkers, and relinker ASan jobs are also green.
I did not test console behavior or a GPU path.
AI-assisted: yes.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
What
webrtc::VideoFrameBuffer::CropAndScalewas a stub inlibwebrtc, although it sits in the virtual table of every bufferI420Buffer::Createmakes. This implements it fromapi/video/video_frame_buffer.ccandI420Buffer::CropAndScaleFromofapi/video/i420_buffer.cc, at the commit the library already pins (M134,8d78f5de):ToI420slot, so a guest buffer of another type is scaled from what it converts to, and that reference is released at the end;Create(the width, and half the width rounded up);libyuv::I420Scalewith the box filter.Order and refusals. Upstream creates the destination first and checks afterwards, with
RTC_CHECKs that abort. Here every argument is checked before anything is allocated, and the buffer is created last; for a call that succeeds the two orders give the same result. A refused call throwsstd::invalid_argumentand leaves the result pointer, the reference counts and the heap as they were:int(computed in 64 bits; the chroma stride iswidth / 2 + width % 2, which cannot overflow);INT_MINwould also be negated inside libyuv before its own check;ToI420that returns nothing, a null plane.If libyuv itself fails after that (its only remaining reason is its own allocation), the new buffer is released and
std::runtime_erroris thrown.libyuv. The scaler is upstream's own:
3rdparty/libyuvis a new submodule at10592b60, the revision theDEPSfile of that WebRTC commit pins. Awebrtc_yuvstatic target incore/libs/CMakeLists.txtbuilds the ten sources the scaler needs and is linked privately intolibwebrtc, next tofvad; the configuration stops with thegit submodule update --init 3rdparty/libyuvinstruction when the submodule is empty. ItsLICENSEandPATENTSjoin the noticestools/package_release.pyships withlibwebrtc.prx.libyuv is built as upstream builds it, with its x86 rows chosen from the host CPU. I measured the alternative: on a Zen 2 host, a build limited to the C rows gives other pixels than the SSSE3 and AVX2 rows for the 3/4 and 3/8 ratios (1280x720 to 960x540 for one), and the same pixels for the other ratios I tried, so a C-only build would not follow the console's CPU on common sizes.
Recorded in the debt entry: the module's libyuv revision is unknown; a host without SSSE3 can differ by a rounding step; the refusals above.
Tested
Windows 11, MinGW GCC 15.2, Ryzen 5 3600. Not tested on a console. A reviewer built and ran the two test targets on Ubuntu 24.04 with GCC 13.3 at an earlier head.
guest_webrtc_crop_and_scaletest.(sum * (65536 / 9)) >> 16.ToI420is called once, its result is read and released once; a guest I420 buffer with unusual strides; the same buffer with each plane null in turn.int, flipped crops taller than what is left below the offset, zero and negative widths, zero heights,INT_MIN), 15 scaled sizes (zero, negative,INT_MAXandINT_MINon each axis, sizes whose luma or chroma alone would fit), a null conversion. After each one the result pointer is untouched, no reference is left and the allocator was not called; on a guest buffer a refused size or crop size is reported beforeToI420is called.guest_webrtc_i420_buffer_create_virtualsrequired the stub to throw; it now checks the buffer the slot returns. The 119guest_webrtctests pass.python -m unittest tools.tests.test_package_releasepasses (140 tests), with the libyuv notices added to the WebRTC case.src/VideoFrameBufferCropAndScale.cpp, each rebuilt and run against the test: every table slot, each term and bound of the size, crop and rectangle checks, the 32768 limit on both sides, the 64-bit sums, the magnitude of a negative height, the rounding of the offsets and of the chroma stride, each null-plane test, the origin and the stride of each plane, the order of the planes and of the sizes on both sides of the scaler, the filter, each release. All 89 make the test fail. Not covered by a control: the branch taken when libyuv fails after the buffer exists, and the release of the buffer on that branch, which the test cannot reach. Two terms of upstream's rectangle check,crop_width <= widthandcrop_height <= height, follow from the others and are not repeated.python tools/check_conventions.py --base origin/main,python tools/debt_fold.py --checkandpython core/libs/tests/test_public_headers.py --audit-onlypass.Not verified. I read no console module: the revision of libyuv it embeds and the rows it selects are not known. The failure of libyuv after the buffer is created cannot be provoked from the test.
Overlap (
python tools/pr_overlap.py --branch feat/webrtc-video-frame-buffer-crop-and-scale):The tool reports no conflicting file and no shared export, then ends with
overlap check failed closed: 17 open PRs that conflict withmainshare.gitmodules(#1835),core/libs/CMakeLists.txt(#7275, #8650, #9156, #9293, #9297, #9302, #9383, #12642, #16793, #19542, #20315, #23786, #24322, #24917) orExport.cppandApi.hppoflibwebrtc(#18498, #24668), so it cannot compare them. I compared each by hand (its diff againstmainon those files and oncore/libs/prx/libwebrtc): none mentions libyuv,I420ScaleorCropAndScale.python tools/pr_overlap.py --nameson the symbol answersopen: no matching PS5 export changes.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)