Mesen-X/Core/VideoDecoder.h

77 lines
1.6 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"
#include "../Utilities/AviWriter.h"
2015-07-23 23:16:31 -04:00
#include "EmulationSettings.h"
#include "HdNesPack.h"
2016-12-22 23:08:34 -05:00
#include "FrameInfo.h"
class AviRecorder;
class BaseVideoFilter;
class IRenderingDevice;
struct ScreenSize
{
int32_t Width;
int32_t Height;
2016-12-22 23:08:34 -05:00
double Scale;
};
class VideoDecoder
{
private:
2015-07-23 23:16:31 -04:00
static unique_ptr<VideoDecoder> Instance;
uint16_t *_ppuOutputBuffer = nullptr;
HdPpuPixelInfo *_hdScreenTiles = nullptr;
unique_ptr<thread> _decodeThread;
shared_ptr<AviRecorder> _aviRecorder;
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;
VideoFilterType _videoFilterType = VideoFilterType::None;
2016-12-11 10:56:23 -05:00
unique_ptr<BaseVideoFilter> _videoFilter;
void UpdateVideoFilter();
void DecodeThread();
public:
2015-07-23 23:16:31 -04:00
static VideoDecoder* GetInstance();
VideoDecoder();
2015-07-23 23:16:31 -04:00
~VideoDecoder();
static void Release();
void DecodeFrame();
void TakeScreenshot();
uint32_t GetFrameCount();
void GetScreenSize(ScreenSize &size, bool ignoreScale);
void DebugDecodeFrame(uint16_t* inputBuffer, uint32_t* outputBuffer, uint32_t length);
void UpdateFrame(void* frameBuffer, HdPpuPixelInfo *screenTiles = nullptr);
bool IsRunning();
void StartThread();
void StopThread();
void StartRecording(string filename, VideoCodec codec, uint32_t compressionLevel);
void AddRecordingSound(int16_t* soundBuffer, uint32_t sampleCount, uint32_t sampleRate);
void StopRecording();
bool IsRecording();
};