Mesen-X/Core/VideoDecoder.h

67 lines
1.5 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"
#include "HdNesPack.h"
class IRenderingDevice;
class VideoDecoder
{
private:
2015-07-23 23:16:31 -04:00
static unique_ptr<VideoDecoder> Instance;
2015-12-28 09:56:51 -05:00
IRenderingDevice* _renderer = nullptr;
uint16_t *_ppuOutputBuffer = nullptr;
HdPpuPixelInfo *_hdScreenTiles = nullptr;
unique_ptr<thread> _decodeThread;
unique_ptr<thread> _renderThread;
2015-07-23 23:16:31 -04:00
OverscanDimensions _overscan;
uint32_t* _frameBuffer = nullptr;
SimpleLock _screenshotLock;
AutoResetEvent _waitForFrame;
AutoResetEvent _waitForRender;
bool _isHD = false;
atomic<bool> _frameChanged = false;
atomic<bool> _stopFlag = false;
uint32_t _frameCount = 0;
unique_ptr<HdNesPack> _hdNesPack = nullptr;
uint32_t _hdScale = 1;
2015-07-23 23:16:31 -04:00
uint32_t ProcessIntensifyBits(uint16_t ppuPixel);
void UpdateBufferSize();
void DecodeThread();
void RenderThread();
public:
2015-07-23 23:16:31 -04:00
static VideoDecoder* GetInstance();
VideoDecoder();
2015-07-23 23:16:31 -04:00
~VideoDecoder();
void DecodeFrame();
2015-07-23 23:16:31 -04:00
void TakeScreenshot(string romFilename);
uint32_t GetScale();
uint32_t GetFrameCount();
void DebugDecodeFrame(uint16_t* inputBuffer, uint32_t* outputBuffer, uint32_t length);
bool UpdateFrame(void* frameBuffer, HdPpuPixelInfo *screenTiles = nullptr);
void StartThread();
void StopThread();
void RegisterRenderingDevice(IRenderingDevice *renderer);
2015-12-26 17:11:00 -05:00
void UnregisterRenderingDevice(IRenderingDevice *renderer);
};