2019-06-27 04:02:33 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "renderer.h"
|
|
|
|
|
2021-12-14 03:41:00 +00:00
|
|
|
#include <ffnvcodec/dynlink_loader.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavutil/hwcontext_cuda.h>
|
|
|
|
}
|
|
|
|
|
2019-06-27 04:02:33 +00:00
|
|
|
class CUDARenderer : public IFFmpegRenderer {
|
|
|
|
public:
|
|
|
|
CUDARenderer();
|
|
|
|
virtual ~CUDARenderer() override;
|
|
|
|
virtual bool initialize(PDECODER_PARAMETERS) override;
|
2020-02-09 01:47:26 +00:00
|
|
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
2019-06-27 04:02:33 +00:00
|
|
|
virtual void renderFrame(AVFrame* frame) override;
|
|
|
|
virtual bool needsTestFrame() override;
|
|
|
|
virtual bool isDirectRenderingSupported() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
AVBufferRef* m_HwContext;
|
|
|
|
};
|
|
|
|
|
2021-12-14 03:41:00 +00:00
|
|
|
#define NV12_PLANES 2
|
|
|
|
|
|
|
|
// Helper class used by SDLRenderer to read our CUDA frame
|
|
|
|
class CUDAGLInteropHelper {
|
|
|
|
public:
|
|
|
|
CUDAGLInteropHelper(AVHWDeviceContext* context);
|
|
|
|
~CUDAGLInteropHelper();
|
|
|
|
|
|
|
|
bool registerBoundTextures();
|
|
|
|
void unregisterTextures();
|
|
|
|
|
|
|
|
bool copyCudaFrameToTextures(AVFrame* frame);
|
|
|
|
|
|
|
|
private:
|
|
|
|
CudaFunctions* m_Funcs;
|
|
|
|
AVCUDADeviceContext* m_Context;
|
|
|
|
CUgraphicsResource m_Resources[NV12_PLANES];
|
|
|
|
};
|