[Pkg-gstreamer-commits] [gstreamer-vaapi] 163/176: context: move rate-control mode to encoder specific config.

Vincent Cheng vcheng at moszumanska.debian.org
Tue Jun 3 08:09:37 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 14ad694fdcd10035f4e62714d322d1f2beb59f19
Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Date:   Thu Jan 23 14:01:33 2014 +0100

    context: move rate-control mode to encoder specific config.
    
    Move usage-specific config out of the common GstVaapiContextInfo.
    Create a specialized config for encoding and move rate-control mode
    to there.
---
 gst-libs/gst/vaapi/gstvaapicontext.c | 26 ++++++++++++++++++++++----
 gst-libs/gst/vaapi/gstvaapicontext.h | 19 +++++++++++++++----
 gst-libs/gst/vaapi/gstvaapiencoder.c |  5 ++++-
 3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c
index f09e289..92a591e 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.c
+++ b/gst-libs/gst/vaapi/gstvaapicontext.c
@@ -189,12 +189,14 @@ context_create (GstVaapiContext * context)
   switch (cip->usage) {
     case GST_VAAPI_CONTEXT_USAGE_ENCODE:
     {
+      const GstVaapiConfigInfoEncoder *const config = &cip->config.encoder;
+
       /* Rate control */
       attrib->type = VAConfigAttribRateControl;
       if (!gst_vaapi_context_get_attribute (context, attrib->type, &value))
         goto cleanup;
 
-      va_rate_control = from_GstVaapiRateControl (cip->rc_mode);
+      va_rate_control = from_GstVaapiRateControl (config->rc_mode);
       if ((value & va_rate_control) != va_rate_control) {
         GST_ERROR ("unsupported %s rate control",
             string_of_VARateControl (va_rate_control));
@@ -234,6 +236,23 @@ cleanup:
   return success;
 }
 
+/** Updates config for encoding. Returns %TRUE if config changed */
+static gboolean
+context_update_config_encoder (GstVaapiContext * context,
+    const GstVaapiConfigInfoEncoder * new_config)
+{
+  GstVaapiConfigInfoEncoder *const config = &context->info.config.encoder;
+  gboolean config_changed = FALSE;
+
+  g_assert (context->info.usage == GST_VAAPI_CONTEXT_USAGE_ENCODE);
+
+  if (config->rc_mode != new_config->rc_mode) {
+    config->rc_mode = new_config->rc_mode;
+    config_changed = TRUE;
+  }
+  return config_changed;
+}
+
 static inline void
 gst_vaapi_context_init (GstVaapiContext * context,
     const GstVaapiContextInfo * cip)
@@ -323,11 +342,10 @@ gst_vaapi_context_reset (GstVaapiContext * context,
   if (cip->usage != new_cip->usage) {
     cip->usage = new_cip->usage;
     config_changed = TRUE;
+    memcpy (&cip->config, &new_cip->config, sizeof (cip->config));
   } else if (new_cip->usage == GST_VAAPI_CONTEXT_USAGE_ENCODE) {
-    if (cip->rc_mode != new_cip->rc_mode) {
-      cip->rc_mode = new_cip->rc_mode;
+    if (context_update_config_encoder (context, &new_cip->config.encoder))
       config_changed = TRUE;
-    }
   }
 
   if (size_changed)
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.h b/gst-libs/gst/vaapi/gstvaapicontext.h
index f19dca5..680dc3e 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.h
+++ b/gst-libs/gst/vaapi/gstvaapicontext.h
@@ -37,6 +37,7 @@ G_BEGIN_DECLS
 #define GST_VAAPI_CONTEXT(obj) \
   ((GstVaapiContext *) (obj))
 
+typedef struct _GstVaapiConfigInfoEncoder GstVaapiConfigInfoEncoder;
 typedef struct _GstVaapiContextInfo GstVaapiContextInfo;
 typedef struct _GstVaapiContext GstVaapiContext;
 typedef struct _GstVaapiContextClass GstVaapiContextClass;
@@ -56,24 +57,34 @@ typedef enum {
 } GstVaapiContextUsage;
 
 /**
+ * GstVaapiConfigInfoEncoder:
+ * @rc_mode: rate-control mode (#GstVaapiRateControl).
+ *
+ * Extra configuration for encoding.
+ */
+struct _GstVaapiConfigInfoEncoder
+{
+  GstVaapiRateControl rc_mode;
+};
+
+/**
  * GstVaapiContextInfo:
  *
  * Structure holding VA context info like encoded size, decoder
  * profile and entry-point to use, and maximum number of reference
  * frames reported by the bitstream.
- *
- * Note: @rc_mode is only valid for VA context used for encoding,
- * i.e. if @entrypoint is set to @GST_VAAPI_ENTRYPOINT_SLICE_ENCODE.
  */
 struct _GstVaapiContextInfo
 {
   GstVaapiContextUsage usage;
   GstVaapiProfile profile;
   GstVaapiEntrypoint entrypoint;
-  GstVaapiRateControl rc_mode;
   guint width;
   guint height;
   guint ref_frames;
+  union _GstVaapiConfigInfo {
+    GstVaapiConfigInfoEncoder encoder;
+  } config;
 };
 
 /**
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c
index 23f60d2..8ec052c 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -483,14 +483,17 @@ static void
 set_context_info (GstVaapiEncoder * encoder)
 {
   GstVaapiContextInfo *const cip = &encoder->context_info;
+  GstVaapiConfigInfoEncoder *const config = &cip->config.encoder;
 
   cip->usage = GST_VAAPI_CONTEXT_USAGE_ENCODE;
   cip->profile = encoder->profile;
   cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
-  cip->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
   cip->width = GST_VAAPI_ENCODER_WIDTH (encoder);
   cip->height = GST_VAAPI_ENCODER_HEIGHT (encoder);
   cip->ref_frames = encoder->num_ref_frames;
+
+  memset (config, 0, sizeof (*config));
+  config->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
 }
 
 /* Ensures the underlying VA context for encoding is created */

-- 
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