[Pkg-gstreamer-commits] [gstreamer-vaapi] 168/176: libs: factor out usages of vaGetConfigAttributes().

Vincent Cheng vcheng at moszumanska.debian.org
Tue Jun 3 08:09:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

vcheng pushed a commit to branch upstream
in repository gstreamer-vaapi.

commit db7a3b8d3e179b055ca1b793d711e12ba6cee025
Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Date:   Thu Jan 23 18:41:24 2014 +0100

    libs: factor out usages of vaGetConfigAttributes().
    
    Add gst_vaapi_get_config_attribute() helper function that takes a
    GstVaapiDisplay and the rest of the arguments with VA types. The aim
    is to have thread-safe VA helpers by default.
---
 gst-libs/gst/vaapi/Makefile.am          |  2 +
 gst-libs/gst/vaapi/gstvaapicontext.c    | 54 +++++------------------
 gst-libs/gst/vaapi/gstvaapicontext.h    |  5 ---
 gst-libs/gst/vaapi/gstvaapiencoder.c    | 26 +++--------
 gst-libs/gst/vaapi/gstvaapiutils_core.c | 77 +++++++++++++++++++++++++++++++++
 gst-libs/gst/vaapi/gstvaapiutils_core.h | 40 +++++++++++++++++
 6 files changed, 138 insertions(+), 66 deletions(-)

diff --git a/gst-libs/gst/vaapi/Makefile.am b/gst-libs/gst/vaapi/Makefile.am
index 92b875a..69eda14 100644
--- a/gst-libs/gst/vaapi/Makefile.am
+++ b/gst-libs/gst/vaapi/Makefile.am
@@ -71,6 +71,7 @@ libgstvaapi_source_c =				\
 	gstvaapisurfacepool.c			\
 	gstvaapisurfaceproxy.c			\
 	gstvaapiutils.c				\
+	gstvaapiutils_core.c			\
 	gstvaapiutils_h264.c			\
 	gstvaapiutils_mpeg2.c			\
 	gstvaapivalue.c				\
@@ -127,6 +128,7 @@ libgstvaapi_source_priv_h =			\
 	gstvaapisurface_priv.h			\
 	gstvaapisurfaceproxy_priv.h		\
 	gstvaapiutils.h				\
+	gstvaapiutils_core.h			\
 	gstvaapiutils_h264_priv.h		\
 	gstvaapiutils_mpeg2_priv.h		\
 	gstvaapiversion.h			\
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c
index 96f1499..236f891 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.c
+++ b/gst-libs/gst/vaapi/gstvaapicontext.c
@@ -39,6 +39,7 @@
 #include "gstvaapisurfaceproxy.h"
 #include "gstvaapivideopool_priv.h"
 #include "gstvaapiutils.h"
+#include "gstvaapiutils_core.h"
 
 #define DEBUG 1
 #include "gstvaapidebug.h"
@@ -50,6 +51,14 @@ unref_surface_cb (GstVaapiSurface * surface)
   gst_vaapi_object_unref (surface);
 }
 
+static inline gboolean
+context_get_attribute (GstVaapiContext * context, VAConfigAttribType type,
+    guint * out_value_ptr)
+{
+  return gst_vaapi_get_config_attribute (GST_VAAPI_OBJECT_DISPLAY (context),
+      context->va_profile, context->va_entrypoint, type, out_value_ptr);
+}
+
 static void
 context_destroy_surfaces (GstVaapiContext * context)
 {
@@ -179,7 +188,7 @@ context_create (GstVaapiContext * context)
 
   /* Validate VA surface format */
   attrib->type = VAConfigAttribRTFormat;
-  if (!gst_vaapi_context_get_attribute (context, attrib->type, &value))
+  if (!context_get_attribute (context, attrib->type, &value))
     goto cleanup;
   if (!(value & VA_RT_FORMAT_YUV420))
     goto cleanup;
@@ -193,7 +202,7 @@ context_create (GstVaapiContext * context)
 
       /* Rate control */
       attrib->type = VAConfigAttribRateControl;
-      if (!gst_vaapi_context_get_attribute (context, attrib->type, &value))
+      if (!context_get_attribute (context, attrib->type, &value))
         goto cleanup;
 
       va_rate_control = from_GstVaapiRateControl (config->rc_mode);
@@ -208,7 +217,7 @@ context_create (GstVaapiContext * context)
       /* Packed headers */
       if (config->packed_headers) {
         attrib->type = VAConfigAttribEncPackedHeaders;
-        if (!gst_vaapi_context_get_attribute (context, attrib->type, &value))
+        if (!context_get_attribute (context, attrib->type, &value))
           goto cleanup;
 
         if ((value & config->packed_headers) != config->packed_headers) {
@@ -436,42 +445,3 @@ gst_vaapi_context_get_surface_count (GstVaapiContext * context)
 
   return gst_vaapi_video_pool_get_size (context->surfaces_pool);
 }
-
-/**
- * gst_vaapi_context_get_attribute:
- * @context: a #GstVaapiContext
- * @type: a VA config attribute type
- * @out_value_ptr: return location for the config attribute value
- *
- * Determines the value for the VA config attribute @type.
- *
- * Note: this function only returns success if the VA driver does
- * actually know about this config attribute type and that it returned
- * a valid value for it.
- *
- * Return value: %TRUE if the VA driver knows about the requested
- *   config attribute and returned a valid value, %FALSE otherwise
- */
-gboolean
-gst_vaapi_context_get_attribute (GstVaapiContext * context,
-    VAConfigAttribType type, guint * out_value_ptr)
-{
-  VAConfigAttrib attrib;
-  VAStatus status;
-
-  g_return_val_if_fail (context != NULL, FALSE);
-
-  GST_VAAPI_OBJECT_LOCK_DISPLAY (context);
-  attrib.type = type;
-  status = vaGetConfigAttributes (GST_VAAPI_OBJECT_VADISPLAY (context),
-      context->va_profile, context->va_entrypoint, &attrib, 1);
-  GST_VAAPI_OBJECT_UNLOCK_DISPLAY (context);
-  if (!vaapi_check_status (status, "vaGetConfigAttributes()"))
-    return FALSE;
-  if (attrib.value == VA_ATTRIB_NOT_SUPPORTED)
-    return FALSE;
-
-  if (out_value_ptr)
-    *out_value_ptr = attrib.value;
-  return TRUE;
-}
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.h b/gst-libs/gst/vaapi/gstvaapicontext.h
index 24ba697..64e758f 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.h
+++ b/gst-libs/gst/vaapi/gstvaapicontext.h
@@ -142,11 +142,6 @@ G_GNUC_INTERNAL
 guint
 gst_vaapi_context_get_surface_count (GstVaapiContext * context);
 
-G_GNUC_INTERNAL
-gboolean
-gst_vaapi_context_get_attribute (GstVaapiContext * context,
-    VAConfigAttribType type, guint * out_value_ptr);
-
 G_END_DECLS
 
 #endif /* GST_VAAPI_CONTEXT_H */
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c
index 89eb579..b055ef5 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -28,6 +28,7 @@
 #include "gstvaapicontext.h"
 #include "gstvaapidisplay_priv.h"
 #include "gstvaapiutils.h"
+#include "gstvaapiutils_core.h"
 #include "gstvaapivalue.h"
 
 #define DEBUG 1
@@ -507,31 +508,18 @@ get_profile (GstVaapiEncoder * encoder)
 /* Gets config attribute for the supplied profile */
 static gboolean
 get_config_attribute (GstVaapiEncoder * encoder, VAConfigAttribType type,
-    guint32 * out_value_ptr)
+    guint * out_value_ptr)
 {
   GstVaapiProfile profile;
-  VAConfigAttrib attrib;
-  VAStatus status;
+  VAProfile va_profile;
 
   profile = get_profile (encoder);
   if (!profile)
     return FALSE;
 
-  GST_VAAPI_DISPLAY_LOCK (encoder->display);
-  attrib.type = type;
-  status =
-      vaGetConfigAttributes (GST_VAAPI_DISPLAY_VADISPLAY (encoder->display),
-      gst_vaapi_profile_get_va_profile (profile), VAEntrypointEncSlice,
-      &attrib, 1);
-  GST_VAAPI_DISPLAY_UNLOCK (encoder->display);
-  if (!vaapi_check_status (status, "vaGetConfigAttributes()"))
-    return FALSE;
-  if (attrib.value == VA_ATTRIB_NOT_SUPPORTED)
-    return FALSE;
-
-  if (out_value_ptr)
-    *out_value_ptr = attrib.value;
-  return TRUE;
+  va_profile = gst_vaapi_profile_get_va_profile (profile);
+  return gst_vaapi_get_config_attribute (encoder->display, va_profile,
+      VAEntrypointEncSlice, type, out_value_ptr);
 }
 
 /* Determines the set of supported packed headers */
@@ -781,7 +769,7 @@ error_invalid_property:
 }
 
 /* Determine the supported rate control modes */
-static guint32
+static guint
 get_rate_control_mask (GstVaapiEncoder * encoder)
 {
   const GstVaapiEncoderClassData *const cdata =
diff --git a/gst-libs/gst/vaapi/gstvaapiutils_core.c b/gst-libs/gst/vaapi/gstvaapiutils_core.c
new file mode 100644
index 0000000..fe08326
--- /dev/null
+++ b/gst-libs/gst/vaapi/gstvaapiutils_core.c
@@ -0,0 +1,77 @@
+/*
+ *  gstvaapiutils_core.c - VA-API utilities (Core, MT-safe)
+ *
+ *  Copyright (C) 2010-2011 Splitted-Desktop Systems
+ *    Author: Gwenole Beauchesne <gwenole.beauchesne at splitted-desktop.com>
+ *  Copyright (C) 2011-2014 Intel Corporation
+ *    Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1
+ *  of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301 USA
+ */
+
+#include "sysdeps.h"
+#include "gstvaapicompat.h"
+#include "gstvaapiutils.h"
+#include "gstvaapiutils_core.h"
+#include "gstvaapidisplay_priv.h"
+
+#define DEBUG 1
+#include "gstvaapidebug.h"
+
+/**
+ * gst_vaapi_get_config_attribute:
+ * @display: a #GstVaapiDisplay
+ * @profile: a VA profile
+ * @entrypoint: a VA entrypoint
+ * @type: a VA config attribute type
+ * @out_value_ptr: return location for the config attribute value
+ *
+ * Determines the value for the VA config attribute @type and the
+ * given @profile/@entrypoint pair. If @out_value_ptr is %NULL, then
+ * this functions acts as a way to query whether the underlying VA
+ * driver supports the specified attribute @type, no matter the
+ * returned value.
+ *
+ * Note: this function only returns success if the VA driver does
+ * actually know about this config attribute type and that it returned
+ * a valid value for it.
+ *
+ * Return value: %TRUE if the VA driver knows about the requested
+ *   config attribute and returned a valid value, %FALSE otherwise
+ */
+gboolean
+gst_vaapi_get_config_attribute (GstVaapiDisplay * display, VAProfile profile,
+    VAEntrypoint entrypoint, VAConfigAttribType type, guint * out_value_ptr)
+{
+  VAConfigAttrib attrib;
+  VAStatus status;
+
+  g_return_val_if_fail (display != NULL, FALSE);
+
+  GST_VAAPI_DISPLAY_LOCK (display);
+  attrib.type = type;
+  status = vaGetConfigAttributes (GST_VAAPI_DISPLAY_VADISPLAY (display),
+      profile, entrypoint, &attrib, 1);
+  GST_VAAPI_DISPLAY_UNLOCK (display);
+  if (!vaapi_check_status (status, "vaGetConfigAttributes()"))
+    return FALSE;
+  if (attrib.value == VA_ATTRIB_NOT_SUPPORTED)
+    return FALSE;
+
+  if (out_value_ptr)
+    *out_value_ptr = attrib.value;
+  return TRUE;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapiutils_core.h b/gst-libs/gst/vaapi/gstvaapiutils_core.h
new file mode 100644
index 0000000..7f9dcf9
--- /dev/null
+++ b/gst-libs/gst/vaapi/gstvaapiutils_core.h
@@ -0,0 +1,40 @@
+/*
+ *  gstvaapiutils_core.h - VA-API utilities (Core, MT-safe)
+ *
+ *  Copyright (C) 2010-2011 Splitted-Desktop Systems
+ *    Author: Gwenole Beauchesne <gwenole.beauchesne at splitted-desktop.com>
+ *  Copyright (C) 2011-2013 Intel Corporation
+ *    Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1
+ *  of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301 USA
+ */
+
+#ifndef GST_VAAPI_UTILS_CORE_H
+#define GST_VAAPI_UTILS_CORE_H
+
+#include <gst/vaapi/gstvaapidisplay.h>
+
+G_BEGIN_DECLS
+
+/* Gets attribute value for the supplied profile/entrypoint pair (MT-safe) */
+G_GNUC_INTERNAL
+gboolean
+gst_vaapi_get_config_attribute (GstVaapiDisplay * display, VAProfile profile,
+    VAEntrypoint entrypoint, VAConfigAttribType type, guint * out_value_ptr);
+
+G_END_DECLS
+
+#endif /* GST_VAAPI_UTILS_CORE_H */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gstreamer/gstreamer-vaapi.git



More information about the Pkg-gstreamer-commits mailing list