Commit graph

20 commits

Author SHA1 Message Date
Mengkejiergeli Ba 799c6ff860 msdkdec: Check available surfaces when all pre-allocated surfaces are in use
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3439>
2023-02-27 12:22:13 +00:00
Mengkejiergeli Ba 3062f1b6b0 msdkdec: Apply the modified memory allocation logic
We did several things to enable the new memory logic in msdkdec:
(1) We always use video memory for decoder in linux path;
(2) We give negotiated pool to alloc_pool stored in GstMsdkContext which
will be used in callback mfxFrameAllocator:Alloc to alloc surfaces as
MediaSDK needs, and this pool is also available for decoder itself;
(3) We modify decide_allocation process, that is we make pool negotiaion
before gst_msdk_init_decoder to ensure the pool is decided and ready for
use in mfxFrameAllocator:Alloc callback; then we will consider the case
when we need to do the gpu to cpu copy.
(4) In gst_msdkdec_finish_task, we modify the way for copy following the
logic in (3).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3439>
2023-02-27 12:22:13 +00:00
Mengkejiergeli Ba 75efb204e5 msdkdec: Add a function to create va pool
Add a pool creation function name as 2 for later use which will create
va pool for video memory in linux and keep system pool for windows.
This gst_msdkdec_create_buffer_pool2 will replace gst_msdkdec_create_buffer_pool
when all the memory allocation modifications are ready in the commits after.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3439>
2023-02-27 12:22:13 +00:00
Mengkejiergeli Ba 4124b8ffd4 msdkdec: Add a function to directly allocate output GstMsdkSurface
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3439>
2023-02-27 12:22:13 +00:00
Mengkejiergeli Ba 3b0d300759 msdkdec: Enable va caps at srcpad
Set caps with VA memory at src pad with a higher priority, then comes
dmabuf caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3439>
2023-02-27 12:22:13 +00:00
Mengkejiergeli Ba 4e60e91a05 msdkdec: Fix some lock issue
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3947>
2023-02-20 09:38:09 +08:00
Ma, Mingyang 66087b6276 msdkdec: Update decoding pts
Update frame pts before calling gst_video_decoder_finish_frame, or frames may be lost when transcoding in specific stream

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3449>
2022-11-25 01:42:58 +00:00
Tong Wu d61a248ac8 MSDK: Introduce d3d11 device to MSDK context
Currently MSDK context does not support d3d11va. Now introduce d3d11va
device to MSDK context, making it able to create msdk session with d3d11
device and to easily share with upstream and donwstream.

Add environment variable to enable user to choose GPU device in multi-GPU
environment. This variable is only valid when there's no context
returned by upstream or downstream. Otherwise it will use the device
that created by upstream or downstream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3231>
2022-11-11 06:02:28 +00:00
Vincent Cheah Beng Keat 5ffaf2aa09 msdkmjpegdec: Add support for error report
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2401>
2022-07-01 06:29:30 +00:00
Mengkejiergeli Ba 1fe5655c2a msdkdec: Decoder should use its own pool when downstream allocator is not recognizable
Msdkdec should use it own pool when the allocation from downstream query
is not any msdk_allocator (i.e. msdk_video_allocator,
msdk_dmabuf_allocator and msdk_system_allocator). Otherwise, when using
pipeline "msdkh264dec ! vah264enc !" to transcode a not 16-bit-aligned
stream (i.e. 1920x1080), the transcoding will fail due to the size
mismatch issue between decoder pool and encoder pool.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2451>
2022-06-08 02:48:53 +00:00
Mengkejiergeli Ba d8ab85c3ef msdkdec: Check width and height of mfxVideoParam before allocation
DecodeHeader must be called to fill the mfxVideoParam before allocation,
and thus the check for width and height in mfxVideoParam is necessary.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1817>
2022-03-22 05:22:09 +00:00
Mengkejiergeli Ba c9aa529484 msdkdec: Fix to not trigger SFC scaling when vpp at downstream
When there is vpp scaling downstream, we need to make sure SFC is not
triggered because vpp may fall into passthrough mode which causes
the decoder negotiation to create src caps with vpp scaled width/height.

This patch includes bitstream's original size in first query with
downstream in gst_msdkdec_src_caps, which is the same for what we do for
color format in this query. This is to ensure SFC scaling starts to
work only when downstream directly asks for a different size instead of
through vpp.

Note that here SFC scaling follows the same behavior as msdkvpp:
if user only changes width or height, e.g. dec ! video/x-raw,width=xx !,
the height will be modified to the value which fits the original DAR.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1838>
2022-03-07 07:26:40 +00:00
Mengkejiergeli Ba b41c70aed5 msdkdec: Fix uninitialized variables
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1731>
2022-02-25 03:11:29 +00:00
Mengkejiergeli Ba e1090c152c msdk: Fix unchecked return values
There are several calls of gst_video_info_from_caps and gst_video_frame_copy
without checks for the returned values. This patch adds all necessary
function return checks.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1738>
2022-02-25 02:04:20 +00:00
Mengkejiergeli Ba 586dfab9bd msdkdec: Enable SFC scaling for AVC and HEVC
Decoder SFC only supports down-scaling at most to 1/8.
For example, given a 4K bistream, SFC can scale it to 1080p via:
"msdkh265dec ! video/x-raw,width=1920,height=1080 ! glimagesink"

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1444>
2022-02-16 08:26:46 +00:00
Mengkejiergeli Ba c5f0e075e2 msdkdec: Enable SFC csc for AVC and HEVC
Decoder SFC will be triggered when default output format is not accept at
downstream. One use case below can work without using msdkvpp:
"! msdkh265dec ! "video/x-raw,format=BGRA" ! glimagesink",

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1444>
2022-02-16 08:26:46 +00:00
Mengkejiergeli Ba eb742c8ed0 msdkdec: Add SFC codes
SFC refers to Scaler Format Converter, more details here:
https://01.org/sites/default/files/documentation/intel-gfx-prm-osrc-kbl-vol15-sfc.pdf
By attaching mfxExtDecVideoProcessing buffer to mfxVideoParam, decoder
can do SFC for csc and scaling.

MSDK will check if surface bitdepth equals to input when no SFC is
triggered, which means in the case of SFC, there is no need to update
surface bitdepth via gst_msdk_update_mfx_frame_info_from_mfx_video_param.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1444>
2022-02-16 08:26:46 +00:00
He Junyan db5be289c7 MSDK: Handle context query into the decoder's query function.
The MSDK decoder's query function is not set and it just forwards
all query to its base class. We now need to answer the context
query correctly. Other VA plugins need to query the VA display.

By the way, the current query of "gst.msdk.Context" is also missing.
The other MSDK elements must depend on the bin's context message(
sent in context_propagate()) to set their MsdkContext correctly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1087>
2022-02-11 07:13:45 +00:00
He Junyan 85664b5af6 MSDK: Improve the GstContext setting logic.
We now can use the gst va lib's display to create our MSDK context,
and use its helper functions to simplify our code. The improved logic
is like this:
1. Every MSDK element should use gst_msdk_context_find() to find a MSDK
context from neighbour. If valid, reuse it.
2. Use gst_msdk_ensure_new_context(). It will first query neighbours
about the GstVaDisplay, if found(e.g. some VA element is connected),
use gst_msdk_context_from_external_display() to create a MSDK context.
3. Then, creating the MSDK context from scratch. It creates both the
display and MSDK context.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1087>
2022-02-11 07:13:45 +00:00
Thibault Saunier 019971a3c7 Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir 2021-09-24 16:14:36 -03:00
Renamed from sys/msdk/gstmsdkdec.c (Browse further)