plugins: add support for GstVideoGLTextureUploadMeta.

If the allocation meta GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE is
requested, and more specifically under a GLX configuration, then add
the GstVideoGLTextureUploadMeta to the output buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=703236

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
Víctor Manuel Jáquez Leal 2013-07-15 13:41:00 +02:00 committed by Gwenole Beauchesne
parent 8fe3bb0b14
commit 41c4da5571
6 changed files with 175 additions and 2 deletions

View file

@ -75,6 +75,19 @@ libgstvaapi_source_h += $(libgstvaapi_glx_source_h)
endif
endif
libgstvaapi_1_2p_source_c = \
gstvaapivideometa_texture.c \
$(NULL)
libgstvaapi_1_2p_source_h = \
gstvaapivideometa_texture.h \
$(NULL)
if USE_GST_API_1_2p
libgstvaapi_source_c += $(libgstvaapi_1_2p_source_c)
libgstvaapi_source_h += $(libgstvaapi_1_2p_source_h)
endif
libgstvaapi_1_0p_source_c = \
gstvaapivideobufferpool.c \
gstvaapivideomemory.c \
@ -135,6 +148,8 @@ libgstvaapi_la_LIBTOOLFLAGS = --tag=disable-static
EXTRA_DIST = \
$(libgstvaapi_glx_source_c) \
$(libgstvaapi_glx_source_h) \
$(libgstvaapi_1_2p_source_c) \
$(libgstvaapi_1_2p_source_h) \
$(libgstvaapi_1_0p_source_c) \
$(libgstvaapi_1_0p_source_h) \
$(libgstvaapi_0_10_source_c) \

View file

@ -35,6 +35,9 @@
#include "gstvaapipluginutil.h"
#include "gstvaapivideocontext.h"
#include "gstvaapivideobuffer.h"
#if GST_CHECK_VERSION(1,1,0)
#include "gstvaapivideometa_texture.h"
#endif
#if GST_CHECK_VERSION(1,0,0)
#include "gstvaapivideobufferpool.h"
#include "gstvaapivideomemory.h"
@ -69,7 +72,10 @@ static const char gst_vaapidecode_sink_caps_str[] =
static const char gst_vaapidecode_src_caps_str[] =
#if GST_CHECK_VERSION(1,1,0)
GST_VIDEO_CAPS_MAKE_WITH_FEATURES(
GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, GST_VIDEO_FORMATS_ALL);
GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, GST_VIDEO_FORMATS_ALL) ";"
GST_VIDEO_CAPS_MAKE_WITH_FEATURES(
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META,
GST_VIDEO_FORMATS_ALL);
#else
GST_VAAPI_SURFACE_CAPS;
#endif
@ -343,6 +349,11 @@ gst_vaapidecode_push_decoded_frame(GstVideoDecoder *vdec)
crop_meta->height = crop_rect->height;
}
}
#if GST_CHECK_VERSION(1,1,0)
if (decode->has_texture_upload_meta)
gst_buffer_add_texture_upload_meta(out_frame->output_buffer);
#endif
#else
out_frame->output_buffer =
gst_vaapi_video_buffer_new_with_surface_proxy(proxy);
@ -529,6 +540,18 @@ gst_vaapidecode_decide_allocation(GstVideoDecoder *vdec, GstQuery *query)
gst_buffer_pool_set_config(pool, config);
}
decode->has_texture_upload_meta = FALSE;
if (gst_query_find_allocation_meta(query, GST_VIDEO_META_API_TYPE, NULL)) {
config = gst_buffer_pool_get_config(pool);
gst_buffer_pool_config_add_option(config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
gst_buffer_pool_set_config(pool, config);
#if GST_CHECK_VERSION(1,1,0)
decode->has_texture_upload_meta = gst_query_find_allocation_meta(query,
GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, NULL);
#endif
}
if (update_pool)
gst_query_set_nth_allocation_pool(query, 0, pool, size, min, max);
else
@ -636,6 +659,8 @@ gst_vaapidecode_reset_full(GstVaapiDecode *decode, GstCaps *caps, gboolean hard)
{
GstVaapiCodec codec;
decode->has_texture_upload_meta = FALSE;
/* Reset timers if hard reset was requested (e.g. seek) */
if (hard) {
decode->render_time_base = 0;

View file

@ -79,6 +79,7 @@ struct _GstVaapiDecode {
gint64 render_time_base;
GstClockTime last_buffer_time;
guint current_frame_size;
guint has_texture_upload_meta : 1;
};
struct _GstVaapiDecodeClass {

View file

@ -86,7 +86,10 @@ GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapisink);
static const char gst_vaapisink_sink_caps_str[] =
#if GST_CHECK_VERSION(1,1,0)
GST_VIDEO_CAPS_MAKE_WITH_FEATURES(
GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, GST_VIDEO_FORMATS_ALL);
GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, GST_VIDEO_FORMATS_ALL) ";"
GST_VIDEO_CAPS_MAKE_WITH_FEATURES(
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META,
GST_VIDEO_FORMATS_ALL);
#else
#if GST_CHECK_VERSION(1,0,0)
GST_VIDEO_CAPS_MAKE(GST_VIDEO_FORMATS_ALL) "; "

View file

@ -0,0 +1,92 @@
/*
* gstvaapivideometa_texture.c - GStreamer/VA video meta (GLTextureUpload)
*
* Copyright (C) 2010-2011 Splitted-Desktop Systems
* Copyright (C) 2011-2013 Intel Corporation
* Copyright (C) 2013 Igalia
*
* 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 "gstvaapivideometa.h"
#include "gstvaapivideometa_texture.h"
#include "gstvaapipluginutil.h"
#if GST_CHECK_VERSION(1,1,0) && USE_GLX
static void
gst_vaapi_texure_upload_free(gpointer data)
{
GstVaapiTexture * const texture = data;
if (texture)
gst_vaapi_texture_unref(texture);
}
static gboolean
gst_vaapi_texture_upload(GstVideoGLTextureUploadMeta *meta, guint texture_id[4])
{
GstVaapiVideoMeta * const vmeta =
gst_buffer_get_vaapi_video_meta(meta->buffer);
GstVaapiTexture *texture = meta->user_data;
GstVaapiSurface * const surface = gst_vaapi_video_meta_get_surface(vmeta);
GstVaapiDisplay * const dpy =
gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface));
if (gst_vaapi_display_get_display_type(dpy) != GST_VAAPI_DISPLAY_TYPE_GLX)
return FALSE;
if (texture) {
GstVaapiDisplay * const tex_dpy =
gst_vaapi_object_get_display(GST_VAAPI_OBJECT(texture));
if (tex_dpy != dpy)
gst_vaapi_texture_replace(&texture, NULL);
}
if (!texture) {
/* FIXME: should we assume target? */
texture = gst_vaapi_texture_new_with_texture(dpy, texture_id[0],
GL_TEXTURE_2D, GL_RGBA);
meta->user_data = texture;
}
if (!gst_vaapi_apply_composition(surface, meta->buffer))
GST_WARNING("could not update subtitles");
return gst_vaapi_texture_put_surface(texture, surface,
gst_vaapi_video_meta_get_render_flags(vmeta));
}
#endif
#if GST_CHECK_VERSION(1,1,0)
gboolean
gst_buffer_add_texture_upload_meta(GstBuffer *buffer)
{
GstVideoGLTextureUploadMeta *meta = NULL;
GstVideoGLTextureType tex_type[] = { GST_VIDEO_GL_TEXTURE_TYPE_RGBA };
if (!buffer)
return FALSE;
#if USE_GLX
meta = gst_buffer_add_video_gl_texture_upload_meta(buffer,
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL,
1, tex_type, gst_vaapi_texture_upload,
NULL, NULL, gst_vaapi_texure_upload_free);
#endif
return meta != NULL;
}
#endif

View file

@ -0,0 +1,37 @@
/*
* gstvaapivideometa_texture.h - GStreamer/VA video meta (GLTextureUpload)
*
* Copyright (C) 2010-2011 Splitted-Desktop Systems
* Copyright (C) 2011-2013 Intel Corporation
* Copyright (C) 2013 Igalia
*
* 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_META_TEXTURE_H
#define GST_VAAPI_VIDEO_META_TEXTURE_H
#include <gst/vaapi/gstvaapitexture.h>
G_BEGIN_DECLS
G_GNUC_INTERNAL
gboolean
gst_buffer_add_texture_upload_meta(GstBuffer *buffer);
G_END_DECLS
#endif /* GST_VAAPI_VIDEO_META_TEXTURE_H */