Commit graph

319 commits

Author SHA1 Message Date
Haihao Xiang
ef81c9d6c4 msdkdec: Update frame info from video parameters
A 10bit stream may have different depth values for Luma and Chroma, and
MSDK requires the frame info must match the corresponding video
parameters
2019-08-06 09:20:21 +00:00
Aaron Boxer
40f7001bef msdkdec: no need to cache allocation_caps 2019-08-05 13:32:15 +00:00
Aaron Boxer
6c7a07bc2a msdk: enable 32 bit build on windows 2019-07-26 11:42:55 +02:00
Aaron Boxer
96dc150b8b msdkdec: improve spelling and grammar of comments 2019-07-24 12:30:31 +02:00
Haihao Xiang
20f61db2e5 msdkdec: make sure mfx frame width/height meets MSDK's requirement
It is possible that the output region size (e.g. 192x144) is different
from the coded picture size (e.g. 192x256). We may adjust the alignment
parameters so that the padding is respected in GstVideoInfo and use
GstVideoInfo to calculate mfx frame width and height

This fixes the error below when decoding a stream which has different
output region size and coded picture size

0:00:00.057726900 28634 0x55df6c3220a0 ERROR                msdkdec
gstmsdkdec.c:1065:gst_msdkdec_handle_frame:<msdkh265dec0>
DecodeFrameAsync failed (failed to allocate memory)

Sample pipeline:

gst-launch-1.0 filesrc location=output.h265 ! h265parse ! msdkh265dec !
glimagesink
2019-07-24 08:41:13 +08:00
Haihao Xiang
8145a2236d msdkdec: remove unneeded code
Before calling gst_msdkdec_create_buffer_pool, the alignment parameters
have been adjusted.
2019-07-24 08:17:29 +08:00
Seungha Yang
9ec62418c3 msdk: Do not expose DMA buffer caps feature on Windows
On Windows, DMA buffer is not supported. PadTemplate with actually
supported feature seems to more make sense.
2019-07-22 16:13:43 +00:00
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