mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 14:40:56 +00:00
Add decoder options dictionary to prepareDecoderContext()
This commit is contained in:
@@ -28,7 +28,7 @@ bool CUDARenderer::initialize(PDECODER_PARAMETERS)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUDARenderer::prepareDecoderContext(AVCodecContext* context)
|
bool CUDARenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary**)
|
||||||
{
|
{
|
||||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public:
|
|||||||
CUDARenderer();
|
CUDARenderer();
|
||||||
virtual ~CUDARenderer() override;
|
virtual ~CUDARenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS) override;
|
virtual bool initialize(PDECODER_PARAMETERS) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame() override;
|
virtual bool needsTestFrame() override;
|
||||||
virtual bool isDirectRenderingSupported() override;
|
virtual bool isDirectRenderingSupported() override;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ DrmRenderer::~DrmRenderer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrmRenderer::prepareDecoderContext(AVCodecContext*)
|
bool DrmRenderer::prepareDecoderContext(AVCodecContext*, AVDictionary**)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public:
|
|||||||
DrmRenderer();
|
DrmRenderer();
|
||||||
virtual ~DrmRenderer() override;
|
virtual ~DrmRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ AVBufferRef* DXVA2Renderer::ffPoolAlloc(void* opaque, int)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DXVA2Renderer::prepareDecoderContext(AVCodecContext* context)
|
bool DXVA2Renderer::prepareDecoderContext(AVCodecContext* context, AVDictionary**)
|
||||||
{
|
{
|
||||||
// m_DXVAContext.workaround and report_id already initialized elsewhere
|
// m_DXVAContext.workaround and report_id already initialized elsewhere
|
||||||
m_DXVAContext.decoder = m_Decoder;
|
m_DXVAContext.decoder = m_Decoder;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
DXVA2Renderer();
|
DXVA2Renderer();
|
||||||
virtual ~DXVA2Renderer() override;
|
virtual ~DXVA2Renderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
||||||
virtual int getDecoderColorspace() override;
|
virtual int getDecoderColorspace() override;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ MmalRenderer::~MmalRenderer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MmalRenderer::prepareDecoderContext(AVCodecContext*)
|
bool MmalRenderer::prepareDecoderContext(AVCodecContext*, AVDictionary**)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public:
|
|||||||
MmalRenderer();
|
MmalRenderer();
|
||||||
virtual ~MmalRenderer() override;
|
virtual ~MmalRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
||||||
virtual bool needsTestFrame() override;
|
virtual bool needsTestFrame() override;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) = 0;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) = 0;
|
||||||
virtual void renderFrame(AVFrame* frame) = 0;
|
virtual void renderFrame(AVFrame* frame) = 0;
|
||||||
|
|
||||||
virtual bool needsTestFrame() {
|
virtual bool needsTestFrame() {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ SdlRenderer::~SdlRenderer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SdlRenderer::prepareDecoderContext(AVCodecContext*)
|
bool SdlRenderer::prepareDecoderContext(AVCodecContext*, AVDictionary**)
|
||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public:
|
|||||||
SdlRenderer();
|
SdlRenderer();
|
||||||
virtual ~SdlRenderer() override;
|
virtual ~SdlRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
||||||
virtual bool isRenderThreadSupported() override;
|
virtual bool isRenderThreadSupported() override;
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VAAPIRenderer::prepareDecoderContext(AVCodecContext* context)
|
VAAPIRenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary**)
|
||||||
{
|
{
|
||||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
VAAPIRenderer();
|
VAAPIRenderer();
|
||||||
virtual ~VAAPIRenderer() override;
|
virtual ~VAAPIRenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame() override;
|
virtual bool needsTestFrame() override;
|
||||||
virtual bool isDirectRenderingSupported() override;
|
virtual bool isDirectRenderingSupported() override;
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ bool VDPAURenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VDPAURenderer::prepareDecoderContext(AVCodecContext* context)
|
bool VDPAURenderer::prepareDecoderContext(AVCodecContext* context, AVDictionary**)
|
||||||
{
|
{
|
||||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
VDPAURenderer();
|
VDPAURenderer();
|
||||||
virtual ~VDPAURenderer() override;
|
virtual ~VDPAURenderer() override;
|
||||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
||||||
virtual void renderFrame(AVFrame* frame) override;
|
virtual void renderFrame(AVFrame* frame) override;
|
||||||
virtual bool needsTestFrame() override;
|
virtual bool needsTestFrame() override;
|
||||||
virtual int getDecoderColorspace() override;
|
virtual int getDecoderColorspace() override;
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool prepareDecoderContext(AVCodecContext* context) override
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary**) override
|
||||||
{
|
{
|
||||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||||
|
|
||||||
|
|||||||
@@ -267,8 +267,10 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, PDECODER_PARAM
|
|||||||
m_VideoDecoderCtx->pix_fmt = m_FrontendRenderer->getPreferredPixelFormat(params->videoFormat);
|
m_VideoDecoderCtx->pix_fmt = m_FrontendRenderer->getPreferredPixelFormat(params->videoFormat);
|
||||||
m_VideoDecoderCtx->get_format = ffGetFormat;
|
m_VideoDecoderCtx->get_format = ffGetFormat;
|
||||||
|
|
||||||
|
AVDictionary* options = nullptr;
|
||||||
|
|
||||||
// Allow the backend renderer to attach data to this decoder
|
// Allow the backend renderer to attach data to this decoder
|
||||||
if (!m_BackendRenderer->prepareDecoderContext(m_VideoDecoderCtx)) {
|
if (!m_BackendRenderer->prepareDecoderContext(m_VideoDecoderCtx, &options)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +281,8 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, PDECODER_PARAM
|
|||||||
SDL_assert(m_VideoDecoderCtx->opaque == nullptr);
|
SDL_assert(m_VideoDecoderCtx->opaque == nullptr);
|
||||||
m_VideoDecoderCtx->opaque = this;
|
m_VideoDecoderCtx->opaque = this;
|
||||||
|
|
||||||
int err = avcodec_open2(m_VideoDecoderCtx, decoder, nullptr);
|
int err = avcodec_open2(m_VideoDecoderCtx, decoder, &options);
|
||||||
|
av_dict_free(&options);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Unable to open decoder for format: %x",
|
"Unable to open decoder for format: %x",
|
||||||
|
|||||||
Reference in New Issue
Block a user