feat(libwebrtc): implement AudioDecoderOpusImpl constructor and destructor #21347

Merged
Zyylon merged 4 commits from upstream-pr/21347 into main 2026-11-26 10:25:50 +00:00
Zyylon commented 2026-11-16 05:26:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zyylon on 2026-11-16T05:26:26Z.


What

Implement the M134 three-argument webrtc::AudioDecoderOpusImpl constructor and destructor (_ZN6webrtc20AudioDecoderOpusImplC1ERKNS_15FieldTrialsViewEmi, _ZN6webrtc20AudioDecoderOpusImplD1Ev) in libwebrtc:

  • Add the 32-byte WebRtcAudioDecoderOpusImpl layout header (AudioDecoderOpusImpl.hpp) and update Api.hpp and Export.cpp.
  • Implement AudioDecoderOpusImpl.cpp (with verbatim WebRTC notices pinned to 8d78f5de6c27b2c793039989ea381f1428fb0100), querying "WebRTC-Audio-OpusGeneratePlc" via guest FieldTrialsView::Lookup (slot 2), backing decoding/duration/FEC/PLC operations with 3rdparty/opus, populating all 15 AudioDecoder vtable slots, bounding DecodeInternal/DecodeRedundantInternal/OpusFrame::Decode to the validated expected duration and caller-provided sample capacity, and safely validating guest pointers/buffers with GuestPtr, GuestBytes, and GuestWritable_nid_no_patch.
  • Add guest_webrtc_audio_decoder_opus_tests covering field trials (inline SSO & heap strings), lifecycle, packet duration/FEC estimation, stereo & mono-in-stereo decoding, DTX, Reset, GeneratePlc, ParsePayload/OpusFrame, undersized output/duration bounds, and invalid/guarded guest pointers.

Tested

Windows 11 (x86_64, gcc 16.2.0, build/):

  • Built libwebrtc and guest_webrtc_audio_decoder_opus_tests
  • Ran ctest --test-dir build -R "^guest_webrtc_audio_decoder_opus$" --repeat until-fail:5 -V (5/5 passed)
  • Ran ctest --test-dir build -R "^(guest_webrtc_audio_decoder(_decode)?|guest_webrtc_opus)$" -V (3/3 passed)
  • Verified tools/guest_pointer_audit.py --json libwebrtc reports 0 findings in AudioDecoderOpusImpl.cpp
  • Verified tools/debt_fold.py --check, tools/check_test_registration.py, and tools/check_conventions.py --base origin/main

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5331592422 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347). Originally posted by [Zyylon](https://github.com/Zyylon) on 2026-11-16T05:26:26Z. --- ### What Implement the M134 three-argument `webrtc::AudioDecoderOpusImpl` constructor and destructor (`_ZN6webrtc20AudioDecoderOpusImplC1ERKNS_15FieldTrialsViewEmi`, `_ZN6webrtc20AudioDecoderOpusImplD1Ev`) in `libwebrtc`: - Add the 32-byte `WebRtcAudioDecoderOpusImpl` layout header (`AudioDecoderOpusImpl.hpp`) and update `Api.hpp` and `Export.cpp`. - Implement `AudioDecoderOpusImpl.cpp` (with verbatim WebRTC notices pinned to `8d78f5de6c27b2c793039989ea381f1428fb0100`), querying `"WebRTC-Audio-OpusGeneratePlc"` via guest `FieldTrialsView::Lookup` (slot 2), backing decoding/duration/FEC/PLC operations with `3rdparty/opus`, populating all 15 `AudioDecoder` vtable slots, bounding `DecodeInternal`/`DecodeRedundantInternal`/`OpusFrame::Decode` to the validated expected duration and caller-provided sample capacity, and safely validating guest pointers/buffers with `GuestPtr`, `GuestBytes`, and `GuestWritable_nid_no_patch`. - Add `guest_webrtc_audio_decoder_opus_tests` covering field trials (inline SSO & heap strings), lifecycle, packet duration/FEC estimation, stereo & mono-in-stereo decoding, DTX, `Reset`, `GeneratePlc`, `ParsePayload`/`OpusFrame`, undersized output/duration bounds, and invalid/guarded guest pointers. ### Tested Windows 11 (`x86_64`, `gcc` 16.2.0, `build/`): - Built `libwebrtc` and `guest_webrtc_audio_decoder_opus_tests` - Ran `ctest --test-dir build -R "^guest_webrtc_audio_decoder_opus$" --repeat until-fail:5 -V` (5/5 passed) - Ran `ctest --test-dir build -R "^(guest_webrtc_audio_decoder(_decode)?|guest_webrtc_opus)$" -V` (3/3 passed) - Verified `tools/guest_pointer_audit.py --json libwebrtc` reports 0 findings in `AudioDecoderOpusImpl.cpp` - Verified `tools/debt_fold.py --check`, `tools/check_test_registration.py`, and `tools/check_conventions.py --base origin/main` ### Checklist - [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) and the licence notice of code adapted from upstream (see AGENTS.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
PrivacyOnion commented 2026-11-16 05:28:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T05:28:53Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_audio_decoder_opus_tests built cleanly.
  • CTest (guest_webrtc_audio_decoder_opus):
    1/1 Test #5517: guest_webrtc_audio_decoder_opus ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • 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 core/libs/prx/libwebrtc/include/AudioDecoderOpusImpl.hpp layout and static_asserts (32-byte WebRtcAudioDecoderOpusImpl matching vtable, decState, channels, sampleRateHz, generatePlc offsets)
    • Verified _ZN6webrtc20AudioDecoderOpusImplC1ERKNS_15FieldTrialsViewEmi_nid_postfix and _ZN6webrtc20AudioDecoderOpusImplD1Ev_nid_postfix guest pointer validation, channel count (1 or 2), and sample rate (16000 or 48000 Hz) checks in core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp
    • Verified resource cleanup on error paths in constructor (opus_decoder_destroy and delete state on CopyOut failure) and destructor (opus_decoder_destroy and delete host.decState)
    • Verified FieldTrialsView::Lookup slot 2 invocation and ReleaseGuestString SSO/heap/large-allocation cleanup in IsGeneratePlcEnabled
    • Verified CMakeLists.txt, Export.cpp, Api.hpp, and debt fragment docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md compliance with AGENTS.md rules

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5915422443 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347#pullrequestreview-5915422443). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T05:28:53Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `abee73af88`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_audio_decoder_opus_tests` built cleanly. - **CTest** (`guest_webrtc_audio_decoder_opus`): ``` 1/1 Test #5517: guest_webrtc_audio_decoder_opus ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **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 core/libs/prx/libwebrtc/include/AudioDecoderOpusImpl.hpp layout and static_asserts (32-byte WebRtcAudioDecoderOpusImpl matching vtable, decState, channels, sampleRateHz, generatePlc offsets) - Verified _ZN6webrtc20AudioDecoderOpusImplC1ERKNS_15FieldTrialsViewEmi_nid_postfix and _ZN6webrtc20AudioDecoderOpusImplD1Ev_nid_postfix guest pointer validation, channel count (1 or 2), and sample rate (16000 or 48000 Hz) checks in core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp - Verified resource cleanup on error paths in constructor (opus_decoder_destroy and delete state on CopyOut failure) and destructor (opus_decoder_destroy and delete host.decState) - Verified FieldTrialsView::Lookup slot 2 invocation and ReleaseGuestString SSO/heap/large-allocation cleanup in IsGeneratePlcEnabled - Verified CMakeLists.txt, Export.cpp, Api.hpp, and debt fragment docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md compliance with AGENTS.md rules Looks Good To Me
MarcZX10 commented 2026-11-16 05:35:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T05:35:00Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: prevent decoded samples from being copied beyond the caller-provided output capacity.

What I ran

  • Reviewed head abee73af887c1c518b622537060fbf75e8e19135; no commands or tests were run in this review.
  • Read the prepared description, commits, manifest, and diff, plus all five changed files marked included: true: core/libs/prx/libwebrtc/CMakeLists.txt, core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/AudioDecoderOpusImpl.hpp, core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp, core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp, and docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md.

Results

Check Result Note
Source review failed Decode output capacity is not enforced
Tests not run Author reports passing tests
Console behavior not run Layout and allocator remain unverified

Findings

Blocking

  • core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:591: The decoder vtable's internal Decode callback receives no output capacity, and this implementation writes the decoded frame size returned by Opus directly to decoded. The base AudioDecoder::Decode checks the packet duration against maxDecodedBytes before invoking the callback, but the changed callback also needs to ensure its actual output fits: malformed or mismatched packet duration can make Opus return more samples than the advertised duration. As written, the callback can overwrite the caller's output buffer. Carry the validated capacity into a safe decode path or otherwise bound the output copy to the caller's provided storage.

Non-blocking

None.

Not verified

  • No build or test command was run; the reported Windows test results are author supplied.
  • Console ABI, object layout, allocator behavior, and firmware behavior were not verified.
  • No files were excluded according to the manifest.

To get this to a good state

  • Bound decode writes to the caller's actual output capacity, then rerun the decoder tests and pointer audit on the new head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5915460524 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347#pullrequestreview-5915460524). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T05:35:00Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: prevent decoded samples from being copied beyond the caller-provided output capacity. ## What I ran - Reviewed head `abee73af887c1c518b622537060fbf75e8e19135`; no commands or tests were run in this review. - Read the prepared description, commits, manifest, and diff, plus all five changed files marked `included: true`: `core/libs/prx/libwebrtc/CMakeLists.txt`, `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/AudioDecoderOpusImpl.hpp`, `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp`, `core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp`, and `docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md`. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Decode output capacity is not enforced | | Tests | not run | Author reports passing tests | | Console behavior | not run | Layout and allocator remain unverified | ## Findings ### Blocking - `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:591`: The decoder vtable's internal `Decode` callback receives no output capacity, and this implementation writes the decoded frame size returned by Opus directly to `decoded`. The base `AudioDecoder::Decode` checks the packet duration against `maxDecodedBytes` before invoking the callback, but the changed callback also needs to ensure its actual output fits: malformed or mismatched packet duration can make Opus return more samples than the advertised duration. As written, the callback can overwrite the caller's output buffer. Carry the validated capacity into a safe decode path or otherwise bound the output copy to the caller's provided storage. ### Non-blocking None. ## Not verified - No build or test command was run; the reported Windows test results are author supplied. - Console ABI, object layout, allocator behavior, and firmware behavior were not verified. - No files were excluded according to the manifest. ## To get this to a good state - Bound decode writes to the caller's actual output capacity, then rerun the decoder tests and pointer audit on the new head.
MarcZX10 commented 2026-11-16 06:45:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T06:45:36Z.

Review: COMMENTED


Reviewed — no blocking findings

The review folder and repository reader are not accessible through the available tools, so the change could not be inspected and a review verdict is not justified.

What I ran

Not run. No reader command or file-reading tool is available in this session.

Results

Check Result Note
Change and context review not run Review inputs unavailable
Tests not run Change not inspected

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

The description, commits, diff, manifest, changed files, and relevant repository context were not read. No tests were run.

To get this to a good state

Provide access to the review folder and reader so the change can be reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5916007695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347#pullrequestreview-5916007695). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T06:45:36Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The review folder and repository reader are not accessible through the available tools, so the change could not be inspected and a review verdict is not justified. ## What I ran Not run. No reader command or file-reading tool is available in this session. ## Results | Check | Result | Note | |---|---|---| | Change and context review | not run | Review inputs unavailable | | Tests | not run | Change not inspected | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified The description, commits, diff, manifest, changed files, and relevant repository context were not read. No tests were run. ## To get this to a good state Provide access to the review folder and reader so the change can be reviewed.
MarcZX10 commented 2026-11-16 11:57:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T11:57:50Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: make GeneratePlc append the requested per-channel PCM as interleaved samples for stereo decoders.

What I ran

Reviewed head 9445e63d94b2cfa3cacc57dfde231b6094f22a3f using the pinned repo_read.py reader tools. No build or tests were run. Read all 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/AudioDecoderOpusImpl.hpp, core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp, core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp, and docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md. No changed files were excluded by files.json.

Results

Check Result Note
Changed-file review passed All seven changed files read
Build and tests not run Description reports successful author runs
Console behavior not run Debt note says layout and allocator remain unverified

Findings

Blocking

  • core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:561 uses Opus's per-channel return count as the number of interleaved samples to append. For a stereo decoder, OpusDecode writes ret * 2 samples, but this code advances the buffer by only ret; it therefore appends only half of the generated PCM and reports an undersized buffer. Scale the append count by host.channels (and use that count for buffer sizing and copying). The stereo test currently asserts the incorrect count at core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp:265.

Non-blocking

None.

Sources

  • The decoder's GeneratePlc parameter is named requestedSamplesPerChannel in core/libs/prx/libwebrtc/include/Api.hpp:312; DecodeInternalImpl also scales the returned per-channel count by the channel count before reporting decoded samples (core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:511).

Not verified

  • Build and test results reported in the PR description were not independently run.
  • Console ABI, layout, allocator behavior, and physical-console decoding were not verified.

To get this to a good state

  • Append and report the full interleaved stereo sample count in GeneratePlc, and update the stereo assertion to cover that count. Rerun the decoder test and the reported related checks on the new head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5919577351 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347#pullrequestreview-5919577351). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T11:57:50Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: make `GeneratePlc` append the requested per-channel PCM as interleaved samples for stereo decoders. ## What I ran Reviewed head `9445e63d94b2cfa3cacc57dfde231b6094f22a3f` using the pinned `repo_read.py` reader tools. No build or tests were run. Read all 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/AudioDecoderOpusImpl.hpp`, `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp`, `core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp`, and `docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md`. No changed files were excluded by `files.json`. ## Results | Check | Result | Note | |---|---|---| | Changed-file review | passed | All seven changed files read | | Build and tests | not run | Description reports successful author runs | | Console behavior | not run | Debt note says layout and allocator remain unverified | ## Findings ### Blocking - `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:561` uses Opus's per-channel return count as the number of interleaved samples to append. For a stereo decoder, `OpusDecode` writes `ret * 2` samples, but this code advances the buffer by only `ret`; it therefore appends only half of the generated PCM and reports an undersized buffer. Scale the append count by `host.channels` (and use that count for buffer sizing and copying). The stereo test currently asserts the incorrect count at `core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp:265`. ### Non-blocking None. ## Sources - The decoder's `GeneratePlc` parameter is named `requestedSamplesPerChannel` in `core/libs/prx/libwebrtc/include/Api.hpp:312`; `DecodeInternalImpl` also scales the returned per-channel count by the channel count before reporting decoded samples (`core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:511`). ## Not verified - Build and test results reported in the PR description were not independently run. - Console ABI, layout, allocator behavior, and physical-console decoding were not verified. ## To get this to a good state - Append and report the full interleaved stereo sample count in `GeneratePlc`, and update the stereo assertion to cover that count. Rerun the decoder test and the reported related checks on the new head.
MarcZX10 commented 2026-11-16 12:32:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T12:32:54Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: fix the stereo decode sample count and make ParsePayload preserve ownership on allocation failures.

What I ran

Reviewed head 718923d16abd8b3668b927e0a920da1f386f7651 against base main from the prepared diff and pinned reader. No commands or tests were run; the Windows build and test results in the PR description are author-reported.

Results

Check Result Note
Code review failed Two concrete defects found
Tests not run Author reports Windows runs
Console behavior not run Layout and allocator are unverified

Findings

Blocking

  • core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:511: Opus returns samples per channel, but this multiplies the return by channel count while leaving the AudioDecoder::Decode contract and the call to OpusFrame::Decode measured in samples per channel. For a 960-sample stereo frame this returns 1920, causing OpusFrame::Decode to reject a valid result when given a 960-sample output capacity; the existing test instead passes 1920. Keep the callback return in samples per channel and apply channel scaling only to buffer sizing/copying as required by the ABI.

  • core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:461: After creating the FEC frame, later failures while creating the primary frame or allocating/writing the result vector leave the FEC frame and its payload unowned. In the primary-frame allocation failure case, the original payload also remains owned by neither the input buffer (which has not yet been cleared) nor an output frame if creation partially succeeds. Add cleanup for all constructed frames and ensure input ownership transfers only after result construction succeeds.

Non-blocking

None.

Not verified

  • The prepared bundle lists seven changed files, all included and 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/AudioDecoderOpusImpl.hpp, core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp, core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp, and docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md.
  • No files were excluded by the prepared manifest.
  • Windows test claims were not independently run; console layout, vtable, and allocator behavior remain unverified as the change documents.

To get this to a good state

Fix both blocking findings, then rerun the reported Windows build and decoder tests on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5920013275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347#pullrequestreview-5920013275). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T12:32:54Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: fix the stereo decode sample count and make `ParsePayload` preserve ownership on allocation failures. ## What I ran Reviewed head `718923d16abd8b3668b927e0a920da1f386f7651` against base `main` from the prepared diff and pinned reader. No commands or tests were run; the Windows build and test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Code review | failed | Two concrete defects found | | Tests | not run | Author reports Windows runs | | Console behavior | not run | Layout and allocator are unverified | ## Findings ### Blocking - `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:511`: Opus returns samples per channel, but this multiplies the return by channel count while leaving the `AudioDecoder::Decode` contract and the call to `OpusFrame::Decode` measured in samples per channel. For a 960-sample stereo frame this returns 1920, causing `OpusFrame::Decode` to reject a valid result when given a 960-sample output capacity; the existing test instead passes 1920. Keep the callback return in samples per channel and apply channel scaling only to buffer sizing/copying as required by the ABI. - `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:461`: After creating the FEC frame, later failures while creating the primary frame or allocating/writing the result vector leave the FEC frame and its payload unowned. In the primary-frame allocation failure case, the original payload also remains owned by neither the input buffer (which has not yet been cleared) nor an output frame if creation partially succeeds. Add cleanup for all constructed frames and ensure input ownership transfers only after result construction succeeds. ### Non-blocking None. ## Not verified - The prepared bundle lists seven changed files, all included and 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/AudioDecoderOpusImpl.hpp`, `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp`, `core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp`, and `docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md`. - No files were excluded by the prepared manifest. - Windows test claims were not independently run; console layout, vtable, and allocator behavior remain unverified as the change documents. ## To get this to a good state Fix both blocking findings, then rerun the reported Windows build and decoder tests on the updated head.
MarcZX10 commented 2026-11-16 12:52:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T12:52:04Z.

Review: COMMENTED


Reviewed — no blocking findings

The source review found no verified blocking defect at head 19154ac5cd56ef9df08978eba0e7aafb9869f20d; no build or test command was run in this review.

What I ran

  • Read the prepared description, commits, manifest, diff, and changed source and test files through repo_read.py.
  • No commands or tests were run. The Windows results in the PR description are author-reported.

Results

Check Result Note
Source review passed No blocking defect verified
Build and tests not run Author reports Windows passes

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • Build and test results were not independently verified.
  • Console layout, vtable, and allocator behavior remain unverified, as recorded in the changed technical-debt note.
  • Read: core/libs/prx/libwebrtc/CMakeLists.txt, core/libs/prx/libwebrtc/Export.cpp diff, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/AudioDecoderOpusImpl.hpp, core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp, core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp, and docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md.
  • Excluded: none listed in the prepared manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5920252795 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347#pullrequestreview-5920252795). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T12:52:04Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The source review found no verified blocking defect at head `19154ac5cd56ef9df08978eba0e7aafb9869f20d`; no build or test command was run in this review. ## What I ran - Read the prepared description, commits, manifest, diff, and changed source and test files through `repo_read.py`. - No commands or tests were run. The Windows results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | No blocking defect verified | | Build and tests | not run | Author reports Windows passes | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified - Build and test results were not independently verified. - Console layout, vtable, and allocator behavior remain unverified, as recorded in the changed technical-debt note. - Read: `core/libs/prx/libwebrtc/CMakeLists.txt`, `core/libs/prx/libwebrtc/Export.cpp` diff, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/AudioDecoderOpusImpl.hpp`, `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp`, `core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp`, and `docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md`. - Excluded: none listed in the prepared manifest. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-16 15:00:02 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: prevent the decoder from writing past the caller-provided output capacity.

What I ran

Reviewed head 3be171fed4288967d1eb54c8581bfe1d0f1de731 using repo_read.py to inspect the prepared diff and targeted source ranges. No build or tests were run by me; the test results in the description are author-reported.

Results

Check Result Note
Diff and targeted source review passed All changed files were included and read
Build and tests not run Results are author-reported

Findings

Blocking

  • core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:508: DecodeInternalImpl derives the writable range from the packet’s expected duration, but its ABI receives no output capacity. This check therefore assumes the caller allocated at least that many samples. A caller with a smaller buffer can pass the check and then be overrun by GuestBytes(decoded).CopyOut at line 522. Ensure the capacity is supplied and checked before decoding/copying, or otherwise make the API’s output size contract enforceable.

Non-blocking

None.

Not verified

  • I did not run the author-reported Windows build, CTest commands, or convention and audit tools.
  • No files were excluded from the prepared review bundle; all seven changed files were read.

To get this to a good state

  • Add an enforceable output-capacity check to the decode path, then rerun the reported decoder tests and pointer audit on the updated head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5922124431 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347#pullrequestreview-5922124431). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T15:00:02Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: prevent the decoder from writing past the caller-provided output capacity. ## What I ran Reviewed head `3be171fed4288967d1eb54c8581bfe1d0f1de731` using `repo_read.py` to inspect the prepared diff and targeted source ranges. No build or tests were run by me; the test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | All changed files were included and read | | Build and tests | not run | Results are author-reported | ## Findings ### Blocking - `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:508`: `DecodeInternalImpl` derives the writable range from the packet’s expected duration, but its ABI receives no output capacity. This check therefore assumes the caller allocated at least that many samples. A caller with a smaller buffer can pass the check and then be overrun by `GuestBytes(decoded).CopyOut` at line 522. Ensure the capacity is supplied and checked before decoding/copying, or otherwise make the API’s output size contract enforceable. ### Non-blocking None. ## Not verified - I did not run the author-reported Windows build, CTest commands, or convention and audit tools. - No files were excluded from the prepared review bundle; all seven changed files were read. ## To get this to a good state - Add an enforceable output-capacity check to the decode path, then rerun the reported decoder tests and pointer audit on the updated head.
MarcZX10 commented 2026-11-21 06:26:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:26:03Z.

Review: DISMISSED


Reviewed — changes requested

Changes are required before merge: fix the ParsePayload failure cleanup so it releases the primary frame’s payload allocation.

What I ran

Reviewed head 28158e021441fa5a036f1e2b8fe06abd74eeb942. No build or tests were run here. The reported Windows 11 test and audit results are author supplied.

Results

Check Result Note
Diff and manifest passed Seven changed files; all included
Targeted code review passed Decoder, interfaces, and tests read
Build and tests not run Author reported successful runs

Findings

Blocking

  • In the ParsePayload exception handler, primaryFrame is freed with operator delete without calling its destructor. Its destructor frees the payload allocation it owns, so a failure after frame creation leaks that payload. The allocation-failure test exercises later allocation failures but checks only that allocations are empty after freeing the original payload, which can hide a leaked copy in the FEC path. Run the primary frame destructor before freeing the frame object (or otherwise release its owned payload) in the catch path. (core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:478)

Non-blocking

None.

Not verified

  • Console layout, vtable, allocator behavior, and physical-console behavior were not verified; the change records this limitation.
  • Build, tests, pointer audit, and convention checks were not run in this review.

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/AudioDecoderOpusImpl.hpp, core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp, core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp, docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md, plus core/libs/prx/libwebrtc/include/AudioDecoder.hpp, core/libs/prx/libwebrtc/src/AudioDecoder.cpp, core/libs/prx/libwebrtc/src/AudioDecoderDecode.cpp, and core/libs/prx/libwebrtc/src/Opus.cpp for context. All seven changed files listed in the manifest were read; no changed file was excluded.

To get this to a good state

Call OpusFrameD1_nid_no_patch(primaryFrame) before freeing primaryFrame in the failure cleanup, then rerun the allocation-failure tests and verify that both owned payloads are released.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003493103 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21347#pullrequestreview-6003493103). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T06:26:03Z. **Review:** DISMISSED --- # Reviewed — changes requested Changes are required before merge: fix the `ParsePayload` failure cleanup so it releases the primary frame’s payload allocation. ## What I ran Reviewed head `28158e021441fa5a036f1e2b8fe06abd74eeb942`. No build or tests were run here. The reported Windows 11 test and audit results are author supplied. ## Results | Check | Result | Note | |---|---|---| | Diff and manifest | passed | Seven changed files; all included | | Targeted code review | passed | Decoder, interfaces, and tests read | | Build and tests | not run | Author reported successful runs | ## Findings ### Blocking - In the `ParsePayload` exception handler, `primaryFrame` is freed with `operator delete` without calling its destructor. Its destructor frees the payload allocation it owns, so a failure after frame creation leaks that payload. The allocation-failure test exercises later allocation failures but checks only that allocations are empty after freeing the original payload, which can hide a leaked copy in the FEC path. Run the primary frame destructor before freeing the frame object (or otherwise release its owned payload) in the catch path. (`core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp:478`) ### Non-blocking None. ## Not verified - Console layout, vtable, allocator behavior, and physical-console behavior were not verified; the change records this limitation. - Build, tests, pointer audit, and convention checks were not run in this review. 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/AudioDecoderOpusImpl.hpp`, `core/libs/prx/libwebrtc/src/AudioDecoderOpusImpl.cpp`, `core/libs/prx/libwebrtc/tests/AudioDecoderOpusImpl.cpp`, `docs/dev/debt/changes/feat-libwebrtc-audio-decoder-opus.md`, plus `core/libs/prx/libwebrtc/include/AudioDecoder.hpp`, `core/libs/prx/libwebrtc/src/AudioDecoder.cpp`, `core/libs/prx/libwebrtc/src/AudioDecoderDecode.cpp`, and `core/libs/prx/libwebrtc/src/Opus.cpp` for context. All seven changed files listed in the manifest were read; no changed file was excluded. ## To get this to a good state Call `OpusFrameD1_nid_no_patch(primaryFrame)` before freeing `primaryFrame` in the failure cleanup, then rerun the allocation-failure tests and verify that both owned payloads are released.
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!21347
No description provided.