AvPlayer: fix Crash Bandicoot 4 intro playback and green video padding #848

Manually merged
github merged 2 commits from gh-pr/848/head into gh-pr/848/base 2026-11-26 09:34:51 +00:00
Owner

@⁠Cosmo on GitHub · 2026-09-26 10:30 UTC · original
Cosmo:crash4-video-and-boot-fixes → main · +8 −8 · 1 files · 2 commits · merged 2026-09-26 16:39 UTC

Crash Bandicoot 4: It's About Time (PPSA02433) could stall on the Unreal Engine logo because its final video frame is at 3267 ms, after the last audio frame at 3264 ms. Delivered audio now anchors the existing shared playback clock, which keeps advancing after audio ends and allows the remaining video to drain. This removes the separate audio timestamp gate.

The game also samples the padded columns of its NV12 video frames. Initialize those columns and padded rows with neutral black: Y=16 for limited range or Y=0 for full range, with Cb/Cr=128. Decoded picture pixels overwrite their visible regions. This removes the green strip while preserving pitch and crop metadata. The slight horizontal logo offset matches the real PS5 reference capture.

Validation: both fixes passed independent review and a final compactness audit. Built with the existing CMake configuration and ran through launch.json with Vulkan validation disabled. Intro videos advanced without the green strip or fade-out stall, and the game reached visibly advancing gameplay with increasing frame counts and no fatal exit during the observed run.

**@⁠Cosmo** on GitHub · 2026-09-26 10:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/848) `Cosmo:crash4-video-and-boot-fixes` → `main` · +8 −8 · 1 files · 2 commits · merged 2026-09-26 16:39 UTC Crash Bandicoot 4: It's About Time (PPSA02433) could stall on the Unreal Engine logo because its final video frame is at 3267 ms, after the last audio frame at 3264 ms. Delivered audio now anchors the existing shared playback clock, which keeps advancing after audio ends and allows the remaining video to drain. This removes the separate audio timestamp gate. The game also samples the padded columns of its NV12 video frames. Initialize those columns and padded rows with neutral black: Y=16 for limited range or Y=0 for full range, with Cb/Cr=128. Decoded picture pixels overwrite their visible regions. This removes the green strip while preserving pitch and crop metadata. The slight horizontal logo offset matches the real PS5 reference capture. Validation: both fixes passed independent review and a final compactness audit. Built with the existing CMake configuration and ran through launch.json with Vulkan validation disabled. Intro videos advanced without the green strip or fade-out stall, and the game reached visibly advancing gameplay with increasing frame counts and no fatal exit during the observed run.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:34:51 +00:00
github manually merged commit 944e184938 into gh-pr/848/base 2026-11-26 09:34:51 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 10:38 UTC · original · edited 2026-09-26 16:41 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

AV playback now advances its synchronization clock after audio ends and prepares padded video planes by extending edge pixels. Video pitch alignment and linear block width alignment also change. A new AV player integration test checks playback, padding, and texture pitch. GPU region ownership checks now exclude definitely CPU-dirty images, with updated tests for CPU writes and refresh behavior.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🟡 Moderate · up to f3d8e

This fixes the Crash Bandicoot 4 intro videos, but it changes how GPU-written texture data is tracked and how 8- and 16-bit linear textures are laid out in all games. A partial CPU write can cause shaders to read stale texture data. The layout change has not been tested outside video planes. Address the ownership issue before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to f3d8e

The changes affect playback and graphics data ownership, but the reviewed paths do not establish a new security exposure. Some malformed-media and downstream-consumer behavior remains unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The assessed exposure is guest-supplied media and graphics memory within playback and rendering. The available evidence does not establish an expanded identity, privilege, tenant, service, or deployment boundary.

Trust Boundaries and Controls

  • observed — Frame preparation checks decoded dimensions against allocated pitch and height, buffer capacity, plane presence, and source line sizes. It checks the chroma line size against decoded width, while the new chroma copy width can round an odd width up; behavior for such decoder output remains unverified.

Resilience and Maintainability Implications

  • observed — The region query inspects image state under the texture-cache lock. Exact CPU-write invalidation and subsequent GPU-write commit provide ownership transitions; the separately inspected download path rechecks eligibility after image selection.

Hardening Proposals

  • proposed — Validate the chroma source stride against the rounded chroma copy width, and exercise odd or mismatched decoded dimensions before relying on frame geometry for untrusted media. This is a contract-verification proposal, not a verified exploit.
🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 22.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 4 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary AvPlayer changes: fixing Crash Bandicoot 4 intro playback and green video padding.
Description check ✅ Passed The description directly explains the playback-clock fix, NV12 padding fix, affected game, validation, and observed results.
Full details: Docstring Coverage

Explanation

Docstring coverage is 22.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 4 files. (2 skipped: 1 unsupported, 1 too large.)


Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 10:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/848#issuecomment-5845546776) · edited 2026-09-26 16:41 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/848"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough AV playback now advances its synchronization clock after audio ends and prepares padded video planes by extending edge pixels. Video pitch alignment and linear block width alignment also change. A new AV player integration test checks playback, padding, and texture pitch. GPU region ownership checks now exclude definitely CPU-dirty images, with updated tests for CPU writes and refresh behavior. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"f3d8e1c50f60a066bed044c793aa7c331f553de9" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _🟡 Moderate_ · up to `f3d8e` <!-- final_review_risk_coverage:{"sourceCommitId":"f3d8e1c50f60a066bed044c793aa7c331f553de9","coveredCommitId":"f3d8e1c50f60a066bed044c793aa7c331f553de9","kind":"reviewed"} --> This fixes the Crash Bandicoot 4 intro videos, but it changes how GPU-written texture data is tracked and how 8- and 16-bit linear textures are laid out in all games. A partial CPU write can cause shaders to read stale texture data. The layout change has not been tested outside video planes. Address the ownership issue before merging. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🔵 Low_ · up to `f3d8e` The changes affect playback and graphics data ownership, but the reviewed paths do not establish a new security exposure. Some malformed-media and downstream-consumer behavior remains unverified. **Retained concerns** No architecture-level concerns identified. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The assessed exposure is guest-supplied media and graphics memory within playback and rendering. The available evidence does not establish an expanded identity, privilege, tenant, service, or deployment boundary. **Trust Boundaries and Controls** - _observed_ — Frame preparation checks decoded dimensions against allocated pitch and height, buffer capacity, plane presence, and source line sizes. It checks the chroma line size against decoded width, while the new chroma copy width can round an odd width up; behavior for such decoder output remains unverified. **Resilience and Maintainability Implications** - _observed_ — The region query inspects image state under the texture-cache lock. Exact CPU-write invalidation and subsequent GPU-write commit provide ownership transitions; the separately inspected download path rechecks eligibility after image selection. **Hardening Proposals** - _proposed_ — Validate the chroma source stride against the rounded chroma copy width, and exercise odd or mismatched decoded dimensions before relying on frame geometry for untrusted media. This is a contract-verification proposal, not a verified exploit. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❓ 1</summary> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :----------------: | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ❓ Inconclusive | Docstring coverage is 22.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 4 files. (2 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :--------------------------------------------------------------------------------------------------------------------------- | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Title check | ✅ Passed | The title clearly describes the primary AvPlayer changes: fixing Crash Bandicoot 4 intro playback and green video padding. | | Description check | ✅ Passed | The description directly explains the playback-clock fix, NV12 padding fix, affected game, validation, and observed results. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 22.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 4 files. (2 skipped: 1 unsupported, 1 too large.) </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 10:38 UTC · original
On src/graphics/host_gpu/renderer/cache/textureCache.cpp line 1869 (outdated):

@@ -1864,7 +1864,9 @@ bool TextureCache::IsRegionGpuModified(uint64_t address, uint64_t size) {
 	std::scoped_lock lock {m_lock};
 	for (const auto id: FindImagesInRegion(address, size, false)) {
 		const auto& image = m_slot_images[id];
-		if (!image.depth_id && image.IsGpuModified()) {
+		// A CPU write inside the image supersedes what the GPU rendered: the image is refreshed
+		// from guest memory before its next use, so guest memory holds the live bytes.
+		if (!image.depth_id && image.IsGpuModified() && !image.IsDefinitelyCpuDirty()) {

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 6 --glob '*.{cpp,h,hpp}' '\bIsRegionGpuModified\s*\(' src tests
rg -n -C 6 'IsDefinitelyCpuDirty|InvalidateCpuWrite|RefreshImage' \
  src/graphics/host_gpu/renderer/image/image.h \
  src/graphics/host_gpu/renderer/cache/textureCache.cpp \
  tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 42456


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- production declarations and callers ---'
rg -n -C 12 --glob '*.{cpp,h,hpp}' 'TextureCache::IsRegionGpuModified|\.IsRegionGpuModified\s*\(|IsRegionGpuModified\s*\(' src

printf '%s\n' '--- image invalidation definitions ---'
rg -n -C 18 'InvalidateCpuWrite|IsDefinitelyCpuDirty|IsGpuModified|MarkGpuModified|UntrackImage' \
  src/graphics/host_gpu/renderer/image/image.h \
  src/graphics/host_gpu/renderer/cache/textureCache.cpp

printf '%s\n' '--- refresh and ownership flow ---'
sed -n '500,565p;1160,1245p;1840,1915p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

printf '%s\n' '--- same-page survivor test ---'
sed -n '6135,6220p' tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 42813


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- TryReadGpuCleanBacking callers ---'
rg -n -C 16 'TryReadGpuCleanBacking\s*\(' src

printf '%s\n' '--- memory read/fault path ---'
rg -n -C 18 'TryReadBacking|HandleFault|PageFaultAccess::Read|ReadMemory' \
  src/kernel/memory.cpp \
  src/graphics/host_gpu \
  --glob '*.{cpp,h,hpp}'

Repository: KytyPS5/KytyPS5

Length of output: 42028


Preserve GPU ownership for untouched bytes.

A partial CPU write can mark the entire image definitely CPU-dirty. TextureCache::IsRegionGpuModified then returns false for disjoint GPU-written bytes. TryReadGpuCleanBacking can consequently read stale guest backing during shader reads.

Track CPU-dirty byte ranges, or preserve GPU ownership for bytes that the CPU did not overwrite.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 10:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/848#discussion_r4111113732) On `src/graphics/host_gpu/renderer/cache/textureCache.cpp` line 1869 (outdated): ```diff @@ -1864,7 +1864,9 @@ bool TextureCache::IsRegionGpuModified(uint64_t address, uint64_t size) { std::scoped_lock lock {m_lock}; for (const auto id: FindImagesInRegion(address, size, false)) { const auto& image = m_slot_images[id]; - if (!image.depth_id && image.IsGpuModified()) { + // A CPU write inside the image supersedes what the GPU rendered: the image is refreshed + // from guest memory before its next use, so guest memory holds the live bytes. + if (!image.depth_id && image.IsGpuModified() && !image.IsDefinitelyCpuDirty()) { ``` _🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash set -euo pipefail rg -n -C 6 --glob '*.{cpp,h,hpp}' '\bIsRegionGpuModified\s*\(' src tests rg -n -C 6 'IsDefinitelyCpuDirty|InvalidateCpuWrite|RefreshImage' \ src/graphics/host_gpu/renderer/image/image.h \ src/graphics/host_gpu/renderer/cache/textureCache.cpp \ tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 42456 --- 🏁 Script executed: ```bash #!/bin/bash set -euo pipefail printf '%s\n' '--- production declarations and callers ---' rg -n -C 12 --glob '*.{cpp,h,hpp}' 'TextureCache::IsRegionGpuModified|\.IsRegionGpuModified\s*\(|IsRegionGpuModified\s*\(' src printf '%s\n' '--- image invalidation definitions ---' rg -n -C 18 'InvalidateCpuWrite|IsDefinitelyCpuDirty|IsGpuModified|MarkGpuModified|UntrackImage' \ src/graphics/host_gpu/renderer/image/image.h \ src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- refresh and ownership flow ---' sed -n '500,565p;1160,1245p;1840,1915p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- same-page survivor test ---' sed -n '6135,6220p' tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 42813 --- 🏁 Script executed: ```bash #!/bin/bash set -euo pipefail printf '%s\n' '--- TryReadGpuCleanBacking callers ---' rg -n -C 16 'TryReadGpuCleanBacking\s*\(' src printf '%s\n' '--- memory read/fault path ---' rg -n -C 18 'TryReadBacking|HandleFault|PageFaultAccess::Read|ReadMemory' \ src/kernel/memory.cpp \ src/graphics/host_gpu \ --glob '*.{cpp,h,hpp}' ``` Repository: KytyPS5/KytyPS5 Length of output: 42028 --- </details> **Preserve GPU ownership for untouched bytes.** A partial CPU write can mark the entire image definitely CPU-dirty. `TextureCache::IsRegionGpuModified` then returns `false` for disjoint GPU-written bytes. `TryReadGpuCleanBacking` can consequently read stale guest backing during shader reads. Track CPU-dirty byte ranges, or preserve GPU ownership for bytes that the CPU did not overwrite. <!-- fingerprinting:phantom:triton:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:776b138cf2ac73519570402c --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-26 10:39 UTC · original · reviewed

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/graphics/guest_gpu/tile.cpp (1)

20-23: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add non-video 1-byte and 2-byte linear layout coverage.

CalcLinearBlockWidth affects shared pitch and mip-size calculations. The direct 1-byte and 2-byte assertions cover only AvPlayer R8 and R8G8 pitches. The generic non-video test uses RGBA8, whose alignment is 64 texels before and after this change, so it does not exercise the changed behavior.

Add non-video R8 or R16 cases with discriminating widths, plus a multi-mip case. Assert the pitch, mip sizes, offsets, and total size.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f94d6318-35f0-4ccb-bcb9-89f946584f8c

📥 Commits

Reviewing files that changed from the base of the PR and between fd2e15ee73 and f3d8e1c50f60a066bed044c793aa7c331f553de9.

📒 Files selected for processing (6)
  • CMakeLists.txt
  • src/graphics/guest_gpu/tile.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/libs/avPlayer.cpp
  • tests/AvPlayerTests.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-26 10:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/848#pullrequestreview-5325634665) · **reviewed** **Actionable comments posted: 1** <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>src/graphics/guest_gpu/tile.cpp (1)</summary><blockquote> `20-23`: _🎯 Functional Correctness_ | _🔵 Trivial_ | _⚡ Quick win_ **Add non-video 1-byte and 2-byte linear layout coverage.** `CalcLinearBlockWidth` affects shared pitch and mip-size calculations. The direct 1-byte and 2-byte assertions cover only AvPlayer R8 and R8G8 pitches. The generic non-video test uses RGBA8, whose alignment is 64 texels before and after this change, so it does not exercise the changed behavior. Add non-video R8 or R16 cases with discriminating widths, plus a multi-mip case. Assert the pitch, mip sizes, offsets, and total size. <!-- cr-comment:v1:14b7829df54e987d9ff6e806 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `f94d6318-35f0-4ccb-bcb9-89f946584f8c` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between fd2e15ee737ea9a671619246129bc2aae7e0bfda and f3d8e1c50f60a066bed044c793aa7c331f553de9. </details> <details> <summary>📒 Files selected for processing (6)</summary> * `CMakeLists.txt` * `src/graphics/guest_gpu/tile.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/libs/avPlayer.cpp` * `tests/AvPlayerTests.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@⁠Nmzik on GitHub · 2026-09-26 16:39 UTC · original

@⁠Cosmo The Unreal Engine logo is NOT centered on real PS5 (This is NOT a bug).
Valid fixes are: AVPlayer and NV12 green strip. Game now goes in-game. Thanks

**@⁠Nmzik** on GitHub · 2026-09-26 16:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/848#issuecomment-5847975871) @⁠Cosmo The Unreal Engine logo is NOT centered on real PS5 (This is NOT a bug). Valid fixes are: AVPlayer and NV12 green strip. Game now goes in-game. Thanks
This discussion has been locked. Commenting is limited to contributors.
No description provided.