diff --git a/src/core/cheats/cheats.cpp b/src/core/cheats/cheats.cpp index 9053b5ca68..75192f584f 100644 --- a/src/core/cheats/cheats.cpp +++ b/src/core/cheats/cheats.cpp @@ -11,10 +11,11 @@ #include "core/core.h" #include "core/core_timing.h" #include "core/hle/kernel/process.h" +#include "core/hw/gpu.h" namespace Cheats { -constexpr u64 run_interval_ticks = BASE_CLOCK_RATE_ARM11 / 60; +constexpr u64 run_interval_ticks = GPU::frame_ticks; CheatEngine::CheatEngine(Core::System& system_) : system(system_) { LoadCheatFile(); diff --git a/src/core/dumping/ffmpeg_backend.cpp b/src/core/dumping/ffmpeg_backend.cpp index 05cc25acf3..dc7928fe00 100644 --- a/src/core/dumping/ffmpeg_backend.cpp +++ b/src/core/dumping/ffmpeg_backend.cpp @@ -9,6 +9,7 @@ #include "common/param_package.h" #include "common/string_util.h" #include "core/dumping/ffmpeg_backend.h" +#include "core/hw/gpu.h" #include "core/settings.h" #include "video_core/renderer_base.h" #include "video_core/video_core.h" @@ -124,8 +125,13 @@ bool FFmpegVideoStream::Init(FFmpegMuxer& muxer, const Layout::FramebufferLayout codec_context->bit_rate = Settings::values.video_bitrate; codec_context->width = layout.width; codec_context->height = layout.height; - codec_context->time_base.num = 1; - codec_context->time_base.den = 60; + // TODO(xperia64): While these numbers from core timing work fine, certain video codecs do not + // support the strange resulting timebase (280071/16756991); Addressing this issue would require + // resampling the video + // List of codecs known broken by this change: mpeg1, mpeg2, mpeg4, libxvid + // See https://github.com/citra-emu/citra/pull/5273#issuecomment-643023325 for more information + codec_context->time_base.num = static_cast(GPU::frame_ticks); + codec_context->time_base.den = static_cast(BASE_CLOCK_RATE_ARM11); codec_context->gop_size = 12; codec_context->pix_fmt = codec->pix_fmts ? codec->pix_fmts[0] : AV_PIX_FMT_YUV420P; if (format_context->oformat->flags & AVFMT_GLOBALHEADER) diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 4f6a31441b..e31ea4e5cc 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -30,8 +30,6 @@ namespace GPU { Regs g_regs; Memory::MemorySystem* g_memory; -/// 268MHz CPU clocks / 60Hz frames per second -const u64 frame_ticks = static_cast(BASE_CLOCK_RATE_ARM11 / SCREEN_REFRESH_RATE); /// Event id for CoreTiming static Core::TimingEventType* vblank_event; diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 3252364e25..1e49967e9f 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -12,6 +12,7 @@ #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" +#include "core/core_timing.h" namespace Memory { class MemorySystem; @@ -19,7 +20,12 @@ class MemorySystem; namespace GPU { -constexpr float SCREEN_REFRESH_RATE = 60; +// Measured on hardware to be 2240568 timer cycles or 4481136 ARM11 cycles +constexpr u64 frame_ticks = 4481136ull; + +// Refresh rate defined by ratio of ARM11 frequency to ARM11 ticks per frame +// (268,111,856) / (4,481,136) = 59.83122493939037Hz +constexpr double SCREEN_REFRESH_RATE = BASE_CLOCK_RATE_ARM11 / static_cast(frame_ticks); // Returns index corresponding to the Regs member labeled by field_name #define GPU_REG_INDEX(field_name) (offsetof(GPU::Regs, field_name) / sizeof(u32))