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
GST_INFO_OBJECT (thiz, "Found context %" GST_PTR_FORMAT " from neighbour",
thiz->context);
- if (gst_msdk_context_get_job_type (thiz->context) & GST_MSDK_JOB_ENCODER) {
+ /* Check GST_MSDK_JOB_VPP and GST_MSDK_JOB_ENCODER together to avoid sharing context
+ * between VPP and ENCODER
+ * Example:
+ * gst-launch-1.0 videotestsrc ! video/x-raw,format=I420 ! msdkh264enc ! \
+ * msdkh264dec ! msdkvpp ! video/x-raw,format=YUY2 ! fakesink
+ */
+ if (gst_msdk_context_get_job_type (thiz->context) & (GST_MSDK_JOB_VPP |
+ GST_MSDK_JOB_ENCODER)) {
GstMsdkContext *parent_context, *msdk_context;
parent_context = thiz->context;
GST_INFO_OBJECT (thiz, "Found context from neighbour %" GST_PTR_FORMAT,
thiz->context);
- if (gst_msdk_context_get_job_type (thiz->context) & GST_MSDK_JOB_VPP) {
+ /* Check GST_MSDK_JOB_VPP and GST_MSDK_JOB_ENCODER together to avoid sharing context
+ * between VPP and ENCODER
+ * Example:
+ * gst-launch-1.0 videotestsrc ! msdkvpp ! video/x-raw,format=YUY2 ! msdkh264enc ! fakesink
+ */
+ if (gst_msdk_context_get_job_type (thiz->context) & (GST_MSDK_JOB_ENCODER |
+ GST_MSDK_JOB_VPP)) {
GstMsdkContext *parent_context, *msdk_context;
parent_context = thiz->context;