|
1 |
| -From cdb8a7cfa07a0197c3eef0870be8aba197796d37 Mon Sep 17 00:00:00 2001 |
| 1 | +From eff7783ad8ffc8c82d907b35b0fd1483a3228397 Mon Sep 17 00:00:00 2001 |
2 | 2 | From: Mengkejiergeli Ba < [email protected]>
|
3 | 3 | Date: Thu, 21 Sep 2023 17:51:35 +0800
|
4 | 4 | Subject: [PATCH] msdkdec: Apply dynamic allocation for VPL>=2.9
|
5 | 5 |
|
6 | 6 | ---
|
7 | 7 | .../sys/msdk/gstmsdkallocator_d3d.c | 243 +++++++------
|
8 | 8 | .../sys/msdk/gstmsdkallocator_libva.c | 318 +++++++++---------
|
9 |
| - .../gst-plugins-bad/sys/msdk/gstmsdkdec.c | 136 +++++--- |
| 9 | + .../gst-plugins-bad/sys/msdk/gstmsdkdec.c | 144 +++++--- |
10 | 10 | .../gst-plugins-bad/sys/msdk/gstmsdkdec.h | 3 +
|
11 |
| - 4 files changed, 397 insertions(+), 303 deletions(-) |
| 11 | + 4 files changed, 401 insertions(+), 307 deletions(-) |
12 | 12 |
|
13 | 13 | diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkallocator_d3d.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkallocator_d3d.c
|
14 | 14 | index 4dcf154f48..c9ae865e7c 100644
|
@@ -649,7 +649,7 @@ index 4e23b257a6..fbbbb1ac6c 100644
|
649 | 649 |
|
650 | 650 | mfxStatus
|
651 | 651 | 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 |
653 | 653 | --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c
|
654 | 654 | +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c
|
655 | 655 | @@ -175,12 +175,35 @@ gst_msdkdec_free_unlocked_msdk_surfaces (GstMsdkDec * thiz,
|
@@ -716,47 +716,61 @@ index 37afa2ee61..28f1080eeb 100644
|
716 | 716 | * In the case of decoder plus multi-encoders, it is possible
|
717 | 717 | * that all surfaces are used by downstreams and no more surfaces
|
718 | 718 | * 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"); |
720 | 721 | return NULL;
|
721 | 722 | }
|
722 |
| - #endif |
723 |
| -- mem = gst_buffer_peek_memory (out_buffer, 0); |
724 | 723 | +
|
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 | ++ |
731 | 726 | + /* From oneVPL 2.9, we can dynamically allocate buffer from the pool */
|
732 | 727 | + if (MFX_RUNTIME_VERSION_ATLEAST (thiz->version, 2, 9)) {
|
733 | 728 | + if (_get_surface_from_qdata (out_buffer, &msdk_surface)) {
|
734 | 729 | + } else {
|
735 | 730 | + 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); |
737 | 732 | + if (!msdk_surface) {
|
738 | 733 | + g_slice_free (GstMsdkSurface, msdk_surface);
|
739 | 734 | + return NULL;
|
740 | 735 | + }
|
741 | 736 | + }
|
742 | 737 | + } else {
|
743 | 738 | + 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 | ++ } |
744 | 745 | #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 |
745 | 763 | - gst_buffer_unmap (out_buffer, &map_info);
|
746 |
| -+ gst_buffer_unmap (out_buffer, &map_info); |
| 764 | ++ gst_buffer_unmap (out_buffer, &map_info); |
747 | 765 | #endif
|
748 | 766 | - } else {
|
749 | 767 | - GST_ERROR ("No available surfaces");
|
750 | 768 | - g_slice_free (GstMsdkSurface, msdk_surface);
|
751 | 769 | - return NULL;
|
752 |
| -+ } else { |
753 |
| -+ GST_ERROR ("No available surfaces"); |
754 |
| -+ g_slice_free (GstMsdkSurface, msdk_surface); |
755 |
| -+ return NULL; |
756 |
| -+ } |
757 |
| - } |
| 770 | +- } |
758 | 771 |
|
759 | 772 | msdk_surface->buf = out_buffer;
|
| 773 | + |
760 | 774 | @@ -418,6 +450,13 @@ gst_msdkdec_init_decoder (GstMsdkDec * thiz)
|
761 | 775 | }
|
762 | 776 |
|
@@ -880,5 +894,5 @@ index 88eeaa1873..06afe6604d 100644
|
880 | 894 |
|
881 | 895 | struct _GstMsdkDecClass
|
882 | 896 | --
|
883 |
| -2.34.1 |
| 897 | +2.41.0.windows.1 |
884 | 898 |
|
0 commit comments