From 8db21526fe56f66d7f6ffe0712fecdc7bf5770f6 Mon Sep 17 00:00:00 2001 From: MaranBr Date: Thu, 17 Jul 2025 09:48:04 -0400 Subject: [PATCH] Add some comments and organize some things --- src/video_core/host1x/ffmpeg/ffmpeg.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/video_core/host1x/ffmpeg/ffmpeg.cpp b/src/video_core/host1x/ffmpeg/ffmpeg.cpp index 8cdaabda2a..3735906c54 100644 --- a/src/video_core/host1x/ffmpeg/ffmpeg.cpp +++ b/src/video_core/host1x/ffmpeg/ffmpeg.cpp @@ -39,6 +39,7 @@ constexpr std::array PreferredGpuDecoders = { }; AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* pix_fmts) { + // Check if there is a specific pixel format supported by the GPU decoder. for (int i = 0;; i++) { const AVCodecHWConfig* config = avcodec_get_hw_config(codec_context->codec, i); if (!config) { @@ -54,6 +55,7 @@ AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* p } } + // Check if there is another pixel format supported by the GPU decoder. const auto desc = av_pix_fmt_desc_get(codec_context->pix_fmt); if (desc && desc->flags & AV_PIX_FMT_FLAG_HWACCEL) { for (const AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) { @@ -63,7 +65,8 @@ AVPixelFormat GetGpuFormat(AVCodecContext* codec_context, const AVPixelFormat* p } } - LOG_INFO(HW_GPU, "Could not find compatible GPU AV format, falling back to CPU"); + // Fallback to CPU decoder. + LOG_INFO(HW_GPU, "Could not find compatible GPU pixel format, falling back to CPU"); av_buffer_unref(&codec_context->hw_device_ctx); return AV_PIX_FMT_YUV420P; @@ -242,8 +245,6 @@ bool DecoderContext::SendPacket(const Packet& packet) { } std::shared_ptr DecoderContext::ReceiveFrame() { - m_temp_frame = std::make_shared(); - auto ReceiveImpl = [&](AVFrame* frame) -> bool { if (const int ret = avcodec_receive_frame(m_codec_context, frame); ret < 0 && ret != AVERROR_EOF) { LOG_ERROR(HW_GPU, "avcodec_receive_frame error: {}", AVError(ret)); @@ -257,6 +258,7 @@ std::shared_ptr DecoderContext::ReceiveFrame() { return {}; } + m_temp_frame = std::make_shared(); if (m_codec_context->hw_device_ctx) { m_temp_frame->SetFormat(AV_PIX_FMT_NV12); if (int ret = av_hwframe_transfer_data(m_temp_frame->GetFrame(), intermediate_frame->GetFrame(), 0); ret < 0) {