diff --git a/src/video_core/host1x/ffmpeg/ffmpeg.cpp b/src/video_core/host1x/ffmpeg/ffmpeg.cpp
index ffde231aee..ae3578375c 100644
--- a/src/video_core/host1x/ffmpeg/ffmpeg.cpp
+++ b/src/video_core/host1x/ffmpeg/ffmpeg.cpp
@@ -237,16 +237,22 @@ std::shared_ptr DecoderContext::ReceiveFrame() {
if (m_codec_context->hw_device_ctx) {
// If we have a hardware context, make a separate frame here to receive the
// hardware result before sending it to the output.
- Frame intermediate_frame;
+ std::shared_ptr intermediate_frame = std::make_shared();
- if (!receive(intermediate_frame.GetFrame())) {
+ if (!receive(intermediate_frame->GetFrame())) {
return {};
}
- m_temp_frame->SetFormat(PreferredGpuFormat);
- 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));
- return {};
+ const auto fmt = intermediate_frame->GetPixelFormat();
+ const auto desc = av_pix_fmt_desc_get(fmt);
+ if (desc && (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+ m_temp_frame->SetFormat(PreferredGpuFormat);
+ 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));
+ return {};
+ }
+ } else {
+ m_temp_frame = std::move(intermediate_frame);
}
} else {
// Otherwise, decode the frame as normal.
diff --git a/src/video_core/host1x/ffmpeg/ffmpeg.h b/src/video_core/host1x/ffmpeg/ffmpeg.h
index 28f1742b7e..9fe0b1532a 100644
--- a/src/video_core/host1x/ffmpeg/ffmpeg.h
+++ b/src/video_core/host1x/ffmpeg/ffmpeg.h
@@ -21,6 +21,7 @@ extern "C" {
#include
#include
+#include
#include
#if defined(__GNUC__) || defined(__clang__)