Commit graph

362 commits

Author SHA1 Message Date
Haihao Xiang
f5b1c75d4c msdk: add msdkvp9enc element 2019-07-07 15:16:28 +00:00
Haihao Xiang
ba7f3f48c2 msdk: workaround for MFX_FOURCC_VP9_SEGMAP surface
MFX_FOURCC_VP9_SEGMAP surface in MSDK is an internal surface however
MSDK still call the external allocator for this surface, so this plugin
has to return UNSUPPORTED and force MSDK allocates surface using the
internal allocator.

See https://github.com/Intel-Media-SDK/MediaSDK/issues/762 for details
2019-07-07 15:16:28 +00:00
Haihao Xiang
1221898404 msdkenc: allow encode element requires extra frames
The call of MFXVideoENCODE_EncodeFrameAsync may not generate output and
the function returns MFX_ERR_MORE_DATA with NULL sync point, the input
frame is cached in this case, so it is possible that all allocated
frames go into the surfaces_used list after calling
MFXVideoENCODE_EncodeFrameAsync a few times, then the encoder will fail
to get an available surface before releasing used frames

This patch adds a new field of num_extra_frames to GstMsdkEnc and allows
encode element requires extra frames, the default value is 0.

This patch is the preparation for msdkvp9enc element.
2019-07-07 15:16:28 +00:00
Haihao Xiang
98e4967337 msdk: don't share context between msdkvpp and msdkenc
msdkenc supports CSC implicitly, so it is possible that two VPP
processes are required when a pipeline contains msdkvpp and msdkenc.
Before this fix, msdkvpp and msdkenc may share the same context, hence
the same mfx session, which results in MFX_ERR_UNDEFINED_BEHAVIOR
in MSDK because a mfx session has at most one VPP process only

This fixes the broken pipelines below:

gst-launch-1.0 videotestsrc ! video/x-raw,format=I420 ! msdkh264enc ! \
msdkh264dec ! msdkvpp ! video/x-raw,format=YUY2 ! fakesink

gst-launch-1.0 videotestsrc ! msdkvpp ! video/x-raw,format=YUY2 ! \
msdkh264enc ! fakesink
2019-06-30 06:08:31 +00:00
U. Artie Eoff
b756b13ee2 msdkmjpegdec: support 422 output
MSDK supports JPEG YUY2 (422 chroma) output color
format. The color format of input bitstream is
described by JPEGChromaFormat and JPEGColorFormat
fields in the mfxInfoMFX structure which is filled
in by the MFXVideoDECODE_DecodeHeader function.

To obtain lossless decoded output from 422 encoded
JPEGs, we must set the output color format in the
FourCC and ChromaFormat fields in the mfxFrameInfo
structure to the appropriate values at post_configure
so that they are propagated through to the srcpad
caps accordingly.
2019-06-29 17:40:06 +00:00
U. Artie Eoff
70bfd34b41 msdkdec: add post_configure virtual method
A post_configure virtual method is added to allow
codec subclasses to adjust the initialized parameters
after MFXVideoDECODE_DecodeHeader is called from the
gstmsdkdec::gst_msdkdec_handle_frame function.

This is useful if codecs want to adjust the output
parameters based on the codec-specific decoding
options that are present in the mfxInfoMFX structure
after MFXVideoDECODE_DecodeHeader initializes them.
2019-06-29 17:40:06 +00:00
Haihao Xiang
6117a2c6bc msdkvp9dec: add support for VP9 444
The output formats are VUYA for 8bit 444 and Y410 for 10bit 444.
2019-06-29 18:10:23 +02:00
Haihao Xiang
b483f3499a msdkh265dec: add support for main-444-10/main-444-10-intra profile
The output format is Y410
2019-06-29 17:33:57 +02:00
Haihao Xiang
9da737d6aa msdk: return a right pointer for Y410 when mapping a frame 2019-06-29 17:33:57 +02:00
Haihao Xiang
ba24af0490 msdk: set right BitDepth and Shift for Y410 mfx frame
BitDepth is 10 and Shitf must be set to 0 when creating Y410 mfx
frame in MSDK
2019-06-29 17:33:57 +02:00
Haihao Xiang
84a46f04a7 msdk: set parameters in mfxFrameData for a MFX_FOURCC_Y410 frame 2019-06-29 17:33:57 +02:00
Haihao Xiang
bc3a43bdb4 msdk: map MFX_FOURCC_Y410 to VA_FOURCC_Y410 2019-06-29 17:33:57 +02:00
Haihao Xiang
365f6cf0c8 msdk: map GST_VIDEO_FORMAT_Y410 to VA_FOURCC_Y410 2019-06-29 17:33:57 +02:00
Haihao Xiang
9b43a5621f msdk: map GST_VIDEO_FORMAT_Y410 to MFX_FOURCC_Y410 2019-06-29 17:33:57 +02:00
Haihao Xiang
49ae5c2de4 msdkh265dec: add support for main-444 profile
The output format is VUYA
2019-06-29 17:33:57 +02:00
Haihao Xiang
1ee2adc580 msdkh265dec: add support for main-422-10/main-422-10-intra 10bit
The ouput format is Y210
2019-06-29 14:15:32 +00:00
Haihao Xiang
a3f8faa682 msdk: set right BitDepth and Shift for Y210 mfx frame
BitDepth is 10 and Shitf must be set to 1 when creating Y210 mfx
frame in MSDK
2019-06-29 14:15:32 +00:00
Haihao Xiang
32fce730ed msdk: set parameters in mfxFrameData for a MFX_FOURCC_Y210 frame 2019-06-29 14:15:32 +00:00
Haihao Xiang
c763a6f157 msdk: map MFX_FOURCC_Y210 to VA_FOURCC_Y210 2019-06-29 14:15:32 +00:00
Haihao Xiang
47bb53a80a msdk: map GST_VIDEO_FORMAT_Y210 to VA_FOURCC_Y210 2019-06-29 14:15:32 +00:00
Haihao Xiang
24da8ec47b msdk: map GST_VIDEO_FORMAT_Y210 to MFX_FOURCC_Y210 2019-06-29 14:15:32 +00:00
Haihao Xiang
56d6df08f9 msdkh265dec: add support for main-422-10/main-422-10-intra 8bit
The output format is YUY2
2019-06-29 14:15:32 +00:00
Haihao Xiang
1ec231b85d msdk: return a right pointer for VUYA format
The first channel in memory is V for VUYA format, note
GST_VIDEO_FORMAT_VUYA is mapped to MFX_FOURCC_AYUV in this plugin
2019-05-31 14:51:35 +08:00
Haihao Xiang
9f588a97dc msdk: fix the typo for gst_msdkvp9dec_debug 2019-05-16 12:18:30 +08:00
Thibault Saunier
47a49f3381 docs: Build documentation with hotdoc 2019-05-13 17:00:00 -04:00
Haihao Xiang
5b369e6e97 msdk: fix the build error with libva 2.4.0
This fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/949
2019-04-17 13:10:10 +08:00
Peter Seiderer
670481bdeb msdkdec: fix error handling in case of unsupported hardware
Check the return value of gst_msdk_context_ensure_context and
abort in case of failure.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/945
2019-04-10 15:54:31 +00:00
Peter Seiderer
e766aaf2b1 msdkenc: fix error handling in case of unsupported hardware
Check the return value of gst_msdk_context_ensure_context and
abort in case of failure.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/945
2019-04-10 15:54:31 +00:00
Peter Seiderer
9b19968a66 msdk: fix error handling in case of unsupported hardware
Fix double gst_object_unref for GstMsdkContext.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/945
2019-04-10 15:54:31 +00:00
Haihao Xiang
e81a22d741 msdkvpp: add BGR10A2_LE format in the src pad
example pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=P010_10LE ! msdkvpp ! \
video/x-raw,format=BGR10A2_LE ! fakesink
2019-04-09 14:26:02 +00:00
Haihao Xiang
21f07e95f5 msdk: set some parameters in mfxFrameData for a MFX_FOURCC_A2RGB10 frame 2019-04-09 14:26:02 +00:00
Haihao Xiang
c40ecbe7f5 msdk: map MFX_FOURCC_A2RGB10 to VA_FOURCC_A2R10G10B10 2019-04-09 14:26:02 +00:00
Haihao Xiang
95fdc2e984 msdk: map GST_VIDEO_FORMAT_BGR10A2_LE to VA_FOURCC_A2R10G10B10 2019-04-09 14:26:02 +00:00
Haihao Xiang
53fd4a1564 msdk: map GST_VIDEO_FORMAT_BGR10A2_LE to MFX_FOURCC_A2RGB10 2019-04-09 14:26:02 +00:00
Haihao Xiang
8e4d7c3642 msdkdec: add postinit_decoder
The workaround for https://github.com/Intel-Media-SDK/MediaSDK/issues/1139
is required for vp8 only, so move this workaround to the corresponding
postinit_decoder function

The pipeline below works with this change

gst-launch-1.0 filesrc location=SA10104.vc1 ! \
'video/x-wmv,profile=(string)advanced',width=720,height=480,framerate=14/1 ! \
msdkvc1dec ! fakesink
2019-03-29 13:32:06 +08:00
Haihao Xiang
01051e7dfd msdkdec: don't set unknown picture struct to progressive for vc1
MFXVideoDECODE_DecodeHeader only parses the sequence layer for VC1, so
the structure is unknown for a stream with interlace flag set in the
sequence layer. If forcing the struct to progressive in this plugin,
MediaSDK will fail to decode such streams.
2019-03-29 13:13:07 +08:00
Haihao Xiang
5b0247db33 msdkvc1dec: add the preinit_decoder function 2019-03-29 12:57:51 +08:00
Haihao Xiang
ac1408874b msdkvpp: add VUYA format in the src and sink pads 2019-03-25 09:50:33 +00:00
Haihao Xiang
8389e88840 msdk: return the right pointer for GST_VIDEO_FORMAT_VUYA frame
The first component for GST_VIDEO_FORMAT_VUYA in memory is V.
2019-03-25 09:50:33 +00:00
Haihao Xiang
24d12a4abf msdk: set some parameters in mfxFrameData for a MFX_FOURCC_AYUV frame 2019-03-25 09:50:33 +00:00
Haihao Xiang
5a5d707cdd msdk: map MFX_FOURCC_AYUV to VA_FOURCC_AYUV 2019-03-25 09:50:33 +00:00
Haihao Xiang
cd8696d2b2 msdk: map GST_VIDEO_FORMAT_VUYA to VA_FOURCC_AYUV 2019-03-25 09:50:33 +00:00
Haihao Xiang
f7863cc741 msdk: map GST_VIDEO_FORMAT_VUYA to MFX_FOURCC_AYUV 2019-03-25 09:50:33 +00:00
Haihao Xiang
28a1b0c418 msdkdec: avoid infinite loop
It is possible MFXVideoDECODE_DecodeFrameAsync returns MFX_ERR_INCOMPATIBLE_VIDEO_PARAM
and this error can't be recovered by retrying MFXVideoDECODE_DecodeFrameAsync
in some cases, so we need to limit the number of retries to avoid infinite loop.

This fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/909
2019-03-25 09:10:38 +00:00
Haihao Xiang
2e3022c553 msdk: relicense the plugin to LGPL
Some files licensed under LGPL were included, so relicense the plugin
from BSD to LPGL. In addition, this patch removes the README per the
discussion in https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/853

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/853
2019-03-17 18:15:46 +00:00
Seungha Yang
1d17e3891d mskd: Don't use MFX_FOURCC_RGB565 if it's undefined
../subprojects/gst-plugins-bad/sys/msdk/msdk.c(61): error C2065: 'MFX_FOURCC_RGB565'

The minimum required version for the format seems to MFX_VERSION >= 1028
2019-03-01 07:03:01 +00:00
Haihao Xiang
4b8e3b215a msdkdec: fix for small resolution 2019-02-28 11:51:06 +00:00
Haihao Xiang
18d410b81a msdkdec: fix for resolution change
Returning MFX_ERR_INCOMPATIBLE_VIDEO_PARAM from
MFXVideoDECODE_DecodeFrameAsync means the allocated mfx surface is not
suitable for the current frame, we need a new mfx surface and try
MFXVideoDECODE_DecodeFrameAsync again.
2019-02-28 11:08:24 +00:00
Haihao Xiang
a751b33072 msdkdec: force the alignment of width/height to 16 for vp8/vp9
MSDK library requires 16 alignment for vp8/vp9, otherwise a pipeline
for vp8/vp9 decoding might fail.

example pipeline:
gst-launch-1.0 filesrc location=vp8_1280x720.webm ! matroskademux ! \
msdkvp8dec ! fakesink

0:00:00.150565444 10657 0x55c8484036d0 ERROR                msdkdec
gstmsdkdec.c:1056:gst_msdkdec_handle_frame:<msdkvp8dec0>
DecodeFrameAsync failed (invalid video parameters)
2019-02-27 15:56:29 +00:00
Haihao Xiang
0806f94e1c msdkvpp: add RGB16 format in the sink pad
Note: MSDK doesn't support RGB16 output, hence don't add RGB16 format in
the src pad
2019-02-27 15:22:43 +00:00
Haihao Xiang
f39bcd3920 msdk: set some parameters in mfxFrameData for a RGB16 frame 2019-02-27 15:22:43 +00:00
Haihao Xiang
52b5a7e206 msdk: map MFX_FOURCC_RGB565 to VA_FOURCC_RGB565 2019-02-27 15:22:43 +00:00
Haihao Xiang
a09cff84ce msdk: map GST_VIDEO_FORMAT_RGB16 to VA_FOURCC_RGB565 2019-02-27 15:22:43 +00:00
Haihao Xiang
197f7f569b msdk: map GST_VIDEO_FORMAT_RGB16 to MFX_FOURCC_RGB565 2019-02-27 15:22:43 +00:00
Haihao Xiang
6287016a74 msdkdec: release the occupied surface for MFX_WRN_DEVICE_BUSY
When MFXVideoDECODE_DecodeFrameAsync () returns MFX_WRN_DEVICE_BUSY with
an output surface, a new input surface is required when retrying
MFXVideoDECODE_DecodeFrameAsync ().

This fixes the out-of-surface issue mentioned in
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/890
2019-02-24 19:13:57 +00:00
Haihao Xiang
fffb3f628d msdk: don't destroy an image twice
This gets rid of annoying message in the log, e.g. run the pipeline
below:

gst-launch-1.0 videotestsrc num-buffers=100 ! \
video/x-raw,format=NV12,width=352,height=288 ! msdkh264enc ! filesink \
location=test.h264

[LIBVA]:CRITICAL - DdiMedia_DestroyImage:4357: Invalid image
2019-02-24 17:59:43 +00:00
Haihao Xiang
348a4b570d msdk: move the comment to the correct place 2019-02-24 17:59:43 +00:00
Tim-Philipp Müller
16426b3928 msdk: add Hardware tag to element metadata 2019-02-19 23:44:42 +00:00
Haihao Xiang
8213d0b858 msdkvpp: allow UYVY in DMABuf mode in the sink pad
Tested with the pipeline below:

gst-launch-1.0 videotestsrc num-buffers=1 ! msdkvpp ! \
video/x-raw\(memory:DMABuf\),format=UYVY ! msdkvpp ! video/x-raw, \
format=YUY2 ! filesink location=a.yuv
2019-02-19 11:04:47 +00:00
Haihao Xiang
56cada6902 msdkvpp: allow UYVY in the src pad
This make the pipeline below works:

gst-launch-1.0 videotestsrc num-buffers=1 ! msdkvpp ! \
video/x-raw,format=UYVY ! filesink location=a.yuv

Once https://github.com/intel/media-driver/pull/526 in the media-driver
is merged, the pipeline below also works:

gst-launch-1.0 videotestsrc num-buffers=1 ! msdkvpp ! \
video/x-raw\(memory:DMABuf\),format=UYVY ! filesink location=a.yuv
2019-02-19 11:04:47 +00:00
Haihao Xiang
ac9423facb msdk: map GST_VIDEO_FORMAT_UYVY to VA_FOURCC_UYVY 2019-02-19 11:04:47 +00:00
Haihao Xiang
ea6789fec8 msdkvpp: allow BGRx in DMABuf mode in the src pad
Tested with the pipeline below:

gst-launch-1.0 videotestsrc ! msdkvpp ! \
video/x-raw\(memory:DMABuf\),format=BGRx ! glimagesink
2019-02-19 11:04:47 +00:00
Haihao Xiang
028338ff44 msdkdec: set decode_only for output only
MSDK may return MFX_ERR_MORE_DATA but without output surface

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/887
2019-02-12 11:39:04 +00:00
Haihao Xiang
5f2f289b7e msdk: verify the driver name
We need to make sure the Intel graphics card is used in a dual GPU
system.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/895
2019-02-12 12:13:31 +08:00
Haihao Xiang
6c953438f5 msdkdec: Release occupied surface for MFX_ERR_MORE_DATA
An output surface is returned but without sync point when when
MFXVideoDECODE_DecodeFrameAsync () returns MFX_ERR_MORE_DATA, this
surface should be released too, otherwise the surface is occupied
and it is easy to exhaust all pre-allocated mfx surfaces.

Example pipeline (input_vp8.webm contains lots of frame with show_frame
set to 0):

gst-launch-1.0 filesrc location=input_vp8.webm ! matroskademux !
msdkvp8dec ! msdkvpp ! fakesink

0:00:05.995959693 19866 0x563f30f14590 ERROR                default
gstmsdkvideomemory.c:77:gst_msdk_video_allocator_get_surface: failed to
get surface available
ERROR: from element
/GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Internal data
stream error.
2019-02-03 13:44:56 +08:00
Víctor Manuel Jáquez Leal
f974246647 msdkdec: explain the the extra ref of input buffer 2019-02-02 17:52:58 +01:00
Haihao Xiang
74f297f31b msdkdec: avoid releasing the input buffer when it is still in use
The input buffer is released in gst_msdkdec_finish_task () when decoding
some special clips however this buffer is still in use, so ref the input
buffer before gst_msdkdec_finish_task () and unref it at the end of
gst_msdkdec_handle_frame ().

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/862
2019-02-02 16:32:02 +00:00
Haihao Xiang
cd55f8635f msdkvp9dec: output P010_10LE buffer if possible 2019-01-31 10:30:22 +08:00
Haihao Xiang
edc0edc960 msdkvp9dec: use separate src caps
We will add more formats in the src caps of msdkvp9dec, so let
msdkvp9dec uses separate src caps. Note it doesn't change any
capability
2019-01-31 10:30:22 +08:00
Haihao Xiang
546797cecf msdkdec: set the mfx picture structure to MFX_PICSTRUCT_PROGRESSIVE if it is unknown
The picture structure in the output parameters from
MFXVideoDECODE_Query is set to MFX_PICSTRUCT_UNKNOWN for some codecs, so
the structure of the corresponding mfx surfaces created for decoding are
unknown. The pipeline will be broken when these surfaces are used as the
input for msdkvpp.

Example pipeline:

gst-launch-1.0 filesrc location=input_vp8.webm ! matroskademux !
msdkvp8dec ! msdkvpp ! fakesink

Error message:

0:00:00.031568911 14259 0x55b79dc684a0 ERROR                msdkvpp
gstmsdkvpp.c:728:gst_msdkvpp_transform:<msdkvpp0> MSDK Failed to do VPP
ERROR: from element
/GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: Internal data
stream error.

This is a workaround for the above issue
2019-01-25 12:45:43 +08:00
Haihao Xiang
920062cafc msdkh265enc: enable low power mode
Low power mode is disabled by default, set the value of low-power to
true to enable this mode.
2019-01-24 09:59:37 +00:00
Víctor Manuel Jáquez Leal
6b6ed2cad8 msdk: bufferpool: refactor memory type decision
The memory type was used as bitwise enum, but the enum was not
defined in that way.

Nonetheless, most of the usage of the memory type was as mutually
exclusive options, rather than option composition.

This patch refactor how the memory type is defined, so it is kept
the mutual exclusion among options.
2019-01-24 08:49:39 +00:00
Víctor Manuel Jáquez Leal
5d030ed776 msdk: fix some comments typos 2019-01-24 08:49:39 +00:00
Víctor Manuel Jáquez Leal
5f67b4946e msdk: decoder: fatal failure if negotiations fails
Otherwise it crashes when no parser is used placed upstream, v.gr.

gst-launch-1.0 filesrc location=file.264 ! msdkh264dec ! fakesink
2019-01-24 08:49:39 +00:00
Víctor Manuel Jáquez Leal
f238066288 msdk: decoder: comment to explain array reset 2019-01-24 08:49:39 +00:00
Víctor Manuel Jáquez Leal
882befb5db msdk: decoder: fix an usage-after-free pointer bug 2019-01-24 08:49:39 +00:00
Haihao Xiang
697d41c923 msdkvpp: add P010_10LE to sink and src caps
example pipelines:

gst-launch-1.0 videotestsrc num-buffers=100 ! \
video/x-raw,format=P010_10LE,width=352,height=288 ! msdkvpp ! \
video/x-raw,format=NV12! fakesink

gst-launch-1.0 videotestsrc num-buffers=100 ! \
video/x-raw,format=NV12,width=352,height=288 ! msdkvpp ! \
video/x-raw,format=P010_10LE ! fakesink
2019-01-21 17:32:17 +00:00
Haihao Xiang
5e3f94ce28 msdkh265dec: support P010_10LE in DMABuf mode 2019-01-21 17:32:17 +00:00
Nirbheek Chauhan
f710b36ac4 meson: Fix automagic build of msdk plugin
When building the msdk plugin even if libmfx is found, unless the
plugin is explicitly enabled we should not error out if msdk
dependencies are not found.

Also give an error message when we don't build the plugin on Windows
because we're not building with MSVC.
2019-01-19 18:28:42 +00:00
Nirbheek Chauhan
7ffcab3478 build: Don't forget to add windows files to EXTRA_DIST 2019-01-18 13:13:09 +05:30
Haihao Xiang
9aa68dea51 msdk: set the right BRCParamMultiplier
BRCParamMultiplier in mfxInfoMFX is a parameter which specifies a
multiplier for bitrate control parameters [1], it impacts TargetKbps,
MaxKbps, BufferSizeInKB and InitialDelayInKB.

[1]: https://software.intel.com/en-us/node/628473
2019-01-11 09:57:44 +00:00
Haihao Xiang
5fc160fa59 msdk: set the upper bound of max-vbv-bitrate to 2048000 kbps
The upper bound of bitrate is also 2048000 kbps which should be large
enough in practice.

Fix https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/863
2019-01-11 09:57:44 +00:00
Nirbheek Chauhan
0b94ed81a4 meson: Fix building of MSDK plugin on Windows
Variable name was typoed in 604c8d5232
2019-01-10 15:34:51 +05:30
Haihao Xiang
d7ad665d1c msdk: needn't call MFXJoinSession after MFXCloneSession
According to the MSDK documation[1], MFXCloneSession is a light-weight
equivalent of MFXJoinSession after MFXInit, so MFXJoinSession call isn't
needed in the msdk plugin, otherwise the cloned session is joined to the
parent session twice, and we will get a MFX error when closing the
parent session

example pipeline:

gst-launch-1.0 videotestsrc num-buffers=100 ! \
video/x-raw,format=NV12,width=352,height=288 ! msdkh264enc ! msdkh264dec ! \
msdkh264enc ! fakesink

Error message:

0:00:00.211948518 21733 0x5586ee741c60 ERROR                   msdk
msdk.c:148:msdk_close_session: Close failed (undefined behavior)

[1]: https://software.intel.com/en-us/node/628429#MFXCloneSession
2019-01-09 15:52:27 +08:00
Haihao Xiang
6c887f982e msdk: check whether mfx function call fails
And log the failures for debugging
2019-01-09 12:43:56 +08:00
Haihao Xiang
d7606a7667 msdkenc: return NULL instead of FALSE
The returned type is a pointer
2019-01-09 09:50:49 +08:00
Haihao Xiang
ba7f4de298 msdk: release resources if failing to create the buffer pool
Needn't check the pointers against NULL because the pointers are
non-NULL
2019-01-09 09:42:56 +08:00
Víctor Manuel Jáquez Leal
a301150002 msdk: meson: compile vp9dec if available
based on the patches provided by Haihao Xiang <haihao.xiang@intel.com>
2019-01-08 12:59:45 +00:00
Víctor Manuel Jáquez Leal
c22f92c799 msdk: add mfx in include path
Thus removing the preprocessor's directives to included if found.
2019-01-08 12:59:45 +00:00
Víctor Manuel Jáquez Leal
604c8d5232 msdk: meson: use libmfx pkg-config if available
Refactoring to bail out early if MediaSDK is not found.

based on the patches provided by Haihao Xiang <haihao.xiang@intel.com>
2019-01-08 12:59:45 +00:00
Haihao Xiang
3110f3791f msdk: don't reset the external frame allocator
In gst-msdk, a mfx session may be shared between different gst
elements, each element tries to set the frame allocator. However, per
the MSDK documation[1], the behavior is undefined if reset the frame
allocator while the previous allocator is in use. Fortunately all
elements use the same frame allocator, so we can avoid to call
MFXVideoCORE_SetFrameAllocator again.

[1]: https://software.intel.com/en-us/node/628430#MFXVideoCORE3
2019-01-08 09:11:47 +00:00
Haihao Xiang
a0943aec69 msdkvpp: don't use NV12 as default output in normal mode
If so, BGRA is the preferred output format hence BGRA will be selected
as input format by default, e.g. in the pipleline below, BGRA instead of
NV12 is selected without renegotiation, so we can avoid the NV12 issue
(see commit 3f2314a) by default.

gst-launch-1.0 videotestsrc ! msdkvpp ! glimagesink
2019-01-08 10:08:43 +08:00
Haihao Xiang
7681566f29 msdkvpp: close the current VPP session if this session has been initialized
Otherwise MFXVideoVPP_Init will fail because it is called twice without
a close.

Example pipeline:

gst-launch-1.0 videotestsrc ! msdkvpp ! glimagesink

Sometimes glimagesink emits GST_EVENT_RECONFIGURE event which results
in that MFXVideoVPP_Init is called twice, then get the negotiation
failure below:

0:00:00.093715518 21218 0x558ef56231e0 ERROR                msdkvpp
gstmsdkvpp.c:995:gst_msdkvpp_initialize:<msdkvpp0> Init failed
(undefined behavior)
WARNING: from element /GstPipeline:pipeline0/GstMsdkVPP:msdkvpp0: not
negotiated

After applying this commit, the pipeline above may run without
negotiation failure, however NV12 layout in dmabuf mode is selected in
renegotiation, the display image is corrupted due to the NV12 issue which
was mentioned in commit 3f2314a. Some other fixes are needed to avoid
renegotiation by default
2019-01-08 10:08:43 +08:00
Haihao Xiang
e8d2f58e23 msdkvpp: don't update pads' info if nothing have changed 2019-01-08 10:08:43 +08:00
U. Artie Eoff
e91a53f693 msdkenc: break out of flush frames loop on error
In general, we should assume any unhandled error is
non-recoverable.

In the flush frames loop, some error states can cause us
to never increment the task and therefore we get stuck
in an infinite loop and generate GST_ELEMENT_ERROR
over and over again.  This eventually consumes all
system memory and triggers OOM.  Thus, assume the worst
and break out of the loop upon the first "unhandled" error.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/859
2019-01-06 19:07:35 -08:00
Seungha Yang
373580c7be msdk: Fix invalid return type build warning
void function cannot have return value

gst-plugins-bad/sys/msdk/gstmsdkbufferpool.c(332): warning C4098:
'gst_msdk_buffer_pool_release_buffer': ...
2018-12-25 16:14:36 +09:00
Haihao Xiang
88586b4149 msdk: change the wait time for encoder and vpp
In MSDK samples, the wait time for encoder, decoder and vpp is
300000. Let's set the wait time to the same value in msdk plugin
2018-12-12 17:24:00 +00:00
Haihao Xiang
51dc388783 msdk: correct the error message
It is VPP session instead of Encoder session
2018-12-12 17:24:00 +00:00
Haihao Xiang
718b7d0b5d msdk: check the created context against NULL pointer
gst_msdk_context_new_with_parent() may return NULL
2018-12-12 17:24:00 +00:00
Haihao Xiang
801189c02f msdk: decrease the reference count of object
Otherwise there are reference leaks if failed to clone or join a
mfx session
2018-12-12 17:24:00 +00:00
Haihao Xiang
43e5eaeda1 msdk: assign the returned value to status variable
Othervise the subsequent check will use the stale value of status
variable
2018-12-12 17:24:00 +00:00
Xiang, Haihao
9a9e01a1a5 msdkh265enc: output main-10 bitstream if the input is P010_10LE
Tested on KBL using the following command:
gst-launch-1.0 videotestsrc num_buffers=100 ! video/x-raw,format=P010_10LE ! \
msdkh265enc ! filesink location=a.hevc

This fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/829
2018-12-12 09:00:13 +00:00
Xiang, Haihao
9711a21008 msdkh265enc: add P010_10LE to the sink pad template 2018-12-12 09:00:13 +00:00
Xiang, Haihao
ba1f162401 msdkh265enc: re-add the sink pad template
We will add more profiles in the sink caps of msdkh265enc, so let
msdkh265enc re-add the sink pad template. Note this change doesn't
impact any capability
2018-12-12 09:00:13 +00:00
Xiang, Haihao
f45d5dc8bc msdkenc: handle P010_10LE input format
Note it is up to each codec to support P010_10LE format
2018-12-12 09:00:13 +00:00
Xiang, Haihao
506835a484 msdkenc: use macro GST_VIDEO_INFO_FORMAT if possible 2018-12-12 09:00:13 +00:00
Xiang, Haihao
0e7e425bb9 msdk: add missing breaks 2018-12-03 07:09:56 +00:00
Xiang, Haihao
a1aae3fd92 msdk: fix the wrong operator
The condition is for video memory only, so the operator should be
& instead of |
2018-12-03 07:09:56 +00:00
Xiang, Haihao
b0d22f8cb4 msdk: remove unnecessary assignment
CodecProfile will be set in MFXVideoDECODE_DecodeHeader() to match
the input stream. Setting the hard-coded profile here will mislead
user that msdkh265dec supports a special profile only.
2018-11-26 16:47:17 +00:00
Xiang, Haihao
b38f8d301c msdk: update the sink and src caps of msdkh265dec
Now hevc 10bit video can be decoded correctly, so update the sink
and src caps accordingly.

This fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/720
2018-11-26 16:47:17 +00:00
Xiang, Haihao
2b0923842a msdk: set right BitDepth and Shift for P010 mfx frame
BitDepth is 10 and Shitf must be set to 1 when creating P010 mfx
frame in MSDK
2018-11-26 16:47:17 +00:00
Xiang, Haihao
fda4918cc8 msdk: don't use hard-coded video format
Some codecs may support varied formats, e.g. HEVC may support NV12
and P010_10LE etc
2018-11-26 16:47:17 +00:00
Xiang, Haihao
27ab7fb40f msdk: adjust the RT format for P010 surface
According to VA API, VA_RT_FORMAT_YUV420_10 is expected for P010
surface
2018-11-26 16:47:17 +00:00
Xiang, Haihao
eeb58f64c2 msdk: create VA_FOURCC_P010 surface from dmabuf 2018-11-26 16:47:17 +00:00
Xiang, Haihao
7d58424611 msdk: VA_FOURCC_P010 frame lock
P010 and NV12 have the same layout, so we may reuse the code in
gst_msdk_frame_lock()
2018-11-26 16:47:17 +00:00
Xiang, Haihao
f72c825194 msdk: map MFX_FOURCC_P010 to VA_FOURCC_P010 2018-11-26 16:47:17 +00:00
Xiang, Haihao
dc070a8306 msdk: make sure the surface data is set for GST_VIDEO_FORMAT_P010_10LE
P010_10LE and NV12 have the same layout, so we may reuse the code.
2018-11-26 16:47:17 +00:00
Haihao Xiang
54451b7303 msdk: map GST_VIDEO_FORMAT_P010_10LE to MFX_FOURCC_P010 2018-11-26 16:47:17 +00:00
Xiang, Haihao
1d97a6f00e msdk: add an assert in gst_msdk_frame_lock() for unhandled formats
We will add support for more formats, e.g. P010, Adding an assert
here may catch the error early
2018-11-26 16:47:17 +00:00
Haihao Xiang
1c0160513b msdk: use separate src caps for msdkh265dec
We will add more formats in the src caps of msdkh265dec, so let
msdkh265dec uses separate src caps. Note it doesn't change any
capability
2018-11-26 16:47:17 +00:00
Xiang, Haihao
1bfd1b2bf9 msdk: Make sure a variable is initialized when it is used
Previously alloc_info is initialized when both thiz->initialized
and thiz->allocation_caps are true, but only thiz->initialized is
checked when alloc_info is used.
2018-11-26 16:13:44 +00:00
Xiang, Haihao
38cf42f90f msdk: Close fd handle
Otherwise it will result in resource leak if mem == NULL
2018-11-26 16:13:44 +00:00
Víctor Manuel Jáquez Leal
09dbe83e5d msdk: don't declare headers in meson
This partially reverts commit 0bae648353.

The compiler tells ninja the header dependency, then there is
no need to add them explicity.
2018-11-23 17:10:24 +01:00
Víctor Manuel Jáquez Leal
0bae648353 msdk: declare headers in meson 2018-11-23 13:50:20 +01:00
Wangfei
409d4ff30e msdkdec: move output-order out of decode bass class.
Since output-order is a deprecated attribute, move it out of decode
bass class and configure it in each sub decoder class who need it.

https://bugzilla.gnome.org/show_bug.cgi?id=796853
2018-11-23 12:26:40 +00:00
Víctor Manuel Jáquez Leal
eaa1bd93e8 msdk: add support for open sourced MediaSDK
MediaSDK has been released as open source [1], but the directories
where it installs its files, are different from the binary only
distribution.

This patch adds to the libraries path the directory /lib. Also it
is defined in meson if the include directory has the mfx/ prefix,
something that is already handled in autotools.

1. https://github.com/Intel-Media-SDK/MediaSDK
2018-11-22 17:31:58 +01:00
Jordan Petridis
1e887f9b12
meson: avoid unkown variables in the msdk tests 2018-11-06 23:48:58 +02:00
Florent Thiéry
23b0172ee9 msdk: fix intel sdk libdir path
the 2018.3.1 intel sdk release places libraries into /lib64 instead of
/lib/lin_x64 or /lib/x64, this commit adds /lib64 to the libdir
locations list

Fixes #815
2018-11-06 13:08:45 +00:00
Nirbheek Chauhan
55134df54c meson: Add a feature option for the MSDK plugin 2018-10-28 14:54:52 +00:00
Seungha Yang
f106a10994 msdk: Fix building on MSVC
And add missing #ifdef _WIN32 for MSVC build

https://bugzilla.gnome.org/show_bug.cgi?id=797211
2018-10-02 04:04:24 +05:30
Seungha Yang
44ecf53d1c msdk: Fix meson build
gst-plugins-bad\sys\msdk\meson.build:57:4: ERROR:  File msdk-enum.c does not exist.

https://bugzilla.gnome.org/show_bug.cgi?id=797211
2018-10-02 04:04:24 +05:30
Nirbheek Chauhan
b55dfb5313 Add feature options for almost all plugins
The only plugins remaining are those that haven't been ported to Meson
yet, and msdk. Also, the tests are still automagic.

https://bugzilla.gnome.org/show_bug.cgi?id=795107
2018-07-27 19:04:38 +05:30
Sreerenj Balachandran
dd981d4953 msdkdec: Fix latency calculation
Use async_depth for latency calcuation instead of
the length of Tasks array which could be NULL since we
don't do the msdk decoder init in set_format().
2018-07-03 18:38:04 -08:00
Sreerenj Balachandran
84c33be0c0 msdk: Set 16 bit alignment for width
According to MediaSDK specification,
Width must be a multiple of 16 and Height must be a multiple
of 16 for progressive frame sequence and a multiple of 32 otherwise.

This patch sets a 16 bit alignment for width and 32 bit alignment
for height as default.

https://bugzilla.gnome.org/show_bug.cgi?id=796566
2018-07-02 16:50:46 -08:00
Sreerenj Balachandran
d63a1b4e3f msdkdec: avoid early destruction of frame in dynamic resolution change
In cases where we do hard resest, the current code destroys the frame
which has new resolution bit early and this causes buffer_unmap
warnings. Keep an extra ref to the frame internally to avoid this.
2018-07-02 16:50:02 -08:00
Sreerenj Balachandran
1250af8f09 msdkdec: vc1: Fix handling of advanced profile elementary stream
Advanced profile elementary streams may not have codec_data
always. So make sure we don't do anything with null buffer.
2018-07-02 16:49:23 -08:00
Sreerenj Balachandran
ad6162e99b msdkdec: Fix advanced profile vc1 decode when codec_data presents
The gst-msdk decoders only support packetized formats for
all codecs except VC1. For VC1, it supports codec_data for advanced
profiles and this codec_data wan't submitting to MSDK's DecodeHeader APIs.
Make sure the subclass deocders correctly configured so that
the codec_data buffers are in place in the internal adapter for
MediaSDK's DecoderHeader usage.
2018-07-02 16:48:11 -08:00
Sreerenj Balachandran
9efb4c9179 msdkdec: Fix the PTS of output frames
Currently we use the gst_video_decoder_get_oldest_frame()
to get the old pending frame to output. But this is not correct
if pts re-ordering required. This patch uses a custom made
get_old_frame() which accounts the PTS too similar to the
v4l2decoder.

https://bugzilla.gnome.org/show_bug.cgi?id=796699
2018-07-02 16:42:20 -08:00
Sreerenj Balachandran
5c88da4a4c msdkdec: Remove dead code
We are not using any ExtendedParams for decoding.
2018-07-02 16:41:58 -08:00
Sreerenj Balachandran
1e95c03c7d msdk: dec: Add dynamic-configuration change support
The patch adds a serios of changes to support dynamic resolution
change and efficient utilization of resources.
Major changes:

-- Use MSDK's apis to retrieve the headers instead of only relying
on upsteram notification. For eg: avc decoder requires SEI header
information for dpb count calculation which we don't get from caps.

-- For all codecs other than VP9, we force the reset of decoder
if resoultion changes to fit with gstreamer flow. VP9 enfource
the hard reset only if the new resolution is bigger.

-- delay the src caps setting till msdk api's invokation in
handle_frame to avoid caching multiple configuration values

-- ensure pool negotiation is based on decoder's allocation_caps.

--dynamic resoluttion change use an explicit allocation_query
to reclaim the buffers before closing the decoder (thanks to v4l2dec)

--In case if we don't get upstream notification of res change (for eg,
this can can happen for vp9 frames with ivfheader where ivfparse
is not able to notify the dynamic changes), we handle the the case
based on MFX_ERR_INCOMPATIBLE_VIDEO_PARAM which is the return value
of MFXVideoDECODE_DecodeFrameAsync

-- calculate the minimum surfaces to be preallocated based on
msdk suggestion, downstream requirement, async depth and scratch surface
count for smooth display.

https://bugzilla.gnome.org/show_bug.cgi?id=796566
2018-07-02 16:17:49 -08:00
Tim-Philipp Müller
65c5b9a4f6 msdk: Update for g_type_class_add_private() deprecation in recent GLib
Untested.
2018-06-24 12:22:27 +02:00
Wang,Fei
10f57b73f3 msdk: vpp: remove mfxExtVPPDoUse from vpp filters.
According to msdk spec, there are two ways to enable filters:
1: Filters can be enabled by adding a filter ID
to mfxExtVPPDoUse. In this case, default filter parameters are used
2: Add filter configuration structures directly to mfxVideoParam.

Using 1 with 2 is optional but legal. Unfortunately it won't work
with some specific use cases like Detail/EdgeEnhancement.
Let's stick with option2 which works fine for all VPP operations.

https://bugzilla.gnome.org/show_bug.cgi?id=796468
2018-06-07 15:31:54 -08:00
Sreerenj Balachandran
c4809aa16c msdk: vpp: set passthrough from set_caps method for code clarity
Call passthrough setting method from set_caps so that
msdk initialize subroutine looks more clear.
2018-06-07 15:30:23 -08:00
Sreerenj Balachandran
665f4a140f mskd: vpp: error out gracefully instead of segfaulting if Init failed
Since we do the MSDK initializing in set_caps(), a FALSE
return may still cause the invokation of set_caps() again
and this will leads to buffer allocation and other mess-up.
So make sure the msdk initialized correctly before trying
to do any buffer allocation.

https://bugzilla.gnome.org/show_bug.cgi?id=796465
2018-06-07 15:29:29 -08:00
Sreerenj Balachandran
6cd12cb6a1 msdk: vpp: Add filters to VideoParm before doing the Query
Make sure all the enabled filter structures are added in the
mfxVideoParm before doing the VPPQuery so that msdk
can do the input param validation

https://bugzilla.gnome.org/show_bug.cgi?id=796465
2018-06-07 15:28:44 -08:00
Sreerenj Balachandran
8c7a457669 msdk: vpp: fix the filter count in mfxExtVPPDoUse
Repostion the mfxExtVPPDoUse enabling code
so that it will get the filter algorithm count correctly.
2018-06-05 17:01:13 -08:00
Sreerenj Balachandran
3f2314a1a9 msdk: vpp: don't use NV12 as vpp default output for DMABuf usecase
Using NV12 layout in dmabuf mode giving mis-aligned
VPP output with the media-driver. Keep the NV12 support
(so that we can file the bug agianst msdk or mediadriver),
but lower the ordering so that BGRA picks as default.

NV12 issue can be reproduced with explicit capfilter:
vidoetestsrc ! msdkvpp ! video/x-raw\(memory:DMABuf\),format=NV12 ! glimagesink
2018-05-30 16:29:41 -08:00
Sreerenj Balachandran
57b9875260 msdk: enc: Add supprot for dmabuf-import
MediaSDK requires all the input buffers to be
pre-allocated during init phase and this won't work with
current design of GStreamer or gst-msdk. But this can be
done in future once we have a solution for:
https://bugzilla.gnome.org/show_bug.cgi?id=795747

There is a workaround possible as per
https://github.com/Intel-Media-SDK/MediaSDK/issues/155#issuecomment-381790504
by faking the mem-id during MFXInit.
This patch enabling it in gst-msdk by replacing the MemID of mfxSurface
with dmabuf-backed vasurface dynamically.

Important: v4l2 ! msdkenc won't work without a copy because
of the GMMLib (https://github.com/intel/gmmlib) memory restrictions.

https://bugzilla.gnome.org/show_bug.cgi?id=794817
2018-05-30 16:26:27 -08:00
Sreerenj Balachandran
a972d76784 msdk: vpp: Add supprot for dmabuf-import
MediaSDK requires all the input and output buffers to be
pre-allocated during init phase and this won't work with
current design of GStreamer or gst-msdk. But this can be
done with https://bugzilla.gnome.org/show_bug.cgi?id=795747

There is a workaround possible as per
https://github.com/Intel-Media-SDK/MediaSDK/issues/155#issuecomment-381790504
by faking the mem-id during MFXInit.
This patch do this in gst-msdk by replacing the MemID of mfxSurface
with dmabuf-backed vasurface dynamically.

Important: v4l2 ! msdkvpp won't work without a copy because
of the GMMLib (https://github.com/intel/gmmlib) memory restrictions.

https://bugzilla.gnome.org/show_bug.cgi?id=794817
2018-05-30 16:24:24 -08:00
Sreerenj Balachandran
a7b7939dd7 msdk: Add method to replace internal VASurface of mfxFrameSurface
Added a utility method to replace the MemID (interanl VASurfaceID)
associated with the mfxFrameSurface. This is usefull for dmabuf-import
where we need to replace the memID dynamically

https://bugzilla.gnome.org/show_bug.cgi?id=794817
2018-05-30 16:23:44 -08:00