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"
|
2016-12-29 21:19:13 -05:00
|
|
|
#include "../Utilities/AviWriter.h"
|
2015-07-23 23:16:31 -04:00
|
|
|
#include "EmulationSettings.h"
|
2015-08-14 21:50:14 -04:00
|
|
|
#include "HdNesPack.h"
|
2016-12-22 23:08:34 -05:00
|
|
|
#include "FrameInfo.h"
|
2015-07-22 22:08:28 -04:00
|
|
|
|
2016-12-29 21:19:13 -05:00
|
|
|
class AviRecorder;
|
2016-01-05 21:28:38 -05:00
|
|
|
class BaseVideoFilter;
|
2015-08-30 21:04:21 -04:00
|
|
|
class IRenderingDevice;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
unique_ptr<thread> _decodeThread;
|
2016-12-29 21:19:13 -05:00
|
|
|
shared_ptr<AviRecorder> _aviRecorder;
|
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;
|
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
VideoFilterType _videoFilterType = VideoFilterType::None;
|
2016-12-11 10:56:23 -05:00
|
|
|
unique_ptr<BaseVideoFilter> _videoFilter;
|
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();
|
|
|
|
|
2015-08-30 21:04:21 -04:00
|
|
|
void DecodeFrame();
|
2016-06-17 20:53:05 -04:00
|
|
|
void TakeScreenshot();
|
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
|
|
|
|
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
|
|
|
|
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();
|
2016-12-29 21:19:13 -05:00
|
|
|
|
2017-01-01 10:15:42 -05:00
|
|
|
void StartRecording(string filename, VideoCodec codec, uint32_t compressionLevel);
|
2016-12-29 21:19:13 -05:00
|
|
|
void AddRecordingSound(int16_t* soundBuffer, uint32_t sampleCount, uint32_t sampleRate);
|
|
|
|
void StopRecording();
|
|
|
|
bool IsRecording();
|
2015-07-22 22:08:28 -04:00
|
|
|
};
|