"}"
};
-/* Direct fragments copy without stride-scaling */
-static const char *frag_COPY_DIRECT_prog = {
- "precision mediump float;"
- "varying vec2 opos;"
- "uniform sampler2D tex;"
- "void main(void)"
- "{"
- " vec4 t = texture2D(tex, opos);"
- " gl_FragColor = vec4(t.rgb, 1.0);"
- "}"
-};
-
/* Channel reordering for XYZ <-> ZYX conversion */
static const char *frag_REORDER_prog = {
"precision mediump float;"
}
if (ctx->have_texture) {
- glDeleteTextures (ctx->n_textures + 1, ctx->texture);
+ glDeleteTextures (ctx->n_textures, ctx->texture);
ctx->have_texture = FALSE;
ctx->n_textures = 0;
}
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 2; i++) {
if (ctx->glslprogram[i]) {
glDetachShader (ctx->glslprogram[i], ctx->fragshader[i]);
glDetachShader (ctx->glslprogram[i], ctx->vertshader[i]);
glGetUniformLocation (ctx->glslprogram[0], texnames[i]);
}
- /* custom rendering shader */
-
- if (!create_shader_program (ctx,
- &ctx->glslprogram[2],
- &ctx->vertshader[2],
- &ctx->fragshader[2], vert_COPY_prog, frag_COPY_DIRECT_prog)) {
- if (free_frag_prog)
- g_free (frag_prog);
- frag_prog = NULL;
- goto HANDLE_ERROR;
- }
- if (free_frag_prog)
- g_free (frag_prog);
- frag_prog = NULL;
-
- ctx->position_loc[2] = glGetAttribLocation (ctx->glslprogram[2], "position");
- ctx->texpos_loc[1] = glGetAttribLocation (ctx->glslprogram[2], "texpos");
-
- glEnableVertexAttribArray (ctx->position_loc[2]);
- if (got_gl_error ("glEnableVertexAttribArray"))
- goto HANDLE_ERROR;
-
- ctx->tex_loc[1][0] = glGetUniformLocation (ctx->glslprogram[2], "tex");
-
if (!ctx->buffer_preserved) {
/* Build shader program for black borders */
if (!create_shader_program (ctx,
if (!ctx->have_texture) {
GST_INFO_OBJECT (ctx->element, "Performing initial texture setup");
- glGenTextures (ctx->n_textures + 1, ctx->texture);
+ glGenTextures (ctx->n_textures, ctx->texture);
if (got_gl_error ("glGenTextures"))
goto HANDLE_ERROR_LOCKED;
- for (i = 0; i < ctx->n_textures + 1; i++) {
+ for (i = 0; i < ctx->n_textures; i++) {
glBindTexture (GL_TEXTURE_2D, ctx->texture[i]);
if (got_gl_error ("glBindTexture"))
goto HANDLE_ERROR;
GstEGLDisplay *display, *set_display;
EGLNativeWindowType window, used_window;
- GLuint fragshader[3]; /* frame, border, frame-custom */
- GLuint vertshader[3]; /* frame, border, frame-custom */
- GLuint glslprogram[3]; /* frame, border, frame-custom */
- GLuint texture[4]; /* RGB/Y, U/UV, V, custom */
+ GLuint fragshader[2]; /* frame, border */
+ GLuint vertshader[2]; /* frame, border */
+ GLuint glslprogram[2]; /* frame, border */
+ GLuint texture[3]; /* RGB/Y, U/UV, V */
/* shader vars */
- GLuint position_loc[3]; /* frame, border, frame-custom */
- GLuint texpos_loc[2]; /* frame, frame-custom */
+ GLuint position_loc[2]; /* frame, border */
+ GLuint texpos_loc[1]; /* frame */
GLuint tex_scale_loc[1][3]; /* [frame] RGB/Y, U/UV, V */
- GLuint tex_loc[2][3]; /* [frame,frame-custom] RGB/Y, U/UV, V */
+ GLuint tex_loc[1][3]; /* [frame] RGB/Y, U/UV, V */
coord5 position_array[16]; /* 4 x Frame x-normal,y-normal, 4x Frame x-normal,y-flip, 4 x Border1, 4 x Border2 */
unsigned short index_array[4];
unsigned int position_buffer, index_buffer;
mem[0] =
gst_egl_image_allocator_alloc (allocator, ctx->display,
- GST_EGL_IMAGE_MEMORY_TYPE_RGB, GST_VIDEO_INFO_WIDTH (&info),
+ GST_VIDEO_GL_TEXTURE_TYPE_RGB, GST_VIDEO_INFO_WIDTH (&info),
GST_VIDEO_INFO_HEIGHT (&info), &size);
if (mem[0]) {
stride[0] = size / GST_VIDEO_INFO_HEIGHT (&info);
mem[0] =
gst_egl_image_allocator_wrap (allocator, ctx->display,
- image, GST_EGL_IMAGE_MEMORY_TYPE_RGB,
+ image, GST_VIDEO_GL_TEXTURE_TYPE_RGB,
flags, size, data, (GDestroyNotify) gst_egl_gles_image_data_free);
n_mem = 1;
}
mem[0] =
gst_egl_image_allocator_alloc (allocator, ctx->display,
- GST_EGL_IMAGE_MEMORY_TYPE_RGB, GST_VIDEO_INFO_WIDTH (&info),
+ GST_VIDEO_GL_TEXTURE_TYPE_RGB, GST_VIDEO_INFO_WIDTH (&info),
GST_VIDEO_INFO_HEIGHT (&info), &size);
if (mem[0]) {
stride[0] = size / GST_VIDEO_INFO_HEIGHT (&info);
mem[0] =
gst_egl_image_allocator_wrap (allocator, ctx->display,
- image, GST_EGL_IMAGE_MEMORY_TYPE_RGB,
+ image, GST_VIDEO_GL_TEXTURE_TYPE_RGB,
flags, size, data, (GDestroyNotify) gst_egl_gles_image_data_free);
n_mem = 1;
}
mem[0] =
gst_egl_image_allocator_alloc (allocator, ctx->display,
- GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE, GST_VIDEO_INFO_COMP_WIDTH (&info,
+ GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE, GST_VIDEO_INFO_COMP_WIDTH (&info,
0), GST_VIDEO_INFO_COMP_HEIGHT (&info, 0), &size[0]);
mem[1] =
gst_egl_image_allocator_alloc (allocator, ctx->display,
- GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE_ALPHA,
+ GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
GST_VIDEO_INFO_COMP_WIDTH (&info, 1),
GST_VIDEO_INFO_COMP_HEIGHT (&info, 1), &size[1]);
gst_egl_image_allocator_wrap (allocator, ctx->display,
image,
(i ==
- 0 ? GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE :
- GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE_ALPHA),
+ 0 ? GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE :
+ GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA),
flags, size[i], data,
(GDestroyNotify) gst_egl_gles_image_data_free);
}
mem[0] =
gst_egl_image_allocator_alloc (allocator, ctx->display,
- GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE, GST_VIDEO_INFO_COMP_WIDTH (&info,
+ GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE, GST_VIDEO_INFO_COMP_WIDTH (&info,
0), GST_VIDEO_INFO_COMP_HEIGHT (&info, 0), &size[0]);
mem[1] =
gst_egl_image_allocator_alloc (allocator, ctx->display,
- GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE, GST_VIDEO_INFO_COMP_WIDTH (&info,
+ GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE, GST_VIDEO_INFO_COMP_WIDTH (&info,
1), GST_VIDEO_INFO_COMP_HEIGHT (&info, 1), &size[1]);
mem[2] =
gst_egl_image_allocator_alloc (allocator, ctx->display,
- GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE, GST_VIDEO_INFO_COMP_WIDTH (&info,
+ GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE, GST_VIDEO_INFO_COMP_WIDTH (&info,
2), GST_VIDEO_INFO_COMP_HEIGHT (&info, 2), &size[2]);
if (mem[0] && mem[1] && mem[2]) {
mem[i] =
gst_egl_image_allocator_wrap (allocator, ctx->display,
- image, GST_EGL_IMAGE_MEMORY_TYPE_LUMINANCE,
+ image, GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE,
flags, size[i], data,
(GDestroyNotify) gst_egl_gles_image_data_free);
}
mem[0] =
gst_egl_image_allocator_alloc (allocator, ctx->display,
- GST_EGL_IMAGE_MEMORY_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&info),
+ GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&info),
GST_VIDEO_INFO_HEIGHT (&info), &size);
if (mem[0]) {
stride[0] = size / GST_VIDEO_INFO_HEIGHT (&info);
mem[0] =
gst_egl_image_allocator_wrap (allocator, ctx->display,
- image, GST_EGL_IMAGE_MEMORY_TYPE_RGBA,
+ image, GST_VIDEO_GL_TEXTURE_TYPE_RGBA,
flags, size, data, (GDestroyNotify) gst_egl_gles_image_data_free);
n_mem = 1;
}
if (upload_meta) {
- glActiveTexture (GL_TEXTURE0);
- glBindTexture (GL_TEXTURE_2D,
- eglglessink->egl_context->texture[eglglessink->
- egl_context->n_textures]);
- if (!gst_video_gl_texture_upload_meta_upload (upload_meta, GL_RGBA,
- eglglessink->egl_context->texture[eglglessink->
- egl_context->n_textures]))
+ gint i;
+
+ if (upload_meta->n_textures != eglglessink->egl_context->n_textures)
goto HANDLE_ERROR;
- eglglessink->orientation = GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_NORMAL;
- eglglessink->custom_format = TRUE;
+ for (i = 0; i < eglglessink->egl_context->n_textures; i++) {
+ if (i == 0)
+ glActiveTexture (GL_TEXTURE0);
+ else if (i == 1)
+ glActiveTexture (GL_TEXTURE1);
+ else if (i == 2)
+ glActiveTexture (GL_TEXTURE2);
+
+ glBindTexture (GL_TEXTURE_2D, eglglessink->egl_context->texture[i]);
+ }
+
+ if (!gst_video_gl_texture_upload_meta_upload (upload_meta,
+ eglglessink->egl_context->texture))
+ goto HANDLE_ERROR;
+
+ eglglessink->orientation = upload_meta->texture_orientation;
+ eglglessink->stride[0] = 1;
+ eglglessink->stride[1] = 1;
+ eglglessink->stride[2] = 1;
} else if (gst_buffer_n_memory (buf) >= 1 &&
(mem = gst_buffer_peek_memory (buf, 0))
&& gst_is_egl_image_memory (mem)) {
guint n, i;
- eglglessink->custom_format = FALSE;
-
n = gst_buffer_n_memory (buf);
for (i = 0; i < n; i++) {
goto HANDLE_ERROR;
eglglessink->orientation = gst_egl_image_memory_get_orientation (mem);
if (eglglessink->orientation !=
- GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_NORMAL
+ GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL
&& eglglessink->orientation !=
- GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_FLIP) {
+ GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP) {
GST_ERROR_OBJECT (eglglessink, "Unsupported EGLImage orientation");
return GST_FLOW_ERROR;
}
eglglessink->stride[1] = 1;
eglglessink->stride[2] = 1;
} else {
- eglglessink->custom_format = FALSE;
-
- eglglessink->orientation = GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_NORMAL;
+ eglglessink->orientation =
+ GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL;
if (!gst_eglglessink_fill_texture (eglglessink, buf))
goto HANDLE_ERROR;
}
/* Draw video frame */
GST_DEBUG_OBJECT (eglglessink, "Drawing video frame");
- if (eglglessink->custom_format) {
- glUseProgram (eglglessink->egl_context->glslprogram[2]);
+ glUseProgram (eglglessink->egl_context->glslprogram[0]);
- glUniform1i (eglglessink->egl_context->tex_loc[1][0], 0);
+ glUniform2f (eglglessink->egl_context->tex_scale_loc[0][0],
+ eglglessink->stride[0], 1);
+ glUniform2f (eglglessink->egl_context->tex_scale_loc[0][1],
+ eglglessink->stride[1], 1);
+ glUniform2f (eglglessink->egl_context->tex_scale_loc[0][2],
+ eglglessink->stride[2], 1);
+
+ for (i = 0; i < eglglessink->egl_context->n_textures; i++) {
+ glUniform1i (eglglessink->egl_context->tex_loc[0][i], i);
if (got_gl_error ("glUniform1i"))
goto HANDLE_ERROR;
+ }
- glVertexAttribPointer (eglglessink->egl_context->position_loc[2], 3,
- GL_FLOAT, GL_FALSE, sizeof (coord5), (gpointer) (0));
+ if (eglglessink->orientation ==
+ GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL) {
+ glVertexAttribPointer (eglglessink->egl_context->position_loc[0], 3,
+ GL_FLOAT, GL_FALSE, sizeof (coord5), (gpointer) (0 * sizeof (coord5)));
if (got_gl_error ("glVertexAttribPointer"))
goto HANDLE_ERROR;
- glVertexAttribPointer (eglglessink->egl_context->texpos_loc[1], 2,
+ glVertexAttribPointer (eglglessink->egl_context->texpos_loc[0], 2,
GL_FLOAT, GL_FALSE, sizeof (coord5), (gpointer) (3 * sizeof (gfloat)));
if (got_gl_error ("glVertexAttribPointer"))
goto HANDLE_ERROR;
- } else {
- glUseProgram (eglglessink->egl_context->glslprogram[0]);
-
- glUniform2f (eglglessink->egl_context->tex_scale_loc[0][0],
- eglglessink->stride[0], 1);
- glUniform2f (eglglessink->egl_context->tex_scale_loc[0][1],
- eglglessink->stride[1], 1);
- glUniform2f (eglglessink->egl_context->tex_scale_loc[0][2],
- eglglessink->stride[2], 1);
-
- for (i = 0; i < eglglessink->egl_context->n_textures; i++) {
- glUniform1i (eglglessink->egl_context->tex_loc[0][i], i);
- if (got_gl_error ("glUniform1i"))
- goto HANDLE_ERROR;
- }
-
- if (eglglessink->orientation == GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_NORMAL) {
- glVertexAttribPointer (eglglessink->egl_context->position_loc[0], 3,
- GL_FLOAT, GL_FALSE, sizeof (coord5),
- (gpointer) (0 * sizeof (coord5)));
- if (got_gl_error ("glVertexAttribPointer"))
- goto HANDLE_ERROR;
-
- glVertexAttribPointer (eglglessink->egl_context->texpos_loc[0], 2,
- GL_FLOAT, GL_FALSE, sizeof (coord5),
- (gpointer) (3 * sizeof (gfloat)));
- if (got_gl_error ("glVertexAttribPointer"))
- goto HANDLE_ERROR;
- } else if (eglglessink->orientation ==
- GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_FLIP) {
- glVertexAttribPointer (eglglessink->egl_context->position_loc[0], 3,
- GL_FLOAT, GL_FALSE, sizeof (coord5),
- (gpointer) (4 * sizeof (coord5)));
- if (got_gl_error ("glVertexAttribPointer"))
- goto HANDLE_ERROR;
+ } else if (eglglessink->orientation ==
+ GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP) {
+ glVertexAttribPointer (eglglessink->egl_context->position_loc[0], 3,
+ GL_FLOAT, GL_FALSE, sizeof (coord5), (gpointer) (4 * sizeof (coord5)));
+ if (got_gl_error ("glVertexAttribPointer"))
+ goto HANDLE_ERROR;
- glVertexAttribPointer (eglglessink->egl_context->texpos_loc[0], 2,
- GL_FLOAT, GL_FALSE, sizeof (coord5),
- (gpointer) (4 * sizeof (coord5) + 3 * sizeof (gfloat)));
- if (got_gl_error ("glVertexAttribPointer"))
- goto HANDLE_ERROR;
- } else {
- g_assert_not_reached ();
- }
+ glVertexAttribPointer (eglglessink->egl_context->texpos_loc[0], 2,
+ GL_FLOAT, GL_FALSE, sizeof (coord5),
+ (gpointer) (4 * sizeof (coord5) + 3 * sizeof (gfloat)));
+ if (got_gl_error ("glVertexAttribPointer"))
+ goto HANDLE_ERROR;
+ } else {
+ g_assert_not_reached ();
}
glDrawElements (GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, 0);
GstCaps *current_caps, *configured_caps;
GstVideoInfo configured_info;
gfloat stride[3];
- GstEGLImageOrientation orientation;
- gboolean custom_format; /* If it's a single texture that is just copied */
+ GstVideoGLTextureOrientation orientation;
GstBufferPool *pool;
GstEglAdaptationContext *egl_context;