feat(libSceNKWebKit): implement VP codec parameter parsing #19300

Merged
AlexWhitehouse merged 2 commits from upstream-pr/19300 into main 2026-11-13 20:05:10 +00:00
AlexWhitehouse commented 2026-11-13 02:40:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-13T02:40:47Z.


What

libSceNKWebKit WebCore::parseVPCodecParameters(WTF::StringView) (_ZN7WebCore22parseVPCodecParametersEN3WTF10StringViewE, NID nmGqNyrNQj0) threw not implemented. This PR ports it from the PS5 WebKit tree the other NKWebKit ports use, 80f77e94:

The new src/VPCodec.cpp starts with the notices of VP9Utilities.cpp and StringToIntegerConversion.h, and include/VPCodecExports.hpp with that of VP9Utilities.h.

Behaviour:

  • Codec names: a bare vp8 or vp9, or vp8.0 / vp9.0 exactly, returns the defaults (profile 0, level 10, 8-bit, 4:2:0 colocated, BT.709, video range). Otherwise the name must be vp08 or vp09, case-sensitively.
  • Fields: profile, level and bit depth are required. Chroma subsampling, colour primaries, transfer characteristics, matrix coefficients and range must then come together or not at all; one extra field fails. Each is checked against upstream's table, and identity matrix coefficients need 4:4:4.
  • Splitting and numbers: the string splits on . with empty parts skipped. Each number is parsed as upstream's parseInteger<uint8_t>: leading and trailing whitespace, an optional +, leading zeros, and nothing over 255.
  • Codec name: codecName is a new WTF::String built through the existing StringImpl::create exports, in the input's width.
  • ABI: the record is 16 bytes: the String at 0, then the eight one-byte fields at 8–15. std::optional of it is 24 bytes with the engaged flag at 16. It isn't trivially destructible, so it's returned through a hidden pointer; the StringView is passed by value.
  • Errors: a StringView with null data and a non-zero length throws.

The stub and its LegacyExports.hpp declaration are removed. The older-callable-export counts drop from 2392 to 2391 and from 2161 to 2160 named. Debt entries record the unmeasured console ABI and layout, the splitting rule and the integer parsing rule.

Tested

  • New test: nkwebkit_vpcodec (core/libs/prx/libSceNKWebKit/tests/VPCodec.cpp) runs every case on 8-bit and UTF-16 input:
    • the legacy names vp8, vp9, vp8.0, vp9.0 and vp8..., with vp8.00 and vp8.0. rejected;
    • three-field and eight-field vp08/vp09 strings with each field's value checked;
    • every value from 0 to 256 in each of the eight fields, checked against upstream's tables;
    • identity matrix coefficients with each chroma subsampling;
    • whitespace, +, long runs of leading zeros, empty components, and rejected forms: missing fields, extra fields, -, hex, exponents, uppercase names, a non-ASCII code unit and a no-break space;
    • the returned codecName's contents, the disengaged result's flag at offset 16, and an empty view with null data.
  • Linux x86-64 (Ubuntu 26.04, GCC 15, Release):
    • on main, the test fails with _ZN7WebCore22parseVPCodecParametersEN3WTF10StringViewE not implemented;
    • with this PR, nkwebkit_vpcodec, nkwebkit_wtf and public_headers pass.
  • Windows 11 (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): nkwebkit_vpcodec and nkwebkit_wtf pass at d83a93b0b4, with no compiler warnings in the changed files. The branch was then rebased onto current main without conflicts, and both tests pass again on Linux.
  • Mutation check: requiring 4:2:2 instead of 4:4:4 for identity matrix coefficients fails the test.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • python3 tools/pr_overlap.py: no open PR implements this export, its NID or the new files. It couldn't compare 31 NKWebKit PRs automatically; I checked each diff by hand. They share only Export.cpp, LegacyExports.hpp, libSceNKWebKit.hpp or the debt file's count lines. Whichever merges second recounts.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5288990976 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19300). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-13T02:40:47Z. --- ### What libSceNKWebKit `WebCore::parseVPCodecParameters(WTF::StringView)` (`_ZN7WebCore22parseVPCodecParametersEN3WTF10StringViewE`, NID `nmGqNyrNQj0`) threw `not implemented`. This PR ports it from the PS5 WebKit tree the other NKWebKit ports use, 80f77e94: - [`VP9Utilities.cpp` lines 37–276](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/graphics/VP9Utilities.cpp#L37-L276): the parser and its validation tables; - [`VP9Utilities.h` lines 107–119](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/graphics/VP9Utilities.h#L107-L119): `VPCodecConfigurationRecord` and its defaults; - [`StringView.h` lines 1047–1099](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/StringView.h#L1047-L1099): `split`, which skips empty components; - [`StringToIntegerConversion.h` lines 45–104](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/StringToIntegerConversion.h#L45-L104): `parseInteger<uint8_t>`. The new `src/VPCodec.cpp` starts with the notices of `VP9Utilities.cpp` and `StringToIntegerConversion.h`, and `include/VPCodecExports.hpp` with that of `VP9Utilities.h`. Behaviour: - **Codec names:** a bare `vp8` or `vp9`, or `vp8.0` / `vp9.0` exactly, returns the defaults (profile 0, level 10, 8-bit, 4:2:0 colocated, BT.709, video range). Otherwise the name must be `vp08` or `vp09`, case-sensitively. - **Fields:** profile, level and bit depth are required. Chroma subsampling, colour primaries, transfer characteristics, matrix coefficients and range must then come together or not at all; one extra field fails. Each is checked against upstream's table, and identity matrix coefficients need 4:4:4. - **Splitting and numbers:** the string splits on `.` with empty parts skipped. Each number is parsed as upstream's `parseInteger<uint8_t>`: leading and trailing whitespace, an optional `+`, leading zeros, and nothing over 255. - **Codec name:** `codecName` is a new `WTF::String` built through the existing `StringImpl::create` exports, in the input's width. - **ABI:** the record is 16 bytes: the `String` at 0, then the eight one-byte fields at 8–15. `std::optional` of it is 24 bytes with the engaged flag at 16. It isn't trivially destructible, so it's returned through a hidden pointer; the `StringView` is passed by value. - **Errors:** a `StringView` with null data and a non-zero length throws. The stub and its `LegacyExports.hpp` declaration are removed. The older-callable-export counts drop from 2392 to 2391 and from 2161 to 2160 named. Debt entries record the unmeasured console ABI and layout, the splitting rule and the integer parsing rule. ### Tested - **New test:** `nkwebkit_vpcodec` (`core/libs/prx/libSceNKWebKit/tests/VPCodec.cpp`) runs every case on 8-bit and UTF-16 input: - the legacy names `vp8`, `vp9`, `vp8.0`, `vp9.0` and `vp8...`, with `vp8.00` and `vp8.0.` rejected; - three-field and eight-field `vp08`/`vp09` strings with each field's value checked; - every value from 0 to 256 in each of the eight fields, checked against upstream's tables; - identity matrix coefficients with each chroma subsampling; - whitespace, `+`, long runs of leading zeros, empty components, and rejected forms: missing fields, extra fields, `-`, hex, exponents, uppercase names, a non-ASCII code unit and a no-break space; - the returned `codecName`'s contents, the disengaged result's flag at offset 16, and an empty view with null data. - **Linux x86-64** (Ubuntu 26.04, GCC 15, Release): - on `main`, the test fails with `_ZN7WebCore22parseVPCodecParametersEN3WTF10StringViewE not implemented`; - with this PR, `nkwebkit_vpcodec`, `nkwebkit_wtf` and `public_headers` pass. - **Windows 11** (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): `nkwebkit_vpcodec` and `nkwebkit_wtf` pass at d83a93b0b4, with no compiler warnings in the changed files. The branch was then rebased onto current `main` without conflicts, and both tests pass again on Linux. - **Mutation check:** requiring 4:2:2 instead of 4:4:4 for identity matrix coefficients fails the test. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - **`python3 tools/pr_overlap.py`:** no open PR implements this export, its NID or the new files. It couldn't compare 31 NKWebKit PRs automatically; I checked each diff by hand. They share only `Export.cpp`, `LegacyExports.hpp`, `libSceNKWebKit.hpp` or the debt file's count lines. Whichever merges second recounts. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-13 02:46:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-13T02:46:02Z.

Review: COMMENTED


Reviewed VP codec parsing — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head: 2832c77b72a94355fea4ee643193d2e5e476715a (PR 19300, base main).
  • Read the description, commits, manifest and diff. Checked the head with repo_read.py search and cat (about 10 calls).
  • Files read: the diff for all seven reviewed files, and the full text of the three new files (VPCodecExports.hpp, src/VPCodec.cpp, tests/VPCodec.cpp). Read only through their diff hunks: libSceNKWebKit.hpp, LegacyExports.hpp, Export.cpp and the debt file. Export.cpp and the debt file are excluded from files/.
  • No build and no test run in this review.

Results

Check Result Note
Build and nkwebkit_vpcodec not run Linux and Windows passes are the author's report
Old stub and declaration removed passed Search at head: no references left in Export.cpp or LegacyExports.hpp
Test registration passed tests/*.cpp is globbed into nkwebkit_<name>_tests
Struct layout asserts not run Read against WtfStringAbi.hpp; not compiled
Parser against the test tables not run Checked by hand, not executed

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceNKWebKit/tests/VPCodec.cpp:111: the non-ASCII case passes length 12 for nonASCII, which holds 11 code units, so the NUL terminator is included. The input is still rejected at U+0100, but not for the reason the case names. Use 11.
  • core/libs/prx/libSceNKWebKit/tests/VPCodec.cpp:109: no case checks the throw for null data with a non-zero length, which src/VPCodec.cpp:367 documents. Add one.
  • core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:99: ToStringWithoutCopying calls ToString(), which copies through StringImpl::create. The name is wrong. Call ToString() at src/VPCodec.cpp:281 and drop the wrapper.
  • Style: src/VPCodec.cpp:280 has trailing whitespace, and src/VPCodec.cpp:285–287 and 314–315 have runs of blank lines.

Not verified

  • The parser tables and the whitespace set against upstream (VP9Utilities.cpp, ASCIICType.h, StringToIntegerConversion.h). The cited upstream lines were not opened.
  • Console behaviour: the hidden-pointer return, the 16-byte record, the 24-byte optional, and the throw.
  • The debt counts (2392 to 2391, 2161 to 2160). Each count drops by the one removed line, which matches the diff; they were not recounted.
  • Whether other exports in the module throw std::invalid_argument the same way.
  • The permalinks in the debt file and the description were not opened.

To get this to a good state

Nothing is required. The non-blocking points above are optional.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5885268915 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19300#pullrequestreview-5885268915). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-13T02:46:02Z. **Review:** COMMENTED --- # Reviewed VP codec parsing — no blocking findings Nothing blocks this; the points below are optional. ## What I ran - Head: `2832c77b72a94355fea4ee643193d2e5e476715a` (PR 19300, base `main`). - Read the description, commits, manifest and diff. Checked the head with `repo_read.py` `search` and `cat` (about 10 calls). - Files read: the diff for all seven reviewed files, and the full text of the three new files (`VPCodecExports.hpp`, `src/VPCodec.cpp`, `tests/VPCodec.cpp`). Read only through their diff hunks: `libSceNKWebKit.hpp`, `LegacyExports.hpp`, `Export.cpp` and the debt file. `Export.cpp` and the debt file are excluded from `files/`. - No build and no test run in this review. ## Results | Check | Result | Note | |---|---|---| | Build and `nkwebkit_vpcodec` | not run | Linux and Windows passes are the author's report | | Old stub and declaration removed | passed | Search at head: no references left in `Export.cpp` or `LegacyExports.hpp` | | Test registration | passed | `tests/*.cpp` is globbed into `nkwebkit_<name>_tests` | | Struct layout asserts | not run | Read against `WtfStringAbi.hpp`; not compiled | | Parser against the test tables | not run | Checked by hand, not executed | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceNKWebKit/tests/VPCodec.cpp:111`: the non-ASCII case passes length 12 for `nonASCII`, which holds 11 code units, so the NUL terminator is included. The input is still rejected at U+0100, but not for the reason the case names. Use 11. - `core/libs/prx/libSceNKWebKit/tests/VPCodec.cpp:109`: no case checks the throw for null data with a non-zero length, which `src/VPCodec.cpp:367` documents. Add one. - `core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:99`: `ToStringWithoutCopying` calls `ToString()`, which copies through `StringImpl::create`. The name is wrong. Call `ToString()` at `src/VPCodec.cpp:281` and drop the wrapper. - Style: `src/VPCodec.cpp:280` has trailing whitespace, and `src/VPCodec.cpp:285`–`287` and `314`–`315` have runs of blank lines. ## Not verified - The parser tables and the whitespace set against upstream (`VP9Utilities.cpp`, `ASCIICType.h`, `StringToIntegerConversion.h`). The cited upstream lines were not opened. - Console behaviour: the hidden-pointer return, the 16-byte record, the 24-byte optional, and the throw. - The debt counts (2392 to 2391, 2161 to 2160). Each count drops by the one removed line, which matches the diff; they were not recounted. - Whether other exports in the module throw `std::invalid_argument` the same way. - The permalinks in the debt file and the description were not opened. ## To get this to a good state Nothing is required. The non-blocking points above are optional.
PrivacyOnion commented 2026-11-13 12:43:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T12:43:40Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: nkwebkit_vpcodec_tests built cleanly.
  • CTest (nkwebkit_vpcodec):
    1/1 Test #3859: nkwebkit_vpcodec .................   Passed    0.13 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified input null and empty storage handling in core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:363 (_ZN7WebCore22parseVPCodecParametersEN3WTF10StringViewE), confirming null data with non-zero length throws std::invalid_argument while zero-length inputs safely yield std::nullopt without dereferencing input.data.
    • Verified delimiter parsing and tokenization in View::Split and ParseVPCodecParameters (core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:99-111, 266-357), confirming empty components are skipped per WebKit StringView::split rules and legacy names (vp8, vp9, vp8.0, vp9.0) correctly return default configuration records.
    • Verified integer parsing and overflow safety in ParseInteger (core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:133-152), ensuring leading and trailing whitespace, optional '+', leading zeros, and values up to 255 parse safely without integer overflow while negative signs and values exceeding 255 return std::nullopt.
    • Verified parameter lookup tables in core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:159-264 (IsValidVPProfile, IsValidVPLevel, IsValidBitDepth, IsValidRange, IsValidChromaSubsampling, IsValidVPColorPrimaries, IsValidVPTransferCharacteristics, IsValidVPMatrixCoefficients), ensuring all tables are strictly ordered for std::binary_search and matrix coefficient Identity (0) strictly requires 4:4:4 chroma subsampling (3).
    • Verified struct layout and ABI assertions in core/libs/prx/libSceNKWebKit/include/VPCodecExports.hpp:126-139, confirming 16-byte VPCodecConfigurationRecord layout, member offsets 0 through 15, and 24-byte non-trivially destructible std::optional with engagement at byte offset 16.
    • Verified AGENTS.md compliance across Export.cpp, LegacyExports.hpp, VPCodecExports.hpp, src/VPCodec.cpp, and tests/VPCodec.cpp, confirming zero disallowed comments in code and debt documentation updates in docs/dev/debt/libSceNKWebKit.md correctly adjusting callable counts from 2392 to 2391 and 2161 to 2160.
  • Minor: please drop the Generated with footer from the description; the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5891208696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19300#pullrequestreview-5891208696). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-13T12:43:40Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `0c2f2049c0`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `nkwebkit_vpcodec_tests` built cleanly. - **CTest** (`nkwebkit_vpcodec`): ``` 1/1 Test #3859: nkwebkit_vpcodec ................. Passed 0.13 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified input null and empty storage handling in core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:363 (_ZN7WebCore22parseVPCodecParametersEN3WTF10StringViewE), confirming null data with non-zero length throws std::invalid_argument while zero-length inputs safely yield std::nullopt without dereferencing input.data. - Verified delimiter parsing and tokenization in View::Split and ParseVPCodecParameters (core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:99-111, 266-357), confirming empty components are skipped per WebKit StringView::split rules and legacy names (vp8, vp9, vp8.0, vp9.0) correctly return default configuration records. - Verified integer parsing and overflow safety in ParseInteger (core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:133-152), ensuring leading and trailing whitespace, optional '+', leading zeros, and values up to 255 parse safely without integer overflow while negative signs and values exceeding 255 return std::nullopt. - Verified parameter lookup tables in core/libs/prx/libSceNKWebKit/src/VPCodec.cpp:159-264 (IsValidVPProfile, IsValidVPLevel, IsValidBitDepth, IsValidRange, IsValidChromaSubsampling, IsValidVPColorPrimaries, IsValidVPTransferCharacteristics, IsValidVPMatrixCoefficients), ensuring all tables are strictly ordered for std::binary_search and matrix coefficient Identity (0) strictly requires 4:4:4 chroma subsampling (3). - Verified struct layout and ABI assertions in core/libs/prx/libSceNKWebKit/include/VPCodecExports.hpp:126-139, confirming 16-byte VPCodecConfigurationRecord layout, member offsets 0 through 15, and 24-byte non-trivially destructible std::optional with engagement at byte offset 16. - Verified AGENTS.md compliance across Export.cpp, LegacyExports.hpp, VPCodecExports.hpp, src/VPCodec.cpp, and tests/VPCodec.cpp, confirming zero disallowed comments in code and debt documentation updates in docs/dev/debt/libSceNKWebKit.md correctly adjusting callable counts from 2392 to 2391 and 2161 to 2160. - Minor: please drop the `Generated with` footer from the description; 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!19300
No description provided.