FEI: libs: Add virtual method for secondary context creation.
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>
Wed, 9 Aug 2017 21:10:16 +0000 (14:10 -0700)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 1 Sep 2017 09:32:24 +0000 (11:32 +0200)
Add a new vitrual method ensure_secondary_context to the
base encoder which is only required for the FEI entrypoint, that too
only when user configures the ENC+PAK mode. ENC+PAK mode is not something
supported directly by libva or driver, but this can be enabled
from the middleware.

Original Author of this idea: Leilei Shang <leilei.shang@intel.com>

Signed-off-by: Leilei Shang <leilei.shang@intel.com>
Signed-off-by: xiaominc <xiaomin.chen@intel.com>
Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667

gst-libs/gst/vaapi/gstvaapiencoder.c
gst-libs/gst/vaapi/gstvaapiencoder_priv.h

index 12b090a..8fb60b7 100644 (file)
@@ -843,6 +843,13 @@ gst_vaapi_encoder_reconfigure_internal (GstVaapiEncoder * encoder)
   if (!gst_vaapi_encoder_ensure_context (encoder))
     goto error_reset_context;
 
+  /* Currently only FEI entrypoint needed this.
+   * FEI ENC+PAK requires two contexts where the first one is for ENC
+   * and the second one is for PAK */
+  if (klass->ensure_secondary_context
+      && !klass->ensure_secondary_context (encoder))
+    goto error_reset_secondary_context;
+
 #if VA_CHECK_VERSION(0,36,0)
   if (get_config_attribute (encoder, VAConfigAttribEncQualityRange,
           &quality_level_max) && quality_level_max > 0) {
@@ -879,6 +886,11 @@ error_reset_context:
     GST_ERROR ("failed to update VA context");
     return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
   }
+error_reset_secondary_context:
+  {
+    GST_ERROR ("failed to create/update secondary VA context");
+    return GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED;
+  }
 }
 
 /**
index d73689e..ead9f5e 100644 (file)
@@ -357,6 +357,9 @@ struct _GstVaapiEncoderClass
   /* get_codec_data can be NULL */
   GstVaapiEncoderStatus (*get_codec_data) (GstVaapiEncoder * encoder,
                                            GstBuffer ** codec_data);
+
+  /* To create a secondary context for a single base encoder */
+  gboolean              (*ensure_secondary_context) (GstVaapiEncoder * encoder);
 };
 
 #define GST_VAAPI_ENCODER_CLASS_HOOK(codec, func) \