Mesen-X/Core/VideoDecoder.h

78 lines
1.7 KiB
C
Raw Normal View History

#pragma once
#include "stdafx.h"
#include <thread>
using std::thread;
2015-07-23 23:16:31 -04:00
#include "../Utilities/SimpleLock.h"
#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"
class BaseVideoFilter;
class ScaleFilter;
class RotateFilter;
class IRenderingDevice;
class VideoHud;
class Console;
struct HdScreenInfo;
struct ScreenSize
{
int32_t Width;
int32_t Height;
2016-12-22 23:08:34 -05:00
double Scale;
};
class VideoDecoder
{
private:
shared_ptr<Console> _console;
EmulationSettings* _settings;
uint16_t *_ppuOutputBuffer = nullptr;
HdScreenInfo *_hdScreenInfo = nullptr;
bool _hdFilterEnabled = false;
uint32_t _frameNumber = 0;
unique_ptr<thread> _decodeThread;
unique_ptr<VideoHud> _hud;
AutoResetEvent _waitForFrame;
2016-12-11 10:56:23 -05:00
atomic<bool> _frameChanged;
atomic<bool> _stopFlag;
uint32_t _frameCount = 0;
ScreenSize _previousScreenSize = {};
2016-12-22 23:08:34 -05:00
double _previousScale = 0;
FrameInfo _lastFrameInfo;
2016-12-22 23:08:34 -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;
shared_ptr<RotateFilter> _rotateFilter;
void UpdateVideoFilter();
void DecodeThread();
public:
VideoDecoder(shared_ptr<Console> console);
2015-07-23 23:16:31 -04:00
~VideoDecoder();
void DecodeFrame(bool synchronous = false);
void TakeScreenshot();
void TakeScreenshot(string filePath);
void TakeScreenshot(std::stringstream &stream, bool rawScreenshot = false);
uint32_t GetFrameCount();
2017-04-28 19:54:58 -04:00
FrameInfo GetFrameInfo();
void GetScreenSize(ScreenSize &size, bool ignoreScale);
void UpdateFrameSync(void* frameBuffer, HdScreenInfo *hdScreenInfo = nullptr);
void UpdateFrame(void* frameBuffer, HdScreenInfo *hdScreenInfo = nullptr);
bool IsRunning();
void StartThread();
void StopThread();
};