2015-07-23 02:08:28 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
2015-08-31 01:04:21 +00:00
|
|
|
#include <thread>
|
|
|
|
using std::thread;
|
|
|
|
|
2015-07-24 03:16:31 +00:00
|
|
|
#include "../Utilities/SimpleLock.h"
|
2015-08-31 01:04:21 +00:00
|
|
|
#include "../Utilities/AutoResetEvent.h"
|
2015-07-24 03:16:31 +00:00
|
|
|
#include "EmulationSettings.h"
|
2016-12-23 04:08:34 +00:00
|
|
|
#include "FrameInfo.h"
|
2015-07-23 02:08:28 +00:00
|
|
|
|
2016-01-06 02:28:38 +00:00
|
|
|
class BaseVideoFilter;
|
2017-08-16 03:59:55 +00:00
|
|
|
class ScaleFilter;
|
2015-08-31 01:04:21 +00:00
|
|
|
class IRenderingDevice;
|
2017-07-25 23:46:25 +00:00
|
|
|
struct HdPpuPixelInfo;
|
2015-08-31 01:04:21 +00:00
|
|
|
|
2016-01-06 02:28:38 +00:00
|
|
|
struct ScreenSize
|
|
|
|
{
|
|
|
|
int32_t Width;
|
|
|
|
int32_t Height;
|
2016-12-23 04:08:34 +00:00
|
|
|
double Scale;
|
2016-01-06 02:28:38 +00:00
|
|
|
};
|
|
|
|
|
2015-07-23 02:08:28 +00:00
|
|
|
class VideoDecoder
|
|
|
|
{
|
|
|
|
private:
|
2015-07-24 03:16:31 +00:00
|
|
|
static unique_ptr<VideoDecoder> Instance;
|
2015-08-31 01:04:21 +00:00
|
|
|
|
|
|
|
uint16_t *_ppuOutputBuffer = nullptr;
|
|
|
|
HdPpuPixelInfo *_hdScreenTiles = nullptr;
|
2017-08-16 03:59:55 +00:00
|
|
|
bool _hdFilterEnabled = false;
|
2015-08-31 01:04:21 +00:00
|
|
|
|
|
|
|
unique_ptr<thread> _decodeThread;
|
2015-07-23 02:08:28 +00:00
|
|
|
|
2015-08-31 01:04:21 +00:00
|
|
|
AutoResetEvent _waitForFrame;
|
2016-01-06 02:28:38 +00:00
|
|
|
|
2016-12-11 15:56:23 +00:00
|
|
|
atomic<bool> _frameChanged;
|
|
|
|
atomic<bool> _stopFlag;
|
2015-08-31 01:04:21 +00:00
|
|
|
uint32_t _frameCount = 0;
|
|
|
|
|
2016-12-30 21:43:49 +00:00
|
|
|
ScreenSize _previousScreenSize = {};
|
2016-12-23 04:08:34 +00:00
|
|
|
double _previousScale = 0;
|
|
|
|
|
2016-01-06 02:28:38 +00:00
|
|
|
VideoFilterType _videoFilterType = VideoFilterType::None;
|
2016-12-11 15:56:23 +00:00
|
|
|
unique_ptr<BaseVideoFilter> _videoFilter;
|
2017-09-01 20:00:55 +00:00
|
|
|
shared_ptr<ScaleFilter> _scaleFilter;
|
2015-08-15 01:50:14 +00:00
|
|
|
|
2016-01-06 02:28:38 +00:00
|
|
|
void UpdateVideoFilter();
|
2015-08-31 01:04:21 +00:00
|
|
|
|
|
|
|
void DecodeThread();
|
2015-07-23 02:08:28 +00:00
|
|
|
|
|
|
|
public:
|
2015-07-24 03:16:31 +00:00
|
|
|
static VideoDecoder* GetInstance();
|
2015-08-31 01:04:21 +00:00
|
|
|
VideoDecoder();
|
2015-07-24 03:16:31 +00:00
|
|
|
~VideoDecoder();
|
|
|
|
|
2016-12-27 20:04:20 +00:00
|
|
|
static void Release();
|
|
|
|
|
2015-08-31 01:04:21 +00:00
|
|
|
void DecodeFrame();
|
2016-06-18 00:53:05 +00:00
|
|
|
void TakeScreenshot();
|
2017-05-06 19:27:48 +00:00
|
|
|
void TakeScreenshot(std::stringstream &stream);
|
2015-08-09 02:36:39 +00:00
|
|
|
|
2015-08-31 01:04:21 +00:00
|
|
|
uint32_t GetFrameCount();
|
2015-08-15 01:50:14 +00:00
|
|
|
|
2017-04-28 23:54:58 +00:00
|
|
|
FrameInfo GetFrameInfo();
|
2016-02-07 18:05:32 +00:00
|
|
|
void GetScreenSize(ScreenSize &size, bool ignoreScale);
|
2016-01-06 02:28:38 +00:00
|
|
|
|
2015-08-09 02:36:39 +00:00
|
|
|
void DebugDecodeFrame(uint16_t* inputBuffer, uint32_t* outputBuffer, uint32_t length);
|
2015-08-31 01:04:21 +00:00
|
|
|
|
2017-04-28 23:54:58 +00:00
|
|
|
void UpdateFrameSync(void* frameBuffer, HdPpuPixelInfo *screenTiles = nullptr);
|
2016-01-13 00:42:28 +00:00
|
|
|
void UpdateFrame(void* frameBuffer, HdPpuPixelInfo *screenTiles = nullptr);
|
2015-08-31 01:04:21 +00:00
|
|
|
|
2016-01-31 05:41:33 +00:00
|
|
|
bool IsRunning();
|
2015-08-31 01:04:21 +00:00
|
|
|
void StartThread();
|
|
|
|
void StopThread();
|
2015-07-23 02:08:28 +00:00
|
|
|
};
|