[Pkg-gstreamer-commits] [gstreamer-vaapi] 02/176: libs: add rate-control attributes.

Vincent Cheng vcheng at moszumanska.debian.org
Tue Jun 3 08:09:22 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 082fb3f1b4390aa1fc4c735e57b7ea1b0687b4a2
Author: Wind Yuan <feng.yuan at intel.com>
Date:   Fri Jul 12 21:33:32 2013 +0800

    libs: add rate-control attributes.
    
    Add GstVaapiRateControl types and GType values in view to supporting
    rate controls for encoding. This is meant to be used for instance in
    GstVaapiContext.
    
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
---
 gst-libs/gst/vaapi/gstvaapitypes.h | 23 +++++++++++++++++++
 gst-libs/gst/vaapi/gstvaapiutils.c | 45 ++++++++++++++++++++++++++++++++++++++
 gst-libs/gst/vaapi/gstvaapiutils.h | 12 ++++++++++
 gst-libs/gst/vaapi/gstvaapivalue.c | 31 ++++++++++++++++++++++++++
 gst-libs/gst/vaapi/gstvaapivalue.h | 12 ++++++++++
 5 files changed, 123 insertions(+)

diff --git a/gst-libs/gst/vaapi/gstvaapitypes.h b/gst-libs/gst/vaapi/gstvaapitypes.h
index 053e2e5..771ad75 100644
--- a/gst-libs/gst/vaapi/gstvaapitypes.h
+++ b/gst-libs/gst/vaapi/gstvaapitypes.h
@@ -121,6 +121,29 @@ typedef enum {
     GST_VAAPI_ROTATION_270 = 270,
 } GstVaapiRotation;
 
+/**
+ * GstVaapiRateControl:
+ * @GST_VAAPI_RATECONTROL_NONE: No rate control performed by the
+ *   underlying driver
+ * @GST_VAAPI_RATECONTROL_CQP: Constant QP
+ * @GST_VAAPI_RATECONTROL_CBR: Constant bitrate
+ * @GST_VAAPI_RATECONTROL_VCM: Video conference mode
+ * @GST_VAAPI_RATECONTROL_VBR: Variable bitrate
+ * @GST_VAAPI_RATECONTROL_VBR_CONSTRAINED: Variable bitrate with peak
+ *   rate higher than average bitrate
+ *
+ * The set of allowed rate control values for #GstVaapiRateControl.
+ * Note: this is only valid for encoders.
+ */
+typedef enum {
+    GST_VAAPI_RATECONTROL_NONE = 0,
+    GST_VAAPI_RATECONTROL_CQP,
+    GST_VAAPI_RATECONTROL_CBR,
+    GST_VAAPI_RATECONTROL_VCM,
+    GST_VAAPI_RATECONTROL_VBR,
+    GST_VAAPI_RATECONTROL_VBR_CONSTRAINED,
+} GstVaapiRateControl;
+
 G_END_DECLS
 
 #endif /* GST_VAAPI_TYPES_H */
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.c b/gst-libs/gst/vaapi/gstvaapiutils.c
index 2536ad8..90510e5 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils.c
+++ b/gst-libs/gst/vaapi/gstvaapiutils.c
@@ -210,6 +210,21 @@ string_of_VADisplayAttributeType(VADisplayAttribType attribute_type)
     return "<unknown>";
 }
 
+const char *
+string_of_VARateControl(guint rate_control)
+{
+    switch (rate_control) {
+    case VA_RC_NONE:            return "None";
+    case VA_RC_CQP:             return "CQP";
+    case VA_RC_CBR:             return "CBR";
+    case VA_RC_VCM:             return "VCM";
+    case VA_RC_VBR:             return "VBR";
+    case VA_RC_VBR_CONSTRAINED: return "VBR-Constrained";
+    default: break;
+    }
+    return "<unknown>";
+}
+
 /**
  * from_GstVaapiChromaType:
  * @chroma_type: the #GstVaapiChromaType
@@ -441,6 +456,36 @@ to_GstVaapiRotation(guint value)
     return GST_VAAPI_ROTATION_0;
 }
 
+guint
+from_GstVaapiRateControl(guint value)
+{
+    switch (value) {
+    case GST_VAAPI_RATECONTROL_NONE:            return VA_RC_NONE;
+    case GST_VAAPI_RATECONTROL_CQP:             return VA_RC_CQP;
+    case GST_VAAPI_RATECONTROL_CBR:             return VA_RC_CBR;
+    case GST_VAAPI_RATECONTROL_VCM:             return VA_RC_VCM;
+    case GST_VAAPI_RATECONTROL_VBR:             return VA_RC_VBR;
+    case GST_VAAPI_RATECONTROL_VBR_CONSTRAINED: return VA_RC_VBR_CONSTRAINED;
+    }
+    GST_ERROR("unsupported GstVaapiRateControl value %u", value);
+    return VA_RC_NONE;
+}
+
+guint
+to_GstVaapiRateControl(guint value)
+{
+    switch (value) {
+    case VA_RC_NONE:            return GST_VAAPI_RATECONTROL_NONE;
+    case VA_RC_CQP:             return GST_VAAPI_RATECONTROL_CQP;
+    case VA_RC_CBR:             return GST_VAAPI_RATECONTROL_CBR;
+    case VA_RC_VCM:             return GST_VAAPI_RATECONTROL_VCM;
+    case VA_RC_VBR:             return GST_VAAPI_RATECONTROL_VBR;
+    case VA_RC_VBR_CONSTRAINED: return GST_VAAPI_RATECONTROL_VBR_CONSTRAINED;
+    }
+    GST_ERROR("unsupported VA-API Rate Control value %u", value);
+    return GST_VAAPI_RATECONTROL_NONE;
+}
+
 /* VPP: translate GstVaapiDeinterlaceMethod to VA deinterlacing algorithm */
 guint
 from_GstVaapiDeinterlaceMethod(guint value)
diff --git a/gst-libs/gst/vaapi/gstvaapiutils.h b/gst-libs/gst/vaapi/gstvaapiutils.h
index 3355c7f..21d13c2 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils.h
+++ b/gst-libs/gst/vaapi/gstvaapiutils.h
@@ -76,6 +76,10 @@ const char *
 string_of_VADisplayAttributeType(VADisplayAttribType attribute_type);
 
 G_GNUC_INTERNAL
+const char *
+string_of_VARateControl(guint rate_control);
+
+G_GNUC_INTERNAL
 guint
 from_GstVaapiChromaType(guint chroma_type);
 
@@ -113,6 +117,14 @@ to_GstVaapiRotation(guint value);
 
 G_GNUC_INTERNAL
 guint
+from_GstVaapiRateControl(guint value);
+
+G_GNUC_INTERNAL
+guint
+to_GstVaapiRateControl(guint value);
+
+G_GNUC_INTERNAL
+guint
 from_GstVaapiDeinterlaceMethod(guint value);
 
 G_GNUC_INTERNAL
diff --git a/gst-libs/gst/vaapi/gstvaapivalue.c b/gst-libs/gst/vaapi/gstvaapivalue.c
index 92eb4c3..2f4c239 100644
--- a/gst-libs/gst/vaapi/gstvaapivalue.c
+++ b/gst-libs/gst/vaapi/gstvaapivalue.c
@@ -119,3 +119,34 @@ gst_vaapi_rotation_get_type(void)
         g_type = g_enum_register_static("GstVaapiRotation", rotation_values);
     return g_type;
 }
+
+/* --- GstVaapiRateControl --- */
+
+GType
+gst_vaapi_rate_control_get_type(void)
+{
+    static volatile gsize g_type = 0;
+
+    static const GEnumValue rate_control_values[] = {
+        { GST_VAAPI_RATECONTROL_NONE,
+          "None", "none" },
+        { GST_VAAPI_RATECONTROL_CQP,
+          "Constant QP", "cqp" },
+        { GST_VAAPI_RATECONTROL_CBR,
+          "Constant bitrate", "cbr" },
+        { GST_VAAPI_RATECONTROL_VCM,
+          "Video conference", "vcm" },
+        { GST_VAAPI_RATECONTROL_VBR,
+          "Variable bitrate", "vbr" },
+        { GST_VAAPI_RATECONTROL_VBR_CONSTRAINED,
+          "Variable bitrate - Constrained", "vbr_constrained" },
+        { 0, NULL, NULL },
+    };
+
+    if (g_once_init_enter(&g_type)) {
+        GType type = g_enum_register_static("GstVaapiRateControl",
+            rate_control_values);
+        g_once_init_leave(&g_type, type);
+    }
+    return g_type;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapivalue.h b/gst-libs/gst/vaapi/gstvaapivalue.h
index 05ccdc7..4c4d798 100644
--- a/gst-libs/gst/vaapi/gstvaapivalue.h
+++ b/gst-libs/gst/vaapi/gstvaapivalue.h
@@ -68,6 +68,15 @@ G_BEGIN_DECLS
  */
 #define GST_VAAPI_TYPE_ROTATION gst_vaapi_rotation_get_type()
 
+/**
+ * GST_VAAPI_TYPE_RATE_CONTROL:
+ *
+ * A type that represents the VA rate control.
+ *
+ * Return value: the #GType of GstVaapiRateControl
+ */
+#define GST_VAAPI_TYPE_RATE_CONTROL gst_vaapi_rate_control_get_type()
+
 GType
 gst_vaapi_point_get_type(void) G_GNUC_CONST;
 
@@ -80,6 +89,9 @@ gst_vaapi_render_mode_get_type(void) G_GNUC_CONST;
 GType
 gst_vaapi_rotation_get_type(void) G_GNUC_CONST;
 
+GType
+gst_vaapi_rate_control_get_type(void) G_GNUC_CONST;
+
 G_END_DECLS
 
 #endif /* GST_VAAPI_VALUE_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