2018-07-18 03:00:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-04-19 03:02:14 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2018-07-18 03:00:16 +00:00
|
|
|
#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;
|
2019-04-12 05:27:20 +00:00
|
|
|
virtual bool initialize(PDECODER_PARAMETERS params) 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;
|
2019-04-10 04:46:14 +00:00
|
|
|
virtual void renderFrameOnMainThread() override;
|
2018-07-18 03:00:16 +00:00
|
|
|
|
2019-04-12 05:27:20 +00:00
|
|
|
virtual IFFmpegRenderer* getBackendRenderer();
|
2018-08-03 05:28:59 +00:00
|
|
|
|
2018-07-18 03:00:16 +00:00
|
|
|
private:
|
2019-04-12 05:27:20 +00:00
|
|
|
bool completeInitialization(AVCodec* decoder, PDECODER_PARAMETERS params, 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);
|
|
|
|
|
2019-04-12 05:27:20 +00:00
|
|
|
bool createFrontendRenderer(PDECODER_PARAMETERS params);
|
|
|
|
|
2019-04-19 03:02:14 +00:00
|
|
|
bool tryInitializeRenderer(AVCodec* decoder,
|
|
|
|
PDECODER_PARAMETERS params,
|
|
|
|
const AVCodecHWConfig* hwConfig,
|
|
|
|
std::function<IFFmpegRenderer*()> createRendererFunc);
|
|
|
|
|
|
|
|
static IFFmpegRenderer* createHwAccelRenderer(const AVCodecHWConfig* hwDecodeCfg);
|
2018-08-03 04:57:16 +00:00
|
|
|
|
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;
|
2019-04-12 05:27:20 +00:00
|
|
|
IFFmpegRenderer* m_BackendRenderer;
|
|
|
|
IFFmpegRenderer* m_FrontendRenderer;
|
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
|
|
|
};
|