Skip to content

Commit d63faae

Browse files
tong1wuHeJunyan
authored andcommitted
update dynamic allocation patch to fix regression on Windows
1 parent b09798a commit d63faae

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

patches/0140-msdkdec-Apply-dynamic-allocation-for-VPL-2.9.patch

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From cdb8a7cfa07a0197c3eef0870be8aba197796d37 Mon Sep 17 00:00:00 2001
1+
From eff7783ad8ffc8c82d907b35b0fd1483a3228397 Mon Sep 17 00:00:00 2001
22
From: Mengkejiergeli Ba <[email protected]>
33
Date: Thu, 21 Sep 2023 17:51:35 +0800
44
Subject: [PATCH] msdkdec: Apply dynamic allocation for VPL>=2.9
55

66
---
77
.../sys/msdk/gstmsdkallocator_d3d.c | 243 +++++++------
88
.../sys/msdk/gstmsdkallocator_libva.c | 318 +++++++++---------
9-
.../gst-plugins-bad/sys/msdk/gstmsdkdec.c | 136 +++++---
9+
.../gst-plugins-bad/sys/msdk/gstmsdkdec.c | 144 +++++---
1010
.../gst-plugins-bad/sys/msdk/gstmsdkdec.h | 3 +
11-
4 files changed, 397 insertions(+), 303 deletions(-)
11+
4 files changed, 401 insertions(+), 307 deletions(-)
1212

1313
diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkallocator_d3d.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkallocator_d3d.c
1414
index 4dcf154f48..c9ae865e7c 100644
@@ -649,7 +649,7 @@ index 4e23b257a6..fbbbb1ac6c 100644
649649

650650
mfxStatus
651651
diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c
652-
index 37afa2ee61..28f1080eeb 100644
652+
index 37afa2ee61..4a1395b8aa 100644
653653
--- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c
654654
+++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c
655655
@@ -175,12 +175,35 @@ gst_msdkdec_free_unlocked_msdk_surfaces (GstMsdkDec * thiz,
@@ -716,47 +716,61 @@ index 37afa2ee61..28f1080eeb 100644
716716
* In the case of decoder plus multi-encoders, it is possible
717717
* that all surfaces are used by downstreams and no more surfaces
718718
* available for decoder. So here we need to wait until there is at
719-
@@ -231,20 +253,30 @@ allocate_output_surface (GstMsdkDec * thiz)
719+
@@ -222,30 +244,40 @@ allocate_output_surface (GstMsdkDec * thiz)
720+
GST_ERROR_OBJECT (thiz, "Failed to allocate output buffer");
720721
return NULL;
721722
}
722-
#endif
723-
- mem = gst_buffer_peek_memory (out_buffer, 0);
724723
+
725-
msdk_surface = g_slice_new0 (GstMsdkSurface);
726-
727-
- if ((mfx_surface = gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (mem),
728-
- GST_MSDK_FRAME_SURFACE))) {
729-
- msdk_surface->surface = mfx_surface;
730-
- msdk_surface->from_qdata = TRUE;
724+
+ msdk_surface = g_slice_new0 (GstMsdkSurface);
725+
+
731726
+ /* From oneVPL 2.9, we can dynamically allocate buffer from the pool */
732727
+ if (MFX_RUNTIME_VERSION_ATLEAST (thiz->version, 2, 9)) {
733728
+ if (_get_surface_from_qdata (out_buffer, &msdk_surface)) {
734729
+ } else {
735730
+ msdk_surface = gst_msdk_import_to_msdk_surface (out_buffer, thiz->context,
736-
+ &thiz->alloc_info, GST_MAP_READ);
731+
+ &thiz->alloc_info, GST_MAP_WRITE);
737732
+ if (!msdk_surface) {
738733
+ g_slice_free (GstMsdkSurface, msdk_surface);
739734
+ return NULL;
740735
+ }
741736
+ }
742737
+ } else {
743738
+ if (_get_surface_from_qdata (out_buffer, &msdk_surface)) {
739+
+ } else {
740+
+ GST_ERROR ("No available surfaces");
741+
+ g_slice_free (GstMsdkSurface, msdk_surface);
742+
+ return NULL;
743+
+ }
744+
+ }
744745
#ifdef _WIN32
746+
/* For d3d11 we should call gst_buffer_map with GST_MAP_WRITE |
747+
* GST_MAP_D3D11 flags to make sure the staging texture has been uploaded
748+
*/
749+
if (!gst_buffer_map (out_buffer, &map_info, GST_MAP_WRITE | GST_MAP_D3D11)) {
750+
GST_ERROR ("Failed to map buffer");
751+
+ g_slice_free (GstMsdkSurface, msdk_surface);
752+
return NULL;
753+
}
754+
-#endif
755+
- mem = gst_buffer_peek_memory (out_buffer, 0);
756+
- msdk_surface = g_slice_new0 (GstMsdkSurface);
757+
758+
- if ((mfx_surface = gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (mem),
759+
- GST_MSDK_FRAME_SURFACE))) {
760+
- msdk_surface->surface = mfx_surface;
761+
- msdk_surface->from_qdata = TRUE;
762+
-#ifdef _WIN32
745763
- gst_buffer_unmap (out_buffer, &map_info);
746-
+ gst_buffer_unmap (out_buffer, &map_info);
764+
+ gst_buffer_unmap (out_buffer, &map_info);
747765
#endif
748766
- } else {
749767
- GST_ERROR ("No available surfaces");
750768
- g_slice_free (GstMsdkSurface, msdk_surface);
751769
- return NULL;
752-
+ } else {
753-
+ GST_ERROR ("No available surfaces");
754-
+ g_slice_free (GstMsdkSurface, msdk_surface);
755-
+ return NULL;
756-
+ }
757-
}
770+
- }
758771

759772
msdk_surface->buf = out_buffer;
773+
760774
@@ -418,6 +450,13 @@ gst_msdkdec_init_decoder (GstMsdkDec * thiz)
761775
}
762776

@@ -880,5 +894,5 @@ index 88eeaa1873..06afe6604d 100644
880894

881895
struct _GstMsdkDecClass
882896
--
883-
2.34.1
897+
2.41.0.windows.1
884898

0 commit comments

Comments
 (0)