|
Packit |
0652a1 |
/*
|
|
Packit |
0652a1 |
* GStreamer
|
|
Packit |
0652a1 |
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
0652a1 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
0652a1 |
* License as published by the Free Software Foundation; either
|
|
Packit |
0652a1 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
0652a1 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
0652a1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
0652a1 |
* Library General Public License for more details.
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
0652a1 |
* License along with this library; if not, write to the
|
|
Packit |
0652a1 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
0652a1 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
#ifndef _GST_GL_MEMORY_H_
|
|
Packit |
0652a1 |
#define _GST_GL_MEMORY_H_
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
#include <gst/gl/gstglbasememory.h>
|
|
Packit |
0652a1 |
#include <gst/gl/gstglformat.h>
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
G_BEGIN_DECLS
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
#define GST_TYPE_GL_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_type())
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GType gst_gl_memory_allocator_get_type(void);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
#define GST_IS_GL_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR))
|
|
Packit |
0652a1 |
#define GST_IS_GL_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GL_MEMORY_ALLOCATOR))
|
|
Packit |
0652a1 |
#define GST_GL_MEMORY_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocatorClass))
|
|
Packit |
0652a1 |
#define GST_GL_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocator))
|
|
Packit |
0652a1 |
#define GST_GL_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_MEMORY_ALLOCATOR, GstGLMemoryAllocatorClass))
|
|
Packit |
0652a1 |
#define GST_GL_MEMORY_ALLOCATOR_CAST(obj) ((GstGLMemoryAllocator *)(obj))
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
#define GST_GL_MEMORY_CAST(obj) ((GstGLMemory *) obj)
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/**
|
|
Packit |
0652a1 |
* GST_CAPS_FEATURE_MEMORY_GL_MEMORY:
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* Name of the caps feature for indicating the use of #GstGLMemory
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
#define GST_CAPS_FEATURE_MEMORY_GL_MEMORY "memory:GLMemory"
|
|
Packit |
0652a1 |
/**
|
|
Packit |
0652a1 |
* GST_GL_MEMORY_VIDEO_FORMATS_STR:
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* List of video formats that are supported by #GstGLMemory
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
#define GST_GL_MEMORY_VIDEO_FORMATS_STR \
|
|
Packit |
0652a1 |
"{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, RGB, BGR, RGB16, BGR16, " \
|
|
Packit |
0652a1 |
"AYUV, VUYA, I420, YV12, NV12, NV21, YUY2, UYVY, Y41B, Y42B, Y444, " \
|
|
Packit |
0652a1 |
"GRAY8, GRAY16_LE, GRAY16_BE, ARGB64 }"
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/**
|
|
Packit |
0652a1 |
* GstGLMemory:
|
|
Packit |
0652a1 |
* @mem: the parent #GstGLBaseMemory object
|
|
Packit |
0652a1 |
* @tex_id: the GL texture id for this memory
|
|
Packit |
0652a1 |
* @tex_target: the GL texture target for this memory
|
|
Packit |
0652a1 |
* @tex_format: the texture type
|
|
Packit |
0652a1 |
* @info: the texture's #GstVideoInfo
|
|
Packit |
0652a1 |
* @valign: data alignment for system memory mapping
|
|
Packit |
0652a1 |
* @plane: data plane in @info
|
|
Packit |
0652a1 |
* @tex_scaling: GL shader scaling parameters for @valign and/or width/height
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* Represents information about a GL texture
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
struct _GstGLMemory
|
|
Packit |
0652a1 |
{
|
|
Packit |
0652a1 |
GstGLBaseMemory mem;
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
guint tex_id;
|
|
Packit |
0652a1 |
GstGLTextureTarget tex_target;
|
|
Packit |
0652a1 |
GstGLFormat tex_format;
|
|
Packit |
0652a1 |
GstVideoInfo info;
|
|
Packit |
0652a1 |
GstVideoAlignment valign;
|
|
Packit |
0652a1 |
guint plane;
|
|
Packit |
0652a1 |
gfloat tex_scaling[2];
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/* <protected> */
|
|
Packit |
0652a1 |
gboolean texture_wrapped;
|
|
Packit |
0652a1 |
guint unpack_length;
|
|
Packit |
0652a1 |
guint tex_width;
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/* <private> */
|
|
Packit |
0652a1 |
gpointer _padding[GST_PADDING];
|
|
Packit |
0652a1 |
};
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
#define GST_TYPE_GL_VIDEO_ALLOCATION_PARAMS (gst_gl_video_allocation_params_get_type())
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GType gst_gl_video_allocation_params_get_type (void);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
typedef struct _GstGLVideoAllocationParams GstGLVideoAllocationParams;
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/**
|
|
Packit |
0652a1 |
* GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO:
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* GL allocation flag indicating the allocation of 2D video frames
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
#define GST_GL_ALLOCATION_PARAMS_ALLOC_FLAG_VIDEO (1 << 3)
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/**
|
|
Packit |
0652a1 |
* GstGLVideoAllocationParams:
|
|
Packit |
0652a1 |
* @parent: the parent #GstGLAllocationParams structure
|
|
Packit |
0652a1 |
* @v_info: the #GstVideoInfo to allocate
|
|
Packit |
0652a1 |
* @plane: the video plane index to allocate
|
|
Packit |
0652a1 |
* @valign: the #GstVideoAlignment to align the system representation to (may be %NULL for the default)
|
|
Packit |
0652a1 |
* @target: the #GstGLTextureTarget to allocate
|
|
Packit |
0652a1 |
* @tex_format: the #GstGLFormat to allocate
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
struct _GstGLVideoAllocationParams
|
|
Packit |
0652a1 |
{
|
|
Packit |
0652a1 |
GstGLAllocationParams parent;
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GstVideoInfo *v_info;
|
|
Packit |
0652a1 |
guint plane;
|
|
Packit |
0652a1 |
GstVideoAlignment *valign;
|
|
Packit |
0652a1 |
GstGLTextureTarget target;
|
|
Packit |
0652a1 |
GstGLFormat tex_format;
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/* <private> */
|
|
Packit |
0652a1 |
gpointer _padding[GST_PADDING];
|
|
Packit |
0652a1 |
};
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
gboolean gst_gl_video_allocation_params_init_full (GstGLVideoAllocationParams * params,
|
|
Packit |
0652a1 |
gsize struct_size,
|
|
Packit |
0652a1 |
guint alloc_flags,
|
|
Packit |
0652a1 |
GstGLAllocationParamsCopyFunc copy,
|
|
Packit |
0652a1 |
GstGLAllocationParamsFreeFunc free,
|
|
Packit |
0652a1 |
GstGLContext * context,
|
|
Packit |
0652a1 |
GstAllocationParams * alloc_params,
|
|
Packit |
0652a1 |
GstVideoInfo * v_info,
|
|
Packit |
0652a1 |
guint plane,
|
|
Packit |
0652a1 |
GstVideoAlignment * valign,
|
|
Packit |
0652a1 |
GstGLTextureTarget target,
|
|
Packit |
0652a1 |
GstGLFormat tex_format,
|
|
Packit |
0652a1 |
gpointer wrapped_data,
|
|
Packit |
0652a1 |
gpointer gl_handle,
|
|
Packit |
0652a1 |
gpointer user_data,
|
|
Packit |
0652a1 |
GDestroyNotify notify);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new (GstGLContext * context,
|
|
Packit |
0652a1 |
GstAllocationParams * alloc_params,
|
|
Packit |
0652a1 |
GstVideoInfo * v_info,
|
|
Packit |
0652a1 |
guint plane,
|
|
Packit |
0652a1 |
GstVideoAlignment * valign,
|
|
Packit |
0652a1 |
GstGLTextureTarget target,
|
|
Packit |
0652a1 |
GstGLFormat tex_format);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_data (GstGLContext * context,
|
|
Packit |
0652a1 |
GstAllocationParams * alloc_params,
|
|
Packit |
0652a1 |
GstVideoInfo * v_info,
|
|
Packit |
0652a1 |
guint plane,
|
|
Packit |
0652a1 |
GstVideoAlignment * valign,
|
|
Packit |
0652a1 |
GstGLTextureTarget target,
|
|
Packit |
0652a1 |
GstGLFormat tex_format,
|
|
Packit |
0652a1 |
gpointer wrapped_data,
|
|
Packit |
0652a1 |
gpointer user_data,
|
|
Packit |
0652a1 |
GDestroyNotify notify);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_texture (GstGLContext * context,
|
|
Packit |
0652a1 |
GstAllocationParams * alloc_params,
|
|
Packit |
0652a1 |
GstVideoInfo * v_info,
|
|
Packit |
0652a1 |
guint plane,
|
|
Packit |
0652a1 |
GstVideoAlignment * valign,
|
|
Packit |
0652a1 |
GstGLTextureTarget target,
|
|
Packit |
0652a1 |
GstGLFormat tex_format,
|
|
Packit |
0652a1 |
guint tex_id,
|
|
Packit |
0652a1 |
gpointer user_data,
|
|
Packit |
0652a1 |
GDestroyNotify notify);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GstGLVideoAllocationParams * gst_gl_video_allocation_params_new_wrapped_gl_handle (GstGLContext * context,
|
|
Packit |
0652a1 |
GstAllocationParams * alloc_params,
|
|
Packit |
0652a1 |
GstVideoInfo * v_info,
|
|
Packit |
0652a1 |
guint plane,
|
|
Packit |
0652a1 |
GstVideoAlignment * valign,
|
|
Packit |
0652a1 |
GstGLTextureTarget target,
|
|
Packit |
0652a1 |
GstGLFormat tex_format,
|
|
Packit |
0652a1 |
gpointer gl_handle,
|
|
Packit |
0652a1 |
gpointer user_data,
|
|
Packit |
0652a1 |
GDestroyNotify notify);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/* subclass usage */
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
void gst_gl_video_allocation_params_free_data (GstGLVideoAllocationParams * params);
|
|
Packit |
0652a1 |
/* subclass usage */
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
void gst_gl_video_allocation_params_copy_data (GstGLVideoAllocationParams * src_vid,
|
|
Packit |
0652a1 |
GstGLVideoAllocationParams * dest_vid);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/**
|
|
Packit |
0652a1 |
* GstGLMemoryAllocator
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* Opaque #GstGLMemoryAllocator struct
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
struct _GstGLMemoryAllocator
|
|
Packit |
0652a1 |
{
|
|
Packit |
0652a1 |
/* <private> */
|
|
Packit |
0652a1 |
GstGLBaseMemoryAllocator parent;
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
gpointer _padding[GST_PADDING];
|
|
Packit |
0652a1 |
};
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/**
|
|
Packit |
0652a1 |
* GstGLMemoryAllocatorClass:
|
|
Packit |
0652a1 |
* @map: provide a custom map implementation
|
|
Packit |
0652a1 |
* @copy: provide a custom copy implementation
|
|
Packit |
0652a1 |
* @unmap: provide a custom unmap implementation
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
struct _GstGLMemoryAllocatorClass
|
|
Packit |
0652a1 |
{
|
|
Packit |
0652a1 |
/* <private> */
|
|
Packit |
0652a1 |
GstGLBaseMemoryAllocatorClass parent_class;
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/* <public> */
|
|
Packit |
0652a1 |
GstGLBaseMemoryAllocatorMapFunction map;
|
|
Packit |
0652a1 |
GstGLBaseMemoryAllocatorCopyFunction copy;
|
|
Packit |
0652a1 |
GstGLBaseMemoryAllocatorUnmapFunction unmap;
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/* <private> */
|
|
Packit |
0652a1 |
gpointer _padding[GST_PADDING];
|
|
Packit |
0652a1 |
};
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
#include <gst/gl/gstglbasememory.h>
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/**
|
|
Packit |
0652a1 |
* GST_GL_MEMORY_ALLOCATOR_NAME:
|
|
Packit |
0652a1 |
*
|
|
Packit |
0652a1 |
* The name of the GL memory allocator
|
|
Packit |
0652a1 |
*/
|
|
Packit |
0652a1 |
#define GST_GL_MEMORY_ALLOCATOR_NAME "GLMemory"
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
void gst_gl_memory_init_once (void);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
gboolean gst_is_gl_memory (GstMemory * mem);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
void gst_gl_memory_init (GstGLMemory * mem,
|
|
Packit |
0652a1 |
GstAllocator * allocator,
|
|
Packit |
0652a1 |
GstMemory * parent,
|
|
Packit |
0652a1 |
GstGLContext * context,
|
|
Packit |
0652a1 |
GstGLTextureTarget target,
|
|
Packit |
0652a1 |
GstGLFormat tex_format,
|
|
Packit |
0652a1 |
GstAllocationParams *params,
|
|
Packit |
0652a1 |
GstVideoInfo * info,
|
|
Packit |
0652a1 |
guint plane,
|
|
Packit |
0652a1 |
GstVideoAlignment *valign,
|
|
Packit |
0652a1 |
gpointer user_data,
|
|
Packit |
0652a1 |
GDestroyNotify notify);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
gboolean gst_gl_memory_copy_into (GstGLMemory *gl_mem,
|
|
Packit |
0652a1 |
guint tex_id,
|
|
Packit |
0652a1 |
GstGLTextureTarget target,
|
|
Packit |
0652a1 |
GstGLFormat tex_format,
|
|
Packit |
0652a1 |
gint width,
|
|
Packit |
0652a1 |
gint height);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
gboolean gst_gl_memory_copy_teximage (GstGLMemory * src,
|
|
Packit |
0652a1 |
guint tex_id,
|
|
Packit |
0652a1 |
GstGLTextureTarget out_target,
|
|
Packit |
0652a1 |
GstGLFormat out_tex_format,
|
|
Packit |
0652a1 |
gint out_width,
|
|
Packit |
0652a1 |
gint out_height);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
gboolean gst_gl_memory_read_pixels (GstGLMemory * gl_mem,
|
|
Packit |
0652a1 |
gpointer read_pointer);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
void gst_gl_memory_texsubimage (GstGLMemory * gl_mem,
|
|
Packit |
0652a1 |
gpointer read_pointer);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
/* accessors */
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
gint gst_gl_memory_get_texture_width (GstGLMemory * gl_mem);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
gint gst_gl_memory_get_texture_height (GstGLMemory * gl_mem);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GstGLFormat gst_gl_memory_get_texture_format (GstGLMemory * gl_mem);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GstGLTextureTarget gst_gl_memory_get_texture_target (GstGLMemory * gl_mem);
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
guint gst_gl_memory_get_texture_id (GstGLMemory * gl_mem);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
gboolean gst_gl_memory_setup_buffer (GstGLMemoryAllocator * allocator,
|
|
Packit |
0652a1 |
GstBuffer * buffer,
|
|
Packit |
0652a1 |
GstGLVideoAllocationParams * params,
|
|
Packit |
0652a1 |
GstGLFormat *tex_formats,
|
|
Packit |
0652a1 |
gpointer *wrapped_data,
|
|
Packit |
0652a1 |
gsize n_wrapped_pointers);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
GST_GL_API
|
|
Packit |
0652a1 |
GstGLMemoryAllocator * gst_gl_memory_allocator_get_default (GstGLContext *context);
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
G_END_DECLS
|
|
Packit |
0652a1 |
|
|
Packit |
0652a1 |
#endif /* _GST_GL_MEMORY_H_ */
|