One more time
All checks were successful
eden-license / license-header (pull_request) Successful in 24s
All checks were successful
eden-license / license-header (pull_request) Successful in 24s
This commit is contained in:
parent
6ad351700f
commit
c50dea348f
1 changed files with 9 additions and 7 deletions
|
@ -42,11 +42,14 @@ constexpr std::array PreferredGpuDecoders = {
|
||||||
|
|
||||||
AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* pix_fmts) {
|
AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* pix_fmts) {
|
||||||
// Check if there is a pixel format supported by the GPU decoder.
|
// Check if there is a pixel format supported by the GPU decoder.
|
||||||
for (const AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
|
const auto desc = av_pix_fmt_desc_get(codec_context->pix_fmt);
|
||||||
if (*p == codec_context->pix_fmt) {
|
if (desc && desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
|
||||||
return codec_context->pix_fmt;
|
for (const AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
|
||||||
}
|
if (*p == codec_context->pix_fmt) {
|
||||||
}
|
return codec_context->pix_fmt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fallback to CPU decoder.
|
// Fallback to CPU decoder.
|
||||||
LOG_INFO(HW_GPU, "Could not find supported GPU pixel format, falling back to CPU decoder");
|
LOG_INFO(HW_GPU, "Could not find supported GPU pixel format, falling back to CPU decoder");
|
||||||
|
@ -243,8 +246,7 @@ std::shared_ptr<Frame> DecoderContext::ReceiveFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_temp_frame = std::make_shared<Frame>();
|
m_temp_frame = std::make_shared<Frame>();
|
||||||
const auto desc = av_pix_fmt_desc_get(intermediate_frame->GetPixelFormat());
|
if (m_codec_context->hw_device_ctx) {
|
||||||
if (m_codec_context->hw_device_ctx && desc && desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
|
|
||||||
m_temp_frame->SetFormat(PreferredGpuFormat);
|
m_temp_frame->SetFormat(PreferredGpuFormat);
|
||||||
if (int ret = av_hwframe_transfer_data(m_temp_frame->GetFrame(), intermediate_frame->GetFrame(), 0); ret < 0) {
|
if (int ret = av_hwframe_transfer_data(m_temp_frame->GetFrame(), intermediate_frame->GetFrame(), 0); ret < 0) {
|
||||||
LOG_ERROR(HW_GPU, "av_hwframe_transfer_data error: {}", AVError(ret));
|
LOG_ERROR(HW_GPU, "av_hwframe_transfer_data error: {}", AVError(ret));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue