summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia
diff options
context:
space:
mode:
authorLim Siew Hoon <siew.hoon.lim@intel.com>2020-11-26 03:58:32 (GMT)
committerAnuj Mittal <anuj.mittal@intel.com>2020-11-26 05:28:14 (GMT)
commit64c71508c0f3e30089a8905dd094091793e006dc (patch)
tree5203f2d0740bde62be70e704a7d210192dc16f00 /recipes-multimedia
parentdf2f578b4923bf6513c4309d8aa0f3d3e4074296 (diff)
downloadmeta-intel-64c71508c0f3e30089a8905dd094091793e006dc.tar.gz
intel-mediasdk: backport fixed video stuttering
Fixes issues when playing back video with Weston 8.0. Signed-off-by: Lim Siew Hoon <siew.hoon.lim@intel.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'recipes-multimedia')
-rw-r--r--recipes-multimedia/mediasdk/files/0001-Fix-video-stuttering-during-wayland-rendering.patch230
-rw-r--r--recipes-multimedia/mediasdk/intel-mediasdk_20.3.0.bb1
2 files changed, 231 insertions, 0 deletions
diff --git a/recipes-multimedia/mediasdk/files/0001-Fix-video-stuttering-during-wayland-rendering.patch b/recipes-multimedia/mediasdk/files/0001-Fix-video-stuttering-during-wayland-rendering.patch
new file mode 100644
index 0000000..1a28fa1
--- /dev/null
+++ b/recipes-multimedia/mediasdk/files/0001-Fix-video-stuttering-during-wayland-rendering.patch
@@ -0,0 +1,230 @@
1From 0c07c8b9ecbb1224b74712f5b41f2504d27ff38f Mon Sep 17 00:00:00 2001
2From: Lim Siew Hoon <siew.hoon.lim@intel.com>
3Date: Tue, 24 Nov 2020 14:44:05 +0800
4Subject: [PATCH] Fix video stuttering during wayland rendering
5
6The issue at here when RenderFrame exits, does not mean
7corresponding wl_buffer is not used anymore by weston.
8So, the wl_buffer has be wait until buffer_release function
9call out under wl_buffer_listener get trigger. Than only
10consider wl_buffer is no longer used anymore by weston and
11safe to use by previous upper component like vpp csc.
12
13The implementation code fixed at here is to prevent surface
14get overwrite and used back by vpp csc inside sample_decode
15when wl_buffer still not yet release when RenderFrame exits.
16
17Platform: EHL, TGL-U, TGL-H
18OS: Yocto native wayland weston
19Tested:
20./sample_decode h264 -i Puppies_1920x1080.h264 -rwld -rgb4 -f 30
21
22Signed-off-by: Lim Siew Hoon <siew.hoon.lim@intel.com>
23
24The patch was imported from the MediaSDK git server
25(git@github.com:Intel-Media-SDK/MediaSDK.git) as of commit id
2675bd6562f7ea90e2a2666dccab9c09ea58d3d23e.
27
28Upstream-Status: Backport
29
30Signed-off-by: Lim Siew Hoon <siew.hoon.lim@intel.com>
31---
32 samples/sample_common/src/vaapi_device.cpp | 2 +-
33 .../wayland/include/class_wayland.h | 16 ++++-
34 .../sample_misc/wayland/src/class_wayland.cpp | 67 +++++++++++++++++--
35 .../wayland/src/listener_wayland.cpp | 2 +
36 4 files changed, 78 insertions(+), 9 deletions(-)
37
38diff --git a/samples/sample_common/src/vaapi_device.cpp b/samples/sample_common/src/vaapi_device.cpp
39index de435fe7..238449ff 100644
40--- a/samples/sample_common/src/vaapi_device.cpp
41+++ b/samples/sample_common/src/vaapi_device.cpp
42@@ -397,7 +397,7 @@ mfxStatus CVAAPIDeviceWayland::RenderFrame(mfxFrameSurface1 * pSurface, mfxFrame
43 return mfx_res;
44 }
45
46- m_Wayland->RenderBuffer(m_wl_buffer, pSurface->Info.CropW, pSurface->Info.CropH);
47+ m_Wayland->RenderBuffer(m_wl_buffer, pSurface);
48
49 return mfx_res;
50 }
51diff --git a/samples/sample_misc/wayland/include/class_wayland.h b/samples/sample_misc/wayland/include/class_wayland.h
52index c2c8cea0..18a1e406 100644
53--- a/samples/sample_misc/wayland/include/class_wayland.h
54+++ b/samples/sample_misc/wayland/include/class_wayland.h
55@@ -28,7 +28,13 @@ extern "C"
56 }
57 #include <poll.h>
58 #include <wayland-client.h>
59+#include <list>
60 #include "wayland-drm-client-protocol.h"
61+#include "mfxstructures.h"
62+#include "mfx_buffering.h"
63+#include "sample_defs.h"
64+
65+typedef struct buffer wld_buffer;
66
67 /* ShmPool Struct */
68 struct ShmPool {
69@@ -38,7 +44,7 @@ struct ShmPool {
70 unsigned size;
71 };
72
73-class Wayland {
74+class Wayland: public CBuffering {
75 public:
76 Wayland();
77 virtual ~Wayland();
78@@ -47,8 +53,7 @@ class Wayland {
79 virtual void FreeSurface();
80 virtual void SetRenderWinPos(int x, int y);
81 virtual void RenderBuffer(struct wl_buffer *buffer
82- , int32_t width
83- , int32_t height);
84+ , mfxFrameSurface1 *surface);
85 virtual void RenderBufferWinPosSize(struct wl_buffer *buffer
86 , int x
87 , int y
88@@ -115,6 +120,9 @@ class Wayland {
89 void DestroyCallback();
90 virtual void Sync();
91 virtual void SetPerfMode(bool perf_mode);
92+ void AddBufferToList(wld_buffer *buffer);
93+ void RemoveBufferFromList(struct wl_buffer *buffer);
94+ void DestroyBufferList();
95 private:
96 //no copies allowed
97 Wayland(const Wayland &);
98@@ -140,6 +148,8 @@ class Wayland {
99 char *m_device_name;
100 int m_x, m_y;
101 bool m_perf_mode;
102+ protected:
103+ std::list<wld_buffer*> m_buffers_list;
104 };
105
106 extern "C" Wayland* WaylandCreate();
107diff --git a/samples/sample_misc/wayland/src/class_wayland.cpp b/samples/sample_misc/wayland/src/class_wayland.cpp
108index 5d0e6208..62f326e3 100644
109--- a/samples/sample_misc/wayland/src/class_wayland.cpp
110+++ b/samples/sample_misc/wayland/src/class_wayland.cpp
111@@ -35,6 +35,11 @@ extern "C" {
112
113 #define BATCH_SIZE 0x80000
114
115+struct buffer {
116+ struct wl_buffer *buffer;
117+ mfxFrameSurface1 *pInSurface;
118+};
119+
120 static const struct wl_callback_listener frame_listener = {
121 handle_done
122 };
123@@ -169,15 +174,22 @@ void Wayland::SetRenderWinPos(int x, int y)
124 }
125
126 void Wayland::RenderBuffer(struct wl_buffer *buffer
127- , int32_t width
128- , int32_t height)
129+ , mfxFrameSurface1 *surface)
130 {
131+ wld_buffer *m_buffer = new wld_buffer;
132+ if (m_buffer == NULL)
133+ return;
134+
135+ m_buffer->buffer = buffer;
136+ m_buffer->pInSurface = surface;
137+
138 wl_surface_attach(m_surface, buffer, 0, 0);
139- wl_surface_damage(m_surface, m_x, m_y, width, height);
140+ wl_surface_damage(m_surface, m_x, m_y, surface->Info.CropW, surface->Info.CropH);
141
142 wl_proxy_set_queue((struct wl_proxy *) buffer, m_event_queue);
143
144- wl_buffer_add_listener(buffer, &buffer_listener, NULL);
145+ AddBufferToList(m_buffer);
146+ wl_buffer_add_listener(buffer, &buffer_listener, this);
147 m_pending_frame=1;
148 if (m_perf_mode)
149 m_callback = wl_display_sync(m_display);
150@@ -365,6 +377,8 @@ Wayland::~Wayland()
151 wl_compositor_destroy(m_compositor);
152 if(NULL != m_event_queue)
153 wl_event_queue_destroy(m_event_queue);
154+ if(0 != m_buffers_list.size())
155+ DestroyBufferList();
156 if(NULL != m_registry)
157 wl_registry_destroy(m_registry);
158 if(NULL != m_display)
159@@ -428,6 +442,50 @@ void Wayland::DrmHandleAuthenticated()
160 m_bufmgr = drm_intel_bufmgr_gem_init(m_fd, BATCH_SIZE);
161 }
162
163+void Wayland::AddBufferToList(wld_buffer *buffer)
164+{
165+ if (buffer == NULL)
166+ return;
167+
168+ if (buffer->pInSurface) {
169+ msdkFrameSurface *surface = FindUsedSurface(buffer->pInSurface);
170+ msdk_atomic_inc16(&(surface->render_lock));
171+ m_buffers_list.push_back(buffer);
172+ }
173+}
174+
175+void Wayland::RemoveBufferFromList(struct wl_buffer *buffer)
176+{
177+ wld_buffer *m_buffer = NULL;
178+ m_buffer = m_buffers_list.front();
179+ if (NULL != m_buffer && (m_buffer->buffer == buffer)) {
180+ if (m_buffer->pInSurface) {
181+ msdkFrameSurface *surface = FindUsedSurface(m_buffer->pInSurface);
182+ msdk_atomic_dec16(&(surface->render_lock));
183+ }
184+ m_buffer->buffer = NULL;
185+ m_buffer->pInSurface = NULL;
186+ m_buffers_list.pop_front();
187+ delete m_buffer;
188+ }
189+}
190+
191+void Wayland::DestroyBufferList()
192+{
193+ wld_buffer *m_buffer = NULL;
194+ while (!m_buffers_list.empty())
195+ {
196+ m_buffer = m_buffers_list.front();
197+ if (m_buffer->pInSurface)
198+ {
199+ msdkFrameSurface *surface = FindUsedSurface(m_buffer->pInSurface);
200+ msdk_atomic_dec16(&(surface->render_lock));
201+ }
202+ m_buffers_list.pop_front();
203+ delete m_buffer;
204+ }
205+}
206+
207 Wayland* WaylandCreate()
208 {
209 return new Wayland;
210@@ -437,4 +495,3 @@ void WaylandDestroy(Wayland *pWld)
211 {
212 delete pWld;
213 }
214-
215diff --git a/samples/sample_misc/wayland/src/listener_wayland.cpp b/samples/sample_misc/wayland/src/listener_wayland.cpp
216index dc68c1d5..90f582a7 100644
217--- a/samples/sample_misc/wayland/src/listener_wayland.cpp
218+++ b/samples/sample_misc/wayland/src/listener_wayland.cpp
219@@ -98,6 +98,8 @@ void handle_done(void *data, struct wl_callback *callback, uint32_t time)
220
221 void buffer_release(void *data, struct wl_buffer *buffer)
222 {
223+ Wayland *wayland = static_cast<Wayland*>(data);
224+ wayland->RemoveBufferFromList(buffer);
225 wl_buffer_destroy(buffer);
226 buffer = NULL;
227 }
228--
2292.17.1
230
diff --git a/recipes-multimedia/mediasdk/intel-mediasdk_20.3.0.bb b/recipes-multimedia/mediasdk/intel-mediasdk_20.3.0.bb
index 62cc2a5..871b63f 100644
--- a/recipes-multimedia/mediasdk/intel-mediasdk_20.3.0.bb
+++ b/recipes-multimedia/mediasdk/intel-mediasdk_20.3.0.bb
@@ -34,6 +34,7 @@ PACKAGECONFIG[wayland] = "-DENABLE_WAYLAND=ON, -DENABLE_WAYLAND=OFF, wayland way
34SRC_URI = "git://github.com/Intel-Media-SDK/MediaSDK.git;protocol=https;branch=${BPN}-20.3;lfs=0 \ 34SRC_URI = "git://github.com/Intel-Media-SDK/MediaSDK.git;protocol=https;branch=${BPN}-20.3;lfs=0 \
35 file://0001-FindOpenCL.cmake-don-t-look-for-driver-at-build-time.patch \ 35 file://0001-FindOpenCL.cmake-don-t-look-for-driver-at-build-time.patch \
36 file://0001-FindITT.cmake-fix-detection-of-header-library.patch \ 36 file://0001-FindITT.cmake-fix-detection-of-header-library.patch \
37 file://0001-Fix-video-stuttering-during-wayland-rendering.patch \
37 " 38 "
38SRCREV = "34c7cbbb3775bd547a16ea37576297b290b603a4" 39SRCREV = "34c7cbbb3775bd547a16ea37576297b290b603a4"
39S = "${WORKDIR}/git" 40S = "${WORKDIR}/git"