mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
eglglessink: Always use an RGBA configuration
This commit is contained in:
parent
d290dd74c9
commit
ebe5849443
2 changed files with 339 additions and 476 deletions
|
@ -302,6 +302,16 @@ static const char *frag_NV12_NV21_prog = {
|
||||||
};
|
};
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
static const EGLint eglglessink_RGBA8888_attribs[] = {
|
||||||
|
EGL_RED_SIZE, 8,
|
||||||
|
EGL_GREEN_SIZE, 8,
|
||||||
|
EGL_BLUE_SIZE, 8,
|
||||||
|
EGL_ALPHA_SIZE, 8,
|
||||||
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||||
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
|
||||||
/* Input capabilities. */
|
/* Input capabilities. */
|
||||||
static GstStaticPadTemplate gst_eglglessink_sink_template_factory =
|
static GstStaticPadTemplate gst_eglglessink_sink_template_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
|
@ -327,35 +337,6 @@ enum
|
||||||
PROP_FORCE_ASPECT_RATIO,
|
PROP_FORCE_ASPECT_RATIO,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* will probably move elsewhere */
|
|
||||||
static const EGLint eglglessink_RGBA8888_attribs[] = {
|
|
||||||
EGL_RED_SIZE, 8,
|
|
||||||
EGL_GREEN_SIZE, 8,
|
|
||||||
EGL_BLUE_SIZE, 8,
|
|
||||||
EGL_ALPHA_SIZE, 8,
|
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
static const EGLint eglglessink_RGB888_attribs[] = {
|
|
||||||
EGL_RED_SIZE, 8,
|
|
||||||
EGL_GREEN_SIZE, 8,
|
|
||||||
EGL_BLUE_SIZE, 8,
|
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
static const EGLint eglglessink_RGB565_attribs[] = {
|
|
||||||
EGL_RED_SIZE, 5,
|
|
||||||
EGL_GREEN_SIZE, 6,
|
|
||||||
EGL_BLUE_SIZE, 5,
|
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
static void gst_eglglessink_finalize (GObject * object);
|
static void gst_eglglessink_finalize (GObject * object);
|
||||||
static void gst_eglglessink_get_property (GObject * object, guint prop_id,
|
static void gst_eglglessink_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
@ -384,12 +365,10 @@ static void gst_eglglessink_set_render_rectangle (GstVideoOverlay * overlay,
|
||||||
gint x, gint y, gint width, gint height);
|
gint x, gint y, gint width, gint height);
|
||||||
|
|
||||||
/* Utility */
|
/* Utility */
|
||||||
static GstEglGlesImageFmt *gst_eglglessink_get_compat_format_from_caps
|
|
||||||
(GstEglGlesSink * eglglessink, GstCaps * caps);
|
|
||||||
static EGLNativeWindowType gst_eglglessink_create_window (GstEglGlesSink *
|
static EGLNativeWindowType gst_eglglessink_create_window (GstEglGlesSink *
|
||||||
eglglessink, gint width, gint height);
|
eglglessink, gint width, gint height);
|
||||||
static inline gint
|
static gboolean gst_eglglessink_fill_supported_fbuffer_configs (GstEglGlesSink *
|
||||||
gst_eglglessink_fill_supported_fbuffer_configs (GstEglGlesSink * eglglessink);
|
eglglessink);
|
||||||
static gboolean gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink);
|
static gboolean gst_eglglessink_init_egl_display (GstEglGlesSink * eglglessink);
|
||||||
static gboolean gst_eglglessink_choose_config (GstEglGlesSink * eglglessink);
|
static gboolean gst_eglglessink_choose_config (GstEglGlesSink * eglglessink);
|
||||||
static gboolean gst_eglglessink_init_egl_surface (GstEglGlesSink * eglglessink);
|
static gboolean gst_eglglessink_init_egl_surface (GstEglGlesSink * eglglessink);
|
||||||
|
@ -405,7 +384,6 @@ static GstFlowReturn gst_eglglessink_queue_object (GstEglGlesSink * sink,
|
||||||
GstMiniObject * obj);
|
GstMiniObject * obj);
|
||||||
static inline gboolean got_gl_error (const char *wtf);
|
static inline gboolean got_gl_error (const char *wtf);
|
||||||
static inline gboolean got_egl_error (const char *wtf);
|
static inline gboolean got_egl_error (const char *wtf);
|
||||||
static void gst_eglglessink_wipe_fmt (gpointer data);
|
|
||||||
static inline gboolean egl_init (GstEglGlesSink * eglglessink);
|
static inline gboolean egl_init (GstEglGlesSink * eglglessink);
|
||||||
static gboolean gst_eglglessink_context_make_current (GstEglGlesSink *
|
static gboolean gst_eglglessink_context_make_current (GstEglGlesSink *
|
||||||
eglglessink, gboolean bind);
|
eglglessink, gboolean bind);
|
||||||
|
@ -421,38 +399,6 @@ G_DEFINE_TYPE_WITH_CODE (GstEglGlesSink, gst_eglglessink, GST_TYPE_VIDEO_SINK,
|
||||||
gst_eglglessink_videooverlay_init));
|
gst_eglglessink_videooverlay_init));
|
||||||
|
|
||||||
|
|
||||||
static GstEglGlesImageFmt *
|
|
||||||
gst_eglglessink_get_compat_format_from_caps (GstEglGlesSink * eglglessink,
|
|
||||||
GstCaps * caps)
|
|
||||||
{
|
|
||||||
GList *list;
|
|
||||||
GstEglGlesImageFmt *format;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_EGLGLESSINK (eglglessink), 0);
|
|
||||||
|
|
||||||
list = eglglessink->supported_fmts;
|
|
||||||
|
|
||||||
/* Traverse the list trying to find a compatible format */
|
|
||||||
while (list) {
|
|
||||||
format = list->data;
|
|
||||||
GST_DEBUG_OBJECT (eglglessink, "Checking compatibility between listed %"
|
|
||||||
GST_PTR_FORMAT " and %" GST_PTR_FORMAT, format->caps, caps);
|
|
||||||
if (format) {
|
|
||||||
if (gst_caps_can_intersect (caps, format->caps)) {
|
|
||||||
GST_INFO_OBJECT (eglglessink, "Found compatible format %d",
|
|
||||||
format->fmt);
|
|
||||||
GST_DEBUG_OBJECT (eglglessink,
|
|
||||||
"Got caps %" GST_PTR_FORMAT " and this format can do %"
|
|
||||||
GST_PTR_FORMAT, caps, format->caps);
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list = g_list_next (list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
_gst_video_format_new_template_caps (GstVideoFormat format)
|
_gst_video_format_new_template_caps (GstVideoFormat format)
|
||||||
{
|
{
|
||||||
|
@ -463,12 +409,11 @@ _gst_video_format_new_template_caps (GstVideoFormat format)
|
||||||
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
|
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline gint
|
static gboolean
|
||||||
gst_eglglessink_fill_supported_fbuffer_configs (GstEglGlesSink * eglglessink)
|
gst_eglglessink_fill_supported_fbuffer_configs (GstEglGlesSink * eglglessink)
|
||||||
{
|
{
|
||||||
gint ret = 0;
|
gboolean ret = FALSE;
|
||||||
EGLint cfg_number;
|
EGLint cfg_number;
|
||||||
GstEglGlesImageFmt *format;
|
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (eglglessink,
|
GST_DEBUG_OBJECT (eglglessink,
|
||||||
|
@ -479,79 +424,48 @@ gst_eglglessink_fill_supported_fbuffer_configs (GstEglGlesSink * eglglessink)
|
||||||
|
|
||||||
if (eglChooseConfig (gst_egl_display_get (eglglessink->eglglesctx.display),
|
if (eglChooseConfig (gst_egl_display_get (eglglessink->eglglesctx.display),
|
||||||
eglglessink_RGBA8888_attribs, NULL, 1, &cfg_number) != EGL_FALSE) {
|
eglglessink_RGBA8888_attribs, NULL, 1, &cfg_number) != EGL_FALSE) {
|
||||||
format = g_new0 (GstEglGlesImageFmt, 1);
|
gst_caps_append (caps,
|
||||||
format->fmt = GST_EGLGLESSINK_IMAGE_RGBA8888;
|
|
||||||
format->attribs = eglglessink_RGBA8888_attribs;
|
|
||||||
format->caps = _gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGBA);
|
|
||||||
gst_caps_append (format->caps,
|
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_BGRA));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_BGRA));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_ARGB));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_ARGB));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_ABGR));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_ABGR));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGBx));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGBx));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_BGRx));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_BGRx));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_xRGB));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_xRGB));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_xBGR));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_xBGR));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_AYUV));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_AYUV));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_Y444));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_Y444));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGB));
|
||||||
|
gst_caps_append (caps,
|
||||||
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_BGR));
|
||||||
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_I420));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_I420));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_YV12));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_YV12));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_NV12));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_NV12));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_NV21));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_NV21));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_Y42B));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_Y42B));
|
||||||
gst_caps_append (format->caps,
|
gst_caps_append (caps,
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_Y41B));
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_Y41B));
|
||||||
eglglessink->supported_fmts =
|
gst_caps_append (caps,
|
||||||
g_list_append (eglglessink->supported_fmts, format);
|
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGB16));
|
||||||
ret++;
|
ret = TRUE;
|
||||||
gst_caps_append (caps, gst_caps_ref (format->caps));
|
|
||||||
} else {
|
} else {
|
||||||
GST_INFO_OBJECT (eglglessink,
|
GST_INFO_OBJECT (eglglessink,
|
||||||
"EGL display doesn't support RGBA8888 config");
|
"EGL display doesn't support RGBA8888 config");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eglChooseConfig (gst_egl_display_get (eglglessink->eglglesctx.display),
|
|
||||||
eglglessink_RGB888_attribs, NULL, 1, &cfg_number) != EGL_FALSE) {
|
|
||||||
format = g_new0 (GstEglGlesImageFmt, 1);
|
|
||||||
format->fmt = GST_EGLGLESSINK_IMAGE_RGB888;
|
|
||||||
format->attribs = eglglessink_RGB888_attribs;
|
|
||||||
format->caps = _gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGB);
|
|
||||||
gst_caps_append (format->caps,
|
|
||||||
_gst_video_format_new_template_caps (GST_VIDEO_FORMAT_BGR));
|
|
||||||
eglglessink->supported_fmts =
|
|
||||||
g_list_append (eglglessink->supported_fmts, format);
|
|
||||||
ret++;
|
|
||||||
gst_caps_append (caps, gst_caps_ref (format->caps));
|
|
||||||
} else {
|
|
||||||
GST_INFO_OBJECT (eglglessink, "EGL display doesn't support RGB888 config");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eglChooseConfig (gst_egl_display_get (eglglessink->eglglesctx.display),
|
|
||||||
eglglessink_RGB565_attribs, NULL, 1, &cfg_number) != EGL_FALSE) {
|
|
||||||
format = g_new0 (GstEglGlesImageFmt, 1);
|
|
||||||
format->fmt = GST_EGLGLESSINK_IMAGE_RGB565;
|
|
||||||
format->attribs = eglglessink_RGB565_attribs;
|
|
||||||
format->caps = _gst_video_format_new_template_caps (GST_VIDEO_FORMAT_RGB16);
|
|
||||||
eglglessink->supported_fmts =
|
|
||||||
g_list_append (eglglessink->supported_fmts, format);
|
|
||||||
ret++;
|
|
||||||
gst_caps_append (caps, gst_caps_ref (format->caps));
|
|
||||||
} else {
|
|
||||||
GST_INFO_OBJECT (eglglessink, "EGL display doesn't support RGB565 config");
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (eglglessink);
|
GST_OBJECT_LOCK (eglglessink);
|
||||||
gst_caps_replace (&eglglessink->sinkcaps, caps);
|
gst_caps_replace (&eglglessink->sinkcaps, caps);
|
||||||
GST_OBJECT_UNLOCK (eglglessink);
|
GST_OBJECT_UNLOCK (eglglessink);
|
||||||
|
@ -1595,7 +1509,7 @@ gst_eglglessink_choose_config (GstEglGlesSink * eglglessink)
|
||||||
GLint egl_configs;
|
GLint egl_configs;
|
||||||
|
|
||||||
if ((eglChooseConfig (gst_egl_display_get (eglglessink->eglglesctx.display),
|
if ((eglChooseConfig (gst_egl_display_get (eglglessink->eglglesctx.display),
|
||||||
eglglessink->selected_fmt->attribs,
|
eglglessink_RGBA8888_attribs,
|
||||||
&eglglessink->eglglesctx.config, 1, &egl_configs)) == EGL_FALSE) {
|
&eglglessink->eglglesctx.config, 1, &egl_configs)) == EGL_FALSE) {
|
||||||
got_egl_error ("eglChooseConfig");
|
got_egl_error ("eglChooseConfig");
|
||||||
GST_ERROR_OBJECT (eglglessink, "eglChooseConfig failed");
|
GST_ERROR_OBJECT (eglglessink, "eglChooseConfig failed");
|
||||||
|
@ -1760,8 +1674,9 @@ gst_eglglessink_fill_texture (GstEglGlesSink * eglglessink, GstBuffer * buf)
|
||||||
GST_DEBUG_OBJECT (eglglessink,
|
GST_DEBUG_OBJECT (eglglessink,
|
||||||
"Got buffer %p: %dx%d size %d", buf, w, h, gst_buffer_get_size (buf));
|
"Got buffer %p: %dx%d size %d", buf, w, h, gst_buffer_get_size (buf));
|
||||||
|
|
||||||
switch (eglglessink->selected_fmt->fmt) {
|
switch (eglglessink->configured_info.finfo->format) {
|
||||||
case GST_EGLGLESSINK_IMAGE_RGB888:{
|
case GST_VIDEO_FORMAT_BGR:
|
||||||
|
case GST_VIDEO_FORMAT_RGB:{
|
||||||
gint stride;
|
gint stride;
|
||||||
gint stride_width;
|
gint stride_width;
|
||||||
gint c_w;
|
gint c_w;
|
||||||
|
@ -1805,7 +1720,7 @@ gst_eglglessink_fill_texture (GstEglGlesSink * eglglessink, GstBuffer * buf)
|
||||||
GL_UNSIGNED_BYTE, GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0));
|
GL_UNSIGNED_BYTE, GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_EGLGLESSINK_IMAGE_RGB565:{
|
case GST_VIDEO_FORMAT_RGB16:{
|
||||||
gint stride;
|
gint stride;
|
||||||
gint stride_width;
|
gint stride_width;
|
||||||
gint c_w;
|
gint c_w;
|
||||||
|
@ -1845,315 +1760,309 @@ gst_eglglessink_fill_texture (GstEglGlesSink * eglglessink, GstBuffer * buf)
|
||||||
GL_UNSIGNED_SHORT_5_6_5, GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0));
|
GL_UNSIGNED_SHORT_5_6_5, GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_EGLGLESSINK_IMAGE_RGBA8888:
|
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:{
|
||||||
|
gint stride;
|
||||||
|
gint stride_width;
|
||||||
|
gint c_w;
|
||||||
|
|
||||||
switch (eglglessink->configured_info.finfo->format) {
|
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);
|
||||||
case GST_VIDEO_FORMAT_RGBA:
|
stride_width = c_w = GST_VIDEO_FRAME_WIDTH (&vframe);
|
||||||
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:{
|
|
||||||
gint stride;
|
|
||||||
gint stride_width;
|
|
||||||
gint c_w;
|
|
||||||
|
|
||||||
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);
|
glActiveTexture (GL_TEXTURE0);
|
||||||
stride_width = c_w = GST_VIDEO_FRAME_WIDTH (&vframe);
|
|
||||||
|
|
||||||
glActiveTexture (GL_TEXTURE0);
|
if (GST_ROUND_UP_8 (c_w * 4) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (c_w * 4 == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else {
|
||||||
|
stride_width = stride;
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (c_w * 4) == stride) {
|
if (GST_ROUND_UP_8 (stride_width * 4) == stride) {
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
} else if (c_w * 4 == stride) {
|
} else if (stride_width * 4 == stride) {
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
} else {
|
} else {
|
||||||
stride_width = stride;
|
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
||||||
|
goto HANDLE_ERROR;
|
||||||
if (GST_ROUND_UP_8 (stride_width * 4) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (stride_width * 4 == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else {
|
|
||||||
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (got_gl_error ("glPixelStorei"))
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
|
|
||||||
eglglessink->stride[0] = ((gdouble) stride_width) / ((gdouble) c_w);
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[0]);
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, stride_width, h, 0,
|
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, GST_VIDEO_FRAME_PLANE_DATA (&vframe,
|
|
||||||
0));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case GST_VIDEO_FORMAT_AYUV:{
|
|
||||||
gint stride;
|
|
||||||
gint stride_width;
|
|
||||||
gint c_w;
|
|
||||||
|
|
||||||
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);
|
|
||||||
stride_width = c_w = GST_VIDEO_FRAME_WIDTH (&vframe);
|
|
||||||
|
|
||||||
glActiveTexture (GL_TEXTURE0);
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (c_w * 4) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (c_w * 4 == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else {
|
|
||||||
stride_width = stride;
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (stride_width * 4) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (stride_width * 4 == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else {
|
|
||||||
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (got_gl_error ("glPixelStorei"))
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
|
|
||||||
eglglessink->stride[0] = ((gdouble) stride_width) / ((gdouble) c_w);
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[0]);
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, stride_width, h, 0,
|
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, GST_VIDEO_FRAME_PLANE_DATA (&vframe,
|
|
||||||
0));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GST_VIDEO_FORMAT_Y444:
|
|
||||||
case GST_VIDEO_FORMAT_I420:
|
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
|
||||||
case GST_VIDEO_FORMAT_Y42B:
|
|
||||||
case GST_VIDEO_FORMAT_Y41B:{
|
|
||||||
gint stride;
|
|
||||||
gint stride_width;
|
|
||||||
gint c_w;
|
|
||||||
|
|
||||||
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);
|
|
||||||
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 0);
|
|
||||||
|
|
||||||
glActiveTexture (GL_TEXTURE0);
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (GST_ROUND_UP_2 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else if (c_w == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
} else {
|
|
||||||
stride_width = stride;
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (GST_ROUND_UP_2 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else if (stride_width == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
} else {
|
|
||||||
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (got_gl_error ("glPixelStorei"))
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
|
|
||||||
eglglessink->stride[0] = ((gdouble) stride_width) / ((gdouble) c_w);
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[0]);
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
|
|
||||||
stride_width,
|
|
||||||
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 0),
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
|
||||||
GST_VIDEO_FRAME_COMP_DATA (&vframe, 0));
|
|
||||||
|
|
||||||
|
|
||||||
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 1);
|
|
||||||
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 1);
|
|
||||||
|
|
||||||
glActiveTexture (GL_TEXTURE1);
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (GST_ROUND_UP_2 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else if (c_w == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
} else {
|
|
||||||
stride_width = stride;
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (GST_ROUND_UP_2 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else if (stride_width == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
} else {
|
|
||||||
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (got_gl_error ("glPixelStorei"))
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
|
|
||||||
eglglessink->stride[1] = ((gdouble) stride_width) / ((gdouble) c_w);
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[1]);
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
|
|
||||||
stride_width,
|
|
||||||
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 1),
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
|
||||||
GST_VIDEO_FRAME_COMP_DATA (&vframe, 1));
|
|
||||||
|
|
||||||
|
|
||||||
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 2);
|
|
||||||
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 2);
|
|
||||||
|
|
||||||
glActiveTexture (GL_TEXTURE2);
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (GST_ROUND_UP_2 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else if (c_w == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
} else {
|
|
||||||
stride_width = stride;
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (GST_ROUND_UP_2 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else if (stride_width == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
} else {
|
|
||||||
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (got_gl_error ("glPixelStorei"))
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
|
|
||||||
eglglessink->stride[2] = ((gdouble) stride_width) / ((gdouble) c_w);
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[2]);
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
|
|
||||||
stride_width,
|
|
||||||
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 2),
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
|
||||||
GST_VIDEO_FRAME_COMP_DATA (&vframe, 2));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GST_VIDEO_FORMAT_NV12:
|
|
||||||
case GST_VIDEO_FORMAT_NV21:{
|
|
||||||
gint stride;
|
|
||||||
gint stride_width;
|
|
||||||
gint c_w;
|
|
||||||
|
|
||||||
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);
|
|
||||||
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 0);
|
|
||||||
|
|
||||||
glActiveTexture (GL_TEXTURE0);
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (GST_ROUND_UP_2 (c_w) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else if (c_w == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
} else {
|
|
||||||
stride_width = stride;
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (GST_ROUND_UP_2 (stride_width) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else if (stride_width == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
} else {
|
|
||||||
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (got_gl_error ("glPixelStorei"))
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
|
|
||||||
eglglessink->stride[0] = ((gdouble) stride_width) / ((gdouble) c_w);
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[0]);
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
|
|
||||||
stride_width,
|
|
||||||
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 0),
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
|
||||||
GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0));
|
|
||||||
|
|
||||||
|
|
||||||
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 1);
|
|
||||||
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 1);
|
|
||||||
|
|
||||||
glActiveTexture (GL_TEXTURE1);
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (c_w * 2) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (c_w * 2) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (c_w * 2 == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else {
|
|
||||||
stride_width = stride / 2;
|
|
||||||
|
|
||||||
if (GST_ROUND_UP_8 (stride_width * 2) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
|
||||||
} else if (GST_ROUND_UP_4 (stride_width * 2) == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
} else if (stride_width * 2 == stride) {
|
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
|
||||||
} else {
|
|
||||||
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (got_gl_error ("glPixelStorei"))
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
|
|
||||||
eglglessink->stride[1] = ((gdouble) stride_width) / ((gdouble) c_w);
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[1]);
|
|
||||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
|
|
||||||
stride_width,
|
|
||||||
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 1),
|
|
||||||
0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
|
|
||||||
GST_VIDEO_FRAME_PLANE_DATA (&vframe, 1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (got_gl_error ("glPixelStorei"))
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
|
||||||
|
eglglessink->stride[0] = ((gdouble) stride_width) / ((gdouble) c_w);
|
||||||
|
|
||||||
|
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[0]);
|
||||||
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, stride_width, h, 0,
|
||||||
|
GL_RGBA, GL_UNSIGNED_BYTE, GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GST_VIDEO_FORMAT_AYUV:{
|
||||||
|
gint stride;
|
||||||
|
gint stride_width;
|
||||||
|
gint c_w;
|
||||||
|
|
||||||
|
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);
|
||||||
|
stride_width = c_w = GST_VIDEO_FRAME_WIDTH (&vframe);
|
||||||
|
|
||||||
|
glActiveTexture (GL_TEXTURE0);
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (c_w * 4) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (c_w * 4 == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else {
|
||||||
|
stride_width = stride;
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (stride_width * 4) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (stride_width * 4 == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (got_gl_error ("glPixelStorei"))
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
|
||||||
|
eglglessink->stride[0] = ((gdouble) stride_width) / ((gdouble) c_w);
|
||||||
|
|
||||||
|
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[0]);
|
||||||
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, stride_width, h, 0,
|
||||||
|
GL_RGBA, GL_UNSIGNED_BYTE, GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GST_VIDEO_FORMAT_Y444:
|
||||||
|
case GST_VIDEO_FORMAT_I420:
|
||||||
|
case GST_VIDEO_FORMAT_YV12:
|
||||||
|
case GST_VIDEO_FORMAT_Y42B:
|
||||||
|
case GST_VIDEO_FORMAT_Y41B:{
|
||||||
|
gint stride;
|
||||||
|
gint stride_width;
|
||||||
|
gint c_w;
|
||||||
|
|
||||||
|
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);
|
||||||
|
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 0);
|
||||||
|
|
||||||
|
glActiveTexture (GL_TEXTURE0);
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (GST_ROUND_UP_2 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else if (c_w == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
} else {
|
||||||
|
stride_width = stride;
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (GST_ROUND_UP_2 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else if (stride_width == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (got_gl_error ("glPixelStorei"))
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
|
||||||
|
eglglessink->stride[0] = ((gdouble) stride_width) / ((gdouble) c_w);
|
||||||
|
|
||||||
|
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[0]);
|
||||||
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
|
||||||
|
stride_width,
|
||||||
|
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 0),
|
||||||
|
0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
||||||
|
GST_VIDEO_FRAME_COMP_DATA (&vframe, 0));
|
||||||
|
|
||||||
|
|
||||||
|
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 1);
|
||||||
|
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 1);
|
||||||
|
|
||||||
|
glActiveTexture (GL_TEXTURE1);
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (GST_ROUND_UP_2 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else if (c_w == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
} else {
|
||||||
|
stride_width = stride;
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (GST_ROUND_UP_2 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else if (stride_width == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (got_gl_error ("glPixelStorei"))
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
|
||||||
|
eglglessink->stride[1] = ((gdouble) stride_width) / ((gdouble) c_w);
|
||||||
|
|
||||||
|
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[1]);
|
||||||
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
|
||||||
|
stride_width,
|
||||||
|
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 1),
|
||||||
|
0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
||||||
|
GST_VIDEO_FRAME_COMP_DATA (&vframe, 1));
|
||||||
|
|
||||||
|
|
||||||
|
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 2);
|
||||||
|
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 2);
|
||||||
|
|
||||||
|
glActiveTexture (GL_TEXTURE2);
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (GST_ROUND_UP_2 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else if (c_w == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
} else {
|
||||||
|
stride_width = stride;
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (GST_ROUND_UP_2 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else if (stride_width == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (got_gl_error ("glPixelStorei"))
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
|
||||||
|
eglglessink->stride[2] = ((gdouble) stride_width) / ((gdouble) c_w);
|
||||||
|
|
||||||
|
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[2]);
|
||||||
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
|
||||||
|
stride_width,
|
||||||
|
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 2),
|
||||||
|
0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
||||||
|
GST_VIDEO_FRAME_COMP_DATA (&vframe, 2));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GST_VIDEO_FORMAT_NV12:
|
||||||
|
case GST_VIDEO_FORMAT_NV21:{
|
||||||
|
gint stride;
|
||||||
|
gint stride_width;
|
||||||
|
gint c_w;
|
||||||
|
|
||||||
|
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 0);
|
||||||
|
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 0);
|
||||||
|
|
||||||
|
glActiveTexture (GL_TEXTURE0);
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (GST_ROUND_UP_2 (c_w) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else if (c_w == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
} else {
|
||||||
|
stride_width = stride;
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (GST_ROUND_UP_2 (stride_width) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else if (stride_width == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (got_gl_error ("glPixelStorei"))
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
|
||||||
|
eglglessink->stride[0] = ((gdouble) stride_width) / ((gdouble) c_w);
|
||||||
|
|
||||||
|
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[0]);
|
||||||
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE,
|
||||||
|
stride_width,
|
||||||
|
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 0),
|
||||||
|
0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
||||||
|
GST_VIDEO_FRAME_PLANE_DATA (&vframe, 0));
|
||||||
|
|
||||||
|
|
||||||
|
stride = GST_VIDEO_FRAME_PLANE_STRIDE (&vframe, 1);
|
||||||
|
stride_width = c_w = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, 1);
|
||||||
|
|
||||||
|
glActiveTexture (GL_TEXTURE1);
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (c_w * 2) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (c_w * 2) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (c_w * 2 == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else {
|
||||||
|
stride_width = stride / 2;
|
||||||
|
|
||||||
|
if (GST_ROUND_UP_8 (stride_width * 2) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 8);
|
||||||
|
} else if (GST_ROUND_UP_4 (stride_width * 2) == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
|
} else if (stride_width * 2 == stride) {
|
||||||
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 2);
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (eglglessink, "Unsupported stride %d", stride);
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (got_gl_error ("glPixelStorei"))
|
||||||
|
goto HANDLE_ERROR;
|
||||||
|
|
||||||
|
eglglessink->stride[1] = ((gdouble) stride_width) / ((gdouble) c_w);
|
||||||
|
|
||||||
|
glBindTexture (GL_TEXTURE_2D, eglglessink->eglglesctx.texture[1]);
|
||||||
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
|
||||||
|
stride_width,
|
||||||
|
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, 1),
|
||||||
|
0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
|
||||||
|
GST_VIDEO_FRAME_PLANE_DATA (&vframe, 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got_gl_error ("glTexImage2D"))
|
if (got_gl_error ("glTexImage2D"))
|
||||||
|
@ -2568,7 +2477,6 @@ static gboolean
|
||||||
gst_eglglessink_configure_caps (GstEglGlesSink * eglglessink, GstCaps * caps)
|
gst_eglglessink_configure_caps (GstEglGlesSink * eglglessink, GstCaps * caps)
|
||||||
{
|
{
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
GstEglGlesImageFmt *format;
|
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
|
|
||||||
gst_video_info_init (&info);
|
gst_video_info_init (&info);
|
||||||
|
@ -2577,16 +2485,6 @@ gst_eglglessink_configure_caps (GstEglGlesSink * eglglessink, GstCaps * caps)
|
||||||
goto HANDLE_ERROR;
|
goto HANDLE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
format = gst_eglglessink_get_compat_format_from_caps (eglglessink, caps);
|
|
||||||
if (!format) {
|
|
||||||
GST_ERROR_OBJECT (eglglessink,
|
|
||||||
"No supported and compatible EGL/GLES format found for given caps");
|
|
||||||
goto HANDLE_ERROR;
|
|
||||||
} else
|
|
||||||
GST_INFO_OBJECT (eglglessink, "Selected compatible EGL/GLES format %d",
|
|
||||||
format->fmt);
|
|
||||||
|
|
||||||
eglglessink->selected_fmt = format;
|
|
||||||
eglglessink->configured_info = info;
|
eglglessink->configured_info = info;
|
||||||
GST_VIDEO_SINK_WIDTH (eglglessink) = info.width;
|
GST_VIDEO_SINK_WIDTH (eglglessink) = info.width;
|
||||||
GST_VIDEO_SINK_HEIGHT (eglglessink) = info.height;
|
GST_VIDEO_SINK_HEIGHT (eglglessink) = info.height;
|
||||||
|
@ -2709,14 +2607,6 @@ gst_eglglessink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_eglglessink_wipe_fmt (gpointer data)
|
|
||||||
{
|
|
||||||
GstEglGlesImageFmt *format = data;
|
|
||||||
gst_caps_unref (format->caps);
|
|
||||||
g_free (format);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_eglglessink_open (GstEglGlesSink * eglglessink)
|
gst_eglglessink_open (GstEglGlesSink * eglglessink)
|
||||||
{
|
{
|
||||||
|
@ -2735,9 +2625,6 @@ gst_eglglessink_close (GstEglGlesSink * eglglessink)
|
||||||
eglglessink->eglglesctx.display = NULL;
|
eglglessink->eglglesctx.display = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
eglglessink->selected_fmt = NULL;
|
|
||||||
g_list_free_full (eglglessink->supported_fmts, gst_eglglessink_wipe_fmt);
|
|
||||||
eglglessink->supported_fmts = NULL;
|
|
||||||
gst_caps_unref (eglglessink->sinkcaps);
|
gst_caps_unref (eglglessink->sinkcaps);
|
||||||
eglglessink->sinkcaps = NULL;
|
eglglessink->sinkcaps = NULL;
|
||||||
eglglessink->egl_started = FALSE;
|
eglglessink->egl_started = FALSE;
|
||||||
|
|
|
@ -70,10 +70,7 @@ G_BEGIN_DECLS
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EGLGLESSINK))
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EGLGLESSINK))
|
||||||
#define GST_IS_EGLGLESSINK_CLASS(klass) \
|
#define GST_IS_EGLGLESSINK_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_EGLGLESSINK))
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_EGLGLESSINK))
|
||||||
#define GST_EGLGLESSINK_IMAGE_NOFMT 0
|
|
||||||
#define GST_EGLGLESSINK_IMAGE_RGB888 1
|
|
||||||
#define GST_EGLGLESSINK_IMAGE_RGB565 2
|
|
||||||
#define GST_EGLGLESSINK_IMAGE_RGBA8888 3
|
|
||||||
#define GST_EGLGLESSINK_EGL_MIN_VERSION 1
|
#define GST_EGLGLESSINK_EGL_MIN_VERSION 1
|
||||||
typedef struct _GstEglGlesSink GstEglGlesSink;
|
typedef struct _GstEglGlesSink GstEglGlesSink;
|
||||||
typedef struct _GstEglGlesSinkClass GstEglGlesSinkClass;
|
typedef struct _GstEglGlesSinkClass GstEglGlesSinkClass;
|
||||||
|
@ -147,33 +144,15 @@ struct _GstEglGlesRenderContext
|
||||||
unsigned int position_buffer, index_buffer;
|
unsigned int position_buffer, index_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* GstEglGlesImageFmt:
|
|
||||||
* @fmt: Internal identifier for the EGL attribs / GST caps pairing
|
|
||||||
* @attribs: Pointer to the set of EGL attributes asociated with this format
|
|
||||||
* @caps: Pointer to the GST caps asociated with this format
|
|
||||||
*
|
|
||||||
* This struct holds a pairing between GST caps and the matching EGL attributes
|
|
||||||
* associated with a given pixel format
|
|
||||||
*/
|
|
||||||
struct _GstEglGlesImageFmt
|
|
||||||
{
|
|
||||||
gint fmt; /* Private identifier */
|
|
||||||
const EGLint *attribs; /* EGL Attributes */
|
|
||||||
GstCaps *caps; /* Matching caps for the attribs */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GstEglGlesSink:
|
* GstEglGlesSink:
|
||||||
* @format: Caps' video format field
|
* @format: Caps' video format field
|
||||||
* @display_region: Surface region to use as rendering canvas
|
* @display_region: Surface region to use as rendering canvas
|
||||||
* @sinkcaps: Full set of suported caps
|
* @sinkcaps: Full set of suported caps
|
||||||
* @current_caps: Current caps
|
* @current_caps: Current caps
|
||||||
* @selected_fmt: Pointer to the GST caps/EGL attribs pairing in use
|
|
||||||
* @rendering_path: Rendering path (Slow/Fast)
|
* @rendering_path: Rendering path (Slow/Fast)
|
||||||
* @eglglesctx: Pointer to the associated EGL/GLESv2 rendering context
|
* @eglglesctx: Pointer to the associated EGL/GLESv2 rendering context
|
||||||
* @flow_lock: Simple concurrent access ward to the sink's runtime state
|
* @flow_lock: Simple concurrent access ward to the sink's runtime state
|
||||||
* @supported_fmts: Pointer to the runtime supported format list
|
|
||||||
* @have_window: Set if the sink has access to a window to hold it's canvas
|
* @have_window: Set if the sink has access to a window to hold it's canvas
|
||||||
* @using_own_window: Set if the sink created its own window
|
* @using_own_window: Set if the sink created its own window
|
||||||
* @have_surface: Set if the EGL surface setup has been performed
|
* @have_surface: Set if the EGL surface setup has been performed
|
||||||
|
@ -207,11 +186,8 @@ struct _GstEglGlesSink
|
||||||
gfloat stride[3];
|
gfloat stride[3];
|
||||||
GstBufferPool *pool;
|
GstBufferPool *pool;
|
||||||
|
|
||||||
GstEglGlesImageFmt *selected_fmt;
|
|
||||||
GstEglGlesRenderContext eglglesctx;
|
GstEglGlesRenderContext eglglesctx;
|
||||||
|
|
||||||
GList *supported_fmts;
|
|
||||||
|
|
||||||
/* Runtime flags */
|
/* Runtime flags */
|
||||||
gboolean have_window;
|
gboolean have_window;
|
||||||
gboolean using_own_window;
|
gboolean using_own_window;
|
||||||
|
|
Loading…
Reference in a new issue