Commit graph

414 commits

Author SHA1 Message Date
Haihao Xiang
54091d0290 msdk: allow user specify a drm device via an env variable
User may specify the required device via GST_MSDK_DRM_DEVICE

Example:
GST_MSDK_DRM_DEVICE=/dev/dri/card0 gst-launch-1.0 videotestsrc ! msdkh264enc
! fakesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1953>
2021-02-24 04:40:14 +00:00
Haihao Xiang
3e2e07bb8a msdkenc: the unit for max-frame-size is kbyte
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1944>
2021-01-07 12:07:28 +00:00
Haihao Xiang
1f1a5b4ad1 msdkenc{h264,h265}: add min-qp and max-qp properties
The SDK allows user to set a QP range [1], so add min-qp and max-qp to
sepecify QP range. By default, there is no limitations on QP.

[1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxextcodingoption2

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1908>
2020-12-30 06:40:36 +00:00
Haihao Xiang
7bc3d51b42 msdkenc{h264,h265}: add p-pyramid property
The SDK can support P-Pyramid reference structure [1], so add a new
property to enable this feature in msdkenc{h264,h265}.

[1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#preftype

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1908>
2020-12-30 06:40:36 +00:00
Haihao Xiang
af988e282a msdkh265enc: add b-pyramid property
Like as msdkh264enc, b-pyramid is added to enable B-Pyramid reference
structure for H265 encoding

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1908>
2020-12-30 06:40:36 +00:00
Haihao Xiang
ff206f6525 msdkh265enc: add transform-skip property
Since the SDK API 1.26, TransformSkip was added to control
transform_skip_enabled_flag setting in PPS [1]

[1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxextcodingoption3

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1908>
2020-12-30 06:40:36 +00:00
Haihao Xiang
bdff6f5e42 msdk: needn't close mfx session when failed
Otherwise we will get double free issue because mfx session is closed in
finalize. See
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1867#note_739346
for the double free issue.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1916>
2020-12-30 05:08:52 +00:00
Haihao Xiang
86fdd39147 msdk: check GstMsdkContext instead of mfxSession instance
When creating a GstMsdkContext instance, it also creates a mfxSession
instance, so we may check GstMsdkContext instead of mfxSession instance
to make sure MSDK is available. In addition, according to MSDK doc [1],
MFXVideoCORE_SetHandle function should be executed before any actual
usage of library including queries, otherwise the behavior is
unexpected, so we should call MFXVideoCORE_QueryPlatform after
MFXVideoCORE_SetHandle on Linux

[1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#working-with-va-api-applications

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1867>
2020-12-24 02:53:13 +00:00
Olivier Crête
e17e88e033 msdkh264dec: Accept constrained-high and progressive-high profiles
They're just subsets of the high profile.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1634>
2020-11-18 15:46:52 -05:00
Haihao Xiang
df49114275 msdk: call vaExportSurfaceHandle() to get DMABuf FD
Compared to vaAcquireBufferHandle(), vaExportSurfaceHandle() may
provide the handle details, so we needn't call vaDeriveImage().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1353>
2020-09-29 02:06:02 +00:00
Haihao Xiang
912fa7ce99 msdk: add support for AV1 decoding
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1448>
2020-09-22 06:54:27 +00:00
Haihao Xiang
9443bf7a22 msdk: enable GPUCopy
Note it works for system memory only

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/910>
2020-09-20 01:40:08 +00:00
Haihao Xiang
1d082baf18 msdk: call MFXInitEx instead of MFXInit
MFXInitEx has more control than MFXInit. The current setting in this
commit is identical to MFXInit

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/910>
2020-09-20 01:40:08 +00:00
Randy Li (ayaka)
2f5904c20d msdk: vpp: fixup passthrough checking for DMA
I think it is just a typo from e1a90f1ec9
msdkvpp: Disable passthrough if memory capsfeature changes

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1559>
2020-09-16 03:02:31 +00:00
Haihao Xiang
cc3057e4ea msdkvp9dec: change the include header order
This fixes the compiler error when MFX_VERSION_USE_LATEST is defined in
the SDK.

/usr/include/mfx/mfxvp9.h:48:5: error: unknown type name ‘mfxExtBuffer’
     mfxExtBuffer Header;

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1549>
2020-09-01 13:57:13 +08:00
Xu Guangxin
9123b9ba39 msdkvpp: do not hold too many input buffers in locked list
If the surface is locked before vpp, upstream takes the reference.
We do not need to take a reference for msdk in vpp.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1490>
2020-08-13 01:43:19 +00:00
Xu Guangxin
ea0aac4c19 msdkvpp: refact, put input and output surface in diffrent list
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1490>
2020-08-13 01:43:19 +00:00
Haihao Xiang
e7160a97cf msdkh265enc: add the missing comma
Otherwise main-444 and main-444-10 are concatenated

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1436>
2020-07-15 08:38:07 +08:00
Haihao Xiang
c0e809d6b8 msdkh265enc: add support for screen content coding extension
Because the valid input formats for screen content coding extension is
a subset of input formats for range extension, user must specify the
profile for screen content coding extension in the caps filter

Example:
gst-launch-1.0 videotestsrc ! video/x-raw,format=NV12 ! msdkh265enc
low-power=1 ! video/x-h265,profile=screen-extended-main ! fakesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1389>
2020-07-11 23:42:52 +08:00
Haihao Xiang
e1d1cb07a6 msdkh265enc: allow user to choose profile
Example:
gst-launch-1.0 videotestsrc ! video/x-raw,format=NV12 ! msdkh265enc !
video/x-h265,profile=main-444 ! fakesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1389>
2020-07-11 23:42:52 +08:00
Haihao Xiang
55f3590317 msdkenc: support tune property in msdkh264enc and msdkh265enc
Introduce a new property for encoding mode selection, the default value
for this new property allows the SDK to decide what to do. In addition,
low-power is marked as deprecated since this fix

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1426>
2020-07-11 13:57:52 +00:00
Haihao Xiang
3ecb2a82be Revert "msdkh265enc: let MSDK select the encoding mode by default"
This reverts commit 9e977832c1.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1426>
2020-07-11 13:57:52 +00:00
Haihao Xiang
9e977832c1 msdkh265enc: let MSDK select the encoding mode by default
MSDK may support lowpower and non-lowpower modes, some features are
available only under one of the two modes, which is hard to know for
user, so let MSDK select the mode by default.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1405>
2020-07-06 14:43:31 +00:00
Xu Guangxin
610e477565 msdkdec: hold a reference for the surfaces locked by msdk
previous code releases GstBuffer too earlier. so we will see

ERROR                default gstmsdkvideomemory.c:77:gst_msdk_video_allocator_get_surface: failed to get surface available
ERROR         msdkbufferpool gstmsdkbufferpool.c:270:gst_msdk_buffer_pool_alloc_buffer:<msdkbufferpool0> failed to create new MSDK memory

We need to hold GstBuffer reference for msdk if the surfaced locked by msdk.

step to reproduce.
1. ffmpeg -f lavfi -i testsrc=duration=10:size=320x240:rate=30 -pix_fmt yuv420p -c:v libx265 test.265
2. GST_GL_PLATFORM=egl  gst-launch-1.0 -v filesrc location=test.265  ! h265parse ! msdkh265dec  ! queue ! glimagesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1277>
2020-06-15 02:46:53 +00:00
Haihao Xiang
f685893ed2 msdkh265enc: add support 12-bit 420 encoding
P016 is used for 12-bit encoding in MediaSDK, so the Shift flag is set
in the mfx parameters

Sample pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=P012_LE ! msdkh265enc ! \
fakesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1174>
2020-06-01 05:04:30 +00:00
Xu Guangxin
52be289847 msdkvpp: fix "failed to create new MSDK memory"
all msdk output surfaces come from out_alloc_resp, so the buffer count is not resizable.
we need set min_buffers, max_buffers to same size.

steps to reproduce
1. ffmpeg -f lavfi -i testsrc=duration=10:size=320x240:rate=30:decimals=3 -pix_fmt yuv420p -c:v libx265 ~/bits/hevc/test.265
2. GST_GL_PLATFORM=egl gst-launch-1.0 -v filesrc location=~/bits/hevc/test.265  ! h265parse ! msdkh265dec  ! msdkvpp ! queue ! glimagesink
you will see error like this:
ERROR                default gstmsdkvideomemory.c:77:gst_msdk_video_allocator_get_surface: failed to get surface available
ERROR         msdkbufferpool gstmsdkbufferpool.c:270:gst_msdk_buffer_pool_alloc_buffer:<msdkbufferpool2> failed to create new MSDK memory
ERROR                msdkvpp gstmsdkvpp.c:297:create_output_buffer:<msdkvpp0> failed to create output video buffer
ERROR                msdkdec gstmsdkdec.c:699:gst_msdkdec_finish_task:<msdkh265dec0> Failed to finish frame
ERROR                msdkdec gstmsdkdec.c:1085:gst_msdkdec_handle_frame:<msdkh265dec0> Failed to finish a task

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1278>
2020-06-01 02:09:04 +00:00
Xu Guangxin
275518f661 msdkvpp: hold GstBuffer ref count for locked surfaces
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1278>
2020-06-01 02:09:04 +00:00
Haihao Xiang
98600942e4 msdkvpp: clear the parameters after closing the session
Otherwise the stale values are used for the new process.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1159>
2020-05-11 02:16:44 +00:00
Xu Guangxin
cab1ddf48b msdk: bufferpool: set alignment to video meta
else gst_video_meta_validate_alignment will report error like
"videometa gstvideometa.c:416:gst_video_meta_validate_alignment: Stride of plane 0 defined in meta (384) is different from the one computed from the alignment (320)"

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1224>
2020-05-07 05:45:36 +00:00
Jordan Petridis
87fc038f67
gstmsdkdec: fix logical operation that misses parenthesis
in C, & is weaker than the ! operator and clang is giving the following
error about it.

```
../subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c:731:7: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses]
  if (!gst_msdk_context_get_job_type (thiz->context) & GST_MSDK_JOB_DECODER) {
      ^                                              ~
../subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c:731:7: note: add parentheses after the '!' to evaluate the bitwise operator first
  if (!gst_msdk_context_get_job_type (thiz->context) & GST_MSDK_JOB_DECODER) {
      ^
       (                                                                   )
../subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c:731:7: note: add parentheses around left hand side expression to silence this warning
  if (!gst_msdk_context_get_job_type (thiz->context) & GST_MSDK_JOB_DECODER) {
      ^
      (                                             )
1 error generated.
```
2020-04-10 18:22:21 +03:00
Haihao Xiang
00baed3ebe msdkvp9dec: add support for VP9 12bit
The output formats are P012_LE for 12bit 420 and Y412_LE for 12bit 444.
2020-04-07 00:39:35 +00:00
Haihao Xiang
4cc5321010 msdkh265dec: add support for main-444-12, main-444-12-intra profiles
The video format is Y412_LE
2020-04-03 01:19:45 +00:00
Haihao Xiang
4d756c07b0 msdk: map Y412_LE to VA_FOURCC_Y416
In media driver, VA_FOURCC_Y416 is used for packed 12 bits 4:4:4:4 YUV
format, the corresponding RT format is VA_RT_FORMAT_YUV442_12
2020-04-03 01:19:45 +00:00
Haihao Xiang
55ed9458b5 msdk: map MFX_FOURCC_Y416 to VA_FOURCC_Y416
Y416 is used for packed 12 bits 4:4:4:4 YUV format in media driver, the
RT format is VA_RT_FORMAT_YUV444_12
2020-04-03 01:19:45 +00:00
Haihao Xiang
e769df9689 msdk: map Y412_LE to MFX_FOURCC_Y416
MFX_FOURCC_Y416 is used for packed 12 bits 4:4:4:4 YUV format in
MediaSDK
2020-04-03 01:19:45 +00:00
Haihao Xiang
3de690ceda msdkh265dec: add support for main-422-12, main-422-12-intra profiles
The video format is Y212_LE
2020-04-03 01:19:45 +00:00
Haihao Xiang
01edef09a3 msdk: map Y212_LE to VA_FOURCC_Y216
In media driver, VA_FOURCC_Y216 is used for packed 12 bits 4:2:2 YUV
format, the corresponding RT format is VA_RT_FORMAT_YUV422_12
2020-04-03 01:19:45 +00:00
Haihao Xiang
34177985e2 msdk: map MFX_FOURCC_Y216 to VA_FOURCC_Y216
In media driver, Y216 is used for packed 12 bits 4:2:2 format YUV
format, so the RT format is VA_RT_FORMAT_YUV422_12.
2020-04-03 01:19:45 +00:00
Haihao Xiang
fb200ccfdd msdk: map Y212_LE to MFX_FOURCC_Y216
MFX_FOURCC_Y216 is used for packed 12 bits 422 YUV format in MediaSDK
2020-04-03 01:19:45 +00:00
Seungha Yang
950aa3d1db msdkh265enc: Fix for wrong parser free function 2020-04-03 00:42:23 +09:00
Seungha Yang
71cf93c361 msdkh264enc: Configure parser and SEI array only if it's required 2020-04-02 09:20:11 +00:00
Seungha Yang
206fe1534d msdkh265enc: Add support for CEA708 closed caption insertion
Functionally identical to that of msdkh264enc
2020-04-02 09:20:11 +00:00
Seungha Yang
882531aa54 msdkh264enc: Port to h264parser API for frame packing SEI injection
Create frame packing SEI memory only once per set_format() and
reuse it if possible.
2020-03-31 08:30:50 +00:00
Haihao Xiang
326b755332 msdkh265enc: support 8-bit 422 encoding
The media driver can support HEVC 8-bit 422 encoding for non-lowpower
mode since ICL[1], so VPP is not needed for this case.

Sample pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=YUY2 ! msdkh265enc ! \
filesink location=output.h265

[1] https://github.com/intel/media-driver#decodingencoding-features
2020-03-31 09:27:03 +08:00
Haihao Xiang
7c91c8c980 msdkh265enc: add support for Y210 in sink pad
Sample pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=Y210 !
msdkh265enc ! filesink location=output.h265
2020-03-31 09:27:03 +08:00
Haihao Xiang
fbd1d0cecb msdk: add a helper function to get codename of the platform
The features supported in MSDK vary from platform to platform. We may
support some features based on the codename of the platform in future.
2020-03-31 09:27:03 +08:00
Seungha Yang
afb042cbb9 msdkenc: Try to find corresponding codec frame for encoded output buffer
The input and output buffers should be matched as much as possible
so that various metadata and its ordering to be preserved.
2020-03-30 07:59:10 +00:00
Seungha Yang
c0787ed1cd msdkh264enc: Add support for CEA708 closed caption insertion
Currently supported caption format is CEA708_RAW
2020-03-30 07:59:10 +00:00
Haihao Xiang
d796707dd4 msdkh265enc: slice size control
Add max-slice-size property to set the maximum slice size
2020-03-30 00:20:11 +00:00
Haihao Xiang
49604d8fbe msdkh265dec: add support for main-12, main-12-intra profiles
The video format is P012_LE
2020-03-23 06:31:30 +00:00