mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-05 05:52:37 +00:00
Add gst_vaapi_{get,put}_image() API.
This commit is contained in:
parent
541d740ea3
commit
d69e59ffee
4 changed files with 83 additions and 0 deletions
|
@ -319,6 +319,19 @@ gst_vaapi_image_get_height(GstVaapiImage *image)
|
||||||
return image->priv->height;
|
return image->priv->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_vaapi_image_get_size(GstVaapiImage *image, guint *pwidth, guint *pheight)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), 0);
|
||||||
|
g_return_val_if_fail(image->priv->is_constructed, FALSE);
|
||||||
|
|
||||||
|
if (pwidth)
|
||||||
|
*pwidth = image->priv->width;
|
||||||
|
|
||||||
|
if (pheight)
|
||||||
|
*pheight = image->priv->height;
|
||||||
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gst_vaapi_image_get_format(GstVaapiImage *image)
|
gst_vaapi_image_get_format(GstVaapiImage *image)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,6 +90,9 @@ gst_vaapi_image_get_width(GstVaapiImage *image);
|
||||||
guint
|
guint
|
||||||
gst_vaapi_image_get_height(GstVaapiImage *image);
|
gst_vaapi_image_get_height(GstVaapiImage *image);
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_vaapi_image_get_size(GstVaapiImage *image, guint *pwidth, guint *pheight);
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gst_vaapi_image_get_format(GstVaapiImage *image);
|
gst_vaapi_image_get_format(GstVaapiImage *image);
|
||||||
|
|
||||||
|
|
|
@ -336,3 +336,63 @@ gst_vaapi_surface_get_size(
|
||||||
*pheight = gst_vaapi_surface_get_height(surface);
|
*pheight = gst_vaapi_surface_get_height(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image)
|
||||||
|
{
|
||||||
|
VAImageID image_id;
|
||||||
|
VAStatus status;
|
||||||
|
guint width, height;
|
||||||
|
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), FALSE);
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), FALSE);
|
||||||
|
|
||||||
|
gst_vaapi_image_get_size(image, &width, &height);
|
||||||
|
if (width != surface->priv->width || height != surface->priv->height)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
image_id = gst_vaapi_image_get_id(image);
|
||||||
|
if (image_id == VA_INVALID_ID)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
status = vaGetImage(
|
||||||
|
gst_vaapi_display_get_display(surface->priv->display),
|
||||||
|
surface->priv->surface_id,
|
||||||
|
0, 0, width, height,
|
||||||
|
image_id
|
||||||
|
);
|
||||||
|
if (!vaapi_check_status(status, "vaGetImage()"))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image)
|
||||||
|
{
|
||||||
|
VAImageID image_id;
|
||||||
|
VAStatus status;
|
||||||
|
guint width, height;
|
||||||
|
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), FALSE);
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), FALSE);
|
||||||
|
|
||||||
|
gst_vaapi_image_get_size(image, &width, &height);
|
||||||
|
if (width != surface->priv->width || height != surface->priv->height)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
image_id = gst_vaapi_image_get_id(image);
|
||||||
|
if (image_id == VA_INVALID_ID)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
status = vaPutImage(
|
||||||
|
gst_vaapi_display_get_display(surface->priv->display),
|
||||||
|
surface->priv->surface_id,
|
||||||
|
image_id,
|
||||||
|
0, 0, width, height,
|
||||||
|
0, 0, width, height
|
||||||
|
);
|
||||||
|
if (!vaapi_check_status(status, "vaPutImage()"))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#ifndef GST_VAAPI_SURFACE_H
|
#ifndef GST_VAAPI_SURFACE_H
|
||||||
#define GST_VAAPI_SURFACE_H
|
#define GST_VAAPI_SURFACE_H
|
||||||
|
|
||||||
|
#include <gst/vaapi/gstvaapiimage.h>
|
||||||
#include <gst/vaapi/gstvaapidisplay.h>
|
#include <gst/vaapi/gstvaapidisplay.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -106,6 +107,12 @@ gst_vaapi_surface_get_size(
|
||||||
guint *pheight
|
guint *pheight
|
||||||
);
|
);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_SURFACE_H */
|
#endif /* GST_VAAPI_SURFACE_H */
|
||||||
|
|
Loading…
Reference in a new issue