diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2012-01-05 10:29:48 +0100 |
---|---|---|
committer | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2012-01-05 10:29:48 +0100 |
commit | 7f8eaa6cbfec856c2364835b9fa3c669aebd7a9d (patch) | |
tree | bf6aa90f8b55679dc19471c35c6147cdeea2ab82 | |
parent | 13f00c67e61a4c72d1566fa88b7ba7ef32fe09cb (diff) |
image: add helpers to extract pixels to user buffers.
-rw-r--r-- | docs/reference/libs/libs-sections.txt | 2 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiimage.c | 84 | ||||
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiimage.h | 14 |
3 files changed, 100 insertions, 0 deletions
diff --git a/docs/reference/libs/libs-sections.txt b/docs/reference/libs/libs-sections.txt index 751ba641..cfd3189c 100644 --- a/docs/reference/libs/libs-sections.txt +++ b/docs/reference/libs/libs-sections.txt @@ -307,6 +307,8 @@ gst_vaapi_image_get_plane_count gst_vaapi_image_get_plane gst_vaapi_image_get_pitch gst_vaapi_image_get_data_size +gst_vaapi_image_get_buffer +gst_vaapi_image_get_raw gst_vaapi_image_update_from_buffer <SUBSECTION Standard> GST_VAAPI_IMAGE diff --git a/gst-libs/gst/vaapi/gstvaapiimage.c b/gst-libs/gst/vaapi/gstvaapiimage.c index f0aa730d..49a19e5b 100644 --- a/gst-libs/gst/vaapi/gstvaapiimage.c +++ b/gst-libs/gst/vaapi/gstvaapiimage.c @@ -1138,6 +1138,90 @@ copy_image( } /** + * gst_vaapi_image_get_buffer: + * @image: a #GstVaapiImage + * @buffer: a #GstBuffer + * @rect: a #GstVaapiRectangle expressing a region, or %NULL for the + * whole image + * + * Transfers pixels data contained in the @image into the #GstBuffer. + * Both image structures shall have the same format. + * + * Return value: %TRUE on success + */ +gboolean +gst_vaapi_image_get_buffer( + GstVaapiImage *image, + GstBuffer *buffer, + GstVaapiRectangle *rect +) +{ + GstVaapiImagePrivate *priv; + GstVaapiImageRaw dst_image, src_image; + gboolean success; + + g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), FALSE); + g_return_val_if_fail(image->priv->is_constructed, FALSE); + g_return_val_if_fail(GST_IS_BUFFER(buffer), FALSE); + + priv = image->priv; + + if (!init_image_from_buffer(&dst_image, buffer)) + return FALSE; + if (dst_image.format != priv->format) + return FALSE; + if (dst_image.width != priv->width || dst_image.height != priv->height) + return FALSE; + + if (!_gst_vaapi_image_map(image, &src_image)) + return FALSE; + + success = copy_image(&dst_image, &src_image, rect); + + if (!_gst_vaapi_image_unmap(image)) + return FALSE; + + return success; +} + +/** + * gst_vaapi_image_get_raw: + * @image: a #GstVaapiImage + * @dst_image: a #GstVaapiImageRaw + * @buffer: a #GstBuffer + * @rect: a #GstVaapiRectangle expressing a region, or %NULL for the + * whole image + * + * Transfers pixels data contained in the @image into the #GstVaapiImageRaw. + * Both image structures shall have the same format. + * + * Return value: %TRUE on success + */ +gboolean +gst_vaapi_image_get_raw( + GstVaapiImage *image, + GstVaapiImageRaw *dst_image, + GstVaapiRectangle *rect +) +{ + GstVaapiImageRaw src_image; + gboolean success; + + g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), FALSE); + g_return_val_if_fail(image->priv->is_constructed, FALSE); + + if (!_gst_vaapi_image_map(image, &src_image)) + return FALSE; + + success = copy_image(dst_image, &src_image, rect); + + if (!_gst_vaapi_image_unmap(image)) + return FALSE; + + return success; +} + +/** * gst_vaapi_image_update_from_buffer: * @image: a #GstVaapiImage * @buffer: a #GstBuffer diff --git a/gst-libs/gst/vaapi/gstvaapiimage.h b/gst-libs/gst/vaapi/gstvaapiimage.h index 5b6557f3..a2b5ba2c 100644 --- a/gst-libs/gst/vaapi/gstvaapiimage.h +++ b/gst-libs/gst/vaapi/gstvaapiimage.h @@ -176,6 +176,20 @@ guint gst_vaapi_image_get_data_size(GstVaapiImage *image); gboolean +gst_vaapi_image_get_buffer( + GstVaapiImage *image, + GstBuffer *buffer, + GstVaapiRectangle *rect +); + +gboolean +gst_vaapi_image_get_raw( + GstVaapiImage *image, + GstVaapiImageRaw *dst_image, + GstVaapiRectangle *rect +); + +gboolean gst_vaapi_image_update_from_buffer( GstVaapiImage *image, GstBuffer *buffer, |