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"
|
2015-08-14 21:50:14 -04:00
|
|
|
#include "HdNesPack.h"
|
2015-07-22 22:08:28 -04:00
|
|
|
|
2015-08-30 21:04:21 -04:00
|
|
|
|
|
|
|
class IRenderingDevice;
|
|
|
|
|
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
|
|
|
|
2015-12-28 09:56:51 -05:00
|
|
|
IRenderingDevice* _renderer = nullptr;
|
2015-08-30 21:04:21 -04:00
|
|
|
|
|
|
|
uint16_t *_ppuOutputBuffer = nullptr;
|
|
|
|
HdPpuPixelInfo *_hdScreenTiles = nullptr;
|
|
|
|
|
|
|
|
unique_ptr<thread> _decodeThread;
|
|
|
|
unique_ptr<thread> _renderThread;
|
2015-07-22 22:08:28 -04:00
|
|
|
|
2015-07-23 23:16:31 -04:00
|
|
|
OverscanDimensions _overscan;
|
|
|
|
uint32_t* _frameBuffer = nullptr;
|
2015-08-30 21:04:21 -04:00
|
|
|
SimpleLock _screenshotLock;
|
|
|
|
AutoResetEvent _waitForFrame;
|
|
|
|
AutoResetEvent _waitForRender;
|
2015-07-22 22:08:28 -04:00
|
|
|
|
2015-08-30 21:04:21 -04:00
|
|
|
bool _isHD = false;
|
|
|
|
atomic<bool> _frameChanged = false;
|
|
|
|
atomic<bool> _stopFlag = false;
|
|
|
|
uint32_t _frameCount = 0;
|
|
|
|
|
|
|
|
unique_ptr<HdNesPack> _hdNesPack = nullptr;
|
2015-08-14 21:50:14 -04:00
|
|
|
uint32_t _hdScale = 1;
|
|
|
|
|
2015-07-23 23:16:31 -04:00
|
|
|
uint32_t ProcessIntensifyBits(uint16_t ppuPixel);
|
2015-08-30 21:04:21 -04:00
|
|
|
void UpdateBufferSize();
|
|
|
|
|
|
|
|
void DecodeThread();
|
|
|
|
void RenderThread();
|
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();
|
|
|
|
|
2015-08-30 21:04:21 -04:00
|
|
|
void DecodeFrame();
|
2015-07-23 23:16:31 -04:00
|
|
|
void TakeScreenshot(string romFilename);
|
2015-08-08 22:36:39 -04:00
|
|
|
|
2015-08-14 21:50:14 -04:00
|
|
|
uint32_t GetScale();
|
2015-08-30 21:04:21 -04:00
|
|
|
uint32_t GetFrameCount();
|
2015-08-14 21:50:14 -04: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
|
|
|
|
|
|
|
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);
|
2015-07-22 22:08:28 -04:00
|
|
|
};
|