From 94483de40f4c5232e0928730e9e27604e0bc54b3 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Wed, 9 Aug 2017 14:10:16 -0700 Subject: [PATCH] FEI: libs: Add virtual method for secondary context creation. 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 Signed-off-by: Leilei Shang Signed-off-by: xiaominc Signed-off-by: Sreerenj Balachandran https://bugzilla.gnome.org/show_bug.cgi?id=785712 https://bugzilla.gnome.org/show_bug.cgi?id=784667 --- gst-libs/gst/vaapi/gstvaapiencoder.c | 12 ++++++++++++ gst-libs/gst/vaapi/gstvaapiencoder_priv.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c index 12b090a..8fb60b7 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder.c @@ -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; + } } /** diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h index d73689e..ead9f5e 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h +++ b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h @@ -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) \ -- 2.7.4