Skip to content

Commit

Permalink
Port over LunaMoo's compat flag for The Warriors video playback
Browse files Browse the repository at this point in the history
This reverts to the old behavior before we started parsing mpeg headers,
that is, in 558b462 which is part of #8867.

LunaMoo has this under "HackFixVideo" in his build.

See #8991. This doesn't really "fix" that, but works around it.
  • Loading branch information
hrydgard committed Sep 11, 2024
1 parent 163af21 commit 16a56aa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
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

0 comments on commit 16a56aa

Please sign in to comment.