mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
plugins: integrate GstVaapiVideoConverterGLX from libgstvaapi.
Make sure libgstvaapi core decoding library doesn't include un-needed dependencies. So, move out GstVaapiVideoConverterGLX to plugins instead. Besides, even if the vaapisink element is not used, we are bound to have a correctly populated GstSurfaceBuffer from vaapidecode. Also clean-up the file along the way.
This commit is contained in:
parent
2000d5d6e1
commit
17e7e67c1f
7 changed files with 255 additions and 222 deletions
|
@ -170,14 +170,12 @@ libgstvaapi_glx_source_c = \
|
||||||
gstvaapiutils.c \
|
gstvaapiutils.c \
|
||||||
gstvaapiutils_glx.c \
|
gstvaapiutils_glx.c \
|
||||||
gstvaapiutils_x11.c \
|
gstvaapiutils_x11.c \
|
||||||
gstvaapivideoconverter_glx.c \
|
|
||||||
gstvaapiwindow_glx.c \
|
gstvaapiwindow_glx.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libgstvaapi_glx_source_h = \
|
libgstvaapi_glx_source_h = \
|
||||||
gstvaapidisplay_glx.h \
|
gstvaapidisplay_glx.h \
|
||||||
gstvaapitexture.h \
|
gstvaapitexture.h \
|
||||||
gstvaapivideoconverter_glx.h \
|
|
||||||
gstvaapiwindow_glx.h \
|
gstvaapiwindow_glx.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -1,142 +0,0 @@
|
||||||
/*
|
|
||||||
* gstvaapivideoconverter_glx.c - Gst VA video converter
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011-2013 Intel Corporation
|
|
||||||
* Copyright (C) 2011 Collabora Ltd.
|
|
||||||
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sysdeps.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include "gstvaapivideoconverter_glx.h"
|
|
||||||
#include "gstvaapivideobuffer.h"
|
|
||||||
#include "gstvaapitexture.h"
|
|
||||||
|
|
||||||
static void gst_vaapi_video_converter_glx_iface_init (GstSurfaceConverterInterface *iface);
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstVaapiVideoConverterGLX, gst_vaapi_video_converter_glx,
|
|
||||||
G_TYPE_OBJECT,
|
|
||||||
G_IMPLEMENT_INTERFACE (GST_TYPE_SURFACE_CONVERTER,
|
|
||||||
gst_vaapi_video_converter_glx_iface_init))
|
|
||||||
|
|
||||||
struct _GstVaapiVideoConverterGLXPrivate {
|
|
||||||
GstVaapiTexture *texture;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_video_converter_glx_dispose(GObject *object)
|
|
||||||
{
|
|
||||||
GstVaapiVideoConverterGLXPrivate *priv =
|
|
||||||
GST_VAAPI_VIDEO_CONVERTER_GLX (object)->priv;
|
|
||||||
|
|
||||||
g_clear_object(&priv->texture);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_vaapi_video_converter_glx_parent_class)->dispose (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_video_converter_glx_class_init(GstVaapiVideoConverterGLXClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GstVaapiVideoConverterGLXPrivate));
|
|
||||||
object_class->dispose = gst_vaapi_video_converter_glx_dispose;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_video_converter_glx_init(GstVaapiVideoConverterGLX *buffer)
|
|
||||||
{
|
|
||||||
buffer->priv = G_TYPE_INSTANCE_GET_PRIVATE(buffer,
|
|
||||||
GST_VAAPI_TYPE_VIDEO_CONVERTER,
|
|
||||||
GstVaapiVideoConverterGLXPrivate);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_video_converter_glx_iface_init (GstSurfaceConverterInterface *iface) {
|
|
||||||
iface->upload = gst_vaapi_video_converter_glx_upload;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_vaapi_video_converter_glx_new:
|
|
||||||
* @surface: the #GstSurfaceBuffer
|
|
||||||
* @type: type of the target buffer (must be "opengl")
|
|
||||||
* @dest: target of the conversion (must be GL texture id)
|
|
||||||
*
|
|
||||||
* Creates an empty #GstBuffer. The caller is responsible for
|
|
||||||
* completing the initialization of the buffer with the
|
|
||||||
* gst_vaapi_video_converter_glx_set_*() functions.
|
|
||||||
*
|
|
||||||
* Return value: the newly allocated #GstBuffer, or %NULL on error
|
|
||||||
*/
|
|
||||||
GstSurfaceConverter *
|
|
||||||
gst_vaapi_video_converter_glx_new(GstSurfaceBuffer *surface, const gchar *type,
|
|
||||||
GValue *dest)
|
|
||||||
{
|
|
||||||
GstVaapiVideoMeta * const meta =
|
|
||||||
gst_vaapi_video_buffer_get_meta(GST_VAAPI_VIDEO_BUFFER(surface));
|
|
||||||
GstVaapiTexture *texture;
|
|
||||||
GstVaapiVideoConverterGLX *converter;
|
|
||||||
|
|
||||||
/* We only support Open GL texture conversion */
|
|
||||||
if (strcmp(type, "opengl") || !G_VALUE_HOLDS_UINT(dest))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* FIXME Should we assume target and format ? */
|
|
||||||
texture = gst_vaapi_texture_new_with_texture(
|
|
||||||
gst_vaapi_video_meta_get_display(meta),
|
|
||||||
g_value_get_uint(dest), GL_TEXTURE_2D, GL_BGRA);
|
|
||||||
if (!texture)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
converter = g_object_new(GST_VAAPI_TYPE_VIDEO_CONVERTER, NULL);
|
|
||||||
converter->priv->texture = texture;
|
|
||||||
return GST_SURFACE_CONVERTER(converter);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_vaapi_video_converter_glx_upload (GstSurfaceConverter *converter,
|
|
||||||
GstSurfaceBuffer *buffer)
|
|
||||||
{
|
|
||||||
GstVaapiVideoConverterGLXPrivate *priv =
|
|
||||||
GST_VAAPI_VIDEO_CONVERTER_GLX (converter)->priv;
|
|
||||||
GstVaapiVideoMeta * const meta =
|
|
||||||
gst_vaapi_video_buffer_get_meta (GST_VAAPI_VIDEO_BUFFER (buffer));
|
|
||||||
GstVaapiSurface *surface = gst_vaapi_video_meta_get_surface (meta);
|
|
||||||
GstVaapiDisplay *new_dpy, *old_dpy;
|
|
||||||
GstVideoOverlayComposition * const composition =
|
|
||||||
gst_video_buffer_get_overlay_composition (GST_BUFFER (buffer));
|
|
||||||
|
|
||||||
new_dpy = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface));
|
|
||||||
old_dpy = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (priv->texture));
|
|
||||||
|
|
||||||
if (old_dpy != new_dpy) {
|
|
||||||
guint texture = gst_vaapi_texture_get_id (priv->texture);
|
|
||||||
g_object_unref (priv->texture);
|
|
||||||
priv->texture = gst_vaapi_texture_new_with_texture (new_dpy,
|
|
||||||
texture,
|
|
||||||
GL_TEXTURE_2D,
|
|
||||||
GL_BGRA);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gst_vaapi_surface_set_subpictures_from_composition (surface,
|
|
||||||
composition, TRUE))
|
|
||||||
GST_WARNING ("could not update subtitles");
|
|
||||||
|
|
||||||
return gst_vaapi_texture_put_surface (priv->texture, surface,
|
|
||||||
gst_vaapi_video_meta_get_render_flags (meta));
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* gstvaapivideoconverter_glx.h - Gstreamer/VA video converter
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011-2012 Intel Corporation
|
|
||||||
* Copyright (C) 2011 Collabora Ltd.
|
|
||||||
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.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_VIDEO_CONVERTER_GLX_H
|
|
||||||
#define GST_VAAPI_VIDEO_CONVERTER_GLX_H
|
|
||||||
|
|
||||||
#include <gst/video/gstsurfaceconverter.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GST_VAAPI_TYPE_VIDEO_CONVERTER (gst_vaapi_video_converter_glx_get_type ())
|
|
||||||
#define GST_VAAPI_VIDEO_CONVERTER_GLX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER, GstVaapiVideoConverterGLX))
|
|
||||||
#define GST_VAAPI_VIDEO_CONVERTER_GLX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER, GstVaapiVideoConverterGLXClass))
|
|
||||||
#define GST_VAAPI_IS_VIDEO_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER))
|
|
||||||
#define GST_VAAPI_IS_VIDEO_CONVERTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER))
|
|
||||||
#define GST_VAAPI_VIDEO_CONVERTER_GLX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER, GstVaapiVideoConverterGLXClass))
|
|
||||||
|
|
||||||
typedef struct _GstVaapiVideoConverterGLX GstVaapiVideoConverterGLX;
|
|
||||||
typedef struct _GstVaapiVideoConverterGLXPrivate GstVaapiVideoConverterGLXPrivate;
|
|
||||||
typedef struct _GstVaapiVideoConverterGLXClass GstVaapiVideoConverterGLXClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiVideoConverterGLX:
|
|
||||||
*
|
|
||||||
* Converter to transform VA buffers into GL textures.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiVideoConverterGLX {
|
|
||||||
/*< private >*/
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
GstVaapiVideoConverterGLXPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiVideoConverterGLXClass:
|
|
||||||
*
|
|
||||||
* Converter to transform VA buffers into GL textures.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiVideoConverterGLXClass {
|
|
||||||
/*< private >*/
|
|
||||||
GObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_vaapi_video_converter_glx_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GstSurfaceConverter *gst_vaapi_video_converter_glx_new (GstSurfaceBuffer *buffer,
|
|
||||||
const gchar *type,
|
|
||||||
GValue *dest);
|
|
||||||
|
|
||||||
gboolean gst_vaapi_video_converter_glx_upload (GstSurfaceConverter *self,
|
|
||||||
GstSurfaceBuffer *buffer);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* GST_VAAPI_VIDEO_CONVERTER_GLX_H */
|
|
|
@ -29,7 +29,7 @@ libgstvaapi_LIBS += \
|
||||||
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-wayland-$(GST_API_VERSION).la
|
$(top_builddir)/gst-libs/gst/vaapi/libgstvaapi-wayland-$(GST_API_VERSION).la
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libgstvaapi_la_SOURCES = \
|
libgstvaapi_source_c = \
|
||||||
gstvaapi.c \
|
gstvaapi.c \
|
||||||
gstvaapidecode.c \
|
gstvaapidecode.c \
|
||||||
gstvaapidownload.c \
|
gstvaapidownload.c \
|
||||||
|
@ -41,7 +41,7 @@ libgstvaapi_la_SOURCES = \
|
||||||
gstvaapiuploader.c \
|
gstvaapiuploader.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
noinst_HEADERS = \
|
libgstvaapi_source_h = \
|
||||||
gstvaapidecode.h \
|
gstvaapidecode.h \
|
||||||
gstvaapidownload.h \
|
gstvaapidownload.h \
|
||||||
gstvaapipluginbuffer.h \
|
gstvaapipluginbuffer.h \
|
||||||
|
@ -52,6 +52,14 @@ noinst_HEADERS = \
|
||||||
gstvaapiuploader.h \
|
gstvaapiuploader.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
if USE_GLX
|
||||||
|
libgstvaapi_source_c += gstvaapivideoconverter_glx.c
|
||||||
|
libgstvaapi_source_h += gstvaapivideoconverter_glx.h
|
||||||
|
endif
|
||||||
|
|
||||||
|
libgstvaapi_la_SOURCES = $(libgstvaapi_source_c)
|
||||||
|
noinst_HEADERS = $(libgstvaapi_source_h)
|
||||||
|
|
||||||
libgstvaapi_la_CFLAGS = \
|
libgstvaapi_la_CFLAGS = \
|
||||||
$(libgstvaapi_CFLAGS) \
|
$(libgstvaapi_CFLAGS) \
|
||||||
$(GST_CFLAGS) \
|
$(GST_CFLAGS) \
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <gst/vaapi/gstvaapivideometa.h>
|
#include <gst/vaapi/gstvaapivideometa.h>
|
||||||
#include <gst/vaapi/gstvaapivideobuffer.h>
|
#include <gst/vaapi/gstvaapivideobuffer.h>
|
||||||
#if USE_GLX
|
#if USE_GLX
|
||||||
# include <gst/vaapi/gstvaapivideoconverter_glx.h>
|
# include "gstvaapivideoconverter_glx.h"
|
||||||
#endif
|
#endif
|
||||||
#include "gstvaapipluginbuffer.h"
|
#include "gstvaapipluginbuffer.h"
|
||||||
|
|
||||||
|
|
154
gst/vaapi/gstvaapivideoconverter_glx.c
Normal file
154
gst/vaapi/gstvaapivideoconverter_glx.c
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
/*
|
||||||
|
* gstvaapivideoconverter_glx.c - Gst VA video converter
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-2013 Intel Corporation
|
||||||
|
* Copyright (C) 2011 Collabora Ltd.
|
||||||
|
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gst/vaapi/sysdeps.h"
|
||||||
|
#include <gst/vaapi/gstvaapivideometa.h>
|
||||||
|
#include <gst/vaapi/gstvaapitexture.h>
|
||||||
|
#include "gstvaapivideoconverter_glx.h"
|
||||||
|
|
||||||
|
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
|
||||||
|
GstSurfaceBuffer *);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE(
|
||||||
|
GstVaapiVideoConverterGLX,
|
||||||
|
gst_vaapi_video_converter_glx,
|
||||||
|
G_TYPE_OBJECT,
|
||||||
|
G_IMPLEMENT_INTERFACE(GST_TYPE_SURFACE_CONVERTER,
|
||||||
|
gst_vaapi_video_converter_glx_iface_init))
|
||||||
|
|
||||||
|
#define GST_VAAPI_VIDEO_CONVERTER_GLX_GET_PRIVATE(obj) \
|
||||||
|
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
|
||||||
|
GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
|
||||||
|
GstVaapiVideoConverterGLXPrivate))
|
||||||
|
|
||||||
|
struct _GstVaapiVideoConverterGLXPrivate {
|
||||||
|
GstVaapiTexture *texture;
|
||||||
|
};
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_vaapi_video_converter_glx_upload(GstSurfaceConverter *self,
|
||||||
|
GstBuffer *buffer);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vaapi_video_converter_glx_dispose(GObject *object)
|
||||||
|
{
|
||||||
|
GstVaapiVideoConverterGLXPrivate * const priv =
|
||||||
|
GST_VAAPI_VIDEO_CONVERTER_GLX(object)->priv;
|
||||||
|
|
||||||
|
g_clear_object(&priv->texture);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS(gst_vaapi_video_converter_glx_parent_class)->dispose(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vaapi_video_converter_glx_class_init(GstVaapiVideoConverterGLXClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
||||||
|
|
||||||
|
g_type_class_add_private(klass, sizeof(GstVaapiVideoConverterGLXPrivate));
|
||||||
|
|
||||||
|
object_class->dispose = gst_vaapi_video_converter_glx_dispose;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vaapi_video_converter_glx_init(GstVaapiVideoConverterGLX *buffer)
|
||||||
|
{
|
||||||
|
buffer->priv = GST_VAAPI_VIDEO_CONVERTER_GLX_GET_PRIVATE(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vaapi_video_converter_glx_iface_init(GstSurfaceConverterInterface *iface)
|
||||||
|
{
|
||||||
|
iface->upload = (GstSurfaceUploadFunction)
|
||||||
|
gst_vaapi_video_converter_glx_upload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_video_converter_glx_new:
|
||||||
|
* @surface: the #GstSurfaceBuffer
|
||||||
|
* @type: type of the target buffer (must be "opengl")
|
||||||
|
* @dest: target of the conversion (must be GL texture id)
|
||||||
|
*
|
||||||
|
* Creates an empty #GstBuffer. The caller is responsible for
|
||||||
|
* completing the initialization of the buffer with the
|
||||||
|
* gst_vaapi_video_converter_glx_set_*() functions.
|
||||||
|
*
|
||||||
|
* Return value: the newly allocated #GstBuffer, or %NULL on error
|
||||||
|
*/
|
||||||
|
GstSurfaceConverter *
|
||||||
|
gst_vaapi_video_converter_glx_new(GstBuffer *buffer, const gchar *type,
|
||||||
|
GValue *dest)
|
||||||
|
{
|
||||||
|
GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
|
||||||
|
GstVaapiTexture *texture;
|
||||||
|
GstVaapiVideoConverterGLX *converter;
|
||||||
|
|
||||||
|
/* We only support Open GL texture conversion */
|
||||||
|
if (strcmp(type, "opengl") != 0 || !G_VALUE_HOLDS_UINT(dest))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* FIXME Should we assume target and format ? */
|
||||||
|
texture = gst_vaapi_texture_new_with_texture(
|
||||||
|
gst_vaapi_video_meta_get_display(meta),
|
||||||
|
g_value_get_uint(dest), GL_TEXTURE_2D, GL_BGRA);
|
||||||
|
if (!texture)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
converter = g_object_new(GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, NULL);
|
||||||
|
converter->priv->texture = texture;
|
||||||
|
return GST_SURFACE_CONVERTER(converter);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_vaapi_video_converter_glx_upload(GstSurfaceConverter *self,
|
||||||
|
GstBuffer *buffer)
|
||||||
|
{
|
||||||
|
GstVaapiVideoConverterGLXPrivate * const priv =
|
||||||
|
GST_VAAPI_VIDEO_CONVERTER_GLX(self)->priv;
|
||||||
|
GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
|
||||||
|
GstVaapiSurface * const surface = gst_vaapi_video_meta_get_surface(meta);
|
||||||
|
GstVaapiDisplay *new_dpy, *old_dpy;
|
||||||
|
GstVideoOverlayComposition * const composition =
|
||||||
|
gst_video_buffer_get_overlay_composition(buffer);
|
||||||
|
|
||||||
|
new_dpy = gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface));
|
||||||
|
old_dpy = gst_vaapi_object_get_display(GST_VAAPI_OBJECT(priv->texture));
|
||||||
|
|
||||||
|
if (old_dpy != new_dpy) {
|
||||||
|
const guint texture = gst_vaapi_texture_get_id(priv->texture);
|
||||||
|
|
||||||
|
g_clear_object(&priv->texture);
|
||||||
|
priv->texture = gst_vaapi_texture_new_with_texture(new_dpy,
|
||||||
|
texture, GL_TEXTURE_2D, GL_BGRA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gst_vaapi_surface_set_subpictures_from_composition(surface,
|
||||||
|
composition, TRUE))
|
||||||
|
GST_WARNING("could not update subtitles");
|
||||||
|
|
||||||
|
return gst_vaapi_texture_put_surface(priv->texture, surface,
|
||||||
|
gst_vaapi_video_meta_get_render_flags(meta));
|
||||||
|
}
|
90
gst/vaapi/gstvaapivideoconverter_glx.h
Normal file
90
gst/vaapi/gstvaapivideoconverter_glx.h
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* gstvaapivideoconverter_glx.h - Gstreamer/VA video converter
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-2012 Intel Corporation
|
||||||
|
* Copyright (C) 2011 Collabora Ltd.
|
||||||
|
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.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_VIDEO_CONVERTER_GLX_H
|
||||||
|
#define GST_VAAPI_VIDEO_CONVERTER_GLX_H
|
||||||
|
|
||||||
|
#include <gst/video/gstsurfaceconverter.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX \
|
||||||
|
(gst_vaapi_video_converter_glx_get_type ())
|
||||||
|
|
||||||
|
#define GST_VAAPI_VIDEO_CONVERTER_GLX(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
|
||||||
|
GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
|
||||||
|
GstVaapiVideoConverterGLX))
|
||||||
|
|
||||||
|
#define GST_VAAPI_VIDEO_CONVERTER_GLX_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_CAST((klass), \
|
||||||
|
GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
|
||||||
|
GstVaapiVideoConverterGLXClass))
|
||||||
|
|
||||||
|
#define GST_VAAPI_IS_VIDEO_CONVERTER_GLX(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX))
|
||||||
|
|
||||||
|
#define GST_VAAPI_IS_VIDEO_CONVERTER_GLX_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX))
|
||||||
|
|
||||||
|
#define GST_VAAPI_VIDEO_CONVERTER_GLX_GET_CLASS(obj) \
|
||||||
|
(G_TYPE_INSTANCE_GET_CLASS((obj), \
|
||||||
|
GST_VAAPI_TYPE_VIDEO_CONVERTER_GLX, \
|
||||||
|
GstVaapiVideoConverterGLXClass))
|
||||||
|
|
||||||
|
typedef struct _GstVaapiVideoConverterGLX GstVaapiVideoConverterGLX;
|
||||||
|
typedef struct _GstVaapiVideoConverterGLXPrivate GstVaapiVideoConverterGLXPrivate;
|
||||||
|
typedef struct _GstVaapiVideoConverterGLXClass GstVaapiVideoConverterGLXClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVaapiVideoConverterGLX:
|
||||||
|
*
|
||||||
|
* Converter to transform VA buffers into GL textures.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiVideoConverterGLX {
|
||||||
|
/*< private >*/
|
||||||
|
GObject parent_instance;
|
||||||
|
|
||||||
|
GstVaapiVideoConverterGLXPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVaapiVideoConverterGLXClass:
|
||||||
|
*
|
||||||
|
* Converter class to transform VA buffers into GL textures.
|
||||||
|
*/
|
||||||
|
struct _GstVaapiVideoConverterGLXClass {
|
||||||
|
/*< private >*/
|
||||||
|
GObjectClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_vaapi_video_converter_glx_get_type(void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GstSurfaceConverter *
|
||||||
|
gst_vaapi_video_converter_glx_new(GstBuffer *buffer, const gchar *type,
|
||||||
|
GValue *dest);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GST_VAAPI_VIDEO_CONVERTER_GLX_H */
|
Loading…
Reference in a new issue