glmemory: add support for rectangle textures
Add the various tokens/strings for the differnet texture types (2D, rect, oes) Changes the GLmemory api to include the GstGLTextureTarget in all relevant functions. Update the relevant caps/templates for 2D only textures.
This commit is contained in:
parent
ff87ffe6e6
commit
e61d504556
@ -167,9 +167,12 @@ static GstStaticPadTemplate gst_ca_opengl_layer_sink_template =
|
|||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
|
||||||
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
"format = (string) RGBA, "
|
||||||
"RGBA"))
|
"width = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"height = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ","
|
||||||
|
"texture-target = (string) 2D")
|
||||||
);
|
);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -58,15 +58,13 @@ static GstStaticPadTemplate gst_gl_color_convert_element_src_pad_template =
|
|||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_GL_COLOR_CONVERT_VIDEO_CAPS ";"
|
GST_STATIC_CAPS (GST_GL_COLOR_CONVERT_VIDEO_CAPS));
|
||||||
GST_GL_COLOR_CONVERT_VIDEO_OVERLAY_COMPOSITION_CAPS));
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_gl_color_convert_element_sink_pad_template =
|
static GstStaticPadTemplate gst_gl_color_convert_element_sink_pad_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_GL_COLOR_CONVERT_VIDEO_CAPS ";"
|
GST_STATIC_CAPS (GST_GL_COLOR_CONVERT_VIDEO_CAPS));
|
||||||
GST_GL_COLOR_CONVERT_VIDEO_OVERLAY_COMPOSITION_CAPS));
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_gl_color_convert_element_stop (GstBaseTransform * bt)
|
gst_gl_color_convert_element_stop (GstBaseTransform * bt)
|
||||||
|
@ -321,17 +321,26 @@ static void gst_glimage_sink_handle_events (GstVideoOverlay * overlay,
|
|||||||
static gboolean update_output_format (GstGLImageSink * glimage_sink);
|
static gboolean update_output_format (GstGLImageSink * glimage_sink);
|
||||||
|
|
||||||
#define GST_GL_SINK_CAPS \
|
#define GST_GL_SINK_CAPS \
|
||||||
GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, "RGBA")
|
"video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), " \
|
||||||
|
"format = (string) RGBA, " \
|
||||||
#define GST_GL_SINK_OVERLAY_CAPS \
|
"width = " GST_VIDEO_SIZE_RANGE ", " \
|
||||||
GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_GL_MEMORY "," \
|
"height = " GST_VIDEO_SIZE_RANGE ", " \
|
||||||
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, "RGBA")
|
"framerate = " GST_VIDEO_FPS_RANGE ", " \
|
||||||
|
"texture-target = (string) 2D " \
|
||||||
|
" ; " \
|
||||||
|
"video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "," \
|
||||||
|
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION "), " \
|
||||||
|
"format = (string) RGBA, " \
|
||||||
|
"width = " GST_VIDEO_SIZE_RANGE ", " \
|
||||||
|
"height = " GST_VIDEO_SIZE_RANGE ", " \
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ", " \
|
||||||
|
"texture-target = (string) 2D "
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_glimage_sink_template =
|
static GstStaticPadTemplate gst_glimage_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_GL_SINK_CAPS ";" GST_GL_SINK_OVERLAY_CAPS));
|
GST_STATIC_CAPS (GST_GL_SINK_CAPS));
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -698,7 +698,7 @@ gst_gl_overlay_load_jpeg (GstGLOverlay * overlay, FILE * fp)
|
|||||||
|
|
||||||
overlay->image_memory = (GstGLMemory *)
|
overlay->image_memory = (GstGLMemory *)
|
||||||
gst_gl_memory_alloc (GST_GL_BASE_FILTER (overlay)->context,
|
gst_gl_memory_alloc (GST_GL_BASE_FILTER (overlay)->context,
|
||||||
NULL, &v_info, 0, &v_align);
|
GST_GL_TEXTURE_TARGET_2D, NULL, &v_info, 0, &v_align);
|
||||||
|
|
||||||
if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info,
|
if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info,
|
||||||
GST_MAP_WRITE)) {
|
GST_MAP_WRITE)) {
|
||||||
@ -803,7 +803,7 @@ gst_gl_overlay_load_png (GstGLOverlay * overlay, FILE * fp)
|
|||||||
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, width, height);
|
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, width, height);
|
||||||
overlay->image_memory = (GstGLMemory *)
|
overlay->image_memory = (GstGLMemory *)
|
||||||
gst_gl_memory_alloc (GST_GL_BASE_FILTER (overlay)->context,
|
gst_gl_memory_alloc (GST_GL_BASE_FILTER (overlay)->context,
|
||||||
NULL, &v_info, 0, NULL);
|
GST_GL_TEXTURE_TARGET_2D, NULL, &v_info, 0, NULL);
|
||||||
|
|
||||||
if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info,
|
if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info,
|
||||||
GST_MAP_WRITE)) {
|
GST_MAP_WRITE)) {
|
||||||
|
@ -58,9 +58,13 @@ enum
|
|||||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
|
||||||
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
"format = (string) RGBA, "
|
||||||
"RGBA") "; "
|
"width = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"height = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ","
|
||||||
|
"texture-target = (string) 2D"
|
||||||
|
"; "
|
||||||
GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
||||||
(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META,
|
(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META,
|
||||||
"RGBA")
|
"RGBA")
|
||||||
@ -70,9 +74,13 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|||||||
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u",
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%u",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_REQUEST,
|
GST_PAD_REQUEST,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
|
||||||
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
"format = (string) RGBA, "
|
||||||
"RGBA") "; "
|
"width = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"height = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ","
|
||||||
|
"texture-target = (string) 2D"
|
||||||
|
"; "
|
||||||
GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
||||||
(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META,
|
(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META,
|
||||||
"RGBA")
|
"RGBA")
|
||||||
|
@ -63,13 +63,18 @@ enum
|
|||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
|
||||||
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
"format = (string) RGBA, "
|
||||||
"RGBA"))
|
"width = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"height = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ","
|
||||||
|
"texture-target = (string) 2D")
|
||||||
);
|
);
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
#define gst_gl_test_src_parent_class parent_class
|
#define gst_gl_test_src_parent_class parent_class
|
||||||
G_DEFINE_TYPE (GstGLTestSrc, gst_gl_test_src, GST_TYPE_PUSH_SRC);
|
G_DEFINE_TYPE (GstGLTestSrc, gst_gl_test_src, GST_TYPE_PUSH_SRC);
|
||||||
|
@ -275,8 +275,8 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!gst_gl_memory_setup_buffer (glpool->context, &priv->params, info,
|
if (!gst_gl_memory_setup_buffer (glpool->context, priv->tex_target,
|
||||||
valign, buf))
|
&priv->params, info, valign, buf))
|
||||||
goto mem_create_failed;
|
goto mem_create_failed;
|
||||||
|
|
||||||
if (priv->add_uploadmeta)
|
if (priv->add_uploadmeta)
|
||||||
|
@ -1619,8 +1619,8 @@ _do_convert_one_view (GstGLContext * context, GstGLColorConvert * convert,
|
|||||||
|
|
||||||
if (!convert->priv->out_tex[j])
|
if (!convert->priv->out_tex[j])
|
||||||
convert->priv->out_tex[j] =
|
convert->priv->out_tex[j] =
|
||||||
(GstGLMemory *) gst_gl_memory_alloc (context, NULL, &temp_info, 0,
|
(GstGLMemory *) gst_gl_memory_alloc (context,
|
||||||
NULL);
|
convert->priv->to_texture_target, NULL, &temp_info, 0, NULL);
|
||||||
} else {
|
} else {
|
||||||
convert->priv->out_tex[j] = out_tex;
|
convert->priv->out_tex[j] = out_tex;
|
||||||
}
|
}
|
||||||
@ -1676,8 +1676,9 @@ out:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
gst_gl_memory_copy_into_texture (convert->priv->out_tex[j],
|
gst_gl_memory_copy_into_texture (convert->priv->out_tex[j],
|
||||||
out_tex->tex_id, out_tex->tex_type, mem_width, mem_height,
|
out_tex->tex_id, convert->priv->to_texture_target, out_tex->tex_type,
|
||||||
GST_VIDEO_INFO_PLANE_STRIDE (&out_tex->info, out_tex->plane), FALSE);
|
mem_width, mem_height, GST_VIDEO_INFO_PLANE_STRIDE (&out_tex->info,
|
||||||
|
out_tex->plane), FALSE);
|
||||||
gst_memory_unmap ((GstMemory *) convert->priv->out_tex[j], &from_info);
|
gst_memory_unmap ((GstMemory *) convert->priv->out_tex[j], &from_info);
|
||||||
gst_memory_unmap ((GstMemory *) out_tex, &to_info);
|
gst_memory_unmap ((GstMemory *) out_tex, &to_info);
|
||||||
} else {
|
} else {
|
||||||
@ -1720,8 +1721,9 @@ _do_convert (GstGLContext * context, GstGLColorConvert * convert)
|
|||||||
}
|
}
|
||||||
|
|
||||||
convert->outbuf = gst_buffer_new ();
|
convert->outbuf = gst_buffer_new ();
|
||||||
if (!gst_gl_memory_setup_buffer (convert->context, NULL, &convert->out_info,
|
if (!gst_gl_memory_setup_buffer (convert->context,
|
||||||
NULL, convert->outbuf)) {
|
convert->priv->to_texture_target, NULL, &convert->out_info, NULL,
|
||||||
|
convert->outbuf)) {
|
||||||
convert->priv->result = FALSE;
|
convert->priv->result = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -95,13 +95,20 @@ struct _GstGLColorConvertClass
|
|||||||
* The currently supported #GstCaps that can be converted
|
* The currently supported #GstCaps that can be converted
|
||||||
*/
|
*/
|
||||||
#define GST_GL_COLOR_CONVERT_VIDEO_CAPS \
|
#define GST_GL_COLOR_CONVERT_VIDEO_CAPS \
|
||||||
GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_GL_MEMORY, \
|
"video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), " \
|
||||||
GST_GL_COLOR_CONVERT_FORMATS)
|
"format = (string) " GST_GL_COLOR_CONVERT_FORMATS ", " \
|
||||||
|
"width = " GST_VIDEO_SIZE_RANGE ", " \
|
||||||
#define GST_GL_COLOR_CONVERT_VIDEO_OVERLAY_COMPOSITION_CAPS \
|
"height = " GST_VIDEO_SIZE_RANGE ", " \
|
||||||
GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_GL_MEMORY \
|
"framerate = " GST_VIDEO_FPS_RANGE ", " \
|
||||||
"," GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, \
|
"texture-target = (string) 2D " \
|
||||||
GST_GL_COLOR_CONVERT_FORMATS)
|
" ; " \
|
||||||
|
"video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "," \
|
||||||
|
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION "), " \
|
||||||
|
"format = (string) " GST_GL_COLOR_CONVERT_FORMATS ", " \
|
||||||
|
"width = " GST_VIDEO_SIZE_RANGE ", " \
|
||||||
|
"height = " GST_VIDEO_SIZE_RANGE ", " \
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ", " \
|
||||||
|
"texture-target = (string) 2D"
|
||||||
|
|
||||||
GstGLColorConvert * gst_gl_color_convert_new (GstGLContext * context);
|
GstGLColorConvert * gst_gl_color_convert_new (GstGLContext * context);
|
||||||
|
|
||||||
|
@ -35,24 +35,31 @@
|
|||||||
#define GST_CAT_DEFAULT gst_gl_filter_debug
|
#define GST_CAT_DEFAULT gst_gl_filter_debug
|
||||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
static GstStaticPadTemplate gst_gl_filter_src_pad_template =
|
static GstStaticPadTemplate gst_gl_filter_src_pad_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
|
||||||
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
"format = (string) RGBA, "
|
||||||
"RGBA"))
|
"width = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
);
|
"height = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ","
|
||||||
|
"texture-target = (string) 2D"
|
||||||
|
));
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_gl_filter_sink_pad_template =
|
static GstStaticPadTemplate gst_gl_filter_sink_pad_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
|
||||||
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
|
"format = (string) RGBA, "
|
||||||
"RGBA"))
|
"width = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
);
|
"height = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ","
|
||||||
|
"texture-target = (string) 2D"
|
||||||
|
));
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
/* Properties */
|
/* Properties */
|
||||||
enum
|
enum
|
||||||
|
@ -108,6 +108,13 @@ static GstAllocator *_gl_allocator;
|
|||||||
#define GL_UNPACK_ROW_LENGTH 0x0CF2
|
#define GL_UNPACK_ROW_LENGTH 0x0CF2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_TEXTURE_RECTANGLE
|
||||||
|
#define GL_TEXTURE_RECTANGLE 0x84F5
|
||||||
|
#endif
|
||||||
|
#ifndef GL_TEXTURE_EXTERNAL_OES
|
||||||
|
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
|
||||||
|
#endif
|
||||||
|
|
||||||
G_DEFINE_TYPE (GstGLAllocator, gst_gl_allocator,
|
G_DEFINE_TYPE (GstGLAllocator, gst_gl_allocator,
|
||||||
GST_TYPE_GL_BASE_BUFFER_ALLOCATOR);
|
GST_TYPE_GL_BASE_BUFFER_ALLOCATOR);
|
||||||
|
|
||||||
@ -119,7 +126,7 @@ typedef struct
|
|||||||
guint out_width, out_height;
|
guint out_width, out_height;
|
||||||
guint out_stride;
|
guint out_stride;
|
||||||
gboolean respecify;
|
gboolean respecify;
|
||||||
guint tex_target;
|
GstGLTextureTarget tex_target;
|
||||||
/* inout */
|
/* inout */
|
||||||
guint tex_id;
|
guint tex_id;
|
||||||
/* out */
|
/* out */
|
||||||
@ -360,6 +367,67 @@ gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gst_gl_texture_target_to_string (GstGLTextureTarget target)
|
||||||
|
{
|
||||||
|
switch (target) {
|
||||||
|
case GST_GL_TEXTURE_TARGET_2D:
|
||||||
|
return GST_GL_TEXTURE_TARGET_2D_STR;
|
||||||
|
case GST_GL_TEXTURE_TARGET_RECTANGLE:
|
||||||
|
return GST_GL_TEXTURE_TARGET_RECTANGLE_STR;
|
||||||
|
case GST_GL_TEXTURE_TARGET_EXTERNAL_OES:
|
||||||
|
return GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GstGLTextureTarget
|
||||||
|
gst_gl_texture_target_from_string (const gchar * str)
|
||||||
|
{
|
||||||
|
if (!str)
|
||||||
|
return GST_GL_TEXTURE_TARGET_NONE;
|
||||||
|
|
||||||
|
if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_2D_STR) == 0)
|
||||||
|
return GST_GL_TEXTURE_TARGET_2D;
|
||||||
|
if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_RECTANGLE_STR) == 0)
|
||||||
|
return GST_GL_TEXTURE_TARGET_RECTANGLE;
|
||||||
|
if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR) == 0)
|
||||||
|
return GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
|
||||||
|
|
||||||
|
return GST_GL_TEXTURE_TARGET_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
gst_gl_texture_target_to_gl (GstGLTextureTarget target)
|
||||||
|
{
|
||||||
|
switch (target) {
|
||||||
|
case GST_GL_TEXTURE_TARGET_2D:
|
||||||
|
return GL_TEXTURE_2D;
|
||||||
|
case GST_GL_TEXTURE_TARGET_RECTANGLE:
|
||||||
|
return GL_TEXTURE_RECTANGLE;
|
||||||
|
case GST_GL_TEXTURE_TARGET_EXTERNAL_OES:
|
||||||
|
return GL_TEXTURE_EXTERNAL_OES;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GstGLTextureTarget
|
||||||
|
gst_gl_texture_target_from_gl (guint target)
|
||||||
|
{
|
||||||
|
switch (target) {
|
||||||
|
case GL_TEXTURE_2D:
|
||||||
|
return GST_GL_TEXTURE_TARGET_2D;
|
||||||
|
case GL_TEXTURE_RECTANGLE:
|
||||||
|
return GST_GL_TEXTURE_TARGET_RECTANGLE;
|
||||||
|
case GL_TEXTURE_EXTERNAL_OES:
|
||||||
|
return GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
|
||||||
|
default:
|
||||||
|
return GST_GL_TEXTURE_TARGET_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline guint
|
static inline guint
|
||||||
_get_plane_width (GstVideoInfo * info, guint plane)
|
_get_plane_width (GstVideoInfo * info, guint plane)
|
||||||
{
|
{
|
||||||
@ -432,7 +500,7 @@ _upload_memory (GstGLMemory * gl_mem, GstMapInfo * info, gsize maxsize)
|
|||||||
gl_type = GL_UNSIGNED_SHORT_5_6_5;
|
gl_type = GL_UNSIGNED_SHORT_5_6_5;
|
||||||
|
|
||||||
gl_format = gst_gl_format_from_gl_texture_type (gl_mem->tex_type);
|
gl_format = gst_gl_format_from_gl_texture_type (gl_mem->tex_type);
|
||||||
gl_target = gl_mem->tex_target;
|
gl_target = gst_gl_texture_target_to_gl (gl_mem->tex_target);
|
||||||
|
|
||||||
if (USING_OPENGL (context) || USING_GLES3 (context)
|
if (USING_OPENGL (context) || USING_GLES3 (context)
|
||||||
|| USING_OPENGL3 (context)) {
|
|| USING_OPENGL3 (context)) {
|
||||||
@ -560,14 +628,17 @@ _new_texture (GstGLContext * context, guint target, guint internal_format,
|
|||||||
|
|
||||||
gl->GenTextures (1, &tex_id);
|
gl->GenTextures (1, &tex_id);
|
||||||
gl->BindTexture (target, tex_id);
|
gl->BindTexture (target, tex_id);
|
||||||
gl->TexImage2D (target, 0, internal_format, width, height, 0, format, type,
|
if (target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE)
|
||||||
NULL);
|
gl->TexImage2D (target, 0, internal_format, width, height, 0, format, type,
|
||||||
|
NULL);
|
||||||
|
|
||||||
gl->TexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
gl->TexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
gl->TexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
gl->TexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
gl->TexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
gl->TexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
gl->TexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
gl->TexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
|
gl->BindTexture (target, 0);
|
||||||
|
|
||||||
return tex_id;
|
return tex_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,8 +665,9 @@ _gl_mem_create (GstGLMemory * gl_mem, GError ** error)
|
|||||||
|
|
||||||
if (!gl_mem->texture_wrapped) {
|
if (!gl_mem->texture_wrapped) {
|
||||||
gl_mem->tex_id =
|
gl_mem->tex_id =
|
||||||
_new_texture (context, gl_mem->tex_target, internal_format, tex_format,
|
_new_texture (context, gst_gl_texture_target_to_gl (gl_mem->tex_target),
|
||||||
tex_type, gl_mem->tex_width, GL_MEM_HEIGHT (gl_mem));
|
internal_format, tex_format, tex_type, gl_mem->tex_width,
|
||||||
|
GL_MEM_HEIGHT (gl_mem));
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_LOG ("generated texture id:%d", gl_mem->tex_id);
|
GST_LOG ("generated texture id:%d", gl_mem->tex_id);
|
||||||
@ -617,10 +689,12 @@ _gl_mem_create (GstGLMemory * gl_mem, GError ** error)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
_gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
|
_gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
|
||||||
GstGLContext * context, GstAllocationParams * params, GstVideoInfo * info,
|
GstGLContext * context, GstGLTextureTarget target,
|
||||||
|
GstAllocationParams * params, GstVideoInfo * info,
|
||||||
GstVideoAlignment * valign, guint plane, gpointer user_data,
|
GstVideoAlignment * valign, guint plane, gpointer user_data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
|
const gchar *target_str;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
g_return_if_fail (plane < GST_VIDEO_INFO_N_PLANES (info));
|
g_return_if_fail (plane < GST_VIDEO_INFO_N_PLANES (info));
|
||||||
@ -649,7 +723,7 @@ _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
|
|||||||
size = gst_gl_get_plane_data_size (info, valign, plane);
|
size = gst_gl_get_plane_data_size (info, valign, plane);
|
||||||
|
|
||||||
/* we always operate on 2D textures unless we're dealing with wrapped textures */
|
/* we always operate on 2D textures unless we're dealing with wrapped textures */
|
||||||
mem->tex_target = GL_TEXTURE_2D;
|
mem->tex_target = target;
|
||||||
mem->tex_type =
|
mem->tex_type =
|
||||||
gst_gl_texture_type_from_format (context, GST_VIDEO_INFO_FORMAT (info),
|
gst_gl_texture_type_from_format (context, GST_VIDEO_INFO_FORMAT (info),
|
||||||
plane);
|
plane);
|
||||||
@ -663,15 +737,17 @@ _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
|
|||||||
gst_gl_base_buffer_init ((GstGLBaseBuffer *) mem, allocator, parent, context,
|
gst_gl_base_buffer_init ((GstGLBaseBuffer *) mem, allocator, parent, context,
|
||||||
params, size);
|
params, size);
|
||||||
|
|
||||||
GST_DEBUG ("new GL texture context:%" GST_PTR_FORMAT " memory:%p format:%u "
|
target_str = gst_gl_texture_target_to_string (target);
|
||||||
"dimensions:%ux%u stride:%u size:%" G_GSIZE_FORMAT, context, mem,
|
GST_DEBUG ("new GL texture context:%" GST_PTR_FORMAT " memory:%p target:%s "
|
||||||
mem->tex_type, mem->tex_width, GL_MEM_HEIGHT (mem), GL_MEM_STRIDE (mem),
|
"format:%u dimensions:%ux%u stride:%u size:%" G_GSIZE_FORMAT, context,
|
||||||
mem->mem.mem.size);
|
mem, target_str, mem->tex_type, mem->tex_width, GL_MEM_HEIGHT (mem),
|
||||||
|
GL_MEM_STRIDE (mem), mem->mem.mem.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstGLMemory *
|
static GstGLMemory *
|
||||||
_gl_mem_new (GstAllocator * allocator, GstMemory * parent,
|
_gl_mem_new (GstAllocator * allocator, GstMemory * parent,
|
||||||
GstGLContext * context, GstAllocationParams * params, GstVideoInfo * info,
|
GstGLContext * context, GstGLTextureTarget target,
|
||||||
|
GstAllocationParams * params, GstVideoInfo * info,
|
||||||
GstVideoAlignment * valign, guint plane, gpointer user_data,
|
GstVideoAlignment * valign, guint plane, gpointer user_data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
@ -679,8 +755,8 @@ _gl_mem_new (GstAllocator * allocator, GstMemory * parent,
|
|||||||
mem = g_slice_new0 (GstGLMemory);
|
mem = g_slice_new0 (GstGLMemory);
|
||||||
mem->texture_wrapped = FALSE;
|
mem->texture_wrapped = FALSE;
|
||||||
|
|
||||||
_gl_mem_init (mem, allocator, parent, context, params, info, valign, plane,
|
_gl_mem_init (mem, allocator, parent, context, target, params, info, valign,
|
||||||
user_data, notify);
|
plane, user_data, notify);
|
||||||
|
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
@ -703,7 +779,7 @@ _gl_mem_read_pixels (GstGLMemory * gl_mem, gpointer read_pointer)
|
|||||||
gl->BindFramebuffer (GL_FRAMEBUFFER, fbo);
|
gl->BindFramebuffer (GL_FRAMEBUFFER, fbo);
|
||||||
|
|
||||||
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||||
gl_mem->tex_target, gl_mem->tex_id, 0);
|
gst_gl_texture_target_to_gl (gl_mem->tex_target), gl_mem->tex_id, 0);
|
||||||
|
|
||||||
if (!gst_gl_context_check_framebuffer_status (context)) {
|
if (!gst_gl_context_check_framebuffer_status (context)) {
|
||||||
GST_CAT_WARNING (GST_CAT_GL_MEMORY,
|
GST_CAT_WARNING (GST_CAT_GL_MEMORY,
|
||||||
@ -799,6 +875,7 @@ _gl_mem_download_get_tex_image (GstGLMemory * gl_mem, GstMapInfo * info,
|
|||||||
if (info->flags & GST_MAP_READ
|
if (info->flags & GST_MAP_READ
|
||||||
&& gl_mem->transfer_state & GST_GL_MEMORY_TRANSFER_NEED_DOWNLOAD) {
|
&& gl_mem->transfer_state & GST_GL_MEMORY_TRANSFER_NEED_DOWNLOAD) {
|
||||||
guint format, type;
|
guint format, type;
|
||||||
|
guint target;
|
||||||
|
|
||||||
GST_CAT_TRACE (GST_CAT_GL_MEMORY, "attempting download of texture %u "
|
GST_CAT_TRACE (GST_CAT_GL_MEMORY, "attempting download of texture %u "
|
||||||
"using glGetTexImage", gl_mem->tex_id);
|
"using glGetTexImage", gl_mem->tex_id);
|
||||||
@ -808,9 +885,10 @@ _gl_mem_download_get_tex_image (GstGLMemory * gl_mem, GstMapInfo * info,
|
|||||||
if (gl_mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
|
if (gl_mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
|
||||||
type = GL_UNSIGNED_SHORT_5_6_5;
|
type = GL_UNSIGNED_SHORT_5_6_5;
|
||||||
|
|
||||||
gl->BindTexture (gl_mem->tex_target, gl_mem->tex_id);
|
target = gst_gl_texture_target_to_gl (gl_mem->tex_target);
|
||||||
gl->GetTexImage (gl_mem->tex_target, 0, format, type, gl_mem->mem.data);
|
gl->BindTexture (target, gl_mem->tex_id);
|
||||||
gl->BindTexture (gl_mem->tex_target, 0);
|
gl->GetTexImage (target, 0, format, type, gl_mem->mem.data);
|
||||||
|
gl->BindTexture (target, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return gl_mem->mem.data;
|
return gl_mem->mem.data;
|
||||||
@ -863,6 +941,9 @@ _gl_mem_map_buffer (GstGLMemory * gl_mem, GstMapInfo * info, gsize maxsize)
|
|||||||
GST_GL_BASE_BUFFER_ALLOCATOR_CLASS (gst_gl_allocator_parent_class);
|
GST_GL_BASE_BUFFER_ALLOCATOR_CLASS (gst_gl_allocator_parent_class);
|
||||||
|
|
||||||
if ((info->flags & GST_MAP_GL) == GST_MAP_GL) {
|
if ((info->flags & GST_MAP_GL) == GST_MAP_GL) {
|
||||||
|
if (gl_mem->tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES)
|
||||||
|
return &gl_mem->tex_id;
|
||||||
|
|
||||||
if ((info->flags & GST_MAP_READ) == GST_MAP_READ) {
|
if ((info->flags & GST_MAP_READ) == GST_MAP_READ) {
|
||||||
GST_TRACE ("mapping GL texture:%u for reading", gl_mem->tex_id);
|
GST_TRACE ("mapping GL texture:%u for reading", gl_mem->tex_id);
|
||||||
|
|
||||||
@ -883,6 +964,11 @@ _gl_mem_map_buffer (GstGLMemory * gl_mem, GstMapInfo * info, gsize maxsize)
|
|||||||
|
|
||||||
data = &gl_mem->tex_id;
|
data = &gl_mem->tex_id;
|
||||||
} else { /* not GL */
|
} else { /* not GL */
|
||||||
|
if (gl_mem->tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
|
||||||
|
GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot map External OES textures");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
data = _gl_mem_map_cpu_access (gl_mem, info, maxsize);
|
data = _gl_mem_map_cpu_access (gl_mem, info, maxsize);
|
||||||
if (info->flags & GST_MAP_WRITE)
|
if (info->flags & GST_MAP_WRITE)
|
||||||
gl_mem->transfer_state |= GST_GL_MEMORY_TRANSFER_NEED_UPLOAD;
|
gl_mem->transfer_state |= GST_GL_MEMORY_TRANSFER_NEED_UPLOAD;
|
||||||
@ -931,7 +1017,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data)
|
|||||||
GstGLMemoryCopyParams *copy_params;
|
GstGLMemoryCopyParams *copy_params;
|
||||||
GstGLMemory *src;
|
GstGLMemory *src;
|
||||||
guint tex_id;
|
guint tex_id;
|
||||||
GLuint out_tex_target;
|
guint out_tex_target;
|
||||||
GLuint fboId;
|
GLuint fboId;
|
||||||
gsize out_width, out_height, out_stride;
|
gsize out_width, out_height, out_stride;
|
||||||
GLuint out_gl_format, out_gl_type;
|
GLuint out_gl_format, out_gl_type;
|
||||||
@ -941,7 +1027,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data)
|
|||||||
copy_params = (GstGLMemoryCopyParams *) data;
|
copy_params = (GstGLMemoryCopyParams *) data;
|
||||||
src = copy_params->src;
|
src = copy_params->src;
|
||||||
tex_id = copy_params->tex_id;
|
tex_id = copy_params->tex_id;
|
||||||
out_tex_target = copy_params->tex_target;
|
out_tex_target = gst_gl_texture_target_to_gl (copy_params->tex_target);
|
||||||
out_width = copy_params->out_width;
|
out_width = copy_params->out_width;
|
||||||
out_height = copy_params->out_height;
|
out_height = copy_params->out_height;
|
||||||
out_stride = copy_params->out_stride;
|
out_stride = copy_params->out_stride;
|
||||||
@ -987,8 +1073,9 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data)
|
|||||||
out_gl_type);
|
out_gl_type);
|
||||||
|
|
||||||
tex_id =
|
tex_id =
|
||||||
_new_texture (context, out_tex_target, internal_format, out_gl_format,
|
_new_texture (context, out_tex_target,
|
||||||
out_gl_type, copy_params->out_width, copy_params->out_height);
|
internal_format, out_gl_format, out_gl_type, copy_params->out_width,
|
||||||
|
copy_params->out_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tex_id) {
|
if (!tex_id) {
|
||||||
@ -1004,7 +1091,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data)
|
|||||||
gl->BindFramebuffer (GL_FRAMEBUFFER, fboId);
|
gl->BindFramebuffer (GL_FRAMEBUFFER, fboId);
|
||||||
|
|
||||||
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||||
src->tex_target, src->tex_id, 0);
|
gst_gl_texture_target_to_gl (src->tex_target), src->tex_id, 0);
|
||||||
|
|
||||||
// if (!gst_gl_context_check_framebuffer_status (src->context))
|
// if (!gst_gl_context_check_framebuffer_status (src->context))
|
||||||
// goto fbo_error;
|
// goto fbo_error;
|
||||||
@ -1080,6 +1167,11 @@ _gl_mem_copy (GstGLMemory * src, gssize offset, gssize size)
|
|||||||
GstGLAllocator *allocator = (GstGLAllocator *) src->mem.mem.allocator;
|
GstGLAllocator *allocator = (GstGLAllocator *) src->mem.mem.allocator;
|
||||||
GstMemory *ret = NULL;
|
GstMemory *ret = NULL;
|
||||||
|
|
||||||
|
if (src->tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) {
|
||||||
|
GST_CAT_ERROR (GST_CAT_GL_MEMORY, "Cannot copy External OES textures");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* If not doing a full copy, then copy to sysmem, the 2D represention of the
|
/* If not doing a full copy, then copy to sysmem, the 2D represention of the
|
||||||
* texture would become wrong */
|
* texture would become wrong */
|
||||||
if (offset > 0 || size < src->mem.mem.size) {
|
if (offset > 0 || size < src->mem.mem.size) {
|
||||||
@ -1088,8 +1180,9 @@ _gl_mem_copy (GstGLMemory * src, gssize offset, gssize size)
|
|||||||
GstAllocationParams params = { 0, src->mem.mem.align, 0, 0 };
|
GstAllocationParams params = { 0, src->mem.mem.align, 0, 0 };
|
||||||
GstGLMemory *dest;
|
GstGLMemory *dest;
|
||||||
|
|
||||||
dest = _gl_mem_new (src->mem.mem.allocator, NULL, src->mem.context, ¶ms,
|
dest = _gl_mem_new (src->mem.mem.allocator, NULL, src->mem.context,
|
||||||
&src->info, &src->valign, src->plane, NULL, NULL);
|
src->tex_target, ¶ms, &src->info, &src->valign, src->plane, NULL,
|
||||||
|
NULL);
|
||||||
dest = (GstGLMemory *) gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *)
|
dest = (GstGLMemory *) gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *)
|
||||||
dest);
|
dest);
|
||||||
|
|
||||||
@ -1127,8 +1220,9 @@ _gl_mem_copy (GstGLMemory * src, gssize offset, gssize size)
|
|||||||
dest = g_slice_new0 (GstGLMemory);
|
dest = g_slice_new0 (GstGLMemory);
|
||||||
/* don't create our own texture */
|
/* don't create our own texture */
|
||||||
dest->texture_wrapped = TRUE;
|
dest->texture_wrapped = TRUE;
|
||||||
_gl_mem_init (dest, src->mem.mem.allocator, NULL, src->mem.context, ¶ms,
|
_gl_mem_init (dest, src->mem.mem.allocator, NULL, src->mem.context,
|
||||||
&src->info, &src->valign, src->plane, NULL, NULL);
|
src->tex_target, ¶ms, &src->info, &src->valign, src->plane, NULL,
|
||||||
|
NULL);
|
||||||
dest->texture_wrapped = FALSE;
|
dest->texture_wrapped = FALSE;
|
||||||
|
|
||||||
dest->tex_id = copy_params.tex_id;
|
dest->tex_id = copy_params.tex_id;
|
||||||
@ -1242,13 +1336,13 @@ gst_gl_allocator_init (GstGLAllocator * allocator)
|
|||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_gl_memory_copy_into_texture (GstGLMemory * gl_mem, guint tex_id,
|
gst_gl_memory_copy_into_texture (GstGLMemory * gl_mem, guint tex_id,
|
||||||
GstVideoGLTextureType tex_type, gint width, gint height, gint stride,
|
GstGLTextureTarget target, GstVideoGLTextureType tex_type, gint width,
|
||||||
gboolean respecify)
|
gint height, gint stride, gboolean respecify)
|
||||||
{
|
{
|
||||||
GstGLMemoryCopyParams copy_params;
|
GstGLMemoryCopyParams copy_params;
|
||||||
|
|
||||||
copy_params.src = gl_mem;
|
copy_params.src = gl_mem;
|
||||||
copy_params.tex_target = gl_mem->tex_target;
|
copy_params.tex_target = target;
|
||||||
copy_params.tex_id = tex_id;
|
copy_params.tex_id = tex_id;
|
||||||
copy_params.out_format = tex_type;
|
copy_params.out_format = tex_type;
|
||||||
copy_params.out_width = width;
|
copy_params.out_width = width;
|
||||||
@ -1278,7 +1372,7 @@ gst_gl_memory_copy_into_texture (GstGLMemory * gl_mem, guint tex_id,
|
|||||||
*/
|
*/
|
||||||
GstGLMemory *
|
GstGLMemory *
|
||||||
gst_gl_memory_wrapped_texture (GstGLContext * context,
|
gst_gl_memory_wrapped_texture (GstGLContext * context,
|
||||||
guint texture_id, guint texture_target,
|
guint texture_id, GstGLTextureTarget target,
|
||||||
GstVideoInfo * info, guint plane, GstVideoAlignment * valign,
|
GstVideoInfo * info, guint plane, GstVideoAlignment * valign,
|
||||||
gpointer user_data, GDestroyNotify notify)
|
gpointer user_data, GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
@ -1289,10 +1383,8 @@ gst_gl_memory_wrapped_texture (GstGLContext * context,
|
|||||||
mem->tex_id = texture_id;
|
mem->tex_id = texture_id;
|
||||||
mem->texture_wrapped = TRUE;
|
mem->texture_wrapped = TRUE;
|
||||||
|
|
||||||
_gl_mem_init (mem, _gl_allocator, NULL, context, NULL, info, valign, plane,
|
_gl_mem_init (mem, _gl_allocator, NULL, context, target, NULL, info, valign,
|
||||||
user_data, notify);
|
plane, user_data, notify);
|
||||||
|
|
||||||
mem->tex_target = texture_target;
|
|
||||||
|
|
||||||
mem = (GstGLMemory *) gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *) mem);
|
mem = (GstGLMemory *) gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *) mem);
|
||||||
GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
|
GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
|
||||||
@ -1315,13 +1407,15 @@ gst_gl_memory_wrapped_texture (GstGLContext * context,
|
|||||||
* from @context
|
* from @context
|
||||||
*/
|
*/
|
||||||
GstMemory *
|
GstMemory *
|
||||||
gst_gl_memory_alloc (GstGLContext * context, GstAllocationParams * params,
|
gst_gl_memory_alloc (GstGLContext * context, GstGLTextureTarget target,
|
||||||
GstVideoInfo * info, guint plane, GstVideoAlignment * valign)
|
GstAllocationParams * params, GstVideoInfo * info, guint plane,
|
||||||
|
GstVideoAlignment * valign)
|
||||||
{
|
{
|
||||||
GstGLMemory *mem;
|
GstGLMemory *mem;
|
||||||
|
|
||||||
mem = _gl_mem_new (_gl_allocator, NULL, context, params, info, valign, plane,
|
mem =
|
||||||
NULL, NULL);
|
_gl_mem_new (_gl_allocator, NULL, context, target, params, info, valign,
|
||||||
|
plane, NULL, NULL);
|
||||||
mem = (GstGLMemory *) gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *) mem);
|
mem = (GstGLMemory *) gst_gl_base_buffer_alloc_data ((GstGLBaseBuffer *) mem);
|
||||||
|
|
||||||
return (GstMemory *) mem;
|
return (GstMemory *) mem;
|
||||||
@ -1344,14 +1438,14 @@ gst_gl_memory_alloc (GstGLContext * context, GstAllocationParams * params,
|
|||||||
* from @context and contents specified by @data
|
* from @context and contents specified by @data
|
||||||
*/
|
*/
|
||||||
GstGLMemory *
|
GstGLMemory *
|
||||||
gst_gl_memory_wrapped (GstGLContext * context, GstVideoInfo * info,
|
gst_gl_memory_wrapped (GstGLContext * context, GstGLTextureTarget target,
|
||||||
guint plane, GstVideoAlignment * valign, gpointer data, gpointer user_data,
|
GstVideoInfo * info, guint plane, GstVideoAlignment * valign, gpointer data,
|
||||||
GDestroyNotify notify)
|
gpointer user_data, GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
GstGLMemory *mem;
|
GstGLMemory *mem;
|
||||||
|
|
||||||
mem = _gl_mem_new (_gl_allocator, NULL, context, NULL, info, valign, plane,
|
mem = _gl_mem_new (_gl_allocator, NULL, context, target, NULL, info, valign,
|
||||||
user_data, notify);
|
plane, user_data, notify);
|
||||||
if (!mem)
|
if (!mem)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -1482,7 +1576,7 @@ gst_is_gl_memory (GstMemory * mem)
|
|||||||
* Returns: whether the memory's were sucessfully added.
|
* Returns: whether the memory's were sucessfully added.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_gl_memory_setup_buffer (GstGLContext * context,
|
gst_gl_memory_setup_buffer (GstGLContext * context, GstGLTextureTarget target,
|
||||||
GstAllocationParams * params, GstVideoInfo * info,
|
GstAllocationParams * params, GstVideoInfo * info,
|
||||||
GstVideoAlignment * valign, GstBuffer * buffer)
|
GstVideoAlignment * valign, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
@ -1500,7 +1594,7 @@ gst_gl_memory_setup_buffer (GstGLContext * context,
|
|||||||
for (v = 0; v < views; v++) {
|
for (v = 0; v < views; v++) {
|
||||||
for (i = 0; i < n_mem; i++) {
|
for (i = 0; i < n_mem; i++) {
|
||||||
gl_mem[i] =
|
gl_mem[i] =
|
||||||
(GstGLMemory *) gst_gl_memory_alloc (context, params, info, i,
|
(GstGLMemory *) gst_gl_memory_alloc (context, target, params, info, i,
|
||||||
valign);
|
valign);
|
||||||
if (gl_mem[i] == NULL)
|
if (gl_mem[i] == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1533,16 +1627,18 @@ gst_gl_memory_setup_buffer (GstGLContext * context,
|
|||||||
* Returns: whether the memory's were sucessfully created.
|
* Returns: whether the memory's were sucessfully created.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_gl_memory_setup_wrapped (GstGLContext * context, GstVideoInfo * info,
|
gst_gl_memory_setup_wrapped (GstGLContext * context, GstGLTextureTarget target,
|
||||||
GstVideoAlignment * valign, gpointer data[GST_VIDEO_MAX_PLANES],
|
GstVideoInfo * info, GstVideoAlignment * valign,
|
||||||
|
gpointer data[GST_VIDEO_MAX_PLANES],
|
||||||
GstGLMemory * textures[GST_VIDEO_MAX_PLANES], gpointer user_data,
|
GstGLMemory * textures[GST_VIDEO_MAX_PLANES], gpointer user_data,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++) {
|
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++) {
|
||||||
textures[i] = (GstGLMemory *) gst_gl_memory_wrapped (context, info, i,
|
textures[i] =
|
||||||
valign, data[i], user_data, notify);
|
(GstGLMemory *) gst_gl_memory_wrapped (context, target, info, i, valign,
|
||||||
|
data[i], user_data, notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -50,6 +50,19 @@ typedef enum _GstGLMemoryTransfer
|
|||||||
|
|
||||||
#define GST_GL_MEMORY_ADD_TRANSFER(mem,state) ((GstGLMemory *)mem)->transfer_state |= state
|
#define GST_GL_MEMORY_ADD_TRANSFER(mem,state) ((GstGLMemory *)mem)->transfer_state |= state
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_GL_TEXTURE_TARGET_NONE,
|
||||||
|
GST_GL_TEXTURE_TARGET_2D,
|
||||||
|
GST_GL_TEXTURE_TARGET_RECTANGLE,
|
||||||
|
GST_GL_TEXTURE_TARGET_EXTERNAL_OES,
|
||||||
|
} GstGLTextureTarget;
|
||||||
|
|
||||||
|
#define GST_GL_TEXTURE_TARGET_2D_STR "2D"
|
||||||
|
#define GST_GL_TEXTURE_TARGET_RECTANGLE_STR "rectangle"
|
||||||
|
#define GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR "external-oes"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstGLMemory:
|
* GstGLMemory:
|
||||||
* @mem: the parent object
|
* @mem: the parent object
|
||||||
@ -69,7 +82,7 @@ struct _GstGLMemory
|
|||||||
GstGLBaseBuffer mem;
|
GstGLBaseBuffer mem;
|
||||||
|
|
||||||
guint tex_id;
|
guint tex_id;
|
||||||
guint tex_target;
|
GstGLTextureTarget tex_target;
|
||||||
GstVideoGLTextureType tex_type;
|
GstVideoGLTextureType tex_type;
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
GstVideoAlignment valign;
|
GstVideoAlignment valign;
|
||||||
@ -102,11 +115,13 @@ void gst_gl_memory_init (void);
|
|||||||
gboolean gst_is_gl_memory (GstMemory * mem);
|
gboolean gst_is_gl_memory (GstMemory * mem);
|
||||||
|
|
||||||
GstMemory * gst_gl_memory_alloc (GstGLContext * context,
|
GstMemory * gst_gl_memory_alloc (GstGLContext * context,
|
||||||
|
GstGLTextureTarget target,
|
||||||
GstAllocationParams *params,
|
GstAllocationParams *params,
|
||||||
GstVideoInfo * info,
|
GstVideoInfo * info,
|
||||||
guint plane,
|
guint plane,
|
||||||
GstVideoAlignment *valign);
|
GstVideoAlignment *valign);
|
||||||
GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context,
|
GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context,
|
||||||
|
GstGLTextureTarget target,
|
||||||
GstVideoInfo * info,
|
GstVideoInfo * info,
|
||||||
guint plane,
|
guint plane,
|
||||||
GstVideoAlignment *valign,
|
GstVideoAlignment *valign,
|
||||||
@ -115,7 +130,7 @@ GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context,
|
|||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
GstGLMemory * gst_gl_memory_wrapped_texture (GstGLContext * context,
|
GstGLMemory * gst_gl_memory_wrapped_texture (GstGLContext * context,
|
||||||
guint texture_id,
|
guint texture_id,
|
||||||
guint texture_target,
|
GstGLTextureTarget target,
|
||||||
GstVideoInfo * info,
|
GstVideoInfo * info,
|
||||||
guint plane,
|
guint plane,
|
||||||
GstVideoAlignment *valign,
|
GstVideoAlignment *valign,
|
||||||
@ -127,6 +142,7 @@ void gst_gl_memory_upload_transfer (GstGLMemory * gl_mem);
|
|||||||
|
|
||||||
gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem,
|
gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem,
|
||||||
guint tex_id,
|
guint tex_id,
|
||||||
|
GstGLTextureTarget target,
|
||||||
GstVideoGLTextureType tex_type,
|
GstVideoGLTextureType tex_type,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
@ -134,11 +150,13 @@ gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem,
|
|||||||
gboolean respecify);
|
gboolean respecify);
|
||||||
|
|
||||||
gboolean gst_gl_memory_setup_buffer (GstGLContext * context,
|
gboolean gst_gl_memory_setup_buffer (GstGLContext * context,
|
||||||
|
GstGLTextureTarget target,
|
||||||
GstAllocationParams * params,
|
GstAllocationParams * params,
|
||||||
GstVideoInfo * info,
|
GstVideoInfo * info,
|
||||||
GstVideoAlignment *valign,
|
GstVideoAlignment *valign,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
gboolean gst_gl_memory_setup_wrapped (GstGLContext * context,
|
gboolean gst_gl_memory_setup_wrapped (GstGLContext * context,
|
||||||
|
GstGLTextureTarget target,
|
||||||
GstVideoInfo * info,
|
GstVideoInfo * info,
|
||||||
GstVideoAlignment *valign,
|
GstVideoAlignment *valign,
|
||||||
gpointer data[GST_VIDEO_MAX_PLANES],
|
gpointer data[GST_VIDEO_MAX_PLANES],
|
||||||
@ -158,6 +176,12 @@ guint gst_gl_sized_gl_format_from_gl_format_type (GstGLContext *
|
|||||||
guint format,
|
guint format,
|
||||||
guint type);
|
guint type);
|
||||||
|
|
||||||
|
const gchar * gst_gl_texture_target_to_string (GstGLTextureTarget target);
|
||||||
|
GstGLTextureTarget gst_gl_texture_target_from_string (const gchar * str);
|
||||||
|
GstGLTextureTarget gst_gl_texture_target_from_gl (guint target);
|
||||||
|
guint gst_gl_texture_target_to_gl (GstGLTextureTarget target);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstGLAllocator
|
* GstGLAllocator
|
||||||
*
|
*
|
||||||
|
@ -347,8 +347,9 @@ gst_gl_composition_overlay_upload (GstGLCompositionOverlay * overlay,
|
|||||||
gst_gl_composition_overlay_add_transformation (overlay, buf);
|
gst_gl_composition_overlay_add_transformation (overlay, buf);
|
||||||
|
|
||||||
comp_gl_memory =
|
comp_gl_memory =
|
||||||
gst_gl_memory_wrapped (overlay->context, &comp_frame->info, 0, NULL,
|
gst_gl_memory_wrapped (overlay->context, GST_GL_TEXTURE_TARGET_2D,
|
||||||
comp_frame->data[0], comp_frame, _video_frame_unmap_and_free);
|
&comp_frame->info, 0, NULL, comp_frame->data[0], comp_frame,
|
||||||
|
_video_frame_unmap_and_free);
|
||||||
|
|
||||||
overlay_buffer = gst_buffer_new ();
|
overlay_buffer = gst_buffer_new ();
|
||||||
gst_buffer_append_memory (overlay_buffer, (GstMemory *) comp_gl_memory);
|
gst_buffer_append_memory (overlay_buffer, (GstMemory *) comp_gl_memory);
|
||||||
|
@ -332,8 +332,17 @@ _egl_image_upload_transform_caps (GstGLContext * context,
|
|||||||
if (direction == GST_PAD_SINK) {
|
if (direction == GST_PAD_SINK) {
|
||||||
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
|
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
|
||||||
} else {
|
} else {
|
||||||
|
gint i, n;
|
||||||
|
|
||||||
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_EGL_IMAGE);
|
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_EGL_IMAGE);
|
||||||
gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
|
gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
|
||||||
|
|
||||||
|
n = gst_caps_get_size (ret);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
GstStructure *s = gst_caps_get_structure (ret, i);
|
||||||
|
|
||||||
|
gst_structure_remove_fields (s, "texture-target", NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -408,7 +417,7 @@ _egl_image_upload_perform_gl_thread (GstGLContext * context,
|
|||||||
|
|
||||||
/* FIXME: buffer pool */
|
/* FIXME: buffer pool */
|
||||||
*image->outbuf = gst_buffer_new ();
|
*image->outbuf = gst_buffer_new ();
|
||||||
gst_gl_memory_setup_buffer (image->upload->context,
|
gst_gl_memory_setup_buffer (image->upload->context, GST_GL_TEXTURE_TARGET_2D,
|
||||||
NULL, &image->upload->priv->out_info, NULL, *image->outbuf);
|
NULL, &image->upload->priv->out_info, NULL, *image->outbuf);
|
||||||
|
|
||||||
n = gst_buffer_n_memory (image->buffer);
|
n = gst_buffer_n_memory (image->buffer);
|
||||||
@ -500,10 +509,19 @@ _upload_meta_upload_transform_caps (GstGLContext * context,
|
|||||||
if (direction == GST_PAD_SINK) {
|
if (direction == GST_PAD_SINK) {
|
||||||
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
|
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
|
||||||
} else {
|
} else {
|
||||||
|
gint i, n;
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
_set_caps_features (caps,
|
_set_caps_features (caps,
|
||||||
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META);
|
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META);
|
||||||
gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
|
gst_caps_set_simple (ret, "format", G_TYPE_STRING, "RGBA", NULL);
|
||||||
|
|
||||||
|
n = gst_caps_get_size (ret);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
GstStructure *s = gst_caps_get_structure (ret, i);
|
||||||
|
|
||||||
|
gst_structure_remove_fields (s, "texture-target", NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -616,7 +634,7 @@ _upload_meta_upload_perform (gpointer impl, GstBuffer * buffer,
|
|||||||
|
|
||||||
/* FIXME: buffer pool */
|
/* FIXME: buffer pool */
|
||||||
*outbuf = gst_buffer_new ();
|
*outbuf = gst_buffer_new ();
|
||||||
gst_gl_memory_setup_buffer (upload->upload->context,
|
gst_gl_memory_setup_buffer (upload->upload->context, GST_GL_TEXTURE_TARGET_2D,
|
||||||
NULL, &upload->upload->priv->in_info, NULL, *outbuf);
|
NULL, &upload->upload->priv->in_info, NULL, *outbuf);
|
||||||
|
|
||||||
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
|
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
|
||||||
@ -756,7 +774,16 @@ _raw_data_upload_transform_caps (GstGLContext * context,
|
|||||||
if (direction == GST_PAD_SINK) {
|
if (direction == GST_PAD_SINK) {
|
||||||
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
|
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
|
||||||
} else {
|
} else {
|
||||||
|
gint i, n;
|
||||||
|
|
||||||
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY);
|
ret = _set_caps_features (caps, GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY);
|
||||||
|
|
||||||
|
n = gst_caps_get_size (ret);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
GstStructure *s = gst_caps_get_structure (ret, i);
|
||||||
|
|
||||||
|
gst_structure_remove_fields (s, "texture-target", NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -802,7 +829,7 @@ _raw_data_upload_perform (gpointer impl, GstBuffer * buffer,
|
|||||||
GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
|
GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
|
||||||
max_planes *= GST_VIDEO_INFO_VIEWS (in_info);
|
max_planes *= GST_VIDEO_INFO_VIEWS (in_info);
|
||||||
|
|
||||||
gst_gl_memory_setup_wrapped (raw->upload->context,
|
gst_gl_memory_setup_wrapped (raw->upload->context, GST_GL_TEXTURE_TARGET_2D,
|
||||||
&raw->upload->priv->in_info, NULL, raw->in_frame->frame.data, in_tex,
|
&raw->upload->priv->in_info, NULL, raw->in_frame->frame.data, in_tex,
|
||||||
raw->in_frame, (GDestroyNotify) _raw_upload_frame_unref);
|
raw->in_frame, (GDestroyNotify) _raw_upload_frame_unref);
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
|
|||||||
if (!upload->priv->out_tex[i]) {
|
if (!upload->priv->out_tex[i]) {
|
||||||
/* the GL upload meta creates GL_TEXTURE_2D textures */
|
/* the GL upload meta creates GL_TEXTURE_2D textures */
|
||||||
upload->priv->out_tex[i] = gst_gl_memory_wrapped_texture (upload->context,
|
upload->priv->out_tex[i] = gst_gl_memory_wrapped_texture (upload->context,
|
||||||
texture_id[i], GL_TEXTURE_2D, &upload->info, i, NULL, NULL, NULL);
|
texture_id[i], GST_GL_TEXTURE_TARGET_2D, &upload->info, i, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
out_mem = upload->priv->out_tex[i];
|
out_mem = upload->priv->out_tex[i];
|
||||||
@ -241,7 +241,7 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
|
|||||||
mem_height = gst_gl_memory_get_texture_height (out_mem);
|
mem_height = gst_gl_memory_get_texture_height (out_mem);
|
||||||
|
|
||||||
if (!(res = gst_gl_memory_copy_into_texture (in_mem, out_mem->tex_id,
|
if (!(res = gst_gl_memory_copy_into_texture (in_mem, out_mem->tex_id,
|
||||||
out_mem->tex_type, mem_width, mem_height,
|
GST_GL_TEXTURE_TARGET_2D, out_mem->tex_type, mem_width, mem_height,
|
||||||
GST_VIDEO_INFO_PLANE_STRIDE (&out_mem->info, out_mem->plane),
|
GST_VIDEO_INFO_PLANE_STRIDE (&out_mem->info, out_mem->plane),
|
||||||
FALSE)))
|
FALSE)))
|
||||||
break;
|
break;
|
||||||
@ -261,7 +261,7 @@ _perform_with_data_unlocked (GstGLUploadMeta * upload,
|
|||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++) {
|
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++) {
|
||||||
if (!upload->priv->in_tex[i])
|
if (!upload->priv->in_tex[i])
|
||||||
upload->priv->in_tex[i] = gst_gl_memory_wrapped (upload->context,
|
upload->priv->in_tex[i] = gst_gl_memory_wrapped (upload->context,
|
||||||
&upload->info, i, NULL, data[i], NULL, NULL);
|
GST_GL_TEXTURE_TARGET_2D, &upload->info, i, NULL, data[i], NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _perform_with_gl_memory (upload, meta, texture_id);
|
return _perform_with_gl_memory (upload, meta, texture_id);
|
||||||
|
@ -39,8 +39,11 @@
|
|||||||
#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
|
#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
|
||||||
|
|
||||||
static GstStaticCaps caps_template =
|
static GstStaticCaps caps_template =
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
GST_STATIC_CAPS ("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), "
|
||||||
(GST_CAPS_FEATURE_MEMORY_GL_MEMORY, "RGBA"));
|
"format = (string) RGBA, "
|
||||||
|
"width = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"height = " GST_VIDEO_SIZE_RANGE ", "
|
||||||
|
"framerate = " GST_VIDEO_FPS_RANGE ", " "texture-target = (string) 2D ");
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT gst_gl_view_convert_debug
|
#define GST_CAT_DEFAULT gst_gl_view_convert_debug
|
||||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||||
@ -1668,8 +1671,9 @@ static gboolean
|
|||||||
_gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
|
_gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
|
||||||
{
|
{
|
||||||
*target = gst_buffer_new ();
|
*target = gst_buffer_new ();
|
||||||
if (!gst_gl_memory_setup_buffer (viewconvert->context, NULL,
|
if (!gst_gl_memory_setup_buffer (viewconvert->context,
|
||||||
&viewconvert->out_info, NULL, *target)) {
|
GST_GL_TEXTURE_TARGET_2D, NULL, &viewconvert->out_info, NULL,
|
||||||
|
*target)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
gst_buffer_add_video_meta_full (*target, 0,
|
gst_buffer_add_video_meta_full (*target, 0,
|
||||||
@ -1792,8 +1796,8 @@ _do_view_convert (GstGLContext * context, GstGLViewConvert * viewconvert)
|
|||||||
* the attachments i.e. the smallest attachment size */
|
* the attachments i.e. the smallest attachment size */
|
||||||
if (!priv->out_tex[j])
|
if (!priv->out_tex[j])
|
||||||
priv->out_tex[j] =
|
priv->out_tex[j] =
|
||||||
(GstGLMemory *) gst_gl_memory_alloc (context, NULL, &temp_info, 0,
|
(GstGLMemory *) gst_gl_memory_alloc (context,
|
||||||
NULL);
|
GST_GL_TEXTURE_TARGET_2D, NULL, &temp_info, 0, NULL);
|
||||||
} else {
|
} else {
|
||||||
priv->out_tex[j] = out_tex;
|
priv->out_tex[j] = out_tex;
|
||||||
}
|
}
|
||||||
@ -1845,8 +1849,9 @@ out:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
gst_gl_memory_copy_into_texture (priv->out_tex[j],
|
gst_gl_memory_copy_into_texture (priv->out_tex[j],
|
||||||
out_tex->tex_id, out_tex->tex_type, width, height,
|
out_tex->tex_id, GST_GL_TEXTURE_TARGET_2D, out_tex->tex_type, width,
|
||||||
GST_VIDEO_INFO_PLANE_STRIDE (&out_tex->info, out_tex->plane), FALSE);
|
height, GST_VIDEO_INFO_PLANE_STRIDE (&out_tex->info, out_tex->plane),
|
||||||
|
FALSE);
|
||||||
gst_memory_unmap ((GstMemory *) out_tex, &to_info);
|
gst_memory_unmap ((GstMemory *) out_tex, &to_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,17 @@ cv_pixel_buffer_from_gst_buffer (GstBuffer * buffer)
|
|||||||
return cm_meta ? cm_meta->pixel_buf : cv_meta->pixbuf;
|
return cm_meta ? cm_meta->pixel_buf : cv_meta->pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstGLTextureTarget
|
||||||
|
_gl_target_to_gst (guint target)
|
||||||
|
{
|
||||||
|
switch (target) {
|
||||||
|
case GL_TEXTURE_2D: return GST_GL_TEXTURE_TARGET_2D;
|
||||||
|
case GL_TEXTURE_RECTANGLE: return GST_GL_TEXTURE_TARGET_RECTANGLE;
|
||||||
|
case GL_TEXTURE_EXTERNAL_OES: return GST_GL_TEXTURE_TARGET_OES;
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gl_mem_from_buffer (GstCoreVideoTextureCache * cache,
|
gl_mem_from_buffer (GstCoreVideoTextureCache * cache,
|
||||||
GstBuffer * buffer, GstMemory **mem1, GstMemory **mem2)
|
GstBuffer * buffer, GstMemory **mem1, GstMemory **mem2)
|
||||||
@ -155,7 +166,8 @@ gl_mem_from_buffer (GstCoreVideoTextureCache * cache,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
*mem1 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx,
|
*mem1 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx,
|
||||||
CVOpenGLTextureGetName (texture), CVOpenGLTextureGetTarget (texture),
|
CVOpenGLTextureGetName (texture),
|
||||||
|
_gl_target_to_gst (CVOpenGLTextureGetTarget (texture)),
|
||||||
&cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);
|
&cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
@ -169,7 +181,8 @@ gl_mem_from_buffer (GstCoreVideoTextureCache * cache,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
*mem1 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx,
|
*mem1 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx,
|
||||||
CVOpenGLESTextureGetName (texture), CVOpenGLESTextureGetTarget (texture),
|
CVOpenGLESTextureGetName (texture),
|
||||||
|
_gl_target_to_gst (CVOpenGLESTextureGetTarget (texture)),
|
||||||
&cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);
|
&cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_NV12: {
|
case GST_VIDEO_FORMAT_NV12: {
|
||||||
@ -188,7 +201,8 @@ gl_mem_from_buffer (GstCoreVideoTextureCache * cache,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
*mem1 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx,
|
*mem1 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx,
|
||||||
CVOpenGLESTextureGetName (texture), CVOpenGLESTextureGetTarget (texture),
|
CVOpenGLESTextureGetName (texture),
|
||||||
|
_gl_target_to_gst (CVOpenGLESTextureGetTarget (texture)),
|
||||||
&cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);
|
&cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);
|
||||||
|
|
||||||
textype = gst_gl_texture_type_from_format (cache->ctx, GST_VIDEO_FORMAT_NV12, 1);
|
textype = gst_gl_texture_type_from_format (cache->ctx, GST_VIDEO_FORMAT_NV12, 1);
|
||||||
@ -202,7 +216,8 @@ gl_mem_from_buffer (GstCoreVideoTextureCache * cache,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
*mem2 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx,
|
*mem2 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx,
|
||||||
CVOpenGLESTextureGetName (texture), CVOpenGLESTextureGetTarget (texture),
|
CVOpenGLESTextureGetName (texture),
|
||||||
|
_gl_target_to_gst (CVOpenGLESTextureGetTarget (texture)),
|
||||||
&cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);
|
&cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,8 @@ GST_START_TEST (test_transfer)
|
|||||||
|
|
||||||
/* wrapped texture creation */
|
/* wrapped texture creation */
|
||||||
mem3 = (GstMemory *) gst_gl_memory_wrapped_texture (context,
|
mem3 = (GstMemory *) gst_gl_memory_wrapped_texture (context,
|
||||||
((GstGLMemory *) mem)->tex_id, GL_TEXTURE_2D, &v_info, 0, NULL, NULL,
|
((GstGLMemory *) mem)->tex_id, GST_GL_TEXTURE_TARGET_2D, &v_info, 0, NULL,
|
||||||
NULL);
|
NULL, NULL);
|
||||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
|
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
|
||||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
|
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user