2013-01-14 00:22:24 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
#include "MpegVideoState.h"
|
|
|
|
#include "bitmap/Bitmap.h"
|
2019-08-26 13:16:36 -04:00
|
|
|
#include "signal/Signal.h"
|
2013-01-14 00:22:24 +00:00
|
|
|
#include <thread>
|
|
|
|
|
2019-06-06 00:42:16 +01:00
|
|
|
class CVideoDecoder
|
2013-01-14 00:22:24 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-06-20 00:40:28 +01:00
|
|
|
typedef Framework::CSignal<void(const Framework::CBitmap&)> NewFrameEvent;
|
2013-01-14 00:22:24 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CVideoDecoder(std::string);
|
|
|
|
virtual ~CVideoDecoder();
|
2019-06-06 00:42:16 +01:00
|
|
|
|
|
|
|
CVideoDecoder(const CVideoDecoder&) = delete;
|
|
|
|
CVideoDecoder& operator=(const CVideoDecoder&) = delete;
|
2013-01-14 00:22:24 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
NewFrameEvent NewFrame;
|
2013-01-14 00:22:24 +00:00
|
|
|
|
|
|
|
private:
|
2013-01-26 09:10:10 +00:00
|
|
|
struct FRAME
|
|
|
|
{
|
|
|
|
public:
|
2018-04-30 21:01:23 +01:00
|
|
|
FRAME();
|
|
|
|
FRAME(FRAME&&);
|
|
|
|
FRAME(unsigned int, unsigned int);
|
|
|
|
~FRAME();
|
2013-01-26 09:10:10 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
FRAME& operator=(FRAME&&);
|
2013-01-26 09:10:10 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
bool IsEmpty() const;
|
|
|
|
unsigned int GetWidth() const;
|
|
|
|
unsigned int GetHeight() const;
|
2013-01-26 09:10:10 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
Framework::CBitmap y;
|
|
|
|
Framework::CBitmap cr;
|
|
|
|
Framework::CBitmap cb;
|
2013-01-26 09:10:10 +00:00
|
|
|
};
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CVideoDecoder(CVideoDecoder&&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CVideoDecoder& operator=(CVideoDecoder&&)
|
|
|
|
{
|
|
|
|
}
|
2013-01-14 00:22:24 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void DecoderThreadProc(std::string);
|
|
|
|
void OnMacroblockDecoded(MPEG_VIDEO_STATE*);
|
|
|
|
void OnPictureDecoded(MPEG_VIDEO_STATE*);
|
|
|
|
static void CopyBlock8x8(Framework::CBitmap&, unsigned int, unsigned int, const int16*);
|
|
|
|
static void CopyBlock8x8(int16*, unsigned int, unsigned int, int16, int16, const Framework::CBitmap&);
|
|
|
|
static void CopyMacroblock(Framework::CBitmap&, unsigned int, unsigned int, const uint32*);
|
2013-01-14 00:22:24 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
std::thread m_decoderThread;
|
|
|
|
bool m_threadDone;
|
2013-01-26 09:10:10 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
FRAME m_previousFrame;
|
|
|
|
FRAME m_currentFrame;
|
2013-01-26 09:10:10 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
Framework::CBitmap m_frame;
|
2013-01-14 00:22:24 +00:00
|
|
|
};
|