From 21cda8141d813db67f3226d8b2a62aee2620bfa4 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 26 Mar 2023 19:59:12 -0500 Subject: [PATCH] Always request AV_PIX_FMT_DRM_PRIME to ensure we get it if available --- app/streaming/video/ffmpeg-renderers/drm.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/drm.cpp b/app/streaming/video/ffmpeg-renderers/drm.cpp index 7e5df975..df42556e 100644 --- a/app/streaming/video/ffmpeg-renderers/drm.cpp +++ b/app/streaming/video/ffmpeg-renderers/drm.cpp @@ -464,18 +464,16 @@ bool DrmRenderer::initialize(PDECODER_PARAMETERS params) enum AVPixelFormat DrmRenderer::getPreferredPixelFormat(int videoFormat) { // DRM PRIME buffers, or whatever the backend renderer wants - if (m_HwAccelBackend) { - return AV_PIX_FMT_DRM_PRIME; - } - else if (m_BackendRenderer != nullptr) { - // Unlike isPixelFormatSupported(), we always return the format - // requested by the backend renderer since it's used for setting - // up the AVCodecContext. + if (m_BackendRenderer != nullptr) { return m_BackendRenderer->getPreferredPixelFormat(videoFormat); } else { - // If we're acting as a non-hwaccel renderer, we'll ask for NV12 or P010 - return (videoFormat & VIDEO_FORMAT_MASK_10BIT) ? AV_PIX_FMT_P010 : AV_PIX_FMT_NV12; + // We must return this pixel format to ensure it's used with + // v4l2m2m decoders that go through non-hwaccel format selection. + // + // For non-hwaccel decoders that don't support DRM PRIME, ffGetFormat() + // will call isPixelFormatSupported() and pick a supported swformat. + return AV_PIX_FMT_DRM_PRIME; } } @@ -490,6 +488,7 @@ bool DrmRenderer::isPixelFormatSupported(int videoFormat, AVPixelFormat pixelFor // If we're going to need to map this as a software frame, check // against the set of formats we support in mapSoftwareFrame(). switch (pixelFormat) { + case AV_PIX_FMT_DRM_PRIME: case AV_PIX_FMT_NV12: case AV_PIX_FMT_NV21: case AV_PIX_FMT_P010: