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;
|
2020-02-09 19:35:05 +00:00
|
|
|
virtual bool isAlwaysFullScreen() override;
|
2018-08-25 19:38:04 +00:00
|
|
|
virtual int getDecoderCapabilities() override;
|
2019-12-14 23:25:56 +00:00
|
|
|
virtual int getDecoderColorspace() override;
|
2020-02-23 08:43:43 +00:00
|
|
|
virtual QSize getDecoderMaxResolution() 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:
|
2021-05-25 04:26:38 +00:00
|
|
|
bool completeInitialization(const AVCodec* decoder, PDECODER_PARAMETERS params, bool testFrame, bool eglOnly);
|
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);
|
|
|
|
|
2021-03-23 03:51:29 +00:00
|
|
|
bool createFrontendRenderer(PDECODER_PARAMETERS params, bool eglOnly);
|
2019-04-12 05:27:20 +00:00
|
|
|
|
2021-02-03 01:05:27 +00:00
|
|
|
bool tryInitializeRendererForDecoderByName(const char* decoderName,
|
|
|
|
PDECODER_PARAMETERS params);
|
|
|
|
|
2021-05-25 04:26:38 +00:00
|
|
|
bool tryInitializeRenderer(const AVCodec* decoder,
|
2019-04-19 03:02:14 +00:00
|
|
|
PDECODER_PARAMETERS params,
|
|
|
|
const AVCodecHWConfig* hwConfig,
|
|
|
|
std::function<IFFmpegRenderer*()> createRendererFunc);
|
|
|
|
|
2019-06-27 04:54:29 +00:00
|
|
|
static IFFmpegRenderer* createHwAccelRenderer(const AVCodecHWConfig* hwDecodeCfg, int pass);
|
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
|
|
|
|
2021-03-05 23:47:04 +00:00
|
|
|
AVPacket* m_Pkt;
|
2018-07-18 03:00:16 +00:00
|
|
|
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
|
|
|
|
2020-01-27 04:15:11 +00:00
|
|
|
int m_FramesIn;
|
|
|
|
int m_FramesOut;
|
|
|
|
|
2018-09-25 07:47:59 +00:00
|
|
|
int m_LastFrameNumber;
|
|
|
|
int m_StreamFps;
|
2020-01-26 23:02:29 +00:00
|
|
|
int m_VideoFormat;
|
2018-10-13 00:59:53 +00:00
|
|
|
bool m_NeedsSpsFixup;
|
2019-02-13 02:42:53 +00:00
|
|
|
bool m_TestOnly;
|
2021-12-15 02:41:27 +00:00
|
|
|
enum {
|
|
|
|
RRF_UNKNOWN,
|
|
|
|
RRF_YES,
|
|
|
|
RRF_NO
|
|
|
|
} m_CanRetryReceiveFrame;
|
2018-08-03 04:37:46 +00:00
|
|
|
|
|
|
|
static const uint8_t k_H264TestFrame[];
|
2019-11-06 01:08:25 +00:00
|
|
|
static const uint8_t k_HEVCMainTestFrame[];
|
|
|
|
static const uint8_t k_HEVCMain10TestFrame[];
|
2018-07-18 03:00:16 +00:00
|
|
|
};
|