Skip to content

Commit c126f44

Browse files
committed
Port over LunaMoo's compat flag for The Warriors video playback
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.
1 parent 163af21 commit c126f44

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

Core/Compatibility.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
140140
CheckSetting(iniFile, gameID, "FramebufferAllowLargeVerticalOffset", &flags_.FramebufferAllowLargeVerticalOffset);
141141
CheckSetting(iniFile, gameID, "DisableMemcpySlicing", &flags_.DisableMemcpySlicing);
142142
CheckSetting(iniFile, gameID, "ForceEnableGPUReadback", &flags_.ForceEnableGPUReadback);
143+
CheckSetting(iniFile, gameID, "UseFFMPEGFindStreamInfo", &flags_.UseFFMPEGFindStreamInfo);
143144
}
144145

145146
void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) {

Core/Compatibility.h

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct CompatFlags {
110110
bool FramebufferAllowLargeVerticalOffset;
111111
bool DisableMemcpySlicing;
112112
bool ForceEnableGPUReadback;
113+
bool UseFFMPEGFindStreamInfo;
113114
};
114115

115116
struct VRCompat {

Core/HW/MediaEngine.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "Common/Serialize/SerializeFuncs.h"
1919
#include "Common/Math/CrossSIMD.h"
2020
#include "Core/Config.h"
21+
#include "Core/Core.h"
2122
#include "Core/Debugger/MemBlockInfo.h"
2223
#include "Core/HW/MediaEngine.h"
2324
#include "Core/MemMap.h"
@@ -303,14 +304,16 @@ bool MediaEngine::openContext(bool keepReadPos) {
303304
}
304305
av_dict_free(&open_opt);
305306

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

316319
if (m_videoStream >= (int)m_pFormatCtx->nb_streams) {
@@ -342,6 +345,11 @@ bool MediaEngine::openContext(bool keepReadPos) {
342345
setVideoDim();
343346
m_audioContext = CreateAudioDecoder((PSPAudioType)m_audioType);
344347
m_isVideoEnd = false;
348+
349+
if (usedFFMPEGFindStreamInfo) {
350+
m_mpegheaderReadPos++;
351+
av_seek_frame(m_pFormatCtx, m_videoStream, 0, 0);
352+
}
345353
#endif // USE_FFMPEG
346354
return true;
347355
}

assets/compat.ini

+5
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,11 @@ UCET00278 = true
13641364
UCUS98670 = true
13651365
UCUS98646 = true
13661366

1367+
[UseFFMPEGFindStreamInfo]
1368+
# The Warriors: Works around regression (#8991) by reverting to the old behavior
1369+
ULUS10213 = true
1370+
ULES00483 = true
1371+
13671372
[ForceLowerResolutionForEffectsOn]
13681373
# The water effect of DiRT 2 and Outrun doesn't work in higher resolutions.
13691374

0 commit comments

Comments
 (0)