2018-07-18 03:00:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "decoder.h"
|
|
|
|
#include "ffmpeg-renderers/renderer.h"
|
2018-08-16 06:57:03 +00:00
|
|
|
#include "ffmpeg-renderers/pacer/pacer.h"
|
2018-07-18 03:00:16 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
class FFmpegVideoDecoder : public IVideoDecoder {
|
|
|
|
public:
|
|
|
|
FFmpegVideoDecoder();
|
|
|
|
virtual ~FFmpegVideoDecoder();
|
|
|
|
virtual bool initialize(StreamingPreferences::VideoDecoderSelection vds,
|
|
|
|
SDL_Window* window,
|
|
|
|
int videoFormat,
|
|
|
|
int width,
|
|
|
|
int height,
|
2018-08-21 01:19:42 +00:00
|
|
|
int maxFps,
|
|
|
|
bool enableVsync) override;
|
2018-07-18 03:00:16 +00:00
|
|
|
virtual bool isHardwareAccelerated() override;
|
|
|
|
virtual int submitDecodeUnit(PDECODE_UNIT du) override;
|
|
|
|
virtual void renderFrame(SDL_UserEvent* event) override;
|
|
|
|
virtual void dropFrame(SDL_UserEvent* event) override;
|
|
|
|
|
2018-08-03 05:28:59 +00:00
|
|
|
virtual IFFmpegRenderer* getRenderer();
|
|
|
|
|
2018-07-18 03:00:16 +00:00
|
|
|
private:
|
2018-08-16 06:57:03 +00:00
|
|
|
bool completeInitialization(AVCodec* decoder, SDL_Window* window,
|
|
|
|
int videoFormat, int width, int height,
|
2018-08-21 01:19:42 +00:00
|
|
|
int maxFps, bool enableVsync, bool testOnly);
|
2018-08-03 04:37:46 +00:00
|
|
|
|
2018-08-03 04:57:16 +00:00
|
|
|
IFFmpegRenderer* createAcceleratedRenderer(const AVCodecHWConfig* hwDecodeCfg);
|
|
|
|
|
2018-08-03 04:37:46 +00:00
|
|
|
void reset();
|
|
|
|
|
|
|
|
static
|
|
|
|
enum AVPixelFormat ffGetFormat(AVCodecContext* context,
|
|
|
|
const enum AVPixelFormat* pixFmts);
|
2018-07-18 03:00:16 +00:00
|
|
|
|
|
|
|
AVPacket m_Pkt;
|
|
|
|
AVCodecContext* m_VideoDecoderCtx;
|
|
|
|
QByteArray m_DecodeBuffer;
|
|
|
|
const AVCodecHWConfig* m_HwDecodeCfg;
|
|
|
|
IFFmpegRenderer* m_Renderer;
|
2018-07-20 20:10:54 +00:00
|
|
|
SDL_atomic_t m_QueuedFrames;
|
2018-08-10 01:39:38 +00:00
|
|
|
int m_ConsecutiveFailedDecodes;
|
2018-08-16 06:57:03 +00:00
|
|
|
Pacer* m_Pacer;
|
2018-08-03 04:37:46 +00:00
|
|
|
|
|
|
|
static const uint8_t k_H264TestFrame[];
|
|
|
|
static const uint8_t k_HEVCTestFrame[];
|
2018-07-18 03:00:16 +00:00
|
|
|
};
|