mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
videometa: Extend GstVideoGLTextureUploadMeta
https://bugzilla.gnome.org/show_bug.cgi?id=697112
This commit is contained in:
parent
e96ca66c36
commit
74f6376c53
2 changed files with 67 additions and 14 deletions
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "gstvideometa.h"
|
#include "gstvideometa.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_video_meta_transform (GstBuffer * dest, GstMeta * meta,
|
gst_video_meta_transform (GstBuffer * dest, GstMeta * meta,
|
||||||
GstBuffer * buffer, GQuark type, gpointer data)
|
GstBuffer * buffer, GQuark type, gpointer data)
|
||||||
|
@ -430,6 +432,10 @@ gst_video_gl_texture_upload_meta_transform (GstBuffer * dest, GstMeta * meta,
|
||||||
if (!dmeta)
|
if (!dmeta)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
dmeta->texture_orientation = smeta->texture_orientation;
|
||||||
|
dmeta->n_textures = smeta->n_textures;
|
||||||
|
memcpy (dmeta->texture_type, smeta->texture_type,
|
||||||
|
sizeof (smeta->texture_type[0] * 4));
|
||||||
dmeta->buffer = dest;
|
dmeta->buffer = dest;
|
||||||
dmeta->upload = smeta->upload;
|
dmeta->upload = smeta->upload;
|
||||||
dmeta->user_data = smeta->user_data;
|
dmeta->user_data = smeta->user_data;
|
||||||
|
@ -475,13 +481,16 @@ gst_video_gl_texture_upload_meta_get_info (void)
|
||||||
*/
|
*/
|
||||||
GstVideoGLTextureUploadMeta *
|
GstVideoGLTextureUploadMeta *
|
||||||
gst_buffer_add_video_gl_texture_upload_meta (GstBuffer * buffer,
|
gst_buffer_add_video_gl_texture_upload_meta (GstBuffer * buffer,
|
||||||
GstVideoGLTextureUpload upload, gpointer user_data,
|
GstVideoGLTextureOrientation texture_orientation, guint n_textures,
|
||||||
GBoxedCopyFunc user_data_copy, GBoxedFreeFunc user_data_free)
|
GstVideoGLTextureType texture_type[4], GstVideoGLTextureUpload upload,
|
||||||
|
gpointer user_data, GBoxedCopyFunc user_data_copy,
|
||||||
|
GBoxedFreeFunc user_data_free)
|
||||||
{
|
{
|
||||||
GstVideoGLTextureUploadMeta *meta;
|
GstVideoGLTextureUploadMeta *meta;
|
||||||
|
|
||||||
g_return_val_if_fail (buffer != NULL, NULL);
|
g_return_val_if_fail (buffer != NULL, NULL);
|
||||||
g_return_val_if_fail (upload != NULL, NULL);
|
g_return_val_if_fail (upload != NULL, NULL);
|
||||||
|
g_return_val_if_fail (n_textures > 0 && n_textures < 5, NULL);
|
||||||
|
|
||||||
meta =
|
meta =
|
||||||
(GstVideoGLTextureUploadMeta *) gst_buffer_add_meta (buffer,
|
(GstVideoGLTextureUploadMeta *) gst_buffer_add_meta (buffer,
|
||||||
|
@ -490,6 +499,9 @@ gst_buffer_add_video_gl_texture_upload_meta (GstBuffer * buffer,
|
||||||
if (!meta)
|
if (!meta)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
meta->texture_orientation = texture_orientation;
|
||||||
|
meta->n_textures = n_textures;
|
||||||
|
memcpy (meta->texture_type, texture_type, sizeof (texture_type[0] * 4));
|
||||||
meta->buffer = buffer;
|
meta->buffer = buffer;
|
||||||
meta->upload = upload;
|
meta->upload = upload;
|
||||||
meta->user_data = user_data;
|
meta->user_data = user_data;
|
||||||
|
@ -502,8 +514,7 @@ gst_buffer_add_video_gl_texture_upload_meta (GstBuffer * buffer,
|
||||||
/**
|
/**
|
||||||
* gst_video_gl_texture_upload_meta_upload:
|
* gst_video_gl_texture_upload_meta_upload:
|
||||||
* @meta: a #GstVideoGLTextureUploadMeta
|
* @meta: a #GstVideoGLTextureUploadMeta
|
||||||
* @format: the GL format of the texture, e.g. GL_RGBA
|
* @texture_id: the texture IDs to upload to
|
||||||
* @texture_id: the texture ID to upload to
|
|
||||||
*
|
*
|
||||||
* Uploads the buffer which owns the meta to a specific texture ID.
|
* Uploads the buffer which owns the meta to a specific texture ID.
|
||||||
*
|
*
|
||||||
|
@ -511,9 +522,9 @@ gst_buffer_add_video_gl_texture_upload_meta (GstBuffer * buffer,
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta * meta,
|
gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta * meta,
|
||||||
guint format, guint texture_id)
|
guint texture_id[4])
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (meta != NULL, FALSE);
|
g_return_val_if_fail (meta != NULL, FALSE);
|
||||||
|
|
||||||
return meta->upload (meta, format, texture_id);
|
return meta->upload (meta, texture_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,22 +140,59 @@ typedef struct {
|
||||||
GstVideoInfo *out_info;
|
GstVideoInfo *out_info;
|
||||||
} GstVideoMetaTransform;
|
} GstVideoMetaTransform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVideoGLTextureType:
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE: Luminance texture, GL_LUMINANCE
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA: Luminance-alpha texture, GL_LUMINANCE_ALPHA
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_TYPE_RGB16: RGB 565 texture, GL_RGB
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_TYPE_RGB: RGB texture, GL_RGB
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_TYPE_RGBA: RGBA texture, GL_RGBA
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_TYPE_R: R texture, GL_RED_EXT
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_TYPE_RG: RG texture, GL_RG_EXT
|
||||||
|
*
|
||||||
|
* The GL texture type.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE,
|
||||||
|
GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
|
||||||
|
GST_VIDEO_GL_TEXTURE_TYPE_RGB16,
|
||||||
|
GST_VIDEO_GL_TEXTURE_TYPE_RGB,
|
||||||
|
GST_VIDEO_GL_TEXTURE_TYPE_RGBA,
|
||||||
|
GST_VIDEO_GL_TEXTURE_TYPE_R,
|
||||||
|
GST_VIDEO_GL_TEXTURE_TYPE_RG
|
||||||
|
} GstVideoGLTextureType;
|
||||||
|
|
||||||
|
/** GstVideoGLTextureOrientation:
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL: Top line first in memory, left row first
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP: Bottom line first in memory, left row first
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL: Top line first in memory, right row first
|
||||||
|
* @GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP: Bottom line first in memory, right row first
|
||||||
|
*
|
||||||
|
* The orientation of the GL texture.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL,
|
||||||
|
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP,
|
||||||
|
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL,
|
||||||
|
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP
|
||||||
|
} GstVideoGLTextureOrientation;
|
||||||
|
|
||||||
#define GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE (gst_video_gl_texture_upload_meta_api_get_type())
|
#define GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE (gst_video_gl_texture_upload_meta_api_get_type())
|
||||||
#define GST_VIDEO_GL_TEXTURE_UPLOAD_META_INFO (gst_video_gl_texture_upload_meta_get_info())
|
#define GST_VIDEO_GL_TEXTURE_UPLOAD_META_INFO (gst_video_gl_texture_upload_meta_get_info())
|
||||||
|
|
||||||
typedef struct _GstVideoGLTextureUploadMeta GstVideoGLTextureUploadMeta;
|
typedef struct _GstVideoGLTextureUploadMeta GstVideoGLTextureUploadMeta;
|
||||||
typedef gboolean (*GstVideoGLTextureUpload) (GstVideoGLTextureUploadMeta *meta, guint format, guint texture_id);
|
typedef gboolean (*GstVideoGLTextureUpload) (GstVideoGLTextureUploadMeta *meta, guint texture_id[4]);
|
||||||
|
|
||||||
#define GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META "meta:GstVideoGLTextureUploadMeta"
|
#define GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META "meta:GstVideoGLTextureUploadMeta"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstVideoGLTextureUploadMeta:
|
* GstVideoGLTextureUploadMeta:
|
||||||
* @meta: parent #GstMeta
|
* @meta: parent #GstMeta
|
||||||
* @buffer: the buffer of this meta
|
* @texture_orientation: Orientation of the textures
|
||||||
* @upload: the function to upload the buffer to a specific texture ID
|
* @n_textures: Number of textures that are generated
|
||||||
* @user_data: user data for the implementor of @upload
|
* @texture_type: Type of each texture
|
||||||
* @user_data_copy: function to copy @user_data
|
|
||||||
* @user_data_free: function to free @user_data
|
|
||||||
*
|
*
|
||||||
* Extra buffer metadata for uploading a buffer to an OpenGL texture
|
* Extra buffer metadata for uploading a buffer to an OpenGL texture
|
||||||
* ID. The caller of gst_video_gl_texture_upload_meta_upload() must
|
* ID. The caller of gst_video_gl_texture_upload_meta_upload() must
|
||||||
|
@ -166,6 +203,11 @@ typedef gboolean (*GstVideoGLTextureUpload) (GstVideoGLTextureUploadMeta *meta,
|
||||||
struct _GstVideoGLTextureUploadMeta {
|
struct _GstVideoGLTextureUploadMeta {
|
||||||
GstMeta meta;
|
GstMeta meta;
|
||||||
|
|
||||||
|
GstVideoGLTextureOrientation texture_orientation;
|
||||||
|
guint n_textures;
|
||||||
|
GstVideoGLTextureType texture_type[4];
|
||||||
|
|
||||||
|
/* <private> */
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstVideoGLTextureUpload upload;
|
GstVideoGLTextureUpload upload;
|
||||||
|
|
||||||
|
@ -175,8 +217,8 @@ struct _GstVideoGLTextureUploadMeta {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define gst_buffer_get_video_gl_texture_upload_meta(b) ((GstVideoGLTextureUploadMeta*)gst_buffer_get_meta((b),GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE))
|
#define gst_buffer_get_video_gl_texture_upload_meta(b) ((GstVideoGLTextureUploadMeta*)gst_buffer_get_meta((b),GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE))
|
||||||
GstVideoGLTextureUploadMeta * gst_buffer_add_video_gl_texture_upload_meta (GstBuffer *buffer, GstVideoGLTextureUpload upload, gpointer user_data, GBoxedCopyFunc copy_user_data, GBoxedFreeFunc free_user_data);
|
GstVideoGLTextureUploadMeta * gst_buffer_add_video_gl_texture_upload_meta (GstBuffer *buffer, GstVideoGLTextureOrientation texture_orientation, guint n_textures, GstVideoGLTextureType texture_type[4], GstVideoGLTextureUpload upload, gpointer user_data, GBoxedCopyFunc user_data_copy, GBoxedFreeFunc user_data_free);
|
||||||
gboolean gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta *meta, guint format, guint texture_id);
|
gboolean gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMeta *meta, guint texture_id[4]);
|
||||||
|
|
||||||
GType gst_video_gl_texture_upload_meta_api_get_type (void);
|
GType gst_video_gl_texture_upload_meta_api_get_type (void);
|
||||||
const GstMetaInfo * gst_video_gl_texture_upload_meta_get_info (void);
|
const GstMetaInfo * gst_video_gl_texture_upload_meta_get_info (void);
|
||||||
|
|
Loading…
Reference in a new issue