gst_gl_effects_init_gl_resources (GstGLFilter * filter)
{
GstGLEffects *effects = GST_GL_EFFECTS (filter);
- GstGLFuncs *gl = GST_GL_BASE_FILTER (filter)->context->gl_vtable;
+ GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
+ GstGLFuncs *gl = context->gl_vtable;
+ guint internal_format;
gint i = 0;
for (i = 0; i < NEEDED_TEXTURES; i++) {
gl->GenTextures (1, &effects->midtexture[i]);
gl->BindTexture (GL_TEXTURE_2D, effects->midtexture[i]);
- gl->TexImage2D (GL_TEXTURE_2D, 0,
- gst_gl_internal_format_rgba (GST_GL_BASE_FILTER (filter)->context),
+ internal_format =
+ gst_gl_sized_gl_format_from_gl_format_type (context, GL_RGBA,
+ GL_UNSIGNED_BYTE);
+ gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0, GL_RGBA, GL_UNSIGNED_BYTE,
NULL);
static void
gst_gl_filtershader_init_resources (GstGLFilter * filter)
{
- glTexImage2D (GL_TEXTURE_2D, 0,
- gst_gl_internal_format_rgba (GST_GL_BASE_FILTER (filter)->context),
+ GstGLContext *context = GST_GL_BASE_FILTER (filter)->context;
+ guint internal_format;
+
+ internal_format =
+ gst_gl_sized_gl_format_from_gl_format_type (context, GL_RGBA,
+ GL_UNSIGNED_BYTE);
+ glTexImage2D (GL_TEXTURE_2D, 0, internal_format,
GST_VIDEO_INFO_WIDTH (&filter->out_info),
GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0, GL_RGBA, GL_UNSIGNED_BYTE,
NULL);
GstGLFuncs *gl;
guint out_width, out_height;
GLuint fake_texture = 0; /* a FBO must hava texture to init */
+ GLenum internal_format;
gl = convert->context->gl_vtable;
/* a fake texture is attached to the convert FBO (cannot init without it) */
gl->GenTextures (1, &fake_texture);
gl->BindTexture (GL_TEXTURE_2D, fake_texture);
- gl->TexImage2D (GL_TEXTURE_2D, 0,
- gst_gl_internal_format_rgba (convert->context), out_width, out_height, 0,
+ internal_format =
+ gst_gl_sized_gl_format_from_gl_format_type (convert->context, GL_RGBA,
+ GL_UNSIGNED_BYTE);
+ gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format, out_width, out_height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
{
GLuint fake_texture = 0;
const GstGLFuncs *gl;
+ GLenum internal_format;
g_return_val_if_fail (GST_IS_GL_FRAMEBUFFER (frame), FALSE);
g_return_val_if_fail (fbo != NULL && depth != NULL, FALSE);
/* setup a texture to render to */
gl->GenTextures (1, &fake_texture);
gl->BindTexture (GL_TEXTURE_2D, fake_texture);
- gl->TexImage2D (GL_TEXTURE_2D, 0,
- gst_gl_internal_format_rgba (frame->context), width, height, 0, GL_RGBA,
+ internal_format =
+ gst_gl_sized_gl_format_from_gl_format_type (frame->context, GL_RGBA,
+ GL_UNSIGNED_BYTE);
+ gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format, width, height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
_gl_type_n_bytes (type);
}
-static inline GLenum
-_gst_gl_format_from_gl_texture_type (GstVideoGLTextureType tex_format)
+static inline guint
+_gl_texture_type_n_bytes (GstVideoGLTextureType tex_format)
+{
+ guint format, type;
+
+ format = gst_gl_format_from_gl_texture_type (tex_format);
+ type = GL_UNSIGNED_BYTE;
+ if (tex_format == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
+ type = GL_UNSIGNED_SHORT_5_6_5;
+
+ return _gl_format_type_n_bytes (format, type);
+}
+
+guint
+gst_gl_format_from_gl_texture_type (GstVideoGLTextureType tex_format)
{
switch (tex_format) {
case GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA:
}
}
-static inline guint
-_gl_texture_type_n_bytes (GstVideoGLTextureType tex_format)
-{
- guint format, type;
-
- format = _gst_gl_format_from_gl_texture_type (tex_format);
- type = GL_UNSIGNED_BYTE;
- if (tex_format == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
- type = GL_UNSIGNED_SHORT_5_6_5;
-
- return _gl_format_type_n_bytes (format, type);
-}
-
GstVideoGLTextureType
gst_gl_texture_type_from_format (GstGLContext * context,
GstVideoFormat v_format, guint plane)
return GST_VIDEO_GL_TEXTURE_TYPE_RGBA;
}
-static inline GLenum
-_sized_gl_format_from_gl_format_type (GstGLContext * context, GLenum format,
- GLenum type)
+guint
+gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
+ guint format, guint type)
{
gboolean ext_texture_rg =
gst_gl_context_check_feature (context, "GL_EXT_texture_rg");
case GL_RGBA:
switch (type) {
case GL_UNSIGNED_BYTE:
- return gst_gl_internal_format_rgba (context);
+ return USING_GLES2 (context)
+ && !USING_GLES3 (context) ? GL_RGBA : GL_RGBA8;
break;
}
break;
data->gl_format, data->gl_type, data->width, data->height);
internal_format =
- _sized_gl_format_from_gl_format_type (context, data->gl_format,
+ gst_gl_sized_gl_format_from_gl_format_type (context, data->gl_format,
data->gl_type);
gl->GenTextures (1, &data->result);
if (gl_mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
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;
if (USING_OPENGL (context) || USING_GLES3 (context)
size = gst_gl_get_plane_data_size (&gl_mem->info, &gl_mem->valign,
gl_mem->plane);
plane_start = _find_plane_frame_start (gl_mem);
- format = _gst_gl_format_from_gl_texture_type (gl_mem->tex_type);
+ format = gst_gl_format_from_gl_texture_type (gl_mem->tex_type);
type = GL_UNSIGNED_BYTE;
if (gl_mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
type = GL_UNSIGNED_SHORT_5_6_5;
GLuint fboId;
gl = context->gl_vtable;
- format = _gst_gl_format_from_gl_texture_type (gl_mem->tex_type);
+ format = gst_gl_format_from_gl_texture_type (gl_mem->tex_type);
type = GL_UNSIGNED_BYTE;
if (gl_mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
type = GL_UNSIGNED_SHORT_5_6_5;
data.width = mem->tex_width;
data.height = GL_MEM_HEIGHT (mem);
- data.gl_format = _gst_gl_format_from_gl_texture_type (mem->tex_type);
+ data.gl_format = gst_gl_format_from_gl_texture_type (mem->tex_type);
data.gl_type = GL_UNSIGNED_BYTE;
data.gl_target = mem->tex_target;
if (mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
out_stride = copy_params->out_stride;
gl = src->context->gl_vtable;
- out_gl_format = _gst_gl_format_from_gl_texture_type (copy_params->out_format);
+ out_gl_format = gst_gl_format_from_gl_texture_type (copy_params->out_format);
out_gl_type = GL_UNSIGNED_BYTE;
if (copy_params->out_format == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
out_gl_type = GL_UNSIGNED_SHORT_5_6_5;
- in_gl_format = _gst_gl_format_from_gl_texture_type (src->tex_type);
+ in_gl_format = gst_gl_format_from_gl_texture_type (src->tex_type);
in_gl_type = GL_UNSIGNED_BYTE;
if (src->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16)
in_gl_type = GL_UNSIGNED_SHORT_5_6_5;
gint gst_gl_memory_get_texture_width (GstGLMemory * gl_mem);
gint gst_gl_memory_get_texture_height (GstGLMemory * gl_mem);
-GstVideoGLTextureType gst_gl_texture_type_from_format (GstGLContext *context, GstVideoFormat v_format, guint plane);
+GstVideoGLTextureType gst_gl_texture_type_from_format (GstGLContext *context,
+ GstVideoFormat v_format,
+ guint plane);
+guint gst_gl_format_from_gl_texture_type (GstVideoGLTextureType tex_format);
+guint gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
+ guint format,
+ guint type);
void gst_gl_memory_download_transfer (GstGLMemory * gl_mem);
_gen_texture (GstGLContext * context, GenTexture * data)
{
const GstGLFuncs *gl = context->gl_vtable;
+ GLenum internal_format;
GST_TRACE ("Generating texture format:%u dimensions:%ux%u", data->format,
data->width, data->height);
gl->GenTextures (1, &data->result);
gl->BindTexture (GL_TEXTURE_2D, data->result);
+ internal_format =
+ gst_gl_sized_gl_format_from_gl_format_type (context, GL_RGBA,
+ GL_UNSIGNED_BYTE);
if (data->width > 0 && data->height > 0)
- gl->TexImage2D (GL_TEXTURE_2D, 0, gst_gl_internal_format_rgba (context),
+ gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format,
data->width, data->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GST_LOG ("generated texture id:%d", data->result);
}
+/* deprecated. replaced by GstGLMemory */
void
gst_gl_context_gen_texture (GstGLContext * context, GLuint * pTexture,
GstVideoFormat v_format, GLint width, GLint height)
context->gl_vtable->DeleteTextures (1, texture);
}
+/* deprecated. replaced by GstGLMemory */
void
gst_gl_context_del_texture (GstGLContext * context, GLuint * pTexture)
{
_gen_texture_full (GstGLContext * context, GenTextureFull * data)
{
const GstGLFuncs *gl = context->gl_vtable;
+ GstVideoGLTextureType tex_type;
+ GstVideoFormat v_format;
GLint glinternalformat = 0;
GLenum glformat = 0;
GLenum gltype = 0;
gl->GenTextures (1, &data->result);
gl->BindTexture (GL_TEXTURE_2D, data->result);
- switch (GST_VIDEO_INFO_FORMAT (data->info)) {
- case GST_VIDEO_FORMAT_RGB:
- case GST_VIDEO_FORMAT_BGR:
- {
- glinternalformat = GL_RGB8;
- glformat = GL_RGB;
- gltype = GL_UNSIGNED_BYTE;
- break;
- }
- case GST_VIDEO_FORMAT_RGB16:
- {
- glinternalformat = GL_RGB16;
- glformat = GL_RGB;
- gltype = GL_UNSIGNED_SHORT_5_6_5;
- break;
- }
- case GST_VIDEO_FORMAT_RGBA:
- case GST_VIDEO_FORMAT_BGRA:
- case GST_VIDEO_FORMAT_ARGB:
- case GST_VIDEO_FORMAT_ABGR:
- case GST_VIDEO_FORMAT_RGBx:
- case GST_VIDEO_FORMAT_BGRx:
- case GST_VIDEO_FORMAT_xRGB:
- case GST_VIDEO_FORMAT_xBGR:
- case GST_VIDEO_FORMAT_AYUV:
- {
- glinternalformat = gst_gl_internal_format_rgba (context);
- glformat = GL_RGBA;
- gltype = GL_UNSIGNED_BYTE;
- break;
- }
- case GST_VIDEO_FORMAT_NV12:
- case GST_VIDEO_FORMAT_NV21:
- {
- glinternalformat = GL_LUMINANCE;
- glformat = data->comp == 0 ? GL_LUMINANCE : GL_LUMINANCE_ALPHA;
- gltype = GL_UNSIGNED_BYTE;
- break;
- }
- case GST_VIDEO_FORMAT_I420:
- case GST_VIDEO_FORMAT_YV12:
- case GST_VIDEO_FORMAT_Y444:
- case GST_VIDEO_FORMAT_Y42B:
- case GST_VIDEO_FORMAT_Y41B:
- {
- glformat = GL_LUMINANCE;
- gltype = GL_UNSIGNED_BYTE;
- break;
- }
- default:
- GST_WARNING ("unsupported %s",
- gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (data->info)));
- break;
- }
+ v_format = GST_VIDEO_INFO_FORMAT (data->info);
+ tex_type = gst_gl_texture_type_from_format (context, v_format, data->comp);
+ glformat = gst_gl_format_from_gl_texture_type (tex_type);
+ gltype = GL_UNSIGNED_BYTE;
+ if (v_format == GST_VIDEO_FORMAT_RGB16)
+ gltype = GL_UNSIGNED_SHORT_5_6_5;
+ glinternalformat = gst_gl_sized_gl_format_from_gl_format_type (context,
+ glformat, gltype);
gl->TexImage2D (GL_TEXTURE_2D, 0, glinternalformat,
GST_VIDEO_INFO_COMP_WIDTH (data->info, data->comp),
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
+/* deprecated. replaced by GstGLMemory */
void
gst_gl_generate_texture_full (GstGLContext * context, const GstVideoInfo * info,
const guint comp, gint stride[], gsize offset[], gsize size[],
return tmp;
}
-
-GLint
-gst_gl_internal_format_rgba (GstGLContext * context)
-{
-#if GST_GL_HAVE_GLES2 && (GST_GL_HAVE_OPENGL || GST_GL_HAVE_GLES3)
- return USING_GLES2 (context) ? GL_RGBA : GL_RGBA8;
-#elif GST_GL_HAVE_OPENGL || GST_GL_HAVE_GLES3
- return GL_RGBA8;
-#else
- return GL_RGBA;
-#endif
-}
*/
typedef void (*GLCB_V2) (gpointer stuff);
+/* deprecated. replaced by GstGLMemory */
void gst_gl_context_gen_texture (GstGLContext * context, GLuint * pTexture,
GstVideoFormat v_format, GLint width, GLint height);
+/* deprecated. replaced by GstGLMemory */
void gst_gl_context_del_texture (GstGLContext * context, GLuint * pTexture);
+/* deprecated. replaced by GstGLMemory */
void gst_gl_generate_texture_full (GstGLContext * context, const GstVideoInfo * info,
const guint comp, gint stride[], gsize offset[], gsize size[], GLuint * pTexture);
guint plane);
GstCaps * gst_gl_caps_replace_all_caps_features (const GstCaps * caps,
const gchar * feature_name);
-GLint gst_gl_internal_format_rgba (GstGLContext * context);
G_END_DECLS