gl/mem: implement texture copying between formats with strides properly
Previously, we used the width to determine the amount of data to be copied using pbos. This, makes it allocate enough data for the the strides as well.
This commit is contained in:
parent
8638a5638c
commit
33091ff6a5
@ -775,7 +775,7 @@ _YUV_to_RGB (GstGLContext * context, GstGLColorConvert * convert)
|
|||||||
GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
|
GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
|
||||||
GST_VIDEO_INFO_WIDTH (&convert->in_info),
|
GST_VIDEO_INFO_WIDTH (&convert->in_info),
|
||||||
GST_VIDEO_INFO_HEIGHT (&convert->in_info),
|
GST_VIDEO_INFO_HEIGHT (&convert->in_info),
|
||||||
GST_VIDEO_INFO_WIDTH (&convert->in_info));
|
GST_VIDEO_INFO_PLANE_STRIDE (&convert->in_info, 0));
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_NV12:
|
case GST_VIDEO_FORMAT_NV12:
|
||||||
info->frag_prog = g_strdup_printf (frag_NV12_NV21_to_RGB, 'r', 'a',
|
info->frag_prog = g_strdup_printf (frag_NV12_NV21_to_RGB, 'r', 'a',
|
||||||
@ -801,7 +801,7 @@ _YUV_to_RGB (GstGLContext * context, GstGLColorConvert * convert)
|
|||||||
GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
|
GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
|
||||||
GST_VIDEO_INFO_WIDTH (&convert->in_info),
|
GST_VIDEO_INFO_WIDTH (&convert->in_info),
|
||||||
GST_VIDEO_INFO_HEIGHT (&convert->in_info),
|
GST_VIDEO_INFO_HEIGHT (&convert->in_info),
|
||||||
GST_VIDEO_INFO_WIDTH (&convert->in_info));
|
GST_VIDEO_INFO_PLANE_STRIDE (&convert->in_info, 0));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1238,7 +1238,7 @@ _do_convert (GstGLContext * context, GstGLColorConvert * convert)
|
|||||||
GST_MAP_WRITE | GST_MAP_GL);
|
GST_MAP_WRITE | GST_MAP_GL);
|
||||||
gst_gl_memory_copy_into_texture (convert->priv->out_temp[i],
|
gst_gl_memory_copy_into_texture (convert->priv->out_temp[i],
|
||||||
gl_mem->tex_id, gl_mem->tex_type, gl_mem->width, gl_mem->height,
|
gl_mem->tex_id, gl_mem->tex_type, gl_mem->width, gl_mem->height,
|
||||||
FALSE);
|
gl_mem->stride, FALSE);
|
||||||
gst_memory_unmap ((GstMemory *) gl_mem, &to_info);
|
gst_memory_unmap ((GstMemory *) gl_mem, &to_info);
|
||||||
gst_memory_unmap ((GstMemory *) convert->priv->out_temp[i], &from_info);
|
gst_memory_unmap ((GstMemory *) convert->priv->out_temp[i], &from_info);
|
||||||
} else {
|
} else {
|
||||||
@ -1287,7 +1287,8 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
|
|||||||
if (convert->priv->scratch) {
|
if (convert->priv->scratch) {
|
||||||
gst_gl_memory_copy_into_texture (convert->in_tex[0],
|
gst_gl_memory_copy_into_texture (convert->in_tex[0],
|
||||||
convert->priv->scratch->tex_id, convert->priv->scratch->tex_type,
|
convert->priv->scratch->tex_id, convert->priv->scratch->tex_type,
|
||||||
convert->priv->scratch->width, convert->priv->scratch->height, TRUE);
|
convert->priv->scratch->width, convert->priv->scratch->height,
|
||||||
|
convert->priv->scratch->stride, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl->BindFramebuffer (GL_FRAMEBUFFER, convert->fbo);
|
gl->BindFramebuffer (GL_FRAMEBUFFER, convert->fbo);
|
||||||
|
@ -76,6 +76,7 @@ typedef struct
|
|||||||
GstGLMemory *src;
|
GstGLMemory *src;
|
||||||
GstVideoGLTextureType out_format;
|
GstVideoGLTextureType out_format;
|
||||||
guint out_width, out_height;
|
guint out_width, out_height;
|
||||||
|
guint out_stride;
|
||||||
gboolean respecify;
|
gboolean respecify;
|
||||||
/* inout */
|
/* inout */
|
||||||
guint tex_id;
|
guint tex_id;
|
||||||
@ -603,7 +604,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data)
|
|||||||
GstGLMemory *src;
|
GstGLMemory *src;
|
||||||
guint tex_id;
|
guint tex_id;
|
||||||
GLuint fboId;
|
GLuint fboId;
|
||||||
gsize out_width, out_height;
|
gsize out_width, out_height, out_stride;
|
||||||
GLuint out_gl_format, out_gl_type;
|
GLuint out_gl_format, out_gl_type;
|
||||||
GLuint in_gl_format, in_gl_type;
|
GLuint in_gl_format, in_gl_type;
|
||||||
gsize in_size, out_size;
|
gsize in_size, out_size;
|
||||||
@ -613,6 +614,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data)
|
|||||||
tex_id = copy_params->tex_id;
|
tex_id = copy_params->tex_id;
|
||||||
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;
|
||||||
|
|
||||||
gl = src->context->gl_vtable;
|
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);
|
||||||
@ -630,10 +632,8 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_size = _gl_format_type_n_bytes (in_gl_format, in_gl_type) * src->width *
|
in_size = src->height * src->stride;
|
||||||
src->height;
|
out_size = out_height * out_stride;
|
||||||
out_size = _gl_format_type_n_bytes (out_gl_format, out_gl_type) * out_width *
|
|
||||||
out_height;
|
|
||||||
|
|
||||||
if (copy_params->respecify) {
|
if (copy_params->respecify) {
|
||||||
if (in_size != out_size) {
|
if (in_size != out_size) {
|
||||||
@ -754,6 +754,7 @@ _gl_mem_copy (GstGLMemory * src, gssize offset, gssize size)
|
|||||||
copy_params.out_format = src->tex_type;
|
copy_params.out_format = src->tex_type;
|
||||||
copy_params.out_width = src->width;
|
copy_params.out_width = src->width;
|
||||||
copy_params.out_height = src->height;
|
copy_params.out_height = src->height;
|
||||||
|
copy_params.out_stride = src->height;
|
||||||
copy_params.respecify = FALSE;
|
copy_params.respecify = FALSE;
|
||||||
|
|
||||||
gst_gl_context_thread_add (src->context, _gl_mem_copy_thread, ©_params);
|
gst_gl_context_thread_add (src->context, _gl_mem_copy_thread, ©_params);
|
||||||
@ -839,9 +840,10 @@ _gl_mem_free (GstAllocator * allocator, GstMemory * mem)
|
|||||||
* gst_gl_memory_copy_into_texture:
|
* gst_gl_memory_copy_into_texture:
|
||||||
* @gl_mem:a #GstGLMemory
|
* @gl_mem:a #GstGLMemory
|
||||||
* @tex_id:OpenGL texture id
|
* @tex_id:OpenGL texture id
|
||||||
* @tex_type: a #GstVIdeoGLTextureType
|
* @tex_type: a #GstVideoGLTextureType
|
||||||
* @width: width of @tex_id
|
* @width: width of @tex_id
|
||||||
* @height: height of @tex_id
|
* @height: height of @tex_id
|
||||||
|
* @stride: stride of the backing texture data
|
||||||
* @respecify: whether to copy the data or copy per texel
|
* @respecify: whether to copy the data or copy per texel
|
||||||
*
|
*
|
||||||
* Copies @gl_mem into the texture specfified by @tex_id. The format of @tex_id
|
* Copies @gl_mem into the texture specfified by @tex_id. The format of @tex_id
|
||||||
@ -862,7 +864,8 @@ _gl_mem_free (GstAllocator * allocator, GstMemory * mem)
|
|||||||
*/
|
*/
|
||||||
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, gboolean respecify)
|
GstVideoGLTextureType tex_type, gint width, gint height, gint stride,
|
||||||
|
gboolean respecify)
|
||||||
{
|
{
|
||||||
GstGLMemoryCopyParams copy_params;
|
GstGLMemoryCopyParams copy_params;
|
||||||
|
|
||||||
@ -871,6 +874,7 @@ gst_gl_memory_copy_into_texture (GstGLMemory * gl_mem, guint tex_id,
|
|||||||
copy_params.out_format = tex_type;
|
copy_params.out_format = tex_type;
|
||||||
copy_params.out_width = width;
|
copy_params.out_width = width;
|
||||||
copy_params.out_height = height;
|
copy_params.out_height = height;
|
||||||
|
copy_params.out_stride = stride;
|
||||||
copy_params.respecify = respecify;
|
copy_params.respecify = respecify;
|
||||||
|
|
||||||
gst_gl_context_thread_add (gl_mem->context, _gl_mem_copy_thread,
|
gst_gl_context_thread_add (gl_mem->context, _gl_mem_copy_thread,
|
||||||
|
@ -162,7 +162,8 @@ GstGLMemory * gst_gl_memory_wrapped_texture (GstGLContext * context, guint textu
|
|||||||
|
|
||||||
gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem, guint tex_id,
|
gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem, guint tex_id,
|
||||||
GstVideoGLTextureType tex_type,
|
GstVideoGLTextureType tex_type,
|
||||||
gint width, gint height, gboolean respecify);
|
gint width, gint height, gint stride,
|
||||||
|
gboolean respecify);
|
||||||
|
|
||||||
gboolean gst_gl_memory_setup_buffer (GstGLContext * context, GstVideoInfo * info,
|
gboolean gst_gl_memory_setup_buffer (GstGLContext * context, GstVideoInfo * info,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
|
@ -237,7 +237,7 @@ gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer,
|
|||||||
upload->out_tex = (GstGLMemory *) gst_gl_memory_alloc (upload->context,
|
upload->out_tex = (GstGLMemory *) gst_gl_memory_alloc (upload->context,
|
||||||
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&upload->in_info),
|
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&upload->in_info),
|
||||||
GST_VIDEO_INFO_HEIGHT (&upload->in_info),
|
GST_VIDEO_INFO_HEIGHT (&upload->in_info),
|
||||||
GST_VIDEO_INFO_WIDTH (&upload->in_info));
|
GST_VIDEO_INFO_PLANE_STRIDE (&upload->in_info, 0));
|
||||||
|
|
||||||
GST_LOG_OBJECT (upload, "Attempting upload with GstGLMemory");
|
GST_LOG_OBJECT (upload, "Attempting upload with GstGLMemory");
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->in_info); i++) {
|
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->in_info); i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user