fix(libSceVideodec2): reject out-of-order HEVC NAL units #27925
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27925"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by gurtgg on 2026-11-27T20:32:10Z.
What
Videodec2Hevc::Parse_nid_no_patch(core/libs/prx/libSceVideodec2/HevcMetadata.cpp) before mutating persistent parser state: reject AUD (type 35) when not first, reject VPS/SPS/PPS (types 32-34) after any slice NAL unit, and reject EOS/EOB (types 36-37) when appearing without a slice, beforelastSliceIndex, duplicated, in invalid EOB-before-EOS order, or followed by unexpected NAL units.state.vps,state.sps,state.pps, orstate.afterEnd. Because Loop 1 rejects pictureless EOS/EOB units before Loop 2 runs,if (!selectedSps)retainsif (flags.endSequencePresent || flags.endStreamPresent) state.afterEnd = true;so slice-containing access units with unavailable SPS/PPS still close the sequence/bitstream at EOS/EOB.Tested
InvalidNalOrder(core/libs/tests/GuestHevcMetadata.cpp): negative-control tests verifying out-of-order VPS/SPS/PPS after slices, duplicate or non-leading AUDs, EOS/EOB before the last slice or in invalid sequence/bitstream order, and slice + unavailable SPS + EOS/EOB followed by a non-IRAP slice are rejected (failing onmainand passing with this fix), alongside positive controls for valid EOS/EOB ordering.MalformedParameterHistory(core/libs/tests/GuestHevcMetadata.cpp) and all existing fixture tests: placed the truncated PPS after the leading AUD sostate.unsupportedpersists acrossResetunder valid NAL ordering, verified viaCheckProjectionWrites(decoder, true).Checklist
main; no other open PR implements the same functionstools/check_conventions.pypasses)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repositorymainand passes after fixSummary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T20:36:20Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
5e16c5ef31:tools/check_conventions.pypassed.guest_hevc_metadata_testsbuilt cleanly.guest_hevc_metadata):core/libs/prx/libSceVideodec2/HevcMetadata.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T20:53:48Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code supports the stated NAL ordering checks and preserves end-state handling when slice metadata cannot be resolved.
What I ran
5e16c5ef312d72d97853979c43e8eba99e878ba6usingrepo_read.pyto read the prepared diff and both changed files.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
core/libs/prx/libSceVideodec2/HevcMetadata.cppandcore/libs/tests/GuestHevcMetadata.cpp; both were read. No files were excluded from the prepared manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:06:05Z.
Review: APPROVED
Checked head
5e16c5ef31. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomaina163d4b886together with #27930, #27929, #27926, #27924, #27923, #27922, #27901, #27828, #27771, #27755, #27748, #27682, #27765.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded.guest_hevc_metadatapasses. In the full CPU suite (5,120 tests) the only failures are unrelated:windows_read_trap_unknownfails onmaintoo (fixed in #28028).frame_capture_minimize,jpeg_external_toolchainandguest_pthread_mutex_contentionare timeouts under load; they pass when run on their own.guest_audio_in_capturepasses 20/20 onmainand with #27922.One non-blocking note: the new rule reports any VPS, SPS or PPS after a slice as unsupported. H.265 7.4.2.4.4 only forbids parameter sets after the last VCL NAL unit of an access unit, so a PPS between two slices of one picture is valid.
AvcMetadata.cpphas the same stricter rule for H.264, so this is consistent and safe, because the stream is reported as unsupported rather than accepted. It may be worth a line indocs/dev/debt/libSceVideodec2.md.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T09:18:02Z.
Review: COMMENTED
The Linux
guest_hevc_metadataCTest passed with the exact parser change. The new cases check ordering of parameter sets and access-unit metadata, plus the decoder's ability to continue after rejecting an out-of-order unit.AI-assisted: yes.