Blame gst-libs/gst/gl/gstglmemory.h

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