From 3844a2fb54a2bdafac1a431dd2ee5501c4af95ae Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Sun, 11 Jan 2026 02:47:34 -0600 Subject: [PATCH] Lib.Videodec2: Stub sceVideodec2AllocateComputeQueue to return a valid computeQueue pointer. (#3915) * Stub compute queue output to cpuGpuMemory * Rename namespace This has bugged me for far too long * Oops --- src/core/libraries/libs.cpp | 4 +-- src/core/libraries/videodec/videodec2.cpp | 34 +++++++++++++++++-- src/core/libraries/videodec/videodec2.h | 4 +-- src/core/libraries/videodec/videodec2_avc.h | 4 +-- .../libraries/videodec/videodec2_impl.cpp | 4 +-- src/core/libraries/videodec/videodec2_impl.h | 4 +-- 6 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index 85923134c..9867d132d 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -120,13 +120,13 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::ErrorDialog::RegisterLib(sym); Libraries::ImeDialog::RegisterLib(sym); Libraries::AvPlayer::RegisterLib(sym); - Libraries::Vdec2::RegisterLib(sym); + Libraries::Videodec::RegisterLib(sym); + Libraries::Videodec2::RegisterLib(sym); Libraries::Audio3d::RegisterLib(sym); Libraries::Ime::RegisterLib(sym); Libraries::GameLiveStreaming::RegisterLib(sym); Libraries::SharePlay::RegisterLib(sym); Libraries::Remoteplay::RegisterLib(sym); - Libraries::Videodec::RegisterLib(sym); Libraries::RazorCpu::RegisterLib(sym); Libraries::Move::RegisterLib(sym); Libraries::Fiber::RegisterLib(sym); diff --git a/src/core/libraries/videodec/videodec2.cpp b/src/core/libraries/videodec/videodec2.cpp index a1edb3b68..121818f39 100644 --- a/src/core/libraries/videodec/videodec2.cpp +++ b/src/core/libraries/videodec/videodec2.cpp @@ -8,7 +8,7 @@ #include "core/libraries/videodec/videodec2_impl.h" #include "core/libraries/videodec/videodec_error.h" -namespace Libraries::Vdec2 { +namespace Libraries::Videodec2 { static constexpr u64 kMinimumMemorySize = 16_MB; ///> Fake minimum memory size for querying @@ -34,7 +34,35 @@ s32 PS4_SYSV_ABI sceVideodec2AllocateComputeQueue(const OrbisVideodec2ComputeConfigInfo* computeCfgInfo, const OrbisVideodec2ComputeMemoryInfo* computeMemInfo, OrbisVideodec2ComputeQueue* computeQueue) { - LOG_INFO(Lib_Vdec2, "called"); + LOG_WARNING(Lib_Vdec2, "called"); + if (!computeCfgInfo || !computeMemInfo || !computeQueue) { + LOG_ERROR(Lib_Vdec2, "Invalid arguments"); + return ORBIS_VIDEODEC2_ERROR_ARGUMENT_POINTER; + } + if (computeCfgInfo->thisSize != sizeof(OrbisVideodec2ComputeConfigInfo) || + computeMemInfo->thisSize != sizeof(OrbisVideodec2ComputeMemoryInfo)) { + LOG_ERROR(Lib_Vdec2, "Invalid struct size"); + return ORBIS_VIDEODEC2_ERROR_STRUCT_SIZE; + } + if (computeCfgInfo->reserved0 != 0 || computeCfgInfo->reserved1 != 0) { + LOG_ERROR(Lib_Vdec2, "Invalid compute config"); + return ORBIS_VIDEODEC2_ERROR_CONFIG_INFO; + } + if (computeCfgInfo->computePipeId > 4) { + LOG_ERROR(Lib_Vdec2, "Invalid compute pipe id"); + return ORBIS_VIDEODEC2_ERROR_COMPUTE_PIPE_ID; + } + if (computeCfgInfo->computeQueueId > 7) { + LOG_ERROR(Lib_Vdec2, "Invalid compute queue id"); + return ORBIS_VIDEODEC2_ERROR_COMPUTE_QUEUE_ID; + } + if (!computeMemInfo->cpuGpuMemory) { + LOG_ERROR(Lib_Vdec2, "Invalid memory pointer"); + return ORBIS_VIDEODEC2_ERROR_MEMORY_POINTER; + } + + // The real library returns a pointer to memory inside cpuGpuMemory + *computeQueue = computeMemInfo->cpuGpuMemory; return ORBIS_OK; } @@ -233,4 +261,4 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) { sceVideodec2GetPictureInfo); } -} // namespace Libraries::Vdec2 +} // namespace Libraries::Videodec2 diff --git a/src/core/libraries/videodec/videodec2.h b/src/core/libraries/videodec/videodec2.h index 0f080129f..0311e4d27 100644 --- a/src/core/libraries/videodec/videodec2.h +++ b/src/core/libraries/videodec/videodec2.h @@ -10,7 +10,7 @@ namespace Core::Loader { class SymbolsResolver; } -namespace Libraries::Vdec2 { +namespace Libraries::Videodec2 { class VdecDecoder; @@ -138,4 +138,4 @@ s32 PS4_SYSV_ABI sceVideodec2GetPictureInfo(const OrbisVideodec2OutputInfo* outp void* p1stPictureInfo, void* p2ndPictureInfo); void RegisterLib(Core::Loader::SymbolsResolver* sym); -} // namespace Libraries::Vdec2 \ No newline at end of file +} // namespace Libraries::Videodec2 \ No newline at end of file diff --git a/src/core/libraries/videodec/videodec2_avc.h b/src/core/libraries/videodec/videodec2_avc.h index 725d2335f..dcf6ae007 100644 --- a/src/core/libraries/videodec/videodec2_avc.h +++ b/src/core/libraries/videodec/videodec2_avc.h @@ -5,7 +5,7 @@ #include "common/types.h" -namespace Libraries::Vdec2 { +namespace Libraries::Videodec2 { struct OrbisVideodec2AvcPictureInfo { u64 thisSize; @@ -127,4 +127,4 @@ struct OrbisVideodec2LegacyAvcPictureInfo { }; static_assert(sizeof(OrbisVideodec2LegacyAvcPictureInfo) == 0x68); -} // namespace Libraries::Vdec2 \ No newline at end of file +} // namespace Libraries::Videodec2 \ No newline at end of file diff --git a/src/core/libraries/videodec/videodec2_impl.cpp b/src/core/libraries/videodec/videodec2_impl.cpp index 2ad3d7e19..08a7f8f00 100644 --- a/src/core/libraries/videodec/videodec2_impl.cpp +++ b/src/core/libraries/videodec/videodec2_impl.cpp @@ -9,7 +9,7 @@ #include "common/support/avdec.h" -namespace Libraries::Vdec2 { +namespace Libraries::Videodec2 { std::vector gPictureInfos; std::vector gLegacyPictureInfos; @@ -278,4 +278,4 @@ AVFrame* VdecDecoder::ConvertNV12Frame(AVFrame& frame) { return nv12_frame; } -} // namespace Libraries::Vdec2 +} // namespace Libraries::Videodec2 diff --git a/src/core/libraries/videodec/videodec2_impl.h b/src/core/libraries/videodec/videodec2_impl.h index 7ee3339db..da16b3baa 100644 --- a/src/core/libraries/videodec/videodec2_impl.h +++ b/src/core/libraries/videodec/videodec2_impl.h @@ -13,7 +13,7 @@ extern "C" { #include } -namespace Libraries::Vdec2 { +namespace Libraries::Videodec2 { extern std::vector gPictureInfos; extern std::vector gLegacyPictureInfos; @@ -37,4 +37,4 @@ private: SwsContext* mSwsContext = nullptr; }; -} // namespace Libraries::Vdec2 \ No newline at end of file +} // namespace Libraries::Videodec2 \ No newline at end of file