2015-07-22 22:08:28 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
2015-08-30 21:04:21 -04:00
|
|
|
#include <thread>
|
|
|
|
using std::thread;
|
|
|
|
|
2015-07-23 23:16:31 -04:00
|
|
|
#include "../Utilities/SimpleLock.h"
|
2015-08-30 21:04:21 -04:00
|
|
|
#include "../Utilities/AutoResetEvent.h"
|
2015-07-23 23:16:31 -04:00
|
|
|
#include "EmulationSettings.h"
|
2016-12-22 23:08:34 -05:00
|
|
|
#include "FrameInfo.h"
|
2015-07-22 22:08:28 -04:00
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
class BaseVideoFilter;
|
2017-08-15 23:59:55 -04:00
|
|
|
class ScaleFilter;
|
2017-11-11 20:55:33 -05:00
|
|
|
class RotateFilter;
|
2015-08-30 21:04:21 -04:00
|
|
|
class IRenderingDevice;
|
2017-11-28 22:44:06 -05:00
|
|
|
class VideoHud;
|
2018-07-01 15:21:05 -04:00
|
|
|
class Console;
|
2018-02-17 23:44:25 -05:00
|
|
|
struct HdScreenInfo;
|
2015-08-30 21:04:21 -04:00
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
struct ScreenSize
|
|
|
|
{
|
|
|
|
int32_t Width;
|
|
|
|
int32_t Height;
|
2016-12-22 23:08:34 -05:00
|
|
|
double Scale;
|
2016-01-05 21:28:38 -05:00
|
|
|
};
|
|
|
|
|
2015-07-22 22:08:28 -04:00
|
|
|
class VideoDecoder
|
|
|
|
{
|
|
|
|
private:
|
2018-07-01 15:21:05 -04:00
|
|
|
shared_ptr<Console> _console;
|
2019-12-24 13:46:10 -05:00
|
|
|
EmulationSettings* _settings;
|
2015-08-30 21:04:21 -04:00
|
|
|
uint16_t *_ppuOutputBuffer = nullptr;
|
2018-02-17 23:44:25 -05:00
|
|
|
HdScreenInfo *_hdScreenInfo = nullptr;
|
2017-08-15 23:59:55 -04:00
|
|
|
bool _hdFilterEnabled = false;
|
2018-03-24 09:48:45 -04:00
|
|
|
uint32_t _frameNumber = 0;
|
2015-08-30 21:04:21 -04:00
|
|
|
|
|
|
|
unique_ptr<thread> _decodeThread;
|
2017-11-28 22:44:06 -05:00
|
|
|
unique_ptr<VideoHud> _hud;
|
2015-07-22 22:08:28 -04:00
|
|
|
|
2015-08-30 21:04:21 -04:00
|
|
|
AutoResetEvent _waitForFrame;
|
2016-01-05 21:28:38 -05:00
|
|
|
|
2016-12-11 10:56:23 -05:00
|
|
|
atomic<bool> _frameChanged;
|
|
|
|
atomic<bool> _stopFlag;
|
2015-08-30 21:04:21 -04:00
|
|
|
uint32_t _frameCount = 0;
|
|
|
|
|
2016-12-30 16:43:49 -05:00
|
|
|
ScreenSize _previousScreenSize = {};
|
2016-12-22 23:08:34 -05:00
|
|
|
double _previousScale = 0;
|
2017-11-11 20:55:33 -05:00
|
|
|
FrameInfo _lastFrameInfo;
|
2016-12-22 23:08:34 -05:00
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
VideoFilterType _videoFilterType = VideoFilterType::None;
|
2016-12-11 10:56:23 -05:00
|
|
|
unique_ptr<BaseVideoFilter> _videoFilter;
|
2017-09-01 16:00:55 -04:00
|
|
|
shared_ptr<ScaleFilter> _scaleFilter;
|
2017-11-11 20:55:33 -05:00
|
|
|
shared_ptr<RotateFilter> _rotateFilter;
|
2015-08-14 21:50:14 -04:00
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
void UpdateVideoFilter();
|
2015-08-30 21:04:21 -04:00
|
|
|
|
|
|
|
void DecodeThread();
|
2015-07-22 22:08:28 -04:00
|
|
|
|
|
|
|
public:
|
2018-07-01 15:21:05 -04:00
|
|
|
VideoDecoder(shared_ptr<Console> console);
|
2015-07-23 23:16:31 -04:00
|
|
|
~VideoDecoder();
|
|
|
|
|
2017-11-26 18:19:37 -05:00
|
|
|
void DecodeFrame(bool synchronous = false);
|
2016-06-17 20:53:05 -04:00
|
|
|
void TakeScreenshot();
|
2020-12-20 22:26:12 +08:00
|
|
|
void TakeScreenshot(string filePath);
|
2020-01-28 20:20:54 -05:00
|
|
|
void TakeScreenshot(std::stringstream &stream, bool rawScreenshot = false);
|
2015-08-08 22:36:39 -04:00
|
|
|
|
2015-08-30 21:04:21 -04:00
|
|
|
uint32_t GetFrameCount();
|
2015-08-14 21:50:14 -04:00
|
|
|
|
2017-04-28 19:54:58 -04:00
|
|
|
FrameInfo GetFrameInfo();
|
2016-02-07 13:05:32 -05:00
|
|
|
void GetScreenSize(ScreenSize &size, bool ignoreScale);
|
2016-01-05 21:28:38 -05:00
|
|
|
|
2018-02-17 23:44:25 -05:00
|
|
|
void UpdateFrameSync(void* frameBuffer, HdScreenInfo *hdScreenInfo = nullptr);
|
|
|
|
void UpdateFrame(void* frameBuffer, HdScreenInfo *hdScreenInfo = nullptr);
|
2015-08-30 21:04:21 -04:00
|
|
|
|
2016-01-31 00:41:33 -05:00
|
|
|
bool IsRunning();
|
2015-08-30 21:04:21 -04:00
|
|
|
void StartThread();
|
|
|
|
void StopThread();
|
2015-07-22 22:08:28 -04:00
|
|
|
};
|