2012-07-24 12:31:25 +00:00
|
|
|
/*
|
|
|
|
* gstvaapipluginbuffer.c - Private GStreamer/VA video buffers
|
|
|
|
*
|
2013-01-29 13:14:45 +00:00
|
|
|
* Copyright (C) 2012-2013 Intel Corporation
|
2012-07-24 12:31:25 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2013-03-20 10:57:03 +00:00
|
|
|
#include "gst/vaapi/sysdeps.h"
|
2013-01-05 16:55:47 +00:00
|
|
|
#include <gst/vaapi/gstvaapivideometa.h>
|
2012-07-24 12:31:25 +00:00
|
|
|
#include <gst/vaapi/gstvaapivideobuffer.h>
|
|
|
|
#if USE_GLX
|
2013-01-05 16:55:47 +00:00
|
|
|
# include <gst/vaapi/gstvaapivideoconverter_glx.h>
|
2012-07-24 12:31:25 +00:00
|
|
|
#endif
|
|
|
|
#include "gstvaapipluginbuffer.h"
|
|
|
|
|
2013-01-05 16:55:47 +00:00
|
|
|
static GFunc
|
|
|
|
get_surface_converter(GstVaapiDisplay *display)
|
2012-07-24 12:31:25 +00:00
|
|
|
{
|
2013-01-05 16:55:47 +00:00
|
|
|
GFunc func;
|
2012-07-25 12:51:28 +00:00
|
|
|
|
|
|
|
switch (gst_vaapi_display_get_display_type(display)) {
|
2012-07-24 12:31:25 +00:00
|
|
|
#if USE_GLX
|
2012-07-25 12:51:28 +00:00
|
|
|
case GST_VAAPI_DISPLAY_TYPE_GLX:
|
2013-01-05 16:55:47 +00:00
|
|
|
func = (GFunc)gst_vaapi_video_converter_glx_new;
|
2012-07-25 12:51:28 +00:00
|
|
|
break;
|
2012-07-24 12:31:25 +00:00
|
|
|
#endif
|
2012-07-25 12:51:28 +00:00
|
|
|
default:
|
2013-01-05 16:55:47 +00:00
|
|
|
func = NULL;
|
2012-07-25 12:51:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-01-05 16:55:47 +00:00
|
|
|
return func;
|
2012-07-24 12:31:25 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 16:55:47 +00:00
|
|
|
static GstBuffer *
|
|
|
|
get_buffer(GstVaapiVideoMeta *meta)
|
2012-07-24 12:31:25 +00:00
|
|
|
{
|
2013-01-05 16:55:47 +00:00
|
|
|
GstBuffer *buffer;
|
|
|
|
|
|
|
|
if (!meta)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
gst_vaapi_video_meta_set_surface_converter(meta,
|
|
|
|
get_surface_converter(gst_vaapi_video_meta_get_display(meta)));
|
2012-07-24 12:31:25 +00:00
|
|
|
|
2013-01-05 16:55:47 +00:00
|
|
|
buffer = gst_vaapi_video_buffer_new(meta);
|
|
|
|
gst_vaapi_video_meta_unref(meta);
|
|
|
|
return buffer;
|
2012-07-24 12:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstBuffer *
|
|
|
|
gst_vaapi_video_buffer_new_from_pool(GstVaapiVideoPool *pool)
|
|
|
|
{
|
2013-01-05 16:55:47 +00:00
|
|
|
return get_buffer(gst_vaapi_video_meta_new_from_pool(pool));
|
2012-07-24 12:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstBuffer *
|
|
|
|
gst_vaapi_video_buffer_new_from_buffer(GstBuffer *buffer)
|
|
|
|
{
|
2013-03-20 13:02:48 +00:00
|
|
|
GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
|
|
|
|
|
|
|
|
if (!meta)
|
|
|
|
return NULL;
|
|
|
|
return get_buffer(gst_vaapi_video_meta_ref(meta));
|
2012-07-24 12:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstBuffer *
|
|
|
|
gst_vaapi_video_buffer_new_with_image(GstVaapiImage *image)
|
|
|
|
{
|
2013-01-05 16:55:47 +00:00
|
|
|
return get_buffer(gst_vaapi_video_meta_new_with_image(image));
|
2012-07-24 12:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstBuffer *
|
|
|
|
gst_vaapi_video_buffer_new_with_surface(GstVaapiSurface *surface)
|
|
|
|
{
|
2013-01-05 16:55:47 +00:00
|
|
|
return get_buffer(gst_vaapi_video_meta_new_with_surface(surface));
|
2012-07-24 12:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstBuffer *
|
|
|
|
gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy)
|
|
|
|
{
|
2013-01-05 16:55:47 +00:00
|
|
|
return get_buffer(gst_vaapi_video_meta_new_with_surface_proxy(proxy));
|
2012-07-24 12:31:25 +00:00
|
|
|
}
|