summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2017-04-06 12:28:51 +0200
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2017-04-06 22:00:05 +0200
commit9aa63e4595105ac035663a22360d75c52b74b4b8 (patch)
treeefe8ad6dff66050f25a5b03c7c411148e757a83e
parent31d326c9ee12e6c8da7b765c9968ac52ac29239f (diff)
libs: encoder: dummy context for get_surface_formats()
Instead of creating (if it doesn't exist, yet) the encoder's context the method gst_vaapi_encoder_get_surface_formats() now it creates dummy contexts, unless the encoder has it already created. The purpose of this is to avoid setting a encoder's context with a wrong profile. https://bugzilla.gnome.org/show_bug.cgi?id=771291
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c
index f4836e39..3ecd2c45 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -1160,17 +1160,18 @@ error:
}
}
-static gboolean
-gst_vaapi_encoder_ensure_context_config (GstVaapiEncoder * encoder)
+static GstVaapiContext *
+create_test_context_config (GstVaapiEncoder * encoder)
{
- GstVaapiContextInfo *const cip = &encoder->context_info;
+ GstVaapiContextInfo cip = { 0, };
+ GstVaapiContext *ctxt;
if (encoder->context)
- return TRUE;
+ return gst_vaapi_object_ref (encoder->context);
- init_context_info (encoder, cip, get_profile (encoder));
- encoder->context = gst_vaapi_context_new (encoder->display, cip);
- return (encoder->context != NULL);
+ init_context_info (encoder, &cip, get_profile (encoder));
+ ctxt = gst_vaapi_context_new (encoder->display, &cip);
+ return ctxt;
}
/**
@@ -1184,9 +1185,15 @@ gst_vaapi_encoder_ensure_context_config (GstVaapiEncoder * encoder)
GArray *
gst_vaapi_encoder_get_surface_formats (GstVaapiEncoder * encoder)
{
- if (!gst_vaapi_encoder_ensure_context_config (encoder))
+ GstVaapiContext *ctxt;
+ GArray *formats;
+
+ ctxt = create_test_context_config (encoder);
+ if (!ctxt)
return NULL;
- return gst_vaapi_context_get_surface_formats (encoder->context);
+ formats = gst_vaapi_context_get_surface_formats (ctxt);
+ gst_vaapi_object_unref (ctxt);
+ return formats;
}
/** Returns a GType for the #GstVaapiEncoderTune set */