libs: encoder: pass profile to get_surface_formats()
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Thu, 6 Apr 2017 10:49:24 +0000 (12:49 +0200)
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Thu, 6 Apr 2017 20:00:05 +0000 (22:00 +0200)
In order to get the supported surface formats within a specific
profile this patch adds the GstVaapiProfile as property to
gst_vaapi_encoder_get_surface_formats().

Currently the extracted formats are only those related with the
default profile of the element's codec.

https://bugzilla.gnome.org/show_bug.cgi?id=771291

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

index 3ecd2c4..cfbdfc8 100644 (file)
@@ -1161,7 +1161,7 @@ error:
 }
 
 static GstVaapiContext *
-create_test_context_config (GstVaapiEncoder * encoder)
+create_test_context_config (GstVaapiEncoder * encoder, GstVaapiProfile profile)
 {
   GstVaapiContextInfo cip = { 0, };
   GstVaapiContext *ctxt;
@@ -1169,7 +1169,11 @@ create_test_context_config (GstVaapiEncoder * encoder)
   if (encoder->context)
     return gst_vaapi_object_ref (encoder->context);
 
-  init_context_info (encoder, &cip, get_profile (encoder));
+  /* if there is no profile, let's figure out one */
+  if (profile == GST_VAAPI_PROFILE_UNKNOWN)
+    profile = get_profile (encoder);
+
+  init_context_info (encoder, &cip, profile);
   ctxt = gst_vaapi_context_new (encoder->display, &cip);
   return ctxt;
 }
@@ -1183,12 +1187,13 @@ create_test_context_config (GstVaapiEncoder * encoder)
  * Returns: a #GArray of valid formats for the current VAConfig
  **/
 GArray *
-gst_vaapi_encoder_get_surface_formats (GstVaapiEncoder * encoder)
+gst_vaapi_encoder_get_surface_formats (GstVaapiEncoder * encoder,
+    GstVaapiProfile profile)
 {
   GstVaapiContext *ctxt;
   GArray *formats;
 
-  ctxt = create_test_context_config (encoder);
+  ctxt = create_test_context_config (encoder, profile);
   if (!ctxt)
     return NULL;
   formats = gst_vaapi_context_get_surface_formats (ctxt);
index 3160036..1c7cd47 100644 (file)
@@ -174,7 +174,8 @@ GstVaapiEncoderStatus
 gst_vaapi_encoder_flush (GstVaapiEncoder * encoder);
 
 GArray *
-gst_vaapi_encoder_get_surface_formats (GstVaapiEncoder * encoder);
+gst_vaapi_encoder_get_surface_formats (GstVaapiEncoder * encoder,
+    GstVaapiProfile profile);
 G_END_DECLS
 
 #endif /* GST_VAAPI_ENCODER_H */
index cc460a4..ff7154d 100644 (file)
@@ -362,7 +362,8 @@ ensure_allowed_sinkpad_caps (GstVaapiEncode * encode)
   if (!out_caps)
     goto failed_create_va_caps;
 
-  formats = gst_vaapi_encoder_get_surface_formats (encode->encoder);
+  formats = gst_vaapi_encoder_get_surface_formats (encode->encoder,
+      GST_VAAPI_PROFILE_UNKNOWN);
   if (!formats)
     goto failed_get_formats;