[Pkg-gstreamer-commits] [gstreamer-vaapi] 146/176: encoder: h264: only submit packed headers when required.

Vincent Cheng vcheng at moszumanska.debian.org
Tue Jun 3 08:09:36 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 71113e4999328bde8b34b0cf713f80e7e106cf43
Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Date:   Tue Jan 21 18:35:17 2014 +0100

    encoder: h264: only submit packed headers when required.
    
    Make sure to submit the packed headers only if the underlying VA driver
    requires those. Currently, only handle packed sequence and picture
    headers.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722737
---
 gst-libs/gst/vaapi/gstvaapicontext.c      | 40 +++++++++++++++++++++++++++++++
 gst-libs/gst/vaapi/gstvaapicontext.h      |  5 ++++
 gst-libs/gst/vaapi/gstvaapiencoder.c      | 11 +++++++++
 gst-libs/gst/vaapi/gstvaapiencoder_h264.c |  6 +++--
 gst-libs/gst/vaapi/gstvaapiencoder_priv.h | 13 ++++++++++
 5 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c
index 0628224..52e9317 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.c
+++ b/gst-libs/gst/vaapi/gstvaapicontext.c
@@ -1005,3 +1005,43 @@ error:
     gst_vaapi_context_clear_overlay(context);
     return FALSE;
 }
+
+
+/**
+ * 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),
+        gst_vaapi_profile_get_va_profile(context->info.profile),
+        gst_vaapi_entrypoint_get_va_entrypoint(context->info.entrypoint),
+        &attrib, 1);
+    GST_VAAPI_OBJECT_UNLOCK_DISPLAY(context);
+    if (!vaapi_check_status(status, "vaGetConfiAttributes()"))
+        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 771f505..22ce752 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.h
+++ b/gst-libs/gst/vaapi/gstvaapicontext.h
@@ -127,6 +127,11 @@ gst_vaapi_context_apply_composition(
     GstVideoOverlayComposition *composition
 );
 
+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 b9767f1..7b3d009 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -466,6 +466,16 @@ error_invalid_framerate:
   }
 }
 
+/* Determines the set of required packed headers */
+static void
+ensure_packed_headers (GstVaapiEncoder * encoder)
+{
+  if (!gst_vaapi_context_get_attribute (encoder->context,
+          VAConfigAttribEncPackedHeaders, &encoder->packed_headers))
+    encoder->packed_headers = 0;
+  GST_INFO ("packed headers mask: 0x%08x", encoder->packed_headers);
+}
+
 /* Updates video context */
 static void
 set_context_info (GstVaapiEncoder * encoder)
@@ -520,6 +530,7 @@ gst_vaapi_encoder_reconfigure_internal (GstVaapiEncoder * encoder)
 
   if (!gst_vaapi_encoder_ensure_context (encoder))
     goto error_reset_context;
+  ensure_packed_headers (encoder);
 
   codedbuf_size = encoder->codedbuf_pool ?
       gst_vaapi_coded_buffer_pool_get_buffer_size (GST_VAAPI_CODED_BUFFER_POOL
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
index 1fc440e..8b7f283 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
@@ -1366,7 +1366,8 @@ ensure_sequence (GstVaapiEncoderH264 * encoder, GstVaapiEncPicture * picture)
     goto error;
 
   if (picture->type == GST_VAAPI_PICTURE_TYPE_I &&
-      !add_packed_sequence_header (encoder, picture, sequence))
+      (GST_VAAPI_ENCODER_PACKED_HEADERS (encoder) & VAEncPackedHeaderH264_SPS)
+      && !add_packed_sequence_header (encoder, picture, sequence))
     goto error;
   gst_vaapi_enc_picture_set_sequence (picture, sequence);
   gst_vaapi_codec_object_replace (&sequence, NULL);
@@ -1430,7 +1431,8 @@ ensure_picture (GstVaapiEncoderH264 * encoder, GstVaapiEncPicture * picture,
     return FALSE;
 
   if (picture->type == GST_VAAPI_PICTURE_TYPE_I &&
-      !add_packed_picture_header (encoder, picture)) {
+      (GST_VAAPI_ENCODER_PACKED_HEADERS (encoder) & VAEncPackedHeaderH264_PPS)
+      && !add_packed_picture_header (encoder, picture)) {
     GST_ERROR ("set picture packed header failed");
     return FALSE;
   }
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h
index abe3309..43e5ad2 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h
@@ -41,6 +41,18 @@ G_BEGIN_DECLS
     GST_VAAPI_ENCODER_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(obj))
 
 /**
+ * GST_VAAPI_ENCODER_PACKED_HEADERS:
+ * @encoder: a #GstVaapiEncoder
+ *
+ * Macro that evaluates to the required set of VA packed headers that
+ * need to be submitted along with the corresponding param buffers.
+ * This is an internal macro that does not do any run-time type check.
+ */
+#undef  GST_VAAPI_ENCODER_PACKED_HEADERS
+#define GST_VAAPI_ENCODER_PACKED_HEADERS(encoder) \
+    GST_VAAPI_ENCODER_CAST(encoder)->packed_headers
+
+/**
  * GST_VAAPI_ENCODER_DISPLAY:
  * @encoder: a #GstVaapiEncoder
  *
@@ -191,6 +203,7 @@ struct _GstVaapiEncoder
   GstVaapiContext *context;
   GstVaapiContextInfo context_info;
   GstVaapiEncoderTune tune;
+  guint packed_headers;
 
   VADisplay va_display;
   VAContextID va_context;

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