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:
|
2019-02-13 02:42:53 +00:00
|
|
|
FFmpegVideoDecoder(bool testOnly);
|
|
|
|
virtual ~FFmpegVideoDecoder() override;
|
2018-07-18 03:00:16 +00:00
|
|
|
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,
|
2018-12-25 20:57:00 +00:00
|
|
|
bool enableVsync,
|
|
|
|
bool enableFramePacing) override;
|
2018-07-18 03:00:16 +00:00
|
|
|
virtual bool isHardwareAccelerated() override;
|
2018-08-25 19:38:04 +00:00
|
|
|
virtual int getDecoderCapabilities() override;
|
2018-07-18 03:00:16 +00:00
|
|
|
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,
|
2019-02-13 02:42:53 +00:00
|
|
|
int maxFps, bool enableFramePacing, bool testFrame);
|
2018-08-03 04:37:46 +00:00
|
|
|
|
2019-01-20 07:05:56 +00:00
|
|
|
void stringifyVideoStats(VIDEO_STATS& stats, char* output);
|
|
|
|
|
2018-09-25 07:47:59 +00:00
|
|
|
void logVideoStats(VIDEO_STATS& stats, const char* title);
|
|
|
|
|
|
|
|
void addVideoStats(VIDEO_STATS& src, VIDEO_STATS& dst);
|
|
|
|
|
2018-08-03 04:57:16 +00:00
|
|
|
IFFmpegRenderer* createAcceleratedRenderer(const AVCodecHWConfig* hwDecodeCfg);
|
|
|
|
|
2018-08-03 04:37:46 +00:00
|
|
|
void reset();
|
|
|
|
|
2018-10-13 00:59:53 +00:00
|
|
|
void writeBuffer(PLENTRY entry, int& offset);
|
|
|
|
|
2018-08-03 04:37:46 +00:00
|
|
|
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-08-10 01:39:38 +00:00
|
|
|
int m_ConsecutiveFailedDecodes;
|
2018-08-16 06:57:03 +00:00
|
|
|
Pacer* m_Pacer;
|
2018-09-25 07:47:59 +00:00
|
|
|
VIDEO_STATS m_ActiveWndVideoStats;
|
|
|
|
VIDEO_STATS m_LastWndVideoStats;
|
|
|
|
VIDEO_STATS m_GlobalVideoStats;
|
2019-01-20 07:05:56 +00:00
|
|
|
|
2018-09-25 07:47:59 +00:00
|
|
|
int m_LastFrameNumber;
|
|
|
|
int m_StreamFps;
|
2018-10-13 00:59:53 +00:00
|
|
|
bool m_NeedsSpsFixup;
|
2019-02-13 02:42:53 +00:00
|
|
|
bool m_TestOnly;
|
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
|
|
|
};
|