summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorHe Junyan <junyan.he@intel.com>2020-07-29 22:32:55 +0800
committerHe Junyan <junyan.he@intel.com>2020-07-30 17:46:24 +0800
commit65c8718f5e99d8a7cdd647ad79878c1ba44f1827 (patch)
tree1a675cae59e39146daccec107830ad824abfad23 /gst-libs
parent38db4bc15e06c34ff99638a87ec5e80086ee6d3d (diff)
libs: display: Add a helper function to get profiles by codec.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/349>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.c38
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.h4
2 files changed, 36 insertions, 6 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c
index 3a6841d0..43914410 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.c
@@ -326,7 +326,7 @@ compare_profiles (gconstpointer a, gconstpointer b)
/* Convert configs array to profiles as GstCaps */
static GArray *
-get_profiles (GPtrArray * configs)
+get_profiles (GPtrArray * configs, GstVaapiCodec codec)
{
GstVaapiProfileConfig *config;
GArray *out_profiles;
@@ -341,7 +341,8 @@ get_profiles (GPtrArray * configs)
for (i = 0; i < configs->len; i++) {
config = g_ptr_array_index (configs, i);
- g_array_append_val (out_profiles, config->profile);
+ if (!codec || (codec == gst_vaapi_profile_get_codec (config->profile)))
+ g_array_append_val (out_profiles, config->profile);
}
return out_profiles;
}
@@ -1560,7 +1561,7 @@ gst_vaapi_display_has_video_processing (GstVaapiDisplay * display)
* reference to the resulting array of #GstVaapiProfile elements, so
* it shall be released with g_array_unref() after usage.
*
- * Return value: a newly allocated #GArray, or %NULL or error or if
+ * Return value: a newly allocated #GArray, or %NULL if error or if
* decoding is not supported at all
*/
GArray *
@@ -1570,7 +1571,7 @@ gst_vaapi_display_get_decode_profiles (GstVaapiDisplay * display)
if (!ensure_profiles (display))
return NULL;
- return get_profiles (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->decoders);
+ return get_profiles (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->decoders, 0);
}
/**
@@ -1604,7 +1605,7 @@ gst_vaapi_display_has_decoder (GstVaapiDisplay * display,
* reference to the resulting array of #GstVaapiProfile elements, so
* it shall be released with g_array_unref() after usage.
*
- * Return value: a newly allocated #GArray, or %NULL or error or if
+ * Return value: a newly allocated #GArray, or %NULL if error or if
* encoding is not supported at all
*/
GArray *
@@ -1614,7 +1615,32 @@ gst_vaapi_display_get_encode_profiles (GstVaapiDisplay * display)
if (!ensure_profiles (display))
return NULL;
- return get_profiles (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->encoders);
+ return get_profiles (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->encoders, 0);
+}
+
+/**
+ * gst_vaapi_display_get_encode_profiles_by_codec:
+ * @display: a #GstVaapiDisplay
+ * @codec: a #GstVaapiCodec
+ *
+ * Gets the supported profiles which belongs to @codec for encoding.
+ * The caller owns an extra reference to the resulting array of
+ * #GstVaapiProfile elements, so it shall be released with g_array_unref()
+ * after usage.
+ *
+ * Return value: a newly allocated #GArray, or %NULL if error or if
+ * no encoding profile is found specified by the @codec.
+ */
+GArray *
+gst_vaapi_display_get_encode_profiles_by_codec (GstVaapiDisplay * display,
+ GstVaapiCodec codec)
+{
+ g_return_val_if_fail (display != NULL, NULL);
+
+ if (!ensure_profiles (display))
+ return NULL;
+ return get_profiles (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->encoders,
+ codec);
}
/**
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.h b/gst-libs/gst/vaapi/gstvaapidisplay.h
index 3eca38aa..07ecc82f 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.h
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.h
@@ -242,6 +242,10 @@ gst_vaapi_display_has_decoder (GstVaapiDisplay * display,
GArray *
gst_vaapi_display_get_encode_profiles (GstVaapiDisplay * display);
+GArray *
+gst_vaapi_display_get_encode_profiles_by_codec (GstVaapiDisplay * display,
+ GstVaapiCodec codec);
+
gboolean
gst_vaapi_display_has_encoder (GstVaapiDisplay * display,
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint);