mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
libs: remove GstVaapiPixmap
GstVaapiPixmap is an abstract base class which only implementation were GstVaapiPixmapX11. This class were used for a special type of rendering in the tests apps, utterly unrelated in GStreamer. Since gstreamer-vaapi is no longer a general-user wrapper for VA-API we should remove this unused API. This removal drops libxrender dependency.
This commit is contained in:
parent
f303b4a30f
commit
bb38055745
19 changed files with 10 additions and 1132 deletions
|
@ -38,10 +38,6 @@
|
|||
# include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_XRENDER
|
||||
# include <X11/extensions/Xrender.h>
|
||||
#endif
|
||||
|
||||
#define DEBUG_VAAPI_DISPLAY 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
|
@ -114,10 +110,6 @@ check_extensions (GstVaapiDisplayX11 * display)
|
|||
priv->use_xrandr = XRRQueryExtension (priv->x11_display,
|
||||
&evt_base, &err_base);
|
||||
#endif
|
||||
#if HAVE_XRENDER
|
||||
priv->has_xrender = XRenderQueryExtension (priv->x11_display,
|
||||
&evt_base, &err_base);
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -132,7 +124,6 @@ gst_vaapi_display_x11_bind_display (GstVaapiDisplay * base_display,
|
|||
priv->use_foreign_display = TRUE;
|
||||
|
||||
check_extensions (display);
|
||||
|
||||
if (!set_display_name (display, XDisplayString (priv->x11_display)))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
|
|
@ -66,17 +66,6 @@ typedef struct _GstVaapiDisplayX11Class GstVaapiDisplayX11Class;
|
|||
#define GST_VAAPI_DISPLAY_XSCREEN(display) \
|
||||
GST_VAAPI_DISPLAY_X11_PRIVATE(display)->x11_screen
|
||||
|
||||
/**
|
||||
* GST_VAAPI_DISPLAY_HAS_XRENDER:
|
||||
* @display: a #GstVaapiDisplay
|
||||
*
|
||||
* Macro that evaluates to the existence of the XRender extension on
|
||||
* @display server.
|
||||
*/
|
||||
#undef GST_VAAPI_DISPLAY_HAS_XRENDER
|
||||
#define GST_VAAPI_DISPLAY_HAS_XRENDER(display) \
|
||||
(GST_VAAPI_DISPLAY_X11_PRIVATE(display)->has_xrender)
|
||||
|
||||
struct _GstVaapiDisplayX11Private
|
||||
{
|
||||
gchar *display_name;
|
||||
|
@ -85,7 +74,6 @@ struct _GstVaapiDisplayX11Private
|
|||
GArray *pixmap_formats;
|
||||
guint use_foreign_display:1; // Foreign native_display?
|
||||
guint use_xrandr:1;
|
||||
guint has_xrender:1; // Has XRender extension?
|
||||
guint synchronous:1;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,263 +0,0 @@
|
|||
/*
|
||||
* gstvaapipixmap.c - Pixmap abstraction
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation
|
||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:gstvaapipixmap
|
||||
* @short_description: Pixmap abstraction
|
||||
*/
|
||||
|
||||
#include "sysdeps.h"
|
||||
#include "gstvaapipixmap.h"
|
||||
#include "gstvaapipixmap_priv.h"
|
||||
#include "gstvaapisurface_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
static inline GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_new_internal (const GstVaapiPixmapClass * pixmap_class,
|
||||
GstVaapiDisplay * display)
|
||||
{
|
||||
g_assert (pixmap_class->create != NULL);
|
||||
g_assert (pixmap_class->render != NULL);
|
||||
|
||||
return gst_vaapi_object_new (GST_VAAPI_OBJECT_CLASS (pixmap_class), display);
|
||||
}
|
||||
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_new (const GstVaapiPixmapClass * pixmap_class,
|
||||
GstVaapiDisplay * display, GstVideoFormat format, guint width, guint height)
|
||||
{
|
||||
GstVaapiPixmap *pixmap;
|
||||
|
||||
g_return_val_if_fail (format != GST_VIDEO_FORMAT_UNKNOWN &&
|
||||
format != GST_VIDEO_FORMAT_ENCODED, NULL);
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
|
||||
pixmap = gst_vaapi_pixmap_new_internal (pixmap_class, display);
|
||||
if (!pixmap)
|
||||
return NULL;
|
||||
|
||||
pixmap->format = format;
|
||||
pixmap->width = width;
|
||||
pixmap->height = height;
|
||||
if (!pixmap_class->create (pixmap))
|
||||
goto error;
|
||||
return pixmap;
|
||||
|
||||
/* ERRORS */
|
||||
error:
|
||||
{
|
||||
gst_vaapi_pixmap_unref (pixmap);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_new_from_native (const GstVaapiPixmapClass * pixmap_class,
|
||||
GstVaapiDisplay * display, gpointer native_pixmap)
|
||||
{
|
||||
GstVaapiPixmap *pixmap;
|
||||
|
||||
pixmap = gst_vaapi_pixmap_new_internal (pixmap_class, display);
|
||||
if (!pixmap)
|
||||
return NULL;
|
||||
|
||||
GST_VAAPI_OBJECT_ID (pixmap) = GPOINTER_TO_SIZE (native_pixmap);
|
||||
pixmap->use_foreign_pixmap = TRUE;
|
||||
if (!pixmap_class->create (pixmap))
|
||||
goto error;
|
||||
return pixmap;
|
||||
|
||||
/* ERRORS */
|
||||
error:
|
||||
{
|
||||
gst_vaapi_pixmap_unref (pixmap);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_ref:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Atomically increases the reference count of the given @pixmap by one.
|
||||
*
|
||||
* Returns: The same @pixmap argument
|
||||
*/
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_ref (GstVaapiPixmap * pixmap)
|
||||
{
|
||||
return gst_vaapi_object_ref (GST_VAAPI_OBJECT (pixmap));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_unref:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Atomically decreases the reference count of the @pixmap by one. If
|
||||
* the reference count reaches zero, the pixmap will be free'd.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_pixmap_unref (GstVaapiPixmap * pixmap)
|
||||
{
|
||||
gst_vaapi_object_unref (GST_VAAPI_OBJECT (pixmap));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_replace:
|
||||
* @old_pixmap_ptr: a pointer to a #GstVaapiPixmap
|
||||
* @new_pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Atomically replaces the pixmap pixmap held in @old_pixmap_ptr with
|
||||
* @new_pixmap. This means that @old_pixmap_ptr shall reference a
|
||||
* valid pixmap. However, @new_pixmap can be NULL.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_pixmap_replace (GstVaapiPixmap ** old_pixmap_ptr,
|
||||
GstVaapiPixmap * new_pixmap)
|
||||
{
|
||||
gst_vaapi_object_replace ((GstVaapiObject **) (old_pixmap_ptr),
|
||||
GST_VAAPI_OBJECT (new_pixmap));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_get_display:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Returns the #GstVaapiDisplay this @pixmap is bound to.
|
||||
*
|
||||
* Return value: the parent #GstVaapiDisplay object
|
||||
*/
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_pixmap_get_display (GstVaapiPixmap * pixmap)
|
||||
{
|
||||
g_return_val_if_fail (pixmap != NULL, NULL);
|
||||
|
||||
return GST_VAAPI_OBJECT_DISPLAY (pixmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_get_format:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Retrieves the format of a #GstVaapiPixmap.
|
||||
*
|
||||
* Return value: the format of the @pixmap
|
||||
*/
|
||||
GstVideoFormat
|
||||
gst_vaapi_pixmap_get_format (GstVaapiPixmap * pixmap)
|
||||
{
|
||||
g_return_val_if_fail (pixmap != NULL, GST_VIDEO_FORMAT_UNKNOWN);
|
||||
|
||||
return GST_VAAPI_PIXMAP_FORMAT (pixmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_get_width:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Retrieves the width of a #GstVaapiPixmap.
|
||||
*
|
||||
* Return value: the width of the @pixmap, in pixels
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_pixmap_get_width (GstVaapiPixmap * pixmap)
|
||||
{
|
||||
g_return_val_if_fail (pixmap != NULL, 0);
|
||||
|
||||
return GST_VAAPI_PIXMAP_WIDTH (pixmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_get_height:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Retrieves the height of a #GstVaapiPixmap
|
||||
*
|
||||
* Return value: the height of the @pixmap, in pixels
|
||||
*/
|
||||
guint
|
||||
gst_vaapi_pixmap_get_height (GstVaapiPixmap * pixmap)
|
||||
{
|
||||
g_return_val_if_fail (pixmap != NULL, 0);
|
||||
|
||||
return GST_VAAPI_PIXMAP_HEIGHT (pixmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_get_size:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
* @width: return location for the width, or %NULL
|
||||
* @height: return location for the height, or %NULL
|
||||
*
|
||||
* Retrieves the dimensions of a #GstVaapiPixmap.
|
||||
*/
|
||||
void
|
||||
gst_vaapi_pixmap_get_size (GstVaapiPixmap * pixmap, guint * width,
|
||||
guint * height)
|
||||
{
|
||||
g_return_if_fail (pixmap != NULL);
|
||||
|
||||
if (width)
|
||||
*width = GST_VAAPI_PIXMAP_WIDTH (pixmap);
|
||||
|
||||
if (height)
|
||||
*height = GST_VAAPI_PIXMAP_HEIGHT (pixmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_put_surface:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
* @surface: a #GstVaapiSurface
|
||||
* @crop_rect: the video cropping rectangle, or %NULL if the entire
|
||||
* surface is to be used.
|
||||
* @flags: postprocessing flags. See #GstVaapiSurfaceRenderFlags
|
||||
*
|
||||
* Renders the whole @surface, or a cropped region defined with
|
||||
* @crop_rect, into the @pixmap, while scaling to fit the target
|
||||
* pixmap. The @flags specify how de-interlacing (if needed), color
|
||||
* space conversion, scaling and other postprocessing transformations
|
||||
* are performed.
|
||||
*
|
||||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_pixmap_put_surface (GstVaapiPixmap * pixmap,
|
||||
GstVaapiSurface * surface, const GstVaapiRectangle * crop_rect, guint flags)
|
||||
{
|
||||
GstVaapiRectangle src_rect;
|
||||
|
||||
g_return_val_if_fail (pixmap != NULL, FALSE);
|
||||
g_return_val_if_fail (surface != NULL, FALSE);
|
||||
|
||||
if (!crop_rect) {
|
||||
src_rect.x = 0;
|
||||
src_rect.y = 0;
|
||||
src_rect.width = GST_VAAPI_SURFACE_WIDTH (surface);
|
||||
src_rect.height = GST_VAAPI_SURFACE_HEIGHT (surface);
|
||||
crop_rect = &src_rect;
|
||||
}
|
||||
return GST_VAAPI_PIXMAP_GET_CLASS (pixmap)->render (pixmap, surface,
|
||||
crop_rect, flags);
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* gstvaapipixmap.h - Pixmap abstraction
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation
|
||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_PIXMAP_H
|
||||
#define GST_VAAPI_PIXMAP_H
|
||||
|
||||
#include <gst/vaapi/gstvaapitypes.h>
|
||||
#include <gst/vaapi/gstvaapiobject.h>
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include <gst/vaapi/gstvaapisurface.h>
|
||||
#include <gst/vaapi/video-format.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_PIXMAP(obj) \
|
||||
((GstVaapiPixmap *)(obj))
|
||||
|
||||
typedef struct _GstVaapiPixmap GstVaapiPixmap;
|
||||
typedef struct _GstVaapiPixmapClass GstVaapiPixmapClass;
|
||||
|
||||
/**
|
||||
* GST_VAAPI_PIXMAP_FORMAT:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Macro that evaluates to the format in pixels of the @pixmap.
|
||||
*/
|
||||
#define GST_VAAPI_PIXMAP_FORMAT(pixmap) \
|
||||
gst_vaapi_pixmap_get_format(GST_VAAPI_PIXMAP(pixmap))
|
||||
|
||||
/**
|
||||
* GST_VAAPI_PIXMAP_WIDTH:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Macro that evaluates to the width in pixels of the @pixmap.
|
||||
*/
|
||||
#define GST_VAAPI_PIXMAP_WIDTH(pixmap) \
|
||||
gst_vaapi_pixmap_get_width(GST_VAAPI_PIXMAP(pixmap))
|
||||
|
||||
/**
|
||||
* GST_VAAPI_PIXMAP_HEIGHT:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Macro that evaluates to the height in pixels of the @pixmap.
|
||||
*/
|
||||
#define GST_VAAPI_PIXMAP_HEIGHT(pixmap) \
|
||||
gst_vaapi_pixmap_get_height(GST_VAAPI_PIXMAP(pixmap))
|
||||
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_ref(GstVaapiPixmap *pixmap);
|
||||
|
||||
void
|
||||
gst_vaapi_pixmap_unref(GstVaapiPixmap *pixmap);
|
||||
|
||||
void
|
||||
gst_vaapi_pixmap_replace(GstVaapiPixmap **old_pixmap_ptr,
|
||||
GstVaapiPixmap *new_pixmap);
|
||||
|
||||
GstVaapiDisplay *
|
||||
gst_vaapi_pixmap_get_display(GstVaapiPixmap *pixmap);
|
||||
|
||||
GstVideoFormat
|
||||
gst_vaapi_pixmap_get_format(GstVaapiPixmap *pixmap);
|
||||
|
||||
guint
|
||||
gst_vaapi_pixmap_get_width(GstVaapiPixmap *pixmap);
|
||||
|
||||
guint
|
||||
gst_vaapi_pixmap_get_height(GstVaapiPixmap *pixmap);
|
||||
|
||||
void
|
||||
gst_vaapi_pixmap_get_size(GstVaapiPixmap *pixmap, guint *width, guint *height);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_pixmap_put_surface(GstVaapiPixmap *pixmap, GstVaapiSurface *surface,
|
||||
const GstVaapiRectangle *crop_rect, guint flags);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_PIXMAP_H */
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* gstvaapipixmap_priv.h - Pixmap abstraction (private definitions)
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation
|
||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_PIXMAP_PRIV_H
|
||||
#define GST_VAAPI_PIXMAP_PRIV_H
|
||||
|
||||
#include "gstvaapiobject_priv.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_PIXMAP_CLASS(klass) \
|
||||
((GstVaapiPixmapClass *)(klass))
|
||||
|
||||
#define GST_VAAPI_PIXMAP_GET_CLASS(obj) \
|
||||
GST_VAAPI_PIXMAP_CLASS(GST_VAAPI_OBJECT_GET_CLASS(obj))
|
||||
|
||||
/**
|
||||
* GST_VAAPI_PIXMAP_FORMAT:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Macro that evaluates to the format in pixels of the @pixmap.
|
||||
*/
|
||||
#undef GST_VAAPI_PIXMAP_FORMAT
|
||||
#define GST_VAAPI_PIXMAP_FORMAT(pixmap) \
|
||||
(GST_VAAPI_PIXMAP(pixmap)->format)
|
||||
|
||||
/**
|
||||
* GST_VAAPI_PIXMAP_WIDTH:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Macro that evaluates to the width in pixels of the @pixmap.
|
||||
*/
|
||||
#undef GST_VAAPI_PIXMAP_WIDTH
|
||||
#define GST_VAAPI_PIXMAP_WIDTH(pixmap) \
|
||||
(GST_VAAPI_PIXMAP(pixmap)->width)
|
||||
|
||||
/**
|
||||
* GST_VAAPI_PIXMAP_HEIGHT:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Macro that evaluates to the height in pixels of the @pixmap.
|
||||
*/
|
||||
#undef GST_VAAPI_PIXMAP_HEIGHT
|
||||
#define GST_VAAPI_PIXMAP_HEIGHT(pixmap) \
|
||||
(GST_VAAPI_PIXMAP(pixmap)->height)
|
||||
|
||||
/* GstVaapiPixmapClass hooks */
|
||||
typedef gboolean (*GstVaapiPixmapCreateFunc) (GstVaapiPixmap *pixmap);
|
||||
typedef gboolean (*GstVaapiPixmapRenderFunc) (GstVaapiPixmap *pixmap,
|
||||
GstVaapiSurface *surface, const GstVaapiRectangle *crop_rect, guint flags);
|
||||
|
||||
/**
|
||||
* GstVaapiPixmap:
|
||||
*
|
||||
* Base class for system-dependent pixmaps.
|
||||
*/
|
||||
struct _GstVaapiPixmap {
|
||||
/*< private >*/
|
||||
GstVaapiObject parent_instance;
|
||||
|
||||
/*< protected >*/
|
||||
GstVideoFormat format;
|
||||
guint width;
|
||||
guint height;
|
||||
guint use_foreign_pixmap : 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstVaapiPixmapClass:
|
||||
* @create: virtual function to create a pixmap with width and height
|
||||
* @render: virtual function to render a #GstVaapiSurface into a pixmap
|
||||
*
|
||||
* Base class for system-dependent pixmaps.
|
||||
*/
|
||||
struct _GstVaapiPixmapClass {
|
||||
/*< private >*/
|
||||
GstVaapiObjectClass parent_class;
|
||||
|
||||
/*< protected >*/
|
||||
GstVaapiPixmapCreateFunc create;
|
||||
GstVaapiPixmapRenderFunc render;
|
||||
};
|
||||
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_new(const GstVaapiPixmapClass *pixmap_class,
|
||||
GstVaapiDisplay *display, GstVideoFormat format, guint width, guint height);
|
||||
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_new_from_native(const GstVaapiPixmapClass *pixmap_class,
|
||||
GstVaapiDisplay *display, gpointer native_pixmap);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_PIXMAP_PRIV_H */
|
|
@ -1,251 +0,0 @@
|
|||
/*
|
||||
* gstvaapipixmap_x11.c - X11 pixmap abstraction
|
||||
*
|
||||
* Copyright (C) 2013-2014 Intel Corporation
|
||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:gstvaapipixmap_x11
|
||||
* @short_description: X11 pixmap abstraction
|
||||
*/
|
||||
|
||||
#include "sysdeps.h"
|
||||
#include "gstvaapicompat.h"
|
||||
#include "gstvaapipixmap_x11.h"
|
||||
#include "gstvaapipixmap_priv.h"
|
||||
#include "gstvaapidisplay_x11.h"
|
||||
#include "gstvaapidisplay_x11_priv.h"
|
||||
#include "gstvaapiutils.h"
|
||||
#include "gstvaapiutils_x11.h"
|
||||
#include "gstvaapisurface_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
typedef struct _GstVaapiPixmapX11Class GstVaapiPixmapX11Class;
|
||||
|
||||
struct _GstVaapiPixmapX11
|
||||
{
|
||||
GstVaapiPixmap parent_instance;
|
||||
};
|
||||
|
||||
struct _GstVaapiPixmapX11Class
|
||||
{
|
||||
GstVaapiPixmapClass parent_class;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_pixmap_x11_create_from_xid (GstVaapiPixmap * pixmap, Pixmap xid)
|
||||
{
|
||||
guint depth;
|
||||
gboolean success;
|
||||
|
||||
if (!xid)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
|
||||
success = x11_get_geometry (GST_VAAPI_OBJECT_NATIVE_DISPLAY (pixmap), xid,
|
||||
NULL, NULL, &pixmap->width, &pixmap->height, &depth);
|
||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
||||
pixmap->format =
|
||||
gst_vaapi_display_x11_get_pixmap_format (GST_VAAPI_OBJECT_DISPLAY_X11
|
||||
(pixmap), depth);
|
||||
if (pixmap->format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_pixmap_x11_create (GstVaapiPixmap * pixmap)
|
||||
{
|
||||
GstVaapiDisplayX11 *const display =
|
||||
GST_VAAPI_DISPLAY_X11 (GST_VAAPI_OBJECT_DISPLAY (pixmap));
|
||||
Display *const dpy = GST_VAAPI_DISPLAY_NATIVE (display);
|
||||
Window rootwin;
|
||||
Pixmap xid;
|
||||
guint depth;
|
||||
|
||||
if (pixmap->use_foreign_pixmap)
|
||||
return gst_vaapi_pixmap_x11_create_from_xid (pixmap,
|
||||
GST_VAAPI_OBJECT_ID (pixmap));
|
||||
|
||||
depth = gst_vaapi_display_x11_get_pixmap_depth (display, pixmap->format);
|
||||
if (!depth)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
|
||||
rootwin = RootWindow (dpy, DefaultScreen (dpy));
|
||||
xid = XCreatePixmap (dpy, rootwin, pixmap->width, pixmap->height, depth);
|
||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
|
||||
|
||||
GST_DEBUG ("xid %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (xid));
|
||||
GST_VAAPI_OBJECT_ID (pixmap) = xid;
|
||||
return xid != None;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_pixmap_x11_destroy (GstVaapiPixmap * pixmap)
|
||||
{
|
||||
const Pixmap xid = GST_VAAPI_OBJECT_ID (pixmap);
|
||||
|
||||
if (xid) {
|
||||
if (!pixmap->use_foreign_pixmap) {
|
||||
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
|
||||
XFreePixmap (GST_VAAPI_OBJECT_NATIVE_DISPLAY (pixmap), xid);
|
||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
|
||||
}
|
||||
GST_VAAPI_OBJECT_ID (pixmap) = None;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_pixmap_x11_render (GstVaapiPixmap * pixmap, GstVaapiSurface * surface,
|
||||
const GstVaapiRectangle * crop_rect, guint flags)
|
||||
{
|
||||
VASurfaceID surface_id;
|
||||
VAStatus status;
|
||||
|
||||
surface_id = GST_VAAPI_SURFACE_ID (surface);
|
||||
if (surface_id == VA_INVALID_ID)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_OBJECT_LOCK_DISPLAY (pixmap);
|
||||
status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (pixmap),
|
||||
surface_id,
|
||||
GST_VAAPI_OBJECT_ID (pixmap),
|
||||
crop_rect->x, crop_rect->y,
|
||||
crop_rect->width, crop_rect->height,
|
||||
0, 0,
|
||||
GST_VAAPI_PIXMAP_WIDTH (pixmap),
|
||||
GST_VAAPI_PIXMAP_HEIGHT (pixmap),
|
||||
NULL, 0, from_GstVaapiSurfaceRenderFlags (flags)
|
||||
);
|
||||
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (pixmap);
|
||||
if (!vaapi_check_status (status, "vaPutSurface() [pixmap]"))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_pixmap_x11_class_init (GstVaapiPixmapX11Class * klass)
|
||||
{
|
||||
GstVaapiObjectClass *const object_class = GST_VAAPI_OBJECT_CLASS (klass);
|
||||
GstVaapiPixmapClass *const pixmap_class = GST_VAAPI_PIXMAP_CLASS (klass);
|
||||
|
||||
object_class->finalize = (GstVaapiObjectFinalizeFunc)
|
||||
gst_vaapi_pixmap_x11_destroy;
|
||||
|
||||
pixmap_class->create = gst_vaapi_pixmap_x11_create;
|
||||
pixmap_class->render = gst_vaapi_pixmap_x11_render;
|
||||
}
|
||||
|
||||
#define gst_vaapi_pixmap_x11_finalize \
|
||||
gst_vaapi_pixmap_x11_destroy
|
||||
|
||||
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiPixmapX11,
|
||||
gst_vaapi_pixmap_x11, gst_vaapi_pixmap_x11_class_init (&g_class))
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_x11_new:
|
||||
* @display: a #GstVaapiDisplay
|
||||
* @format: the requested pixmap format
|
||||
* @width: the requested pixmap width, in pixels
|
||||
* @height: the requested windo height, in pixels
|
||||
*
|
||||
* Creates a pixmap with the specified @format, @width and
|
||||
* @height. The pixmap will be attached to the @display.
|
||||
*
|
||||
* Return value: the newly allocated #GstVaapiPixmap object
|
||||
*/
|
||||
GstVaapiPixmap *gst_vaapi_pixmap_x11_new (GstVaapiDisplay * display,
|
||||
GstVideoFormat format, guint width, guint height)
|
||||
{
|
||||
GST_DEBUG ("new pixmap, format %s, size %ux%u",
|
||||
gst_vaapi_video_format_to_string (format), width, height);
|
||||
|
||||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
|
||||
|
||||
return
|
||||
gst_vaapi_pixmap_new (GST_VAAPI_PIXMAP_CLASS (gst_vaapi_pixmap_x11_class
|
||||
()), display, format, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_x11_new_with_xid:
|
||||
* @display: a #GstVaapiDisplay
|
||||
* @xid: an X11 #Pixmap id
|
||||
*
|
||||
* Creates a #GstVaapiPixmap using the X11 Pixmap @xid. The caller
|
||||
* still owns the pixmap and must call XFreePixmap() when all
|
||||
* #GstVaapiPixmap references are released. Doing so too early can
|
||||
* yield undefined behaviour.
|
||||
*
|
||||
* Return value: the newly allocated #GstVaapiPixmap object
|
||||
*/
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_x11_new_with_xid (GstVaapiDisplay * display, Pixmap xid)
|
||||
{
|
||||
GST_DEBUG ("new pixmap from xid 0x%08x", (guint) xid);
|
||||
|
||||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
|
||||
g_return_val_if_fail (xid != None, NULL);
|
||||
|
||||
return
|
||||
gst_vaapi_pixmap_new_from_native (GST_VAAPI_PIXMAP_CLASS
|
||||
(gst_vaapi_pixmap_x11_class ()), display, GSIZE_TO_POINTER (xid));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_x11_get_xid:
|
||||
* @pixmap: a #GstVaapiPixmapX11
|
||||
*
|
||||
* Returns the underlying X11 Pixmap that was created by
|
||||
* gst_vaapi_pixmap_x11_new() or that was bound with
|
||||
* gst_vaapi_pixmap_x11_new_with_xid().
|
||||
*
|
||||
* Return value: the underlying X11 Pixmap bound to @pixmap.
|
||||
*/
|
||||
Pixmap
|
||||
gst_vaapi_pixmap_x11_get_xid (GstVaapiPixmapX11 * pixmap)
|
||||
{
|
||||
g_return_val_if_fail (pixmap != NULL, None);
|
||||
|
||||
return GST_VAAPI_OBJECT_ID (pixmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_pixmap_x11_is_foreign_xid:
|
||||
* @pixmap: a #GstVaapiPixmapX11
|
||||
*
|
||||
* Checks whether the @pixmap XID was created by gst_vaapi_pixmap_x11_new()
|
||||
* or was bound with gst_vaapi_pixmap_x11_new_with_xid().
|
||||
*
|
||||
* Return value: %TRUE if the underlying X pixmap is owned by the
|
||||
* caller (foreign pixmap)
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_pixmap_x11_is_foreign_xid (GstVaapiPixmapX11 * pixmap)
|
||||
{
|
||||
g_return_val_if_fail (pixmap != NULL, FALSE);
|
||||
|
||||
return GST_VAAPI_PIXMAP (pixmap)->use_foreign_pixmap;
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* gstvaapipixmap_x11.h - X11 pixmap abstraction
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation
|
||||
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef GST_VAAPI_PIXMAP_X11_H
|
||||
#define GST_VAAPI_PIXMAP_X11_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include <gst/vaapi/gstvaapipixmap.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_VAAPI_PIXMAP_X11(obj) \
|
||||
((GstVaapiPixmapX11 *)(obj))
|
||||
|
||||
/**
|
||||
* GST_VAAPI_PIXMAP_XPIXMAP:
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
*
|
||||
* Macro that evaluates to the underlying X11 #Pixmap of @pixmap
|
||||
*/
|
||||
#define GST_VAAPI_PIXMAP_XPIXMAP(pixmap) \
|
||||
gst_vaapi_pixmap_x11_get_xid(GST_VAAPI_PIXMAP_X11(pixmap))
|
||||
|
||||
typedef struct _GstVaapiPixmapX11 GstVaapiPixmapX11;
|
||||
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_x11_new(GstVaapiDisplay *display, GstVideoFormat format,
|
||||
guint width, guint height);
|
||||
|
||||
GstVaapiPixmap *
|
||||
gst_vaapi_pixmap_x11_new_with_xid(GstVaapiDisplay *display, Pixmap xid);
|
||||
|
||||
Pixmap
|
||||
gst_vaapi_pixmap_x11_get_xid(GstVaapiPixmapX11 *pixmap);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_pixmap_x11_is_foreign_xid(GstVaapiPixmapX11 *pixmap);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_PIXMAP_X11_H */
|
|
@ -602,60 +602,6 @@ gst_vaapi_window_put_surface (GstVaapiWindow * window,
|
|||
return klass->render (window, surface, src_rect, dst_rect, flags);
|
||||
}
|
||||
|
||||
static inline void
|
||||
get_pixmap_rect (GstVaapiPixmap * pixmap, GstVaapiRectangle * rect)
|
||||
{
|
||||
guint width, height;
|
||||
|
||||
gst_vaapi_pixmap_get_size (pixmap, &width, &height);
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->width = width;
|
||||
rect->height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_window_put_pixmap:
|
||||
* @window: a #GstVaapiWindow
|
||||
* @pixmap: a #GstVaapiPixmap
|
||||
* @src_rect: the sub-rectangle of the source pixmap to
|
||||
* extract and process. If %NULL, the entire pixmap will be used.
|
||||
* @dst_rect: the sub-rectangle of the destination
|
||||
* window into which the pixmap is rendered. If %NULL, the entire
|
||||
* window will be used.
|
||||
*
|
||||
* Renders the @pixmap region specified by @src_rect into the @window
|
||||
* region specified by @dst_rect.
|
||||
*
|
||||
* Return value: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
gst_vaapi_window_put_pixmap (GstVaapiWindow * window,
|
||||
GstVaapiPixmap * pixmap,
|
||||
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
|
||||
{
|
||||
const GstVaapiWindowClass *klass;
|
||||
GstVaapiRectangle src_rect_default, dst_rect_default;
|
||||
|
||||
g_return_val_if_fail (GST_VAAPI_IS_WINDOW (window), FALSE);
|
||||
g_return_val_if_fail (pixmap != NULL, FALSE);
|
||||
|
||||
klass = GST_VAAPI_WINDOW_GET_CLASS (window);
|
||||
if (!klass->render_pixmap)
|
||||
return FALSE;
|
||||
|
||||
if (!src_rect) {
|
||||
src_rect = &src_rect_default;
|
||||
get_pixmap_rect (pixmap, &src_rect_default);
|
||||
}
|
||||
|
||||
if (!dst_rect) {
|
||||
dst_rect = &dst_rect_default;
|
||||
get_window_rect (window, &dst_rect_default);
|
||||
}
|
||||
return klass->render_pixmap (window, pixmap, src_rect, dst_rect);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_window_reconfigure:
|
||||
* @window: a #GstVaapiWindow
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <gst/vaapi/gstvaapitypes.h>
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include <gst/vaapi/gstvaapisurface.h>
|
||||
#include <gst/vaapi/gstvaapipixmap.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -91,10 +90,6 @@ gst_vaapi_window_put_surface (GstVaapiWindow * window,
|
|||
GstVaapiSurface * surface, const GstVaapiRectangle * src_rect,
|
||||
const GstVaapiRectangle * dst_rect, guint flags);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_window_put_pixmap (GstVaapiWindow * window, GstVaapiPixmap * pixmap,
|
||||
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect);
|
||||
|
||||
void
|
||||
gst_vaapi_window_reconfigure (GstVaapiWindow * window);
|
||||
|
||||
|
|
|
@ -281,8 +281,11 @@ gst_vaapi_window_egl_finalize (GObject * object)
|
|||
{
|
||||
GstVaapiWindowEGL *const window = GST_VAAPI_WINDOW_EGL (object);
|
||||
|
||||
egl_context_run (window->egl_window->context,
|
||||
(EglContextRunFunc) do_destroy_objects, window);
|
||||
if (window->egl_window) {
|
||||
egl_context_run (window->egl_window->context,
|
||||
(EglContextRunFunc) do_destroy_objects, window);
|
||||
}
|
||||
|
||||
gst_vaapi_window_replace (&window->window, NULL);
|
||||
gst_vaapi_texture_replace (&window->texture, NULL);
|
||||
|
||||
|
@ -505,20 +508,6 @@ gst_vaapi_window_egl_render (GstVaapiWindow * window, GstVaapiSurface * surface,
|
|||
(EglContextRunFunc) do_upload_surface, &args) && args.success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_window_egl_render_pixmap (GstVaapiWindow * window,
|
||||
GstVaapiPixmap * pixmap, const GstVaapiRectangle * src_rect,
|
||||
const GstVaapiRectangle * dst_rect)
|
||||
{
|
||||
const GstVaapiWindowClass *const klass =
|
||||
GST_VAAPI_WINDOW_GET_CLASS (GST_VAAPI_WINDOW_EGL_GET_PROXY (window));
|
||||
|
||||
if (!klass->render_pixmap)
|
||||
return FALSE;
|
||||
return klass->render_pixmap (GST_VAAPI_WINDOW_EGL_GET_PROXY (window), pixmap,
|
||||
src_rect, dst_rect);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_window_egl_class_init (GstVaapiWindowEGLClass * klass)
|
||||
{
|
||||
|
@ -534,7 +523,6 @@ gst_vaapi_window_egl_class_init (GstVaapiWindowEGLClass * klass)
|
|||
window_class->set_fullscreen = gst_vaapi_window_egl_set_fullscreen;
|
||||
window_class->resize = gst_vaapi_window_egl_resize;
|
||||
window_class->render = gst_vaapi_window_egl_render;
|
||||
window_class->render_pixmap = gst_vaapi_window_egl_render_pixmap;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -123,8 +123,6 @@ struct _GstVaapiWindowClass
|
|||
gboolean (*render) (GstVaapiWindow * window, GstVaapiSurface * surface,
|
||||
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect,
|
||||
guint flags);
|
||||
gboolean (*render_pixmap) (GstVaapiWindow * window, GstVaapiPixmap * pixmap,
|
||||
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect);
|
||||
guintptr (*get_visual_id) (GstVaapiWindow * window);
|
||||
guintptr (*get_colormap) (GstVaapiWindow * window);
|
||||
gboolean (*unblock) (GstVaapiWindow * window);
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
#include "gstvaapicompat.h"
|
||||
#include "gstvaapiwindow_x11.h"
|
||||
#include "gstvaapiwindow_x11_priv.h"
|
||||
#include "gstvaapipixmap_x11.h"
|
||||
#include "gstvaapipixmap_priv.h"
|
||||
#include "gstvaapidisplay_x11.h"
|
||||
#include "gstvaapidisplay_x11_priv.h"
|
||||
#include "gstvaapisurface_priv.h"
|
||||
|
@ -232,9 +230,6 @@ gst_vaapi_window_x11_create (GstVaapiWindow * window, guint * width,
|
|||
"_NET_WM_STATE_FULLSCREEN",
|
||||
};
|
||||
|
||||
priv->has_xrender =
|
||||
GST_VAAPI_DISPLAY_HAS_XRENDER (GST_VAAPI_WINDOW_DISPLAY (window));
|
||||
|
||||
if (window->use_foreign_window && xid) {
|
||||
GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
|
||||
XGetWindowAttributes (dpy, xid, &wattr);
|
||||
|
@ -291,17 +286,6 @@ gst_vaapi_window_x11_finalize (GObject * object)
|
|||
Display *const dpy = GST_VAAPI_WINDOW_NATIVE_DISPLAY (window);
|
||||
const Window xid = GST_VAAPI_WINDOW_ID (window);
|
||||
|
||||
#if HAVE_XRENDER
|
||||
GstVaapiWindowX11Private *const priv =
|
||||
GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
|
||||
if (priv->picture) {
|
||||
GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
|
||||
XRenderFreePicture (dpy, priv->picture);
|
||||
GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
|
||||
priv->picture = None;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (xid) {
|
||||
if (!window->use_foreign_window) {
|
||||
GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
|
||||
|
@ -500,107 +484,6 @@ conversion:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_window_x11_render_pixmap_xrender (GstVaapiWindow * window,
|
||||
GstVaapiPixmap * pixmap,
|
||||
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
|
||||
{
|
||||
#if HAVE_XRENDER
|
||||
GstVaapiWindowX11Private *const priv =
|
||||
GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
|
||||
Display *const dpy = GST_VAAPI_WINDOW_NATIVE_DISPLAY (window);
|
||||
const Window win = GST_VAAPI_WINDOW_ID (window);
|
||||
const Pixmap pix = GST_VAAPI_OBJECT_ID (pixmap);
|
||||
Picture picture;
|
||||
XRenderPictFormat *pic_fmt;
|
||||
XWindowAttributes wattr;
|
||||
int fmt, op;
|
||||
gboolean success = FALSE;
|
||||
|
||||
/* Ensure Picture for window is created */
|
||||
if (!priv->picture) {
|
||||
GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
|
||||
XGetWindowAttributes (dpy, win, &wattr);
|
||||
pic_fmt = XRenderFindVisualFormat (dpy, wattr.visual);
|
||||
if (pic_fmt)
|
||||
priv->picture = XRenderCreatePicture (dpy, win, pic_fmt, 0, NULL);
|
||||
GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
|
||||
if (!priv->picture)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check pixmap format */
|
||||
switch (GST_VAAPI_PIXMAP_FORMAT (pixmap)) {
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
fmt = PictStandardRGB24;
|
||||
op = PictOpSrc;
|
||||
goto get_pic_fmt;
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
fmt = PictStandardARGB32;
|
||||
op = PictOpOver;
|
||||
get_pic_fmt:
|
||||
GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
|
||||
pic_fmt = XRenderFindStandardFormat (dpy, fmt);
|
||||
GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
|
||||
break;
|
||||
default:
|
||||
pic_fmt = NULL;
|
||||
break;
|
||||
}
|
||||
if (!pic_fmt)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
|
||||
do {
|
||||
const double sx = (double) src_rect->width / dst_rect->width;
|
||||
const double sy = (double) src_rect->height / dst_rect->height;
|
||||
XTransform xform;
|
||||
|
||||
picture = XRenderCreatePicture (dpy, pix, pic_fmt, 0, NULL);
|
||||
if (!picture)
|
||||
break;
|
||||
|
||||
xform.matrix[0][0] = XDoubleToFixed (sx);
|
||||
xform.matrix[0][1] = XDoubleToFixed (0.0);
|
||||
xform.matrix[0][2] = XDoubleToFixed (src_rect->x);
|
||||
xform.matrix[1][0] = XDoubleToFixed (0.0);
|
||||
xform.matrix[1][1] = XDoubleToFixed (sy);
|
||||
xform.matrix[1][2] = XDoubleToFixed (src_rect->y);
|
||||
xform.matrix[2][0] = XDoubleToFixed (0.0);
|
||||
xform.matrix[2][1] = XDoubleToFixed (0.0);
|
||||
xform.matrix[2][2] = XDoubleToFixed (1.0);
|
||||
XRenderSetPictureTransform (dpy, picture, &xform);
|
||||
|
||||
XRenderComposite (dpy, op, picture, None, priv->picture,
|
||||
0, 0, 0, 0, dst_rect->x, dst_rect->y,
|
||||
dst_rect->width, dst_rect->height);
|
||||
XSync (dpy, False);
|
||||
success = TRUE;
|
||||
} while (0);
|
||||
if (picture)
|
||||
XRenderFreePicture (dpy, picture);
|
||||
GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
|
||||
return success;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapi_window_x11_render_pixmap (GstVaapiWindow * window,
|
||||
GstVaapiPixmap * pixmap,
|
||||
const GstVaapiRectangle * src_rect, const GstVaapiRectangle * dst_rect)
|
||||
{
|
||||
GstVaapiWindowX11Private *const priv =
|
||||
GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
|
||||
|
||||
if (priv->has_xrender)
|
||||
return gst_vaapi_window_x11_render_pixmap_xrender (window, pixmap,
|
||||
src_rect, dst_rect);
|
||||
|
||||
/* XXX: only X RENDER extension is supported for now */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_window_x11_class_init (GstVaapiWindowX11Class * klass)
|
||||
{
|
||||
|
@ -616,7 +499,6 @@ gst_vaapi_window_x11_class_init (GstVaapiWindowX11Class * klass)
|
|||
window_class->set_fullscreen = gst_vaapi_window_x11_set_fullscreen;
|
||||
window_class->resize = gst_vaapi_window_x11_resize;
|
||||
window_class->render = gst_vaapi_window_x11_render;
|
||||
window_class->render_pixmap = gst_vaapi_window_x11_render_pixmap;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -47,12 +47,8 @@ struct _GstVaapiWindowX11Private
|
|||
{
|
||||
Atom atom_NET_WM_STATE;
|
||||
Atom atom_NET_WM_STATE_FULLSCREEN;
|
||||
#if HAVE_XRENDER
|
||||
Picture picture;
|
||||
#endif
|
||||
guint is_mapped:1;
|
||||
guint fullscreen_on_map:1;
|
||||
guint has_xrender:1;
|
||||
gboolean need_vpp;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ gstlibvaapi_sources = [
|
|||
'gstvaapiminiobject.c',
|
||||
'gstvaapiobject.c',
|
||||
'gstvaapiparser_frame.c',
|
||||
'gstvaapipixmap.c',
|
||||
'gstvaapiprofile.c',
|
||||
'gstvaapiprofilecaps.c',
|
||||
'gstvaapisubpicture.c',
|
||||
|
@ -61,7 +60,6 @@ gstlibvaapi_headers = [
|
|||
'gstvaapiimage.h',
|
||||
'gstvaapiimagepool.h',
|
||||
'gstvaapiobject.h',
|
||||
'gstvaapipixmap.h',
|
||||
'gstvaapiprofile.h',
|
||||
'gstvaapiprofilecaps.h',
|
||||
'gstvaapisubpicture.h',
|
||||
|
@ -126,13 +124,11 @@ endif
|
|||
if USE_X11
|
||||
gstlibvaapi_sources += [
|
||||
'gstvaapidisplay_x11.c',
|
||||
'gstvaapipixmap_x11.c',
|
||||
'gstvaapiutils_x11.c',
|
||||
'gstvaapiwindow_x11.c',
|
||||
]
|
||||
gstlibvaapi_headers += [
|
||||
'gstvaapidisplay_x11.h',
|
||||
'gstvaapipixmap_x11.h',
|
||||
'gstvaapiwindow_x11.h',
|
||||
]
|
||||
endif
|
||||
|
@ -212,7 +208,7 @@ if USE_WAYLAND
|
|||
gstlibvaapi_deps += [libva_wayland_dep, wayland_client_dep, wayland_protocols_dep]
|
||||
endif
|
||||
if USE_X11
|
||||
gstlibvaapi_deps += [libva_x11_dep, x11_dep, xrandr_dep, xrender_dep]
|
||||
gstlibvaapi_deps += [libva_x11_dep, x11_dep, xrandr_dep]
|
||||
endif
|
||||
|
||||
gstlibvaapi = static_library('gstlibvaapi-@0@'.format(api_version),
|
||||
|
|
|
@ -90,7 +90,6 @@ wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15', requ
|
|||
wayland_scanner_bin = find_program('wayland-scanner', required: false)
|
||||
x11_dep = dependency('x11', required: false)
|
||||
xrandr_dep = dependency('xrandr', required: false)
|
||||
xrender_dep = dependency('xrender', required: false)
|
||||
|
||||
# some of the examples can use GTK+-3
|
||||
gtk_dep = dependency('gtk+-3.0', version : '>= 3.10', required : get_option('examples'))
|
||||
|
@ -144,7 +143,6 @@ cdata.set10('USE_WAYLAND', USE_WAYLAND)
|
|||
cdata.set10('USE_X11', USE_X11)
|
||||
cdata.set10('HAVE_XKBLIB', cc.has_header('X11/XKBlib.h', dependencies: x11_dep))
|
||||
cdata.set10('HAVE_XRANDR', xrandr_dep.found())
|
||||
cdata.set10('HAVE_XRENDER', xrender_dep.found())
|
||||
cdata.set10('USE_GST_GL_HELPERS', gstgl_dep.found())
|
||||
cdata.set('USE_GLES_VERSION_MASK', GLES_VERSION_MASK)
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#if USE_X11
|
||||
# include <gst/vaapi/gstvaapidisplay_x11.h>
|
||||
# include <gst/vaapi/gstvaapiwindow_x11.h>
|
||||
# include <gst/vaapi/gstvaapipixmap_x11.h>
|
||||
#endif
|
||||
#if USE_GLX
|
||||
# include <gst/vaapi/gstvaapidisplay_glx.h>
|
||||
|
@ -56,14 +55,12 @@ static const VideoOutputInfo g_video_outputs[] = {
|
|||
#if USE_X11
|
||||
{"x11",
|
||||
gst_vaapi_display_x11_new,
|
||||
gst_vaapi_window_x11_new,
|
||||
gst_vaapi_pixmap_x11_new},
|
||||
gst_vaapi_window_x11_new},
|
||||
#endif
|
||||
#if USE_GLX
|
||||
{"glx",
|
||||
gst_vaapi_display_glx_new,
|
||||
gst_vaapi_window_glx_new,
|
||||
gst_vaapi_pixmap_x11_new},
|
||||
gst_vaapi_window_glx_new},
|
||||
#endif
|
||||
#if USE_DRM
|
||||
{"drm",
|
||||
|
@ -228,12 +225,3 @@ video_output_create_window (GstVaapiDisplay * display, guint width,
|
|||
gst_vaapi_window_set_fullscreen (window, TRUE);
|
||||
return window;
|
||||
}
|
||||
|
||||
GstVaapiPixmap *
|
||||
video_output_create_pixmap (GstVaapiDisplay * display, GstVideoFormat format,
|
||||
guint width, guint height)
|
||||
{
|
||||
if (!g_video_output || !g_video_output->create_pixmap)
|
||||
return NULL;
|
||||
return g_video_output->create_pixmap (display, format, width, height);
|
||||
}
|
||||
|
|
|
@ -26,21 +26,16 @@
|
|||
#include <glib.h>
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include <gst/vaapi/gstvaapiwindow.h>
|
||||
#include <gst/vaapi/gstvaapipixmap.h>
|
||||
|
||||
typedef GstVaapiDisplay *(*CreateDisplayFunc)(const gchar *display_name);
|
||||
typedef GstVaapiWindow *(*CreateWindowFunc)(GstVaapiDisplay *display,
|
||||
guint width, guint height);
|
||||
typedef GstVaapiPixmap *(*CreatePixmapFunc)(GstVaapiDisplay *display,
|
||||
GstVideoFormat format, guint width, guint height);
|
||||
|
||||
|
||||
typedef struct _VideoOutputInfo VideoOutputInfo;
|
||||
struct _VideoOutputInfo {
|
||||
const gchar *name;
|
||||
CreateDisplayFunc create_display;
|
||||
CreateWindowFunc create_window;
|
||||
CreatePixmapFunc create_pixmap;
|
||||
};
|
||||
|
||||
gboolean
|
||||
|
@ -58,8 +53,4 @@ video_output_create_display(const gchar *display_name);
|
|||
GstVaapiWindow *
|
||||
video_output_create_window(GstVaapiDisplay *display, guint width, guint height);
|
||||
|
||||
GstVaapiPixmap *
|
||||
video_output_create_pixmap(GstVaapiDisplay *display, GstVideoFormat format,
|
||||
guint width, guint height);
|
||||
|
||||
#endif /* OUTPUT_H */
|
||||
|
|
|
@ -35,12 +35,10 @@
|
|||
#include <gst/vaapi/gstvaapidecoder_mpeg4.h>
|
||||
#include <gst/vaapi/gstvaapidecoder_vc1.h>
|
||||
#include <gst/vaapi/gstvaapiwindow.h>
|
||||
#include <gst/vaapi/gstvaapipixmap.h>
|
||||
#include "codec.h"
|
||||
#include "output.h"
|
||||
|
||||
static gchar *g_codec_str;
|
||||
static gboolean g_use_pixmap;
|
||||
static gboolean g_benchmark;
|
||||
|
||||
static GOptionEntry g_options[] = {
|
||||
|
@ -48,10 +46,6 @@ static GOptionEntry g_options[] = {
|
|||
0,
|
||||
G_OPTION_ARG_STRING, &g_codec_str,
|
||||
"suggested codec", NULL},
|
||||
{"pixmap", 0,
|
||||
0,
|
||||
G_OPTION_ARG_NONE, &g_use_pixmap,
|
||||
"use render-to-pixmap", NULL},
|
||||
{"benchmark", 0,
|
||||
0,
|
||||
G_OPTION_ARG_NONE, &g_benchmark,
|
||||
|
@ -100,10 +94,6 @@ typedef struct
|
|||
guint32 frame_duration;
|
||||
guint surface_width;
|
||||
guint surface_height;
|
||||
GstVaapiPixmap *pixmaps[2];
|
||||
guint pixmap_id;
|
||||
guint pixmap_width;
|
||||
guint pixmap_height;
|
||||
GstVaapiWindow *window;
|
||||
guint window_width;
|
||||
guint window_height;
|
||||
|
@ -434,43 +424,6 @@ ensure_window_size (App * app, GstVaapiSurface * surface)
|
|||
&app->window_width, &app->window_height);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ensure_pixmaps (App * app, GstVaapiSurface * surface,
|
||||
const GstVaapiRectangle * crop_rect)
|
||||
{
|
||||
GstVaapiPixmap *pixmaps[G_N_ELEMENTS (app->pixmaps)];
|
||||
guint num_pixmaps, i, width, height;
|
||||
gboolean success = FALSE;
|
||||
|
||||
if (crop_rect) {
|
||||
width = crop_rect->width;
|
||||
height = crop_rect->height;
|
||||
} else
|
||||
gst_vaapi_surface_get_size (surface, &width, &height);
|
||||
if (app->pixmap_width == width && app->pixmap_height == height)
|
||||
return TRUE;
|
||||
|
||||
for (i = 0, num_pixmaps = 0; i < G_N_ELEMENTS (pixmaps); i++) {
|
||||
GstVaapiPixmap *const pixmap =
|
||||
video_output_create_pixmap (app->display, GST_VIDEO_FORMAT_xRGB,
|
||||
width, height);
|
||||
if (!pixmap)
|
||||
goto end;
|
||||
pixmaps[num_pixmaps++] = pixmap;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_pixmaps; i++)
|
||||
gst_vaapi_pixmap_replace (&app->pixmaps[i], pixmaps[i]);
|
||||
app->pixmap_width = width;
|
||||
app->pixmap_height = height;
|
||||
success = TRUE;
|
||||
|
||||
end:
|
||||
for (i = 0; i < num_pixmaps; i++)
|
||||
gst_vaapi_pixmap_replace (&pixmaps[i], NULL);
|
||||
return success;
|
||||
}
|
||||
|
||||
static inline void
|
||||
renderer_wait_until (App * app, GstClockTime pts)
|
||||
{
|
||||
|
@ -500,8 +453,6 @@ renderer_process (App * app, RenderFrame * rfp)
|
|||
ensure_window_size (app, surface);
|
||||
|
||||
crop_rect = gst_vaapi_surface_proxy_get_crop_rect (rfp->proxy);
|
||||
if (g_use_pixmap && !ensure_pixmaps (app, surface, crop_rect))
|
||||
SEND_ERROR ("failed to create intermediate pixmaps");
|
||||
|
||||
if (!gst_vaapi_surface_sync (surface))
|
||||
SEND_ERROR ("failed to sync decoded surface");
|
||||
|
@ -509,19 +460,7 @@ renderer_process (App * app, RenderFrame * rfp)
|
|||
if (G_LIKELY (!g_benchmark))
|
||||
renderer_wait_until (app, rfp->pts);
|
||||
|
||||
if (G_UNLIKELY (g_use_pixmap)) {
|
||||
GstVaapiPixmap *const pixmap = app->pixmaps[app->pixmap_id];
|
||||
|
||||
if (!gst_vaapi_pixmap_put_surface (pixmap, surface, crop_rect,
|
||||
GST_VAAPI_PICTURE_STRUCTURE_FRAME))
|
||||
SEND_ERROR ("failed to render to pixmap");
|
||||
|
||||
if (!gst_vaapi_window_put_pixmap (app->window, pixmap, NULL, NULL))
|
||||
SEND_ERROR ("failed to render surface %" GST_VAAPI_ID_FORMAT,
|
||||
GST_VAAPI_ID_ARGS (pixmap));
|
||||
|
||||
app->pixmap_id = (app->pixmap_id + 1) % G_N_ELEMENTS (app->pixmaps);
|
||||
} else if (!gst_vaapi_window_put_surface (app->window, surface,
|
||||
if (!gst_vaapi_window_put_surface (app->window, surface,
|
||||
crop_rect, NULL, GST_VAAPI_PICTURE_STRUCTURE_FRAME))
|
||||
SEND_ERROR ("failed to render surface %" GST_VAAPI_ID_FORMAT,
|
||||
GST_VAAPI_ID_ARGS (gst_vaapi_surface_get_id (surface)));
|
||||
|
@ -594,8 +533,6 @@ stop_renderer (App * app)
|
|||
static void
|
||||
app_free (App * app)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (!app)
|
||||
return;
|
||||
|
||||
|
@ -605,8 +542,6 @@ app_free (App * app)
|
|||
}
|
||||
g_free (app->file_name);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (app->pixmaps); i++)
|
||||
gst_vaapi_pixmap_replace (&app->pixmaps[i], NULL);
|
||||
gst_vaapi_decoder_replace (&app->decoder, NULL);
|
||||
gst_vaapi_window_replace (&app->window, NULL);
|
||||
gst_vaapi_display_replace (&app->display, NULL);
|
||||
|
|
|
@ -38,17 +38,12 @@ pause (void)
|
|||
}
|
||||
|
||||
static gchar *g_codec_str;
|
||||
static gboolean g_use_pixmap;
|
||||
|
||||
static GOptionEntry g_options[] = {
|
||||
{"codec", 'c',
|
||||
0,
|
||||
G_OPTION_ARG_STRING, &g_codec_str,
|
||||
"codec to test", NULL},
|
||||
{"pixmap", 0,
|
||||
0,
|
||||
G_OPTION_ARG_NONE, &g_use_pixmap,
|
||||
"use render-to-pixmap", NULL},
|
||||
{NULL,}
|
||||
};
|
||||
|
||||
|
@ -57,7 +52,6 @@ main (int argc, char *argv[])
|
|||
{
|
||||
GstVaapiDisplay *display, *display2;
|
||||
GstVaapiWindow *window;
|
||||
GstVaapiPixmap *pixmap = NULL;
|
||||
GstVaapiDecoder *decoder;
|
||||
GstVaapiSurfaceProxy *proxy;
|
||||
GstVaapiSurface *surface;
|
||||
|
@ -104,34 +98,12 @@ main (int argc, char *argv[])
|
|||
|
||||
gst_vaapi_window_show (window);
|
||||
|
||||
if (g_use_pixmap) {
|
||||
guint width, height;
|
||||
|
||||
if (crop_rect) {
|
||||
width = crop_rect->width;
|
||||
height = crop_rect->height;
|
||||
} else
|
||||
gst_vaapi_surface_get_size (surface, &width, &height);
|
||||
|
||||
pixmap = video_output_create_pixmap (display, GST_VIDEO_FORMAT_xRGB,
|
||||
width, height);
|
||||
if (!pixmap)
|
||||
g_error ("could not create pixmap");
|
||||
|
||||
if (!gst_vaapi_pixmap_put_surface (pixmap, surface, crop_rect,
|
||||
GST_VAAPI_PICTURE_STRUCTURE_FRAME))
|
||||
g_error ("could not render to pixmap");
|
||||
|
||||
if (!gst_vaapi_window_put_pixmap (window, pixmap, NULL, NULL))
|
||||
g_error ("could not render pixmap");
|
||||
} else if (!gst_vaapi_window_put_surface (window, surface, crop_rect, NULL,
|
||||
if (!gst_vaapi_window_put_surface (window, surface, crop_rect, NULL,
|
||||
GST_VAAPI_PICTURE_STRUCTURE_FRAME))
|
||||
g_error ("could not render surface");
|
||||
|
||||
pause ();
|
||||
|
||||
if (pixmap)
|
||||
gst_vaapi_pixmap_unref (pixmap);
|
||||
gst_vaapi_surface_proxy_unref (proxy);
|
||||
gst_object_unref (decoder);
|
||||
gst_object_unref (window);
|
||||
|
|
Loading…
Reference in a new issue