From c2ced5695054a42fe4ba8520669d7c69e583e2a1 Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com>
Date: Tue, 20 Jun 2023 15:14:02 +0100
Subject: [PATCH 11/12] DVDVideoCodecDRMPRIME: Request v4l2 buffers be
 allocated through cache

This is an optional request, but will improve performance of sw deinterlace
if supported.
---
 .../VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp     | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index 023334f5db..0182f30a61 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -367,6 +367,10 @@ bool CDVDVideoCodecDRMPRIME::Open(CDVDStreamInfo& hints, CDVDCodecOptions& optio
   for (auto&& option : options.m_keys)
     av_opt_set(m_pCodecContext, option.m_name.c_str(), option.m_value.c_str(), 0);
 
+  // this requests v4l2 buffers are allocated through cache. It will work if this is not supported,
+  // but subsequent operations like deinterlace may be less efficient
+  av_opt_set(m_pCodecContext->priv_data, "dmabuf_alloc", "cma", 0);
+
   if (avcodec_open2(m_pCodecContext, pCodec, nullptr) < 0)
   {
     CLog::Log(LOGINFO, "CDVDVideoCodecDRMPRIME::{} - unable to open codec", __FUNCTION__);
-- 
2.39.2

