encoder: add infrastructure for per-slice handling of packed headers.
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>
Thu, 5 Jun 2014 12:30:38 +0000 (15:30 +0300)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 17 Jun 2014 14:03:33 +0000 (16:03 +0200)
The packed slice header and packed raw data need to be paired with
the submission of VAEncSliceHeaderParameterBuffer. So handle them
on a per-slice basis insted of a per-picture basis.

[removed useless initializer]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/vaapi/gstvaapiencoder_objects.c
gst-libs/gst/vaapi/gstvaapiencoder_objects.h

index a9ed0fa..f022264 100644 (file)
@@ -156,6 +156,11 @@ GST_VAAPI_CODEC_DEFINE_TYPE (GstVaapiEncSlice, gst_vaapi_enc_slice);
 void
 gst_vaapi_enc_slice_destroy (GstVaapiEncSlice * slice)
 {
+  if (slice->packed_headers) {
+    g_ptr_array_unref (slice->packed_headers);
+    slice->packed_headers = NULL;
+  }
+
   vaapi_destroy_buffer (GET_VA_DISPLAY (slice), &slice->param_id);
   slice->param = NULL;
 }
@@ -173,6 +178,12 @@ gst_vaapi_enc_slice_create (GstVaapiEncSlice * slice,
       args->param_size, args->param, &slice->param_id, &slice->param);
   if (!success)
     return FALSE;
+
+  slice->packed_headers = g_ptr_array_new_with_free_func ((GDestroyNotify)
+      gst_vaapi_mini_object_unref);
+  if (!slice->packed_headers)
+    return FALSE;
+
   return TRUE;
 }
 
@@ -381,6 +392,16 @@ gst_vaapi_enc_picture_add_slice (GstVaapiEncPicture * picture,
   g_ptr_array_add (picture->slices, gst_vaapi_codec_object_ref (slice));
 }
 
+void
+gst_vaapi_enc_slice_add_packed_header (GstVaapiEncSlice * slice,
+    GstVaapiEncPackedHeader * header)
+{
+  g_return_if_fail (slice != NULL);
+  g_return_if_fail (header != NULL);
+
+  g_ptr_array_add (slice->packed_headers, gst_vaapi_codec_object_ref (header));
+}
+
 static gboolean
 do_encode (VADisplay dpy, VAContextID ctx, VABufferID * buf_id, void **buf_ptr)
 {
@@ -449,6 +470,17 @@ gst_vaapi_enc_picture_encode (GstVaapiEncPicture * picture)
   /* Submit Slice parameters */
   for (i = 0; i < picture->slices->len; i++) {
     GstVaapiEncSlice *const slice = g_ptr_array_index (picture->slices, i);
+    guint j;
+
+    /* Submit packed_slice_header and packed_raw_data */
+    for (j = 0; j < slice->packed_headers->len; j++) {
+      GstVaapiEncPackedHeader *const header =
+          g_ptr_array_index (slice->packed_headers, j);
+      if (!do_encode (va_display, va_context,
+              &header->param_id, &header->param) ||
+          !do_encode (va_display, va_context, &header->data_id, &header->data))
+        return FALSE;
+    }
     if (!do_encode (va_display, va_context, &slice->param_id, &slice->param))
       return FALSE;
   }
index dca1cda..aa1ccbf 100644 (file)
@@ -118,6 +118,7 @@ struct _GstVaapiEncSlice
   /*< public >*/
   VABufferID param_id;
   gpointer param;
+  GPtrArray *packed_headers;
 };
 
 G_GNUC_INTERNAL
@@ -231,6 +232,11 @@ gst_vaapi_enc_picture_add_slice (GstVaapiEncPicture * picture,
     GstVaapiEncSlice * slice);
 
 G_GNUC_INTERNAL
+void
+gst_vaapi_enc_slice_add_packed_header (GstVaapiEncSlice *slice,
+    GstVaapiEncPackedHeader * header);
+
+G_GNUC_INTERNAL
 gboolean
 gst_vaapi_enc_picture_encode (GstVaapiEncPicture * picture);