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-07-25 19:46:25 -04:00
|
|
|
struct HdPpuPixelInfo;
|
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:
|
2015-07-23 23:16:31 -04:00
|
|
|
static unique_ptr<VideoDecoder> Instance;
|
2015-08-30 21:04:21 -04:00
|
|
|
|
|
|
|
uint16_t *_ppuOutputBuffer = nullptr;
|
|
|
|
HdPpuPixelInfo *_hdScreenTiles = nullptr;
|
2017-08-15 23:59:55 -04:00
|
|
|
bool _hdFilterEnabled = false;
|
2015-08-30 21:04:21 -04:00
|
|
|
|
|
|
|
unique_ptr<thread> _decodeThread;
|
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:
|
2015-07-23 23:16:31 -04:00
|
|
|
static VideoDecoder* GetInstance();
|
2015-08-30 21:04:21 -04:00
|
|
|
VideoDecoder();
|
2015-07-23 23:16:31 -04:00
|
|
|
~VideoDecoder();
|
|
|
|
|
2016-12-27 15:04:20 -05:00
|
|
|
static void Release();
|
|
|
|
|
2017-11-26 18:19:37 -05:00
|
|
|
void DecodeFrame(bool synchronous = false);
|
2016-06-17 20:53:05 -04:00
|
|
|
void TakeScreenshot();
|
2017-05-06 15:27:48 -04:00
|
|
|
void TakeScreenshot(std::stringstream &stream);
|
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
|
|
|
|
2015-08-08 22:36:39 -04:00
|
|
|
void DebugDecodeFrame(uint16_t* inputBuffer, uint32_t* outputBuffer, uint32_t length);
|
2015-08-30 21:04:21 -04:00
|
|
|
|
2017-04-28 19:54:58 -04:00
|
|
|
void UpdateFrameSync(void* frameBuffer, HdPpuPixelInfo *screenTiles = nullptr);
|
2016-01-12 19:42:28 -05:00
|
|
|
void UpdateFrame(void* frameBuffer, HdPpuPixelInfo *screenTiles = 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
|
|
|
};
|