feat(videodec2): add HEVC picture-information queries #2161

Closed
inmert wants to merge 1 commit from upstream-pr/2161 into main
inmert commented 2026-10-09 10:22:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by inmert on 2026-10-09T10:22:12Z.


What

HEVC decoding is already supported, but sceVideodec2GetHevcPictureInfo is missing and the generic picture-info query rejects HEVC output.

Add the HEVC export and dispatch to it from sceVideodec2GetPictureInfo. Capture SPS/VUI metadata and timestamps with each access unit so they stay attached to the right picture through B-frame reordering. Queries report coded dimensions, profile and level, timing, aspect ratio, colour information and NAL-presence flags.

Keep metadata available for retained output buffers and track which decoder last wrote each buffer. Reusing a buffer between decoders must return the newer picture's metadata; resetting or deleting its decoder invalidates the record.

This covers single-layer, single-temporal-layer, uncropped 8-bit 4:2:0 pictures. Crop/display windows, field sequences, explicit scaling lists, predicted SPS reference sets, HRD, SPS extensions and picture-timing/frame-packing/alternative-transfer SEI still throw when queried. Existing decoding continues to work. Unsupported persistent SEI keeps subsequent queries unsupported until decoder reset.

The 184-byte layout follows the public PS5 declaration and matches the shadPS4 layout. Metadata parsing follows FFmpeg's HEVC syntax. Accepted structure sizes, inferred defaults and unverified console behaviour are recorded in TechnicalDebt.md. There is no known title caller used to validate these queries.

The overlap warning with #1831, #1916 and #2142 is limited to docs/dev/TechnicalDebt.md. Those PRs append unrelated entries immediately after the decoder note that this PR corrects. There are no shared exports or implementation changes, and none is a dependency. The documentation conflict can be resolved by keeping the corrected HEVC note and the other PR's entry.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON. The full project build completed after rebasing onto current main, and both focused CTest cases passed with no skips (6.85 seconds total). Tests use synthetic bitstreams; no game, console or Linux testing.

  • guest_videodec2: Annex-B and length-prefixed HEVC, B-frame timestamps, SPS/VUI changes, retained and reused buffers, reset/deletion, structure bounds, malformed input and unsupported persistent SEI. Existing H.264, HEVC and VP9 decode hashes still pass.
  • The buffer-reuse regression failed before ownership tracking was added, returning the previous decoder's metadata; it passes with the fix.
  • patched_libraries: all 116 libraries loaded, with no failures.
  • Repository conventions, test registration and git diff --check passed.
cmake --build build --parallel 2
ctest --test-dir build -R '^(guest_videodec2|patched_libraries)$' --output-on-failure --timeout 30

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 in TechnicalDebt. No new stubs.
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source. No new dependency added.
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799127460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2161). Originally posted by [inmert](https://github.com/inmert) on 2026-10-09T10:22:12Z. --- ### What HEVC decoding is already supported, but `sceVideodec2GetHevcPictureInfo` is missing and the generic picture-info query rejects HEVC output. Add the HEVC export and dispatch to it from `sceVideodec2GetPictureInfo`. Capture SPS/VUI metadata and timestamps with each access unit so they stay attached to the right picture through B-frame reordering. Queries report coded dimensions, profile and level, timing, aspect ratio, colour information and NAL-presence flags. Keep metadata available for retained output buffers and track which decoder last wrote each buffer. Reusing a buffer between decoders must return the newer picture's metadata; resetting or deleting its decoder invalidates the record. This covers single-layer, single-temporal-layer, uncropped 8-bit 4:2:0 pictures. Crop/display windows, field sequences, explicit scaling lists, predicted SPS reference sets, HRD, SPS extensions and picture-timing/frame-packing/alternative-transfer SEI still throw when queried. Existing decoding continues to work. Unsupported persistent SEI keeps subsequent queries unsupported until decoder reset. The 184-byte layout follows the [public PS5 declaration](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Video/Videodec2.cs) and matches the [shadPS4 layout](https://github.com/shadps4-emu/shadPS4/blob/0fe263a4760dfbfa973366890061749b4af0de97/src/core/libraries/videodec/videodec2.h). Metadata parsing follows [FFmpeg's HEVC syntax](https://github.com/FFmpeg/FFmpeg/blob/n7.1/libavcodec/cbs_h265_syntax_template.c). Accepted structure sizes, inferred defaults and unverified console behaviour are recorded in `TechnicalDebt.md`. There is no known title caller used to validate these queries. The overlap warning with #1831, #1916 and #2142 is limited to `docs/dev/TechnicalDebt.md`. Those PRs append unrelated entries immediately after the decoder note that this PR corrects. There are no shared exports or implementation changes, and none is a dependency. The documentation conflict can be resolved by keeping the corrected HEVC note and the other PR's entry. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, Ninja, Release, `BUILD_TESTING=ON`. The full project build completed after rebasing onto current `main`, and both focused CTest cases passed with no skips (6.85 seconds total). Tests use synthetic bitstreams; no game, console or Linux testing. - `guest_videodec2`: Annex-B and length-prefixed HEVC, B-frame timestamps, SPS/VUI changes, retained and reused buffers, reset/deletion, structure bounds, malformed input and unsupported persistent SEI. Existing H.264, HEVC and VP9 decode hashes still pass. - The buffer-reuse regression failed before ownership tracking was added, returning the previous decoder's metadata; it passes with the fix. - `patched_libraries`: all 116 libraries loaded, with no failures. - Repository conventions, test registration and `git diff --check` passed. ```sh cmake --build build --parallel 2 ctest --test-dir build -R '^(guest_videodec2|patched_libraries)$' --output-on-failure --timeout 30 ``` ### 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) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs). No new stubs. - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source. No new dependency added. - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-09 10:27:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T10:27:44Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2142 docs/dev/TechnicalDebt.md L367
#2182 docs/dev/TechnicalDebt.md L367
#2203 core/libs/tests/GuestVideodec2.cpp L8
#2281 docs/dev/TechnicalDebt.md L367
#2381 docs/dev/TechnicalDebt.md L366-367
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079070829 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2161#issuecomment-6079070829). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T10:27:44Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2142 | `docs/dev/TechnicalDebt.md` [L367](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/docs/dev/TechnicalDebt.md#L367) | | | | #2182 | `docs/dev/TechnicalDebt.md` [L367](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/docs/dev/TechnicalDebt.md#L367) | | | | #2203 | `core/libs/tests/GuestVideodec2.cpp` [L8](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/core/libs/tests/GuestVideodec2.cpp#L8) | | | | #2281 | `docs/dev/TechnicalDebt.md` [L367](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/docs/dev/TechnicalDebt.md#L367) | | | | #2381 | `docs/dev/TechnicalDebt.md` [L366-367](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/docs/dev/TechnicalDebt.md#L366-L367) | | |
muhzain05 commented 2026-10-09 12:49:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by muhzain05 on 2026-10-09T12:49:03Z.


Thanks for the HEVC picture-information work!

I've been building a complementary follow-up on top of this PR that extends picture metadata support to VP9 and generalizes picture ownership across AVC, HEVC, and VP9.

The follow-up also addresses a conversion-retry edge case where a failed output conversion can consume a queued picture before it is successfully published.

I'll keep those changes separate to avoid expanding the scope of #2161, and plan to rebase onto main once this lands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081213600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2161#issuecomment-6081213600). Originally posted by [muhzain05](https://github.com/muhzain05) on 2026-10-09T12:49:03Z. --- Thanks for the HEVC picture-information work! I've been building a complementary follow-up on top of this PR that extends picture metadata support to VP9 and generalizes picture ownership across AVC, HEVC, and VP9. The follow-up also addresses a conversion-retry edge case where a failed output conversion can consume a queued picture before it is successfully published. I'll keep those changes separate to avoid expanding the scope of #2161, and plan to rebase onto main once this lands.
oneandonlydean commented 2026-10-09 20:09:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:09:13Z.


Closing: no title calls sceVideodec2GetHevcPictureInfo on main, as the description says, and a new HEVC metadata parser needs one that does. Please reopen with the title ID and the log line if you find one.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088430394 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2161#issuecomment-6088430394). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:09:13Z. --- Closing: no title calls `sceVideodec2GetHevcPictureInfo` on main, as the description says, and a new HEVC metadata parser needs one that does. Please reopen with the title ID and the log line if you find one.

Pull request closed

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!2161
No description provided.