feat(libSceVideodec2): output 10-bit pictures as low-bit 16-bit words #6709

Merged
johnmaia merged 1 commit from upstream-pr/6709 into main 2026-10-19 09:47:14 +00:00
johnmaia commented 2026-10-16 06:07:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-16T06:07:32Z.


What

Mortalfin (PPSA99141) stops as soon as it plays an HEVC Main10 video (#6640):

Videodec2: output deeper than 8 bits is not implemented

A 10-bit picture is now written in the layout below instead of throwing:

  • 16-bit little-endian words with the sample in the low 10 bits;
  • Y rows, then interleaved UV rows starting at framePitchInBytes × the picture height;
  • framePitch in samples, framePitchInBytes in bytes: twice the width, aligned to 256 as for 8-bit;
  • QueryDecoderMemoryInfo sizes a frame of an HEVC or VP9 profile 2 configuration with two bytes per sample.

Evidence. On #6640 @MarcZX100 asked for hardware or independent consumer evidence for the pitch fields, the alignment and the memory contract, not only the sample packing. EVO-PLAYER-PS5 decodes and presents 1080p HEVC Main10 on hardware through sceVideodec2 ("a 1080p 10-bit file decodes and presents correctly today (198 frames verified)", docs/evo-pro/on-demand-decoder-handoff.md). Its decoder (projects/evoplayer/media/src/evo_vdec_native.c, ro_harvest):

  • takes a picture as 10-bit when pitch_bytes >= pitch * 2, so pitch is in samples and pitch_bytes in bytes;
  • places UV at pitch_bytes × the height and borrows the buffer as it is, so Y and UV are contiguous at one byte pitch;
  • samples it with the low-bit factor #2427 recorded (64.06 ≈ 65535 / 1023).

Its hardware logs give the memory contract (same file):

Main10 decoder frame= logged (rounded to 16 KiB) This PR, rounded to 16 KiB
1920x1088 6128 KB 6128 KB (3840 × 1088 × 1.5 = 6,266,880 bytes)
3840x2176 24496 KB 24480 KB

The 1080p size also settles the pitch. A 1920-sample row is 3840 bytes, not 2 × 2048: a 4096-byte pitch would need 6,684,672 bytes, more than the console allocates. That is EVO's own expectation too ("expected 1920/3840" in its first-frame log). At 4K the console allocates 16 KiB more than the formula gives. I don't know where that comes from, so the debt entry records it. A buffer of this PR's size still holds the frame.

Unverified (in the debt entry):

  • frameFormat stays 0. EVO, SharpProspero and the other public consumers I found don't read it.
  • VP9 profile 2 output: no hardware evidence; it takes the same path.
  • 12-bit pictures and decoded formats other than yuv420p10le still throw.

Mortalfin's four decoders match EVO's resident layout (AVC, a 4K HEVC decoder, and 1080p HEVC decoders), so its Main10 decoder is most likely an HEVC profile 2 configuration that this PR sizes.

Overlap. #6414 changes ChromaOffset to align the height. This PR adds a sample-size parameter to the same function, so whichever merges second takes both: PitchBytes(width, sampleBytes) * AlignUp(height, HeightAlignment).

Tested

  • guest_videodec2 (core/libs/tests/GuestVideodec2.cpp), Linux, GCC, Release. The existing Main10 fixture (64x40, samples 0 to 1023) used to be expected to throw. It now checks:
    • the 1920x1088 frame size: 6,266,880 bytes for profile 2 and 3,342,336 for profile 1, for HEVC and VP9;
    • the geometry: framePitch 128, framePitchInBytes 256, frameFormat 0;
    • the largest word is 1023, so the samples are in the low bits;
    • the Y and interleaved UV words hash to the value computed independently from ffmpeg -pix_fmt yuv420p10le output of the same stream, rearranged into this layout.
  • Red on main 5d9dcc42d with only the test applied: 1920x1088 frame size differs for profile 2. Green with the change.
  • python3 tools/check_conventions.py --base upstream/main: passed.
  • Not run in a title: I don't have Mortalfin. @coltken95, could you try it with this branch?

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
  • Related: #6640, #2427, #1931
  • Unblocks: Mortalfin (PPSA99141) HEVC Main10 playback
  • GPUs tested: none needed (CPU decode path); unit test on Linux
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4884256447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6709). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-16T06:07:32Z. --- ### What Mortalfin (PPSA99141) stops as soon as it plays an HEVC Main10 video (#6640): ``` Videodec2: output deeper than 8 bits is not implemented ``` A 10-bit picture is now written in the layout below instead of throwing: - 16-bit little-endian words with the sample in the low 10 bits; - Y rows, then interleaved UV rows starting at `framePitchInBytes` × the picture height; - `framePitch` in samples, `framePitchInBytes` in bytes: twice the width, aligned to 256 as for 8-bit; - `QueryDecoderMemoryInfo` sizes a frame of an HEVC or VP9 profile 2 configuration with two bytes per sample. **Evidence.** On #6640 @MarcZX100 asked for hardware or independent consumer evidence for the pitch fields, the alignment and the memory contract, not only the sample packing. [EVO-PLAYER-PS5](https://github.com/sainsaji/EVO-PLAYER-PS5/tree/9715f6ee9bf9b53461d6fdf9a2e11b4c48357783) decodes and presents 1080p HEVC Main10 on hardware through `sceVideodec2` ("a 1080p 10-bit file decodes and presents correctly today (198 frames verified)", `docs/evo-pro/on-demand-decoder-handoff.md`). Its decoder (`projects/evoplayer/media/src/evo_vdec_native.c`, `ro_harvest`): - takes a picture as 10-bit when `pitch_bytes >= pitch * 2`, so `pitch` is in samples and `pitch_bytes` in bytes; - places UV at `pitch_bytes` × the height and borrows the buffer as it is, so Y and UV are contiguous at one byte pitch; - samples it with the low-bit factor #2427 recorded (`64.06` ≈ 65535 / 1023). Its hardware logs give the memory contract (same file): | Main10 decoder | `frame=` logged (rounded to 16 KiB) | This PR, rounded to 16 KiB | |---|---|---| | 1920x1088 | 6128 KB | 6128 KB (`3840 × 1088 × 1.5` = 6,266,880 bytes) | | 3840x2176 | 24496 KB | 24480 KB | The 1080p size also settles the pitch. A 1920-sample row is 3840 bytes, not 2 × 2048: a 4096-byte pitch would need 6,684,672 bytes, more than the console allocates. That is EVO's own expectation too ("expected 1920/3840" in its first-frame log). At 4K the console allocates 16 KiB more than the formula gives. I don't know where that comes from, so the debt entry records it. A buffer of this PR's size still holds the frame. **Unverified** (in the debt entry): - `frameFormat` stays 0. EVO, SharpProspero and the other public consumers I found don't read it. - VP9 profile 2 output: no hardware evidence; it takes the same path. - 12-bit pictures and decoded formats other than yuv420p10le still throw. Mortalfin's four decoders match EVO's resident layout (AVC, a 4K HEVC decoder, and 1080p HEVC decoders), so its Main10 decoder is most likely an HEVC profile 2 configuration that this PR sizes. **Overlap.** #6414 changes `ChromaOffset` to align the height. This PR adds a sample-size parameter to the same function, so whichever merges second takes both: `PitchBytes(width, sampleBytes) * AlignUp(height, HeightAlignment)`. ### Tested - `guest_videodec2` (`core/libs/tests/GuestVideodec2.cpp`), Linux, GCC, Release. The existing Main10 fixture (64x40, samples 0 to 1023) used to be expected to throw. It now checks: - the 1920x1088 frame size: 6,266,880 bytes for profile 2 and 3,342,336 for profile 1, for HEVC and VP9; - the geometry: `framePitch` 128, `framePitchInBytes` 256, `frameFormat` 0; - the largest word is 1023, so the samples are in the low bits; - the Y and interleaved UV words hash to the value computed independently from `ffmpeg -pix_fmt yuv420p10le` output of the same stream, rearranged into this layout. - Red on `main` 5d9dcc42d with only the test applied: `1920x1088 frame size differs for profile 2`. Green with the change. - `python3 tools/check_conventions.py --base upstream/main`: passed. - Not run in a title: I don't have Mortalfin. @coltken95, could you try it with this branch? ### 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 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] Related: #6640, #2427, #1931 - [x] Unblocks: Mortalfin (PPSA99141) HEVC Main10 playback - [x] GPUs tested: none needed (CPU decode path); unit test on Linux - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-16 06:49:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T06:49:11Z.


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.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestVideodec2.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6209824998 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6709#issuecomment-6209824998). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-16T06:49:11Z. --- <!-- pr-overlap --> 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. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestVideodec2.cpp` |
adriadam10 commented 2026-10-19 09:48:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T09:48:57Z.


Checked against EVO-PLAYER-PS5's hardware evidence (pitch units, UV placement, 1080p Main10 allocation), the 10-bit copy and the throw paths for other formats/depths, and the debt entry. The only conflict was the adjacent line in docs/dev/debt/libSceVideodec2.md (the flush entry from #7118); I rebased and resolved it, kept your commit, and re-ran the Videodec2 and library tests (41/41 pass). Merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6264410897 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6709#issuecomment-6264410897). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T09:48:57Z. --- Checked against EVO-PLAYER-PS5's hardware evidence (pitch units, UV placement, 1080p Main10 allocation), the 10-bit copy and the throw paths for other formats/depths, and the debt entry. The only conflict was the adjacent line in `docs/dev/debt/libSceVideodec2.md` (the flush entry from #7118); I rebased and resolved it, kept your commit, and re-ran the Videodec2 and library tests (41/41 pass). Merged.
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!6709
No description provided.