GstGLMemory

GstGLMemory — memory subclass for GL textures

Functions

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GstObject
            ╰── GstAllocator
                ╰── GstGLBaseBufferAllocator
                    ╰── GstGLAllocator

Description

GstGLMemory is a GstGLBaseBuffer subclass providing support for the mapping of GL textures.

GstGLMemory is created through gst_gl_memory_alloc() or system memory can be wrapped through gst_gl_memory_wrapped().

Data is uploaded or downloaded from the GPU as is necessary.

Functions

gst_gl_memory_init ()

void
gst_gl_memory_init (void);

Initializes the GL Memory allocator. It is safe to call this function multiple times. This must be called before any other GstGLMemory operation.


gst_gl_memory_alloc ()

GstMemory *
gst_gl_memory_alloc (GstGLContext *context,
                     GstAllocationParams *params,
                     GstVideoInfo *info,
                     guint plane,
                     GstVideoAlignment *valign);

Allocated a new GstGlMemory.

Parameters

context

a GstGLContext

 

params

a GstAllocationParams

 

info

the GstVideoInfo of the memory

 

plane

the plane this memory will represent

 

valign

the GstVideoAlignment applied to info

 

Returns

a GstMemory object with a GL texture specified by vinfo from context


gst_gl_memory_wrapped ()

GstGLMemory *
gst_gl_memory_wrapped (GstGLContext *context,
                       GstVideoInfo *info,
                       guint plane,
                       GstVideoAlignment *valign,
                       gpointer data,
                       gpointer user_data,
                       GDestroyNotify notify);

Wrapped data into a GstGLMemory. This version will account for padding added to the allocation and expressed through valign .

Parameters

context

a GstGLContext

 

info

the GstVideoInfo of the memory and data

 

plane

the plane this memory will represent

 

valign

the GstVideoAlignment applied to info

 

data

the data to wrap

 

user_data

data called with for notify

 

notify

function called with user_data when data needs to be freed

 

Returns

a GstGLMemory object with a GL texture specified by v_info from context and contents specified by data


gst_gl_memory_wrapped_texture ()

GstGLMemory *
gst_gl_memory_wrapped_texture (GstGLContext *context,
                               guint texture_id,
                               guint texture_target,
                               GstVideoInfo *info,
                               guint plane,
                               GstVideoAlignment *valign,
                               gpointer user_data,
                               GDestroyNotify notify);

Wraps a texture handle into a GstGLMemory.

Parameters

context

a GstGLContext

 

texture_id

the GL texture handle

 

texture_target

the GL texture target

 

info

the GstVideoInfo of the memory

 

plane

The plane this memory will represent

 

user_data

user data

 

notify

Destroy callback for the user data

 

Returns

a newly allocated GstGLMemory


gst_gl_memory_copy_into_texture ()

gboolean
gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem,
                                 guint tex_id,
                                 GstVideoGLTextureType tex_type,
                                 gint width,
                                 gint height,
                                 gint stride,
                                 gboolean respecify);

Copies gl_mem into the texture specfified by tex_id . The format of tex_id is specified by tex_type , width and height .

If respecify is TRUE, then the copy is performed in terms of the texture data. This is useful for splitting RGBA textures into RG or R textures or vice versa. The requirement for this to succeed is that the backing texture data must be the same size, i.e. say a RGBA8 texture is converted into a RG8 texture, then the RG texture must have twice as many pixels available for output as the RGBA texture.

Otherwise, if respecify is FALSE, then the copy is performed per texel using glCopyTexImage. See the OpenGL specification for details on the mappings between texture formats.

Parameters

gl_mem

a GstGLMemory

 

tex_id

OpenGL texture id

 

tex_type

a GstVideoGLTextureType

 

width

width of tex_id

 

height

height of tex_id

 

stride

stride of the backing texture data

 

respecify

whether to copy the data or copy per texel

 

Returns

Whether the copy suceeded


gst_gl_memory_setup_buffer ()

gboolean
gst_gl_memory_setup_buffer (GstGLContext *context,
                            GstAllocationParams *params,
                            GstVideoInfo *info,
                            GstVideoAlignment *valign,
                            GstBuffer *buffer);

Adds the required GstGLMemorys with the correct configuration to buffer based on info . This version handles padding through valign .

Parameters

context

a GstGLContext

 

params

a GstAllocationParams

 

info

a GstVideoInfo

 

valign

the GstVideoAlignment applied to info

 

buffer

a GstBuffer

 

Returns

whether the memory's were sucessfully added.


gst_gl_memory_setup_wrapped ()

gboolean
gst_gl_memory_setup_wrapped (GstGLContext *context,
                             GstVideoInfo *info,
                             GstVideoAlignment *valign,
                             gpointer data[GST_VIDEO_MAX_PLANES],
                             GstGLMemory *textures[GST_VIDEO_MAX_PLANES]);

Wraps per plane data pointer in data into the corresponding entry in textures based on info and padding from valign .

Parameters

context

a GstGLContext

 

info

a GstVideoInfo

 

valign

a GstVideoInfo

 

data

a list of per plane data pointers

 

textures

a list of GstGLMemory.

[transfer out]

Returns

whether the memory's were sucessfully created.


gst_gl_texture_type_from_format ()

GstVideoGLTextureType
gst_gl_texture_type_from_format (GstGLContext *context,
                                 GstVideoFormat v_format,
                                 guint plane);

gst_is_gl_memory ()

gboolean
gst_is_gl_memory (GstMemory *mem);

Parameters

mem

a GstMemory

 

Returns

whether the memory at mem is a GstGLMemory

Types and Values

GstGLAllocator

typedef struct _GstGLAllocator GstGLAllocator;

Opaque GstGLAllocator struct


GstGLAllocatorClass

typedef struct {
  GstGLBaseBufferAllocatorClass parent_class;
} GstGLAllocatorClass;

The GstGLAllocatorClass only contains private data


GST_GL_MEMORY_ALLOCATOR

#define GST_GL_MEMORY_ALLOCATOR   "GLMemory"

The name of the GL memory allocator


GstGLMemory

typedef struct {
  GstGLBaseBuffer       mem;

  guint                 tex_id;
  guint                 tex_target;
  GstVideoGLTextureType tex_type;
  GstVideoInfo          info;
  GstVideoAlignment     valign;
  guint                 plane;
  gfloat                tex_scaling[2];
} GstGLMemory;

Represents information about a GL texture

Members

GstGLBaseBuffer mem;

the parent object

 

guint tex_id;

the GL texture id for this memory

 

guint tex_target;

the GL texture target for this memory

 

GstVideoGLTextureType tex_type;

the texture type

 

GstVideoInfo info;

the texture's GstVideoInfo

 

GstVideoAlignment valign;

data alignment for system memory mapping

 

guint plane;

data plane in info

 

gfloat tex_scaling[2];

GL shader scaling parameters for valign and/or width/height

 

See Also

GstMemory, GstAllocator, GstGLBufferPool