RPi: update kodi patch to support bwdif deinterlace

Signed-off-by: Matthias Reichl <hias@horus.com>
This commit is contained in:
Matthias Reichl 2023-07-21 20:16:20 +02:00
parent c004713bc9
commit 35f659918f
12 changed files with 687 additions and 34 deletions

View File

@ -1,7 +1,7 @@
From e181af5b2b97b3fbc69b9ad7318a3c02f6186ca5 Mon Sep 17 00:00:00 2001 From 89a7f05ee85fca27f1140a035fec804d84959dbe Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com> From: Dom Cobley <popcornmix@gmail.com>
Date: Fri, 3 Dec 2021 16:00:50 +0000 Date: Fri, 3 Dec 2021 16:00:50 +0000
Subject: [PATCH 1/5] gbm: Set max bpc for high bit depth videos Subject: [PATCH 01/12] gbm: Set max bpc for high bit depth videos
--- ---
.../HwDecRender/VideoLayerBridgeDRMPRIME.cpp | 15 +++++++++++++++ .../HwDecRender/VideoLayerBridgeDRMPRIME.cpp | 15 +++++++++++++++

View File

@ -1,7 +1,7 @@
From 05fbbc78734827304edd3eb10de0a0117d10a8b9 Mon Sep 17 00:00:00 2001 From 7d18280622c8ac12dbf1f6d4d5ca9589e1a61b02 Mon Sep 17 00:00:00 2001
From: popcornmix <popcornmix@gmail.com> From: popcornmix <popcornmix@gmail.com>
Date: Sat, 11 Sep 2021 14:03:05 +0100 Date: Sat, 11 Sep 2021 14:03:05 +0100
Subject: [PATCH 2/5] CDVDVideoCodecDRMPRIME: Also support YUV420 buffers Subject: [PATCH 02/12] CDVDVideoCodecDRMPRIME: Also support YUV420 buffers
CDVDVideoCodecDRMPRIME: Add support for deinterlace of sw decoded buffers CDVDVideoCodecDRMPRIME: Add support for deinterlace of sw decoded buffers
@ -11,10 +11,10 @@ Need to call SetDimensions earlier and store the drm descriptor in expected plac
1 file changed, 12 insertions(+), 2 deletions(-) 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index b221cdaf75..c0efa91770 100644 index f5e26b203c..90f1fb07a9 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -619,7 +619,7 @@ bool CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture) @@ -622,7 +622,7 @@ bool CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture)
pVideoPicture->videoBuffer = nullptr; pVideoPicture->videoBuffer = nullptr;
} }
@ -23,7 +23,7 @@ index b221cdaf75..c0efa91770 100644
{ {
CVideoBufferDRMPRIMEFFmpeg* buffer = CVideoBufferDRMPRIMEFFmpeg* buffer =
dynamic_cast<CVideoBufferDRMPRIMEFFmpeg*>(m_videoBufferPool->Get()); dynamic_cast<CVideoBufferDRMPRIMEFFmpeg*>(m_videoBufferPool->Get());
@@ -697,7 +697,7 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -700,7 +700,7 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
const AVFilter* srcFilter = avfilter_get_by_name("buffer"); const AVFilter* srcFilter = avfilter_get_by_name("buffer");
const AVFilter* outFilter = avfilter_get_by_name("buffersink"); const AVFilter* outFilter = avfilter_get_by_name("buffersink");
@ -32,7 +32,7 @@ index b221cdaf75..c0efa91770 100644
std::string args = StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:" std::string args = StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:"
"pixel_aspect={}/{}", "pixel_aspect={}/{}",
@@ -845,6 +845,16 @@ void CDVDVideoCodecDRMPRIME::FilterClose() @@ -848,6 +848,16 @@ void CDVDVideoCodecDRMPRIME::FilterClose()
CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn() CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn()
{ {

View File

@ -1,15 +1,15 @@
From 8fbcf5fada25720b5c6f66959d5ee1c28cff04f9 Mon Sep 17 00:00:00 2001 From e36845fd7e48b364f68a43bd8c66e06a570a6f4c Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com> From: Dom Cobley <popcornmix@gmail.com>
Date: Wed, 18 Jan 2023 16:41:00 +0000 Date: Wed, 18 Jan 2023 16:41:00 +0000
Subject: [PATCH 3/5] CDVDVideoCodecDRMPRIME: Adjust av formats to match recent Subject: [PATCH 03/12] CDVDVideoCodecDRMPRIME: Adjust av formats to match
ffmpeg changes recent ffmpeg changes
--- ---
.../VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 6 ++++-- .../VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-) 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index c0efa91770..29d38a3ec0 100644 index 90f1fb07a9..169e8544de 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -355,6 +355,7 @@ bool CDVDVideoCodecDRMPRIME::Open(CDVDStreamInfo& hints, CDVDCodecOptions& optio @@ -355,6 +355,7 @@ bool CDVDVideoCodecDRMPRIME::Open(CDVDStreamInfo& hints, CDVDCodecOptions& optio
@ -19,8 +19,8 @@ index c0efa91770..29d38a3ec0 100644
+ m_pCodecContext->thread_safe_callbacks = 1; + m_pCodecContext->thread_safe_callbacks = 1;
m_pCodecContext->thread_count = CServiceBroker::GetCPUInfo()->GetCPUCount(); m_pCodecContext->thread_count = CServiceBroker::GetCPUInfo()->GetCPUCount();
if (hints.extradata && hints.extrasize > 0) if (hints.extradata)
@@ -697,13 +698,13 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -700,13 +701,13 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
const AVFilter* srcFilter = avfilter_get_by_name("buffer"); const AVFilter* srcFilter = avfilter_get_by_name("buffer");
const AVFilter* outFilter = avfilter_get_by_name("buffersink"); const AVFilter* outFilter = avfilter_get_by_name("buffersink");
@ -36,7 +36,7 @@ index c0efa91770..29d38a3ec0 100644
m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num ?
m_pCodecContext->time_base.num : 1, m_pCodecContext->time_base.num : 1,
m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num ?
@@ -855,6 +856,7 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn() @@ -858,6 +859,7 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn()
m_pFrame->data[0] = reinterpret_cast<uint8_t*>(descriptor); m_pFrame->data[0] = reinterpret_cast<uint8_t*>(descriptor);
} }

View File

@ -1,7 +1,7 @@
From 56117d2874dcc36ac779609c63f1a8b0bace5366 Mon Sep 17 00:00:00 2001 From 092ae2d56a5b8ed1558e82c2beae6e4223df57ff Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com> From: Dom Cobley <popcornmix@gmail.com>
Date: Mon, 6 Feb 2023 15:19:51 +0000 Date: Mon, 6 Feb 2023 15:19:51 +0000
Subject: [PATCH 4/5] DVDVideoCodecDRMPRIME: Add support for arbitrary output Subject: [PATCH 04/12] DVDVideoCodecDRMPRIME: Add support for arbitrary output
pixel formats pixel formats
This enables any ffmpeg pixel formats to be supported by DRMPRIME decoder This enables any ffmpeg pixel formats to be supported by DRMPRIME decoder
@ -20,7 +20,7 @@ And it happens automatically without requiring user video settings
2 files changed, 77 insertions(+), 50 deletions(-) 2 files changed, 77 insertions(+), 50 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index 29d38a3ec0..611876ba8d 100644 index 169e8544de..28bd0a9bc7 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -219,7 +219,7 @@ enum AVPixelFormat CDVDVideoCodecDRMPRIME::GetFormat(struct AVCodecContext* avct @@ -219,7 +219,7 @@ enum AVPixelFormat CDVDVideoCodecDRMPRIME::GetFormat(struct AVCodecContext* avct
@ -67,7 +67,7 @@ index 29d38a3ec0..611876ba8d 100644
buffer->Export(frame, width, height); buffer->Export(frame, width, height);
buffer->SyncStart(); buffer->SyncStart();
@@ -628,9 +628,9 @@ bool CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture) @@ -631,9 +631,9 @@ bool CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture)
buffer->SetRef(m_pFrame); buffer->SetRef(m_pFrame);
pVideoPicture->videoBuffer = buffer; pVideoPicture->videoBuffer = buffer;
} }
@ -79,7 +79,7 @@ index 29d38a3ec0..611876ba8d 100644
buffer->SetPictureParams(*pVideoPicture); buffer->SetPictureParams(*pVideoPicture);
buffer->Acquire(); buffer->Acquire();
buffer->SyncEnd(); buffer->SyncEnd();
@@ -664,13 +664,13 @@ void CDVDVideoCodecDRMPRIME::FilterTest() @@ -667,13 +667,13 @@ void CDVDVideoCodecDRMPRIME::FilterTest()
if (name.find("deinterlace") != std::string::npos) if (name.find("deinterlace") != std::string::npos)
{ {
@ -96,7 +96,7 @@ index 29d38a3ec0..611876ba8d 100644
return; return;
} }
} }
@@ -680,14 +680,31 @@ void CDVDVideoCodecDRMPRIME::FilterTest() @@ -683,14 +683,31 @@ void CDVDVideoCodecDRMPRIME::FilterTest()
__FUNCTION__); __FUNCTION__);
} }
@ -130,7 +130,7 @@ index 29d38a3ec0..611876ba8d 100644
return true; return true;
if (!(m_pFilterGraph = avfilter_graph_alloc())) if (!(m_pFilterGraph = avfilter_graph_alloc()))
@@ -698,13 +715,13 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -701,13 +718,13 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
const AVFilter* srcFilter = avfilter_get_by_name("buffer"); const AVFilter* srcFilter = avfilter_get_by_name("buffer");
const AVFilter* outFilter = avfilter_get_by_name("buffersink"); const AVFilter* outFilter = avfilter_get_by_name("buffersink");
@ -146,7 +146,7 @@ index 29d38a3ec0..611876ba8d 100644
m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num ?
m_pCodecContext->time_base.num : 1, m_pCodecContext->time_base.num : 1,
m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num ?
@@ -723,7 +740,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -726,7 +743,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
CLog::Log(LOGERROR, CLog::Log(LOGERROR,
"CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_create_filter: src: {} ({})", "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_create_filter: src: {} ({})",
err, result); err, result);
@ -154,7 +154,7 @@ index 29d38a3ec0..611876ba8d 100644
return false; return false;
} }
@@ -731,7 +747,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -734,7 +750,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
if (!par) if (!par)
{ {
CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - unable to alloc buffersrc"); CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - unable to alloc buffersrc");
@ -162,7 +162,7 @@ index 29d38a3ec0..611876ba8d 100644
return false; return false;
} }
@@ -747,7 +762,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -750,7 +765,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
CLog::Log(LOGERROR, CLog::Log(LOGERROR,
"CDVDVideoCodecDRMPRIME::FilterOpen - av_buffersrc_parameters_set: {} ({})", "CDVDVideoCodecDRMPRIME::FilterOpen - av_buffersrc_parameters_set: {} ({})",
err, result); err, result);
@ -170,7 +170,7 @@ index 29d38a3ec0..611876ba8d 100644
return false; return false;
} }
av_freep(&par); av_freep(&par);
@@ -761,7 +775,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -764,7 +778,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
CLog::Log(LOGERROR, CLog::Log(LOGERROR,
"CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_create_filter: out: {} ({})", "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_create_filter: out: {} ({})",
err, result); err, result);
@ -178,7 +178,7 @@ index 29d38a3ec0..611876ba8d 100644
return false; return false;
} }
@@ -770,32 +783,46 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -773,32 +786,46 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
if (result < 0) if (result < 0)
{ {
CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - failed settings pix formats"); CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - failed settings pix formats");
@ -243,7 +243,7 @@ index 29d38a3ec0..611876ba8d 100644
} }
if ((result = avfilter_graph_config(m_pFilterGraph, nullptr)) < 0) if ((result = avfilter_graph_config(m_pFilterGraph, nullptr)) < 0)
@@ -804,15 +831,11 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test) @@ -807,15 +834,11 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool test)
av_strerror(result, err, AV_ERROR_MAX_STRING_SIZE); av_strerror(result, err, AV_ERROR_MAX_STRING_SIZE);
CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_config: {} ({})", CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_config: {} ({})",
err, result); err, result);
@ -259,7 +259,7 @@ index 29d38a3ec0..611876ba8d 100644
m_processInfo.SetVideoDeintMethod(filters); m_processInfo.SetVideoDeintMethod(filters);
@@ -847,16 +870,16 @@ void CDVDVideoCodecDRMPRIME::FilterClose() @@ -850,16 +873,16 @@ void CDVDVideoCodecDRMPRIME::FilterClose()
CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn() CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn()
{ {
// sw decoded buffers need cache flush and for descripter to be set // sw decoded buffers need cache flush and for descripter to be set
@ -279,7 +279,7 @@ index 29d38a3ec0..611876ba8d 100644
int ret = av_buffersrc_add_frame(m_pFilterIn, m_pFrame); int ret = av_buffersrc_add_frame(m_pFilterIn, m_pFrame);
if (ret < 0) if (ret < 0)
{ {
@@ -949,25 +972,28 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::GetPicture(VideoPicture* pVideo @@ -960,25 +983,28 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::GetPicture(VideoPicture* pVideo
return VC_ERROR; return VC_ERROR;
} }

View File

@ -1,7 +1,7 @@
From 85c8218d79f042c6d16b1d1ff6479743f095994e Mon Sep 17 00:00:00 2001 From 4a3cb2af8b0751807d212044ba424d07f2a7ba55 Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com> From: Dom Cobley <popcornmix@gmail.com>
Date: Fri, 14 Apr 2023 19:59:42 +0100 Date: Fri, 14 Apr 2023 19:59:42 +0100
Subject: [PATCH 5/5] DVDVideoCodecDRMPRIME: Remove obsolete Subject: [PATCH 05/12] DVDVideoCodecDRMPRIME: Remove obsolete
thread_safe_callbacks thread_safe_callbacks
--- ---
@ -9,7 +9,7 @@ Subject: [PATCH 5/5] DVDVideoCodecDRMPRIME: Remove obsolete
1 file changed, 1 deletion(-) 1 file changed, 1 deletion(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index 611876ba8d..f7022e1854 100644 index 28bd0a9bc7..670b5f22ce 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -355,7 +355,6 @@ bool CDVDVideoCodecDRMPRIME::Open(CDVDStreamInfo& hints, CDVDCodecOptions& optio @@ -355,7 +355,6 @@ bool CDVDVideoCodecDRMPRIME::Open(CDVDStreamInfo& hints, CDVDCodecOptions& optio
@ -19,7 +19,7 @@ index 611876ba8d..f7022e1854 100644
- m_pCodecContext->thread_safe_callbacks = 1; - m_pCodecContext->thread_safe_callbacks = 1;
m_pCodecContext->thread_count = CServiceBroker::GetCPUInfo()->GetCPUCount(); m_pCodecContext->thread_count = CServiceBroker::GetCPUInfo()->GetCPUCount();
if (hints.extradata && hints.extrasize > 0) if (hints.extradata)
-- --
2.39.2 2.39.2

View File

@ -0,0 +1,24 @@
From 018e080fb3fea185df01d2659d59231aef787759 Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com>
Date: Wed, 31 May 2023 19:40:37 +0100
Subject: [PATCH 06/12] DVDVideoCodecDRMPRIME: Clear m_pFilterGraph
---
xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index 670b5f22ce..8568f162ae 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -866,6 +866,7 @@ void CDVDVideoCodecDRMPRIME::FilterClose()
// Disposed by above code
m_pFilterIn = nullptr;
m_pFilterOut = nullptr;
+ m_pFilterGraph = nullptr;
}
}
--
2.39.2

View File

@ -0,0 +1,70 @@
From b62d5e56d76ce179e3a1169566aa2146da48b147 Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com>
Date: Fri, 2 Jun 2023 11:34:22 +0100
Subject: [PATCH 07/12] DVDVideoCodecDRMPRIME: Move FilterTest from open to
first frame returned
The pixel format is not accurate until the first frame is returned
and it may (later) influence the choice of deinterlacers available.
---
.../DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 24 ++++++++++++-------
.../DVDCodecs/Video/DVDVideoCodecDRMPRIME.h | 1 +
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index 8568f162ae..f515c5d5f1 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -387,15 +387,7 @@ bool CDVDVideoCodecDRMPRIME::Open(CDVDStreamInfo& hints, CDVDCodecOptions& optio
m_processInfo.SetVideoDAR(hints.aspect);
m_processInfo.SetVideoDeintMethod("none");
- FilterTest();
-
- if (!m_deintFilterName.empty())
- {
- std::list<EINTERLACEMETHOD> methods;
- methods.push_back(EINTERLACEMETHOD::VS_INTERLACEMETHOD_DEINTERLACE);
- m_processInfo.UpdateDeinterlacingMethods(methods);
- m_processInfo.SetDeinterlacingMethodDefault(EINTERLACEMETHOD::VS_INTERLACEMETHOD_DEINTERLACE);
- }
+ m_checkedDeinterlace = false;
return true;
}
@@ -983,6 +975,20 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::GetPicture(VideoPicture* pVideo
return VC_ERROR;
}
+ if (!m_checkedDeinterlace)
+ {
+ FilterTest();
+
+ if (!m_deintFilterName.empty())
+ {
+ std::list<EINTERLACEMETHOD> methods;
+ methods.push_back(EINTERLACEMETHOD::VS_INTERLACEMETHOD_DEINTERLACE);
+ m_processInfo.UpdateDeinterlacingMethods(methods);
+ m_processInfo.SetDeinterlacingMethodDefault(EINTERLACEMETHOD::VS_INTERLACEMETHOD_DEINTERLACE);
+ }
+ m_checkedDeinterlace = true;
+ }
+
// we need to scale if the buffer isn't in DRM_PRIME format
bool need_scale = !IsSupportedSwFormat(static_cast<AVPixelFormat>(m_pFrame->format)) && !IsSupportedHwFormat(static_cast<AVPixelFormat>(m_pFrame->format));
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h
index bb88fde1f9..df17f89b96 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h
@@ -56,6 +56,7 @@ protected:
int m_codecControlFlags = 0;
CDVDStreamInfo m_hints;
double m_DAR = 1.0;
+ bool m_checkedDeinterlace = false;
AVCodecContext* m_pCodecContext = nullptr;
AVFrame* m_pFrame = nullptr;
AVFrame* m_pFilterFrame = nullptr;
--
2.39.2

View File

@ -0,0 +1,277 @@
From b359d89684418cc3a6f894434d212611c7c12cd5 Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com>
Date: Wed, 31 May 2023 14:19:20 +0100
Subject: [PATCH 08/12] DVDVideoCodecDRMPRIME: Rework filtering code to handle
sw deinterlace
---
.../DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 134 +++++++++---------
.../DVDCodecs/Video/DVDVideoCodecDRMPRIME.h | 4 +-
2 files changed, 68 insertions(+), 70 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index f515c5d5f1..b614312a77 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -207,11 +207,7 @@ static const AVCodec* FindDecoder(CDVDStreamInfo& hints)
return codec;
}
- codec = avcodec_find_decoder(hints.codec);
- if (codec && (codec->capabilities & AV_CODEC_CAP_DR1) == AV_CODEC_CAP_DR1)
- return codec;
-
- return nullptr;
+ return avcodec_find_decoder(hints.codec);
}
enum AVPixelFormat CDVDVideoCodecDRMPRIME::GetFormat(struct AVCodecContext* avctx,
@@ -645,27 +641,33 @@ bool CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture)
return true;
}
-void CDVDVideoCodecDRMPRIME::FilterTest()
+void CDVDVideoCodecDRMPRIME::FilterTest(AVPixelFormat pix_fmt)
{
- const AVFilter* filter;
- void* opaque{};
-
m_deintFilterName.clear();
- while ((filter = av_filter_iterate(&opaque)) != nullptr)
+ // look twice, first for DRM_PRIME support, then for actual pixel format
+ for (int i=0; i < 2; i++)
{
- std::string name(filter->name);
+ const AVFilter* filter;
+ void* opaque{};
- if (name.find("deinterlace") != std::string::npos)
+ while ((filter = av_filter_iterate(&opaque)) != nullptr)
{
- bool ret = FilterOpen(name, false, true);
- FilterClose();
- if (ret)
+ std::string name(filter->name);
+
+ if (name.find(i == 0 ? "deinterlace" : "bwdif") != std::string::npos)
{
- m_deintFilterName = name;
- CLog::Log(LOGDEBUG, "CDVDVideoCodecDRMPRIME::{} - found deinterlacing filter {}",
- __FUNCTION__, name);
- return;
+ bool ret = FilterOpen(name, pix_fmt, true);
+ FilterClose();
+ if (ret)
+ {
+ m_deintFilterName = name;
+ if (name == "bwdif" || name == "yadif")
+ m_deintFilterName += "=1:-1:1";
+ CLog::Log(LOGDEBUG, "CDVDVideoCodecDRMPRIME::{} - found deinterlacing filter {}",
+ __FUNCTION__, name);
+ return;
+ }
}
}
}
@@ -691,14 +693,17 @@ AVFrame *CDVDVideoCodecDRMPRIME::alloc_filter_frame(AVFilterContext * ctx, void
return frame;
}
-bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool scale, bool test)
+bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, AVPixelFormat pix_fmt, bool test)
{
int result;
+ if (filters.find("deinterlace") != std::string::npos && pix_fmt == AV_PIX_FMT_YUV420P)
+ pix_fmt = AV_PIX_FMT_DRM_PRIME;
+
if (m_pFilterGraph)
FilterClose();
- if (filters.empty() && !scale)
+ if (filters.empty())
return true;
if (!(m_pFilterGraph = avfilter_graph_alloc()))
@@ -709,13 +714,12 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool scale,
const AVFilter* srcFilter = avfilter_get_by_name("buffer");
const AVFilter* outFilter = avfilter_get_by_name("buffersink");
- enum AVPixelFormat pix_fmts[] = { scale ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_DRM_PRIME, AV_PIX_FMT_NONE };
std::string args = StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:"
"pixel_aspect={}/{}",
m_pCodecContext->width,
m_pCodecContext->height,
- scale ? m_pCodecContext->pix_fmt : AV_PIX_FMT_DRM_PRIME,
+ pix_fmt,
m_pCodecContext->time_base.num ?
m_pCodecContext->time_base.num : 1,
m_pCodecContext->time_base.num ?
@@ -772,6 +776,7 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool scale,
return false;
}
+ enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_DRM_PRIME, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE };
result = av_opt_set_int_list(m_pFilterOut, "pix_fmts", &pix_fmts[0],
AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
if (result < 0)
@@ -780,43 +785,32 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool scale,
return false;
}
- if (!filters.empty())
+ if ((result = av_buffersink_set_alloc_video_frame(m_pFilterOut, alloc_filter_frame, static_cast<void*>(this))) < 0)
{
- AVFilterInOut* outputs = avfilter_inout_alloc();
- AVFilterInOut* inputs = avfilter_inout_alloc();
+ CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - av_buffersink_set_alloc_video_frame = {}", result);
+ return result;
+ }
+ AVFilterInOut* outputs = avfilter_inout_alloc();
+ AVFilterInOut* inputs = avfilter_inout_alloc();
- outputs->name = av_strdup("in");
- outputs->filter_ctx = m_pFilterIn;
- outputs->pad_idx = 0;
- outputs->next = nullptr;
+ outputs->name = av_strdup("in");
+ outputs->filter_ctx = m_pFilterIn;
+ outputs->pad_idx = 0;
+ outputs->next = nullptr;
- inputs->name = av_strdup("out");
- inputs->filter_ctx = m_pFilterOut;
- inputs->pad_idx = 0;
- inputs->next = nullptr;
+ inputs->name = av_strdup("out");
+ inputs->filter_ctx = m_pFilterOut;
+ inputs->pad_idx = 0;
+ inputs->next = nullptr;
- result = avfilter_graph_parse_ptr(m_pFilterGraph, filters.c_str(), &inputs, &outputs, NULL);
- avfilter_inout_free(&outputs);
- avfilter_inout_free(&inputs);
+ result = avfilter_graph_parse_ptr(m_pFilterGraph, filters.c_str(), &inputs, &outputs, NULL);
+ avfilter_inout_free(&outputs);
+ avfilter_inout_free(&inputs);
- if (result < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_parse");
- return false;
- }
- }
- else
+ if (result < 0)
{
- if ((result = av_buffersink_set_alloc_video_frame(m_pFilterOut, alloc_filter_frame, static_cast<void*>(this))) < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - av_buffersink_set_alloc_video_frame = {}", result);
- return result;
- }
- if ((result = avfilter_link(m_pFilterIn, 0, m_pFilterOut, 0)) < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_link");
- return false;
- }
+ CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_parse");
+ return false;
}
if ((result = avfilter_graph_config(m_pFilterGraph, nullptr)) < 0)
@@ -831,8 +825,6 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, bool scale,
if (test)
return true;
- m_processInfo.SetVideoDeintMethod(filters);
-
if (CServiceBroker::GetLogging().CanLogComponent(LOGVIDEO))
{
char* graphDump = avfilter_graph_dump(m_pFilterGraph, nullptr);
@@ -864,8 +856,8 @@ void CDVDVideoCodecDRMPRIME::FilterClose()
CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn()
{
- // sw decoded buffers need cache flush and for descripter to be set
- if (!IsSupportedHwFormat(static_cast<AVPixelFormat>(m_pFrame->format)) && IsSupportedSwFormat(static_cast<AVPixelFormat>(m_pFrame->format)))
+ // sw decoded buffers submitted to hw decoder need cache flush and for descripter to be set
+ if (m_pFrame->format != AV_PIX_FMT_DRM_PRIME && m_pFilterGraph && m_pFilterIn->outputs[0]->format == AV_PIX_FMT_DRM_PRIME)
{
CVideoBufferDMA* buffer = static_cast<CVideoBufferDMA*>(av_buffer_get_opaque(m_pFrame->buf[0]));
buffer->SetDimensions(m_pFrame->width, m_pFrame->height);
@@ -975,9 +967,10 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::GetPicture(VideoPicture* pVideo
return VC_ERROR;
}
+ AVPixelFormat pix_fmt = static_cast<AVPixelFormat>(m_pFrame->format);
if (!m_checkedDeinterlace)
{
- FilterTest();
+ FilterTest(pix_fmt);
if (!m_deintFilterName.empty())
{
@@ -989,28 +982,33 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::GetPicture(VideoPicture* pVideo
m_checkedDeinterlace = true;
}
- // we need to scale if the buffer isn't in DRM_PRIME format
- bool need_scale = !IsSupportedSwFormat(static_cast<AVPixelFormat>(m_pFrame->format)) && !IsSupportedHwFormat(static_cast<AVPixelFormat>(m_pFrame->format));
-
if (!m_processInfo.GetVideoInterlaced() && m_pFrame->interlaced_frame)
m_processInfo.SetVideoInterlaced(true);
std::string filterChain = GetFilterChain(m_pFrame->interlaced_frame);
- if (!filterChain.empty() || need_scale)
+
+ // we need to scale if the buffer isn't in DRM_PRIME format
+ if (!IsSupportedSwFormat(pix_fmt) && !IsSupportedHwFormat(pix_fmt))
+ filterChain = "scale";
+ // we need to copy if the buffer wasn't allocated by us
+ else if (!IsSupportedHwFormat(pix_fmt) && !(m_pCodecContext->codec->capabilities & AV_CODEC_CAP_DR1))
+ filterChain = "copy";
+
+ if (!filterChain.empty())
{
- bool reopenFilter = false;
- if (m_filters != filterChain)
- reopenFilter = true;
+ bool reopenFilter = m_filters != filterChain;
if (m_pFilterGraph &&
(m_pFilterIn->outputs[0]->w != m_pFrame->width ||
m_pFilterIn->outputs[0]->h != m_pFrame->height))
reopenFilter = true;
- if (reopenFilter || (need_scale && m_pFilterGraph == nullptr))
+ if (reopenFilter)
{
m_filters = filterChain;
- if (!FilterOpen(filterChain, need_scale, false))
+ m_processInfo.SetVideoDeintMethod(m_filters);
+
+ if (!FilterOpen(filterChain, pix_fmt, false))
FilterClose();
}
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h
index df17f89b96..55675c3c2e 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h
@@ -45,9 +45,9 @@ protected:
static enum AVPixelFormat GetFormat(struct AVCodecContext* avctx, const enum AVPixelFormat* fmt);
static int GetBuffer(struct AVCodecContext* avctx, AVFrame* frame, int flags);
static AVFrame *alloc_filter_frame(AVFilterContext * ctx, void * v, int w, int h);
- bool FilterOpen(const std::string& filters, bool scale, bool test);
+ bool FilterOpen(const std::string& filters, AVPixelFormat pix_fmt, bool test);
void FilterClose();
- void FilterTest();
+ void FilterTest(AVPixelFormat pix_fmt);
std::string GetFilterChain(bool interlaced);
std::string m_name;
--
2.39.2

View File

@ -0,0 +1,74 @@
From c9a70db5879a6ac37b5840621aa102812104087f Mon Sep 17 00:00:00 2001
From: Alan Swanson <reiver@improbability.net>
Date: Thu, 18 May 2023 16:12:43 +0100
Subject: [PATCH 09/12] VideoPlayer: ffmpeg change default software
deinterlacer from yadif to bwdif
---
.../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 10 +++++-----
xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
index 032ee16454..5d1b7162f9 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
@@ -55,7 +55,7 @@ enum DecoderState
enum EFilterFlags {
FILTER_NONE = 0x0,
- FILTER_DEINTERLACE_YADIF = 0x1, //< use first deinterlace mode
+ FILTER_DEINTERLACE_BWDIF = 0x1, //< use first deinterlace mode
FILTER_DEINTERLACE_ANY = 0xf, //< use any deinterlace mode
FILTER_DEINTERLACE_FLAGGED = 0x10, //< only deinterlace flagged frames
FILTER_DEINTERLACE_HALFED = 0x20, //< do half rate deinterlacing
@@ -526,12 +526,12 @@ void CDVDVideoCodecFFmpeg::SetFilters()
}
}
- if (filters & FILTER_DEINTERLACE_YADIF)
+ if (filters & FILTER_DEINTERLACE_BWDIF)
{
if (filters & FILTER_DEINTERLACE_HALFED)
- m_filters_next = "yadif=0:-1";
+ m_filters_next = "bwdif=0:-1";
else
- m_filters_next = "yadif=1:-1";
+ m_filters_next = "bwdif=1:-1";
if (filters & FILTER_DEINTERLACE_FLAGGED)
m_filters_next += ":1";
@@ -1226,7 +1226,7 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const std::string& filters, bool scale)
return result;
}
- if (filters.compare(0,5,"yadif") == 0)
+ if (filters.compare(0,5,"bwdif") == 0)
{
m_processInfo.SetVideoDeintMethod(filters);
}
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
index 24edd058e9..f9b6f17824 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
@@ -3007,7 +3007,7 @@ bool CFFmpegPostproc::Init(EINTERLACEMETHOD method)
{
std::string filter;
- filter = "yadif=1:-1";
+ filter = "bwdif=1:-1";
if (avfilter_graph_parse_ptr(m_pFilterGraph, filter.c_str(), &inputs, &outputs, NULL) < 0)
{
@@ -3026,7 +3026,7 @@ bool CFFmpegPostproc::Init(EINTERLACEMETHOD method)
return false;
}
- m_config.processInfo->SetVideoDeintMethod("yadif");
+ m_config.processInfo->SetVideoDeintMethod("bwdif");
}
else if (method == VS_INTERLACEMETHOD_RENDER_BOB ||
method == VS_INTERLACEMETHOD_NONE)
--
2.39.2

View File

@ -0,0 +1,55 @@
From 88d0dd1bb5be849f2066f92f55bd7d8c80eb7edf Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com>
Date: Tue, 20 Jun 2023 15:13:09 +0100
Subject: [PATCH 10/12] CDVDVideoCodecDRMPRIME: Support decoding to DRMPRIME
with sw deinterlace
We can map a YUV style DRM_PRIME buffer back to AV_PIX_FMT_YUV420P
to allow subsquent sw deinterlace
---
.../DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index b614312a77..023334f5db 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -700,6 +700,9 @@ bool CDVDVideoCodecDRMPRIME::FilterOpen(const std::string& filters, AVPixelForma
if (filters.find("deinterlace") != std::string::npos && pix_fmt == AV_PIX_FMT_YUV420P)
pix_fmt = AV_PIX_FMT_DRM_PRIME;
+ if (filters.find("bwdif") != std::string::npos && pix_fmt == AV_PIX_FMT_DRM_PRIME)
+ pix_fmt = AV_PIX_FMT_YUV420P;
+
if (m_pFilterGraph)
FilterClose();
@@ -866,6 +869,25 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn()
m_pFrame->data[0] = reinterpret_cast<uint8_t*>(descriptor);
m_pFrame->format = AV_PIX_FMT_DRM_PRIME;
}
+ // hw decoded buffers submitted to sw decoder need mapping of planes for cpu to access
+ else if (m_pFrame->format == AV_PIX_FMT_DRM_PRIME && m_pFilterGraph && m_pFilterIn->outputs[0]->format == AV_PIX_FMT_YUV420P)
+ {
+ AVFrame *frame = av_frame_alloc();
+ frame->width = m_pFrame->width;
+ frame->height = m_pFrame->height;
+ frame->format = AV_PIX_FMT_YUV420P;
+ int ret = av_hwframe_map(frame, m_pFrame, (int)AV_HWFRAME_MAP_READ);
+ if (ret < 0)
+ {
+ char err[AV_ERROR_MAX_STRING_SIZE] = {};
+ av_strerror(ret, err, AV_ERROR_MAX_STRING_SIZE);
+ CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::{} - av_hwframe_map failed: {} ({})",
+ __FUNCTION__, err, ret);
+ return VC_ERROR;
+ }
+ av_frame_unref(m_pFrame);
+ av_frame_move_ref(m_pFrame, frame);
+ }
int ret = av_buffersrc_add_frame(m_pFilterIn, m_pFrame);
if (ret < 0)
--
2.39.2

View File

@ -0,0 +1,30 @@
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

View File

@ -0,0 +1,123 @@
From 4eded8af13fe44c12ed2c26e40abfe9e9d08281f Mon Sep 17 00:00:00 2001
From: Dom Cobley <popcornmix@gmail.com>
Date: Wed, 21 Jun 2023 13:16:01 +0100
Subject: [PATCH 12/12] DVDVideoCodecDRMPRIME: Add setting to enable hw
deinterlace
HW deinterlace has lower cpu, but may have higher quality,
so allow user to choose appropriate setting.
---
.../resource.language.en_gb/resources/strings.po | 11 +++++++++++
system/settings/linux.xml | 12 ++++++++++++
.../DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 16 +++++++++++++++-
xbmc/settings/Settings.h | 1 +
4 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
index 062d3afd2b..8c6e31965a 100644
--- a/addons/resource.language.en_gb/resources/strings.po
+++ b/addons/resource.language.en_gb/resources/strings.po
@@ -7311,6 +7311,11 @@ msgctxt "#13438"
msgid "Allow hardware acceleration with DRM PRIME"
msgstr ""
+#: system/settings/settings.xml
+msgctxt "#13500"
+msgid "Allow hardware deinterlace with DRM PRIME"
+msgstr ""
+
#: system/settings/settings.xml
msgctxt "#13439"
msgid "Allow hardware acceleration - MediaCodec"
@@ -19424,6 +19429,12 @@ msgctxt "#36172"
msgid "Enable PRIME decoding of video files"
msgstr ""
+#. Description of setting with label #13500 "Allow hardware deinterlace - PRIME"
+#: system/settings/settings.xml
+msgctxt "#36290"
+msgid "Enable PRIME hardware deinterlace of video files"
+msgstr ""
+
#. Description of setting with label #14109 "Short date format"
#: system/settings/settings.xml
msgctxt "#36173"
diff --git a/system/settings/linux.xml b/system/settings/linux.xml
index 531974f3f4..c2df62c047 100644
--- a/system/settings/linux.xml
+++ b/system/settings/linux.xml
@@ -180,6 +180,18 @@
<default>true</default>
<control type="toggle" />
</setting>
+ <setting id="videoplayer.primeallowhwdeinterlace" type="boolean" parent="videoplayer.useprimedecoder" label="13500" help="36290">
+ <requirement>HAS_GLES</requirement>
+ <visible>false</visible>
+ <dependencies>
+ <dependency type="enable">
+ <condition setting="videoplayer.useprimedecoder" operator="is">true</condition>
+ </dependency>
+ </dependencies>
+ <level>3</level>
+ <default>true</default>
+ <control type="toggle" />
+ </setting>
<setting id="videoplayer.useprimerenderer" type="integer" label="13462" help="13463">
<requirement>HAS_GLES</requirement>
<visible>false</visible>
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
index 0182f30a61..cd3b4e89a2 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
@@ -41,6 +41,7 @@ namespace
{
constexpr const char* SETTING_VIDEOPLAYER_USEPRIMEDECODERFORHW{"videoplayer.useprimedecoderforhw"};
+constexpr const char* SETTING_VIDEOPLAYER_ALLOWHWDEINTERLACE{"videoplayer.primeallowhwdeinterlace"};
static void ReleaseBuffer(void* opaque, uint8_t* data)
{
@@ -149,6 +150,15 @@ void CDVDVideoCodecDRMPRIME::Register()
setting->SetVisible(true);
+ setting = settings->GetSetting(SETTING_VIDEOPLAYER_ALLOWHWDEINTERLACE);
+ if (!setting)
+ {
+ CLog::Log(LOGERROR, "Failed to load setting for: {}", SETTING_VIDEOPLAYER_ALLOWHWDEINTERLACE);
+ return;
+ }
+
+ setting->SetVisible(true);
+
CDVDFactoryCodec::RegisterHWVideoCodec("drm_prime", CDVDVideoCodecDRMPRIME::Create);
}
@@ -650,7 +660,11 @@ void CDVDVideoCodecDRMPRIME::FilterTest(AVPixelFormat pix_fmt)
m_deintFilterName.clear();
// look twice, first for DRM_PRIME support, then for actual pixel format
- for (int i=0; i < 2; i++)
+
+ bool hw = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
+ SETTING_VIDEOPLAYER_ALLOWHWDEINTERLACE);
+
+ for (int i = hw ? 0 : 1; i < 2; i++)
{
const AVFilter* filter;
void* opaque{};
diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h
index a4f91e9f92..e9cb3dc2be 100644
--- a/xbmc/settings/Settings.h
+++ b/xbmc/settings/Settings.h
@@ -117,6 +117,7 @@ public:
static constexpr auto SETTING_VIDEOPLAYER_USEMEDIACODEC = "videoplayer.usemediacodec";
static constexpr auto SETTING_VIDEOPLAYER_USEMEDIACODECSURFACE =
"videoplayer.usemediacodecsurface";
+ static constexpr auto SETTING_VIDEOPLAYER_ALLOWHWDEINTERLACE = "videoplayer.primeallowhwdeinterlace";
static constexpr auto SETTING_VIDEOPLAYER_USEVDPAU = "videoplayer.usevdpau";
static constexpr auto SETTING_VIDEOPLAYER_USEVDPAUMIXER = "videoplayer.usevdpaumixer";
static constexpr auto SETTING_VIDEOPLAYER_USEVDPAUMPEG2 = "videoplayer.usevdpaumpeg2";
--
2.39.2