-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy path0042-IMXRender-Refactor-to-improve-readability-and-perfor.patch
102 lines (89 loc) · 3.54 KB
/
0042-IMXRender-Refactor-to-improve-readability-and-perfor.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
From bc3d7cdaaeb4e6c532672f65d27509f312eff21e Mon Sep 17 00:00:00 2001
From: Rudi <[email protected]>
Date: Sun, 1 Jan 2017 17:56:17 +0100
Subject: [PATCH] IMXRender: Refactor to improve readability and performance
---
.../VideoRenderers/HwDecRender/RendererIMX.cpp | 29 ++++++++++------------
.../VideoRenderers/HwDecRender/RendererIMX.h | 5 ++--
2 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp
index b5c7095..5167bd2 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.cpp
@@ -34,13 +34,14 @@
CRendererIMX::CRendererIMX()
{
- m_bufHistory.clear();
+ m_bufHistory[0] = m_bufHistory[1] = nullptr;
}
CRendererIMX::~CRendererIMX()
{
UnInit();
- std::for_each(m_bufHistory.begin(), m_bufHistory.end(), Release);
+ SAFE_RELEASE(m_bufHistory[1]);
+ SAFE_RELEASE(m_bufHistory[0]);
g_IMX.Deinitialize();
}
@@ -139,12 +140,7 @@ bool CRendererIMX::RenderUpdateVideoHook(bool clear, DWORD flags, DWORD alpha)
CDVDVideoCodecIMXBuffer *buffer = static_cast<CDVDVideoCodecIMXBuffer*>(m_buffers[m_iYV12RenderBuffer].hwDec);
if (buffer)
{
- if (!m_bufHistory.empty() && m_bufHistory.back() != buffer || m_bufHistory.empty())
- {
- buffer->Lock();
- m_bufHistory.push_back(buffer);
- }
- else if (!m_bufHistory.empty() && m_bufHistory.back() == buffer && flagsPrev == flags)
+ if (buffer == m_bufHistory[0] && flagsPrev == flags)
{
g_IMX.WaitVsync();
return true;
@@ -152,12 +148,14 @@ bool CRendererIMX::RenderUpdateVideoHook(bool clear, DWORD flags, DWORD alpha)
flagsPrev = flags;
- int size = flags & RENDER_FLAG_FIELDMASK ? 2 : 1;
- while (m_bufHistory.size() > size)
- {
- m_bufHistory.front()->Release();
- m_bufHistory.pop_front();
- }
+ buffer->Lock();
+
+ SAFE_RELEASE(m_bufHistory[1]);
+ m_bufHistory[1] = m_bufHistory[0];
+ m_bufHistory[0] = buffer;
+
+ if (!(flags & RENDER_FLAG_FIELDMASK))
+ SAFE_RELEASE(m_bufHistory[1]);
// this hack is needed to get the 2D mode of a 3D movie going
RENDER_STEREO_MODE stereo_mode = g_graphicsContext.GetStereoMode();
@@ -206,8 +204,7 @@ bool CRendererIMX::RenderUpdateVideoHook(bool clear, DWORD flags, DWORD alpha)
}
}
- CDVDVideoCodecIMXBuffer *buffer_p = m_bufHistory.front();
- g_IMXContext.Blit(buffer_p == buffer ? nullptr : buffer_p, buffer, srcRect, dstRect, fieldFmt);
+ g_IMXContext.Blit(m_bufHistory[1], m_bufHistory[0], srcRect, dstRect, fieldFmt);
}
#if 0
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.h b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.h
index fc71e89..1a1ee2c 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererIMX.h
@@ -30,6 +30,8 @@
class CRendererIMX : public CLinuxRendererGLES
{
+ CDVDVideoCodecIMXBuffer *m_bufHistory[2];
+
public:
CRendererIMX();
virtual ~CRendererIMX();
@@ -61,9 +63,6 @@ protected:
virtual bool RenderHook(int index);
virtual int GetImageHook(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
virtual bool RenderUpdateVideoHook(bool clear, DWORD flags = 0, DWORD alpha = 255);
-
- std::deque<CDVDVideoCodecIMXBuffer*> m_bufHistory;
- static void Release(CDVDVideoCodecIMXBuffer *&t) { if (t) t->Release(); }
};
#endif
--
1.9.1