From b4b8e2e7332c77e9aeb7d9df26c5e778974f9db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 9 Sep 2026 14:04:26 -0600 Subject: [PATCH] AvcDecoder: Check the pixel format AvcDecoder handed out frame_->data[0..2] without looking at the pixel format, and everything downstream indexes them as 8-bit 4:2:0. Check it, and drop the frame instead of converting whatever else turned up. Co-Authored-By: Claude Opus 5 (1M context) --- Core/HLE/HLETables.cpp | 1 - Core/HW/AvcDecoder.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Core/HLE/HLETables.cpp b/Core/HLE/HLETables.cpp index 44d672aebe..eddb1b028b 100644 --- a/Core/HLE/HLETables.cpp +++ b/Core/HLE/HLETables.cpp @@ -329,7 +329,6 @@ void RegisterAllModules() { Register_sceChkreg(); Register_sceVshBridge(); Register_sceResmgr(); - Register_sceVideocodec(); // add new modules here. diff --git a/Core/HW/AvcDecoder.cpp b/Core/HW/AvcDecoder.cpp index b87bb611be..568adf750f 100644 --- a/Core/HW/AvcDecoder.cpp +++ b/Core/HW/AvcDecoder.cpp @@ -155,6 +155,13 @@ bool AvcDecoder::Decode(const u8 *data, int size) { } #endif + // Everything downstream indexes the three planes as 8-bit 4:2:0, which is all the PSP's + // encoder produced. Anything else would be read as if it were, so say so and drop the frame + // rather than converting garbage. + if (frame_->format != AV_PIX_FMT_YUV420P && frame_->format != AV_PIX_FMT_YUVJ420P) { + WARN_LOG(Log::ME, "AvcDecoder: unexpected pixel format %d, ignoring the frame", frame_->format); + return false; + } width_ = frame_->width; height_ = frame_->height; haveFrame_ = width_ > 0 && height_ > 0;