Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port over LunaMoo's compat flag for The Warriors video playback #19450

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/Compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
CheckSetting(iniFile, gameID, "FramebufferAllowLargeVerticalOffset", &flags_.FramebufferAllowLargeVerticalOffset);
CheckSetting(iniFile, gameID, "DisableMemcpySlicing", &flags_.DisableMemcpySlicing);
CheckSetting(iniFile, gameID, "ForceEnableGPUReadback", &flags_.ForceEnableGPUReadback);
CheckSetting(iniFile, gameID, "UseFFMPEGFindStreamInfo", &flags_.UseFFMPEGFindStreamInfo);
}

void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) {
Expand Down
1 change: 1 addition & 0 deletions Core/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ struct CompatFlags {
bool FramebufferAllowLargeVerticalOffset;
bool DisableMemcpySlicing;
bool ForceEnableGPUReadback;
bool UseFFMPEGFindStreamInfo;
};

struct VRCompat {
Expand Down
10 changes: 9 additions & 1 deletion Core/HW/MediaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Common/Serialize/SerializeFuncs.h"
#include "Common/Math/CrossSIMD.h"
#include "Core/Config.h"
#include "Core/Core.h"
#include "Core/Debugger/MemBlockInfo.h"
#include "Core/HW/MediaEngine.h"
#include "Core/MemMap.h"
Expand Down Expand Up @@ -303,14 +304,16 @@ bool MediaEngine::openContext(bool keepReadPos) {
}
av_dict_free(&open_opt);

if (!SetupStreams()) {
bool usedFFMPEGFindStreamInfo = false;
if (!SetupStreams() || PSP_CoreParameter().compat.flags().UseFFMPEGFindStreamInfo) {
// Fallback to old behavior. Reads too much and corrupts when game doesn't read fast enough.
// SetupStreams sometimes work for newer FFmpeg 3.1+ now, but sometimes framerate is missing.
WARN_LOG_REPORT_ONCE(setupStreams, Log::ME, "Failed to read valid video stream data from header");
if (avformat_find_stream_info(m_pFormatCtx, nullptr) < 0) {
closeContext();
return false;
}
usedFFMPEGFindStreamInfo = true;
}

if (m_videoStream >= (int)m_pFormatCtx->nb_streams) {
Expand Down Expand Up @@ -342,6 +345,11 @@ bool MediaEngine::openContext(bool keepReadPos) {
setVideoDim();
m_audioContext = CreateAudioDecoder((PSPAudioType)m_audioType);
m_isVideoEnd = false;

if (PSP_CoreParameter().compat.flags().UseFFMPEGFindStreamInfo && usedFFMPEGFindStreamInfo) {
m_mpegheaderReadPos++;
av_seek_frame(m_pFormatCtx, m_videoStream, 0, 0);
}
#endif // USE_FFMPEG
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions assets/compat.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,11 @@ UCET00278 = true
UCUS98670 = true
UCUS98646 = true

[UseFFMPEGFindStreamInfo]
# The Warriors: Works around regression (#8991) by reverting to the old behavior
ULUS10213 = true
ULES00483 = true

[ForceLowerResolutionForEffectsOn]
# The water effect of DiRT 2 and Outrun doesn't work in higher resolutions.

Expand Down
Loading