1 From 05bbd82dd527afa44d6b403b02a0dbd198c96859 Mon Sep 17 00:00:00 2001
2 From: Jian Li <jian.li@freescale.com>
3 Date: Fri, 6 Nov 2015 15:00:19 +0800
4 Subject: [PATCH 14/18] MMFMWK-6930 [glplugin] Accelerate gldownload with
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 1) Propose a physical buffer pool to upstream in gldownload
11 2) Bind the physical buffer with texture via dirctviv
12 3) In gldownload, wrap the physical buffer to gstbuffer, pass to
15 Upstream-Status: Inappropriate [i.MX specific]
17 Signed-off-by: Jian Li <jian.li@freescale.com>
18 Signed-off-by: Lyon Wang <lyon.wang@freescale.com>
20 ext/gl/gstgldownloadelement.c | 91 ++++++++++++
21 gst-libs/gst/gl/Makefile.am | 4 +
22 gst-libs/gst/gl/gstglbufferpool.c | 12 ++
23 gst-libs/gst/gl/gstglphymemory.c | 254 ++++++++++++++++++++++++++++++++
24 gst-libs/gst/gl/gstglphymemory.h | 43 ++++++
25 gst-libs/gst/gl/gstglvivdirecttexture.c | 147 +++++++++---------
26 gst-libs/gst/gl/gstglvivdirecttexture.h | 3 +
27 7 files changed, 484 insertions(+), 70 deletions(-)
28 create mode 100644 gst-libs/gst/gl/gstglphymemory.c
29 create mode 100644 gst-libs/gst/gl/gstglphymemory.h
31 diff --git a/ext/gl/gstgldownloadelement.c b/ext/gl/gstgldownloadelement.c
32 index ff931fa..9ea0146 100644
33 --- a/ext/gl/gstgldownloadelement.c
34 +++ b/ext/gl/gstgldownloadelement.c
38 #include <gst/gl/gl.h>
39 +#include <gst/gl/gstglphymemory.h>
40 #include "gstgldownloadelement.h"
42 GST_DEBUG_CATEGORY_STATIC (gst_gl_download_element_debug);
43 @@ -45,6 +46,8 @@ gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt,
44 GstBuffer * buffer, GstBuffer ** outbuf);
45 static GstFlowReturn gst_gl_download_element_transform (GstBaseTransform * bt,
46 GstBuffer * buffer, GstBuffer * outbuf);
47 +static gboolean gst_gl_download_element_propose_allocation (GstBaseTransform *
48 + bt, GstQuery * decide_query, GstQuery * query);
50 static GstStaticPadTemplate gst_gl_download_element_src_pad_template =
51 GST_STATIC_PAD_TEMPLATE ("src",
52 @@ -70,6 +73,7 @@ gst_gl_download_element_class_init (GstGLDownloadElementClass * klass)
53 bt_class->prepare_output_buffer =
54 gst_gl_download_element_prepare_output_buffer;
55 bt_class->transform = gst_gl_download_element_transform;
56 + bt_class->propose_allocation = gst_gl_download_element_propose_allocation;
58 bt_class->passthrough_on_same_caps = TRUE;
60 @@ -160,9 +164,24 @@ static GstFlowReturn
61 gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt,
62 GstBuffer * inbuf, GstBuffer ** outbuf)
64 + GstGLDownloadElement *download = GST_GL_DOWNLOAD_ELEMENT (bt);
65 GstCaps *src_caps = gst_pad_get_current_caps (bt->srcpad);
66 GstCapsFeatures *features = NULL;
70 + glmem = gst_buffer_peek_memory (inbuf, 0);
71 + if (gst_is_gl_physical_memory (glmem)) {
72 + GstGLContext *context = GST_GL_BASE_FILTER (bt)->context;
75 + gst_video_info_from_caps (&info, src_caps);
76 + *outbuf = gst_gl_phymem_buffer_to_gstbuffer (context, &info, inbuf);
78 + GST_DEBUG_OBJECT (download, "gl download with direct viv.");
85 @@ -194,3 +213,75 @@ gst_gl_download_element_transform (GstBaseTransform * bt,
91 +gst_gl_download_element_propose_allocation (GstBaseTransform * bt,
92 + GstQuery * decide_query, GstQuery * query)
94 + GstGLContext *context = GST_GL_BASE_FILTER (bt)->context;
95 + GstGLDownloadElement *download = GST_GL_DOWNLOAD_ELEMENT (bt);
96 + GstAllocationParams params;
97 + GstAllocator *allocator = NULL;
98 + GstBufferPool *pool = NULL;
102 + GstStructure *config;
105 + gst_query_parse_allocation (query, &caps, NULL);
106 + if (!gst_video_info_from_caps (&info, caps)) {
107 + GST_WARNING_OBJECT (bt, "invalid caps specified");
111 + GST_DEBUG_OBJECT (bt, "video format is %s", gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&info)));
113 + gst_allocation_params_init (¶ms);
114 + if (gst_is_gl_physical_memory_supported_fmt (&info)) {
115 + allocator = gst_phy_mem_allocator_obtain ();
116 + GST_DEBUG_OBJECT (bt, "obtain physical memory allocator %p.", allocator);
120 + allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
123 + GST_ERROR_OBJECT (bt, "Can't obtain physical memory allocator.");
127 + gst_query_add_allocation_param (query, allocator, ¶ms);
128 + gst_object_unref (allocator);
130 + n_pools = gst_query_get_n_allocation_pools (query);
131 + for (i = 0; i < n_pools; i++) {
132 + gst_query_parse_nth_allocation_pool (query, i, &pool, NULL, NULL, NULL);
133 + gst_object_unref (pool);
138 + pool = gst_gl_buffer_pool_new (context);
139 + config = gst_buffer_pool_get_config (pool);
141 + /* the normal size of a frame */
143 + gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
144 + gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_GL_SYNC_META);
146 + if (!gst_buffer_pool_set_config (pool, config)) {
147 + gst_object_unref (pool);
148 + GST_WARNING_OBJECT (bt, "failed setting config");
152 + GST_DEBUG_OBJECT (download, "create pool %p", pool);
154 + //propose 3 buffers for better performance
155 + gst_query_add_allocation_pool (query, pool, size, 3, 0);
157 + gst_object_unref (pool);
161 diff --git a/gst-libs/gst/gl/Makefile.am b/gst-libs/gst/gl/Makefile.am
162 index c396603..5c05230 100644
163 --- a/gst-libs/gst/gl/Makefile.am
164 +++ b/gst-libs/gst/gl/Makefile.am
165 @@ -34,6 +34,7 @@ libgstgl_@GST_API_VERSION@_la_SOURCES = \
166 gstgloverlaycompositor.c \
168 gstglvivdirecttexture.c \
170 gstglcontrolbindingproxy.c
172 libgstgl_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl
173 @@ -68,6 +69,7 @@ libgstgl_@GST_API_VERSION@include_HEADERS = \
176 gstglvivdirecttexture.h \
181 @@ -84,6 +86,8 @@ libgstgl_@GST_API_VERSION@_la_LIBADD = \
185 +libgstgl_@GST_API_VERSION@_la_LIBADD += -lgstfsl-$(GST_API_VERSION)
189 libgstgl_@GST_API_VERSION@_la_LIBADD += win32/libgstgl-win32.la
190 diff --git a/gst-libs/gst/gl/gstglbufferpool.c b/gst-libs/gst/gl/gstglbufferpool.c
191 index 90536b0..71c726a 100644
192 --- a/gst-libs/gst/gl/gstglbufferpool.c
193 +++ b/gst-libs/gst/gl/gstglbufferpool.c
195 #include <gst/gl/egl/gsteglimagememory.h>
198 +#include <gst/gl/gstglphymemory.h>
201 * SECTION:gstglbufferpool
202 * @short_description: buffer pool for #GstGLMemory objects
203 @@ -290,6 +292,16 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
207 + if ((g_strcmp0 (priv->allocator->mem_type, GST_GL_PHY_MEM_ALLOCATOR) == 0)) {
208 + GstAllocator* allocator = (GstAllocator*) gst_phy_mem_allocator_obtain ();
209 + if (!gst_gl_physical_memory_setup_buffer (allocator, buf, priv->gl_params)) {
210 + GST_ERROR_OBJECT (pool, "Can't create physcial buffer.");
211 + return GST_FLOW_ERROR;
214 + return GST_FLOW_OK;
217 alloc = GST_GL_MEMORY_ALLOCATOR (priv->allocator);
218 if (!gst_gl_memory_setup_buffer (alloc, buf, priv->gl_params))
219 goto mem_create_failed;
220 diff --git a/gst-libs/gst/gl/gstglphymemory.c b/gst-libs/gst/gl/gstglphymemory.c
222 index 0000000..52ae41f
224 +++ b/gst-libs/gst/gl/gstglphymemory.c
228 + * Copyright (c) 2015, Freescale Semiconductor, Inc.
230 + * This library is free software; you can redistribute it and/or
231 + * modify it under the terms of the GNU Library General Public
232 + * License as published by the Free Software Foundation; either
233 + * version 2 of the License, or (at your option) any later version.
235 + * This library is distributed in the hope that it will be useful,
236 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
237 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
238 + * Library General Public License for more details.
240 + * You should have received a copy of the GNU Library General Public
241 + * License along with this library; if not, write to the
242 + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
243 + * Boston, MA 02110-1301, USA.
246 +#ifdef HAVE_CONFIG_H
250 +#include "gstglvivdirecttexture.h"
251 +#include "gstglphymemory.h"
254 +GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_PHY_MEMORY);
255 +#define GST_CAT_DEFAULT GST_CAT_GL_PHY_MEMORY
257 +typedef struct _GstPhyMemAllocator GstPhyMemAllocator;
258 +typedef struct _GstPhyMemAllocatorClass GstPhyMemAllocatorClass;
260 +struct _GstPhyMemAllocator
262 + GstAllocatorPhyMem parent;
265 +struct _GstPhyMemAllocatorClass
267 + GstAllocatorPhyMemClass parent_class;
270 +GType gst_phy_mem_allocator_get_type (void);
271 +G_DEFINE_TYPE (GstPhyMemAllocator, gst_phy_mem_allocator, GST_TYPE_ALLOCATOR_PHYMEM);
274 +alloc_phymem (GstAllocatorPhyMem *allocator, PhyMemBlock *memblk)
276 + struct g2d_buf *pbuf = NULL;
278 + memblk->size = PAGE_ALIGN(memblk->size);
280 + pbuf = g2d_alloc (memblk->size, 0);
282 + GST_ERROR("G2D allocate %u bytes memory failed: %s",
283 + memblk->size, strerror(errno));
287 + memblk->vaddr = (guchar*) pbuf->buf_vaddr;
288 + memblk->paddr = (guchar*) pbuf->buf_paddr;
289 + memblk->user_data = (gpointer) pbuf;
290 + GST_DEBUG("G2D allocated memory (%p)", memblk->paddr);
296 +free_phymem (GstAllocatorPhyMem *allocator, PhyMemBlock *memblk)
298 + GST_DEBUG("G2D free memory (%p)", memblk->paddr);
299 + gint ret = g2d_free ((struct g2d_buf*)(memblk->user_data));
300 + memblk->user_data = NULL;
301 + memblk->vaddr = NULL;
302 + memblk->paddr = NULL;
309 +gst_phy_mem_allocator_class_init (GstPhyMemAllocatorClass * klass)
311 + GstAllocatorPhyMemClass *phy_allocator_klass = (GstAllocatorPhyMemClass *) klass;
313 + phy_allocator_klass->alloc_phymem = alloc_phymem;
314 + phy_allocator_klass->free_phymem = free_phymem;
318 +gst_phy_mem_allocator_init (GstPhyMemAllocator * allocator)
320 + GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
322 + alloc->mem_type = GST_GL_PHY_MEM_ALLOCATOR;
327 +gst_phy_mem_allocator_init_instance (gpointer data)
329 + GstAllocator *allocator =
330 + g_object_new (gst_phy_mem_allocator_get_type (), NULL);
332 + GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_PHY_MEMORY, "glphymemory", 0,
333 + "GLPhysical Memory");
335 + gst_allocator_register (GST_GL_PHY_MEM_ALLOCATOR, gst_object_ref (allocator));
341 +_finish_texture (GstGLContext * ctx, gpointer *data)
343 + GstGLFuncs *gl = ctx->gl_vtable;
349 +gst_gl_phy_mem_destroy (GstMemory *mem)
351 + gst_memory_unref (mem);
356 +gst_phy_mem_allocator_obtain (void)
358 + static GOnce once = G_ONCE_INIT;
360 + g_once (&once, gst_phy_mem_allocator_init_instance, NULL);
362 + g_return_val_if_fail (once.retval != NULL, NULL);
364 + return (GstAllocator *) (g_object_ref (once.retval));
368 +gst_is_gl_physical_memory (GstMemory * mem)
370 + GstGLBaseMemory *glmem;
371 + g_return_val_if_fail (gst_is_gl_memory (mem), FALSE);
373 + glmem = (GstGLBaseMemory*) mem;
375 + if (glmem->user_data
376 + && GST_IS_MINI_OBJECT_TYPE(glmem->user_data, GST_TYPE_MEMORY))
377 + return gst_memory_is_type ((GstMemory*)glmem->user_data, GST_GL_PHY_MEM_ALLOCATOR);
383 +gst_is_gl_physical_memory_supported_fmt (GstVideoInfo * info)
385 + if (GST_VIDEO_INFO_IS_RGB(info)
386 + && gst_gl_is_directviv_supported_format (GST_VIDEO_INFO_FORMAT (info))) {
394 +gst_gl_physical_memory_setup_buffer (GstAllocator * allocator, GstBuffer *buffer,
395 + GstGLVideoAllocationParams * params)
397 + GstGLBaseMemoryAllocator *gl_alloc;
398 + GstMemory *mem = NULL;
399 + PhyMemBlock *memblk = NULL;
400 + GstGLMemory *glmem = NULL;
403 + GstVideoInfo * info = params->v_info;
404 + GstVideoAlignment * valign = params->valign;
406 + GST_DEBUG ("glphymemory setup buffer format %s", gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (info)));
408 + if (!gst_is_gl_physical_memory_supported_fmt (info)) {
409 + GST_DEBUG ("Not support format.");
413 + //allocator = (GstAllocator*) gst_phy_mem_allocator_obtain ();
414 + size = gst_gl_get_plane_data_size (info, valign, 0);
415 + mem = gst_allocator_alloc (allocator, size, params->parent.alloc_params);
417 + GST_DEBUG ("Can't allocate physical memory size %d", size);
421 + memblk = gst_memory_query_phymem_block (mem);
423 + GST_ERROR("Can't find physic memory block.");
428 + GST_GL_BASE_MEMORY_ALLOCATOR (gst_gl_memory_allocator_get_default
429 + (params->parent.context));
432 + params->parent.user_data = mem;
433 + params->parent.notify = gst_gl_phy_mem_destroy;
435 + glmem = (GstGLMemory *)gst_gl_base_memory_alloc (gl_alloc, (GstGLAllocationParams *) params);
437 + GST_ERROR("Can't get gl memory.");
441 + gst_buffer_append_memory (buffer, (GstMemory *) glmem);
443 + gst_buffer_add_video_meta_full (buffer, 0,
444 + GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
445 + GST_VIDEO_INFO_HEIGHT (info), 1, info->offset, info->stride);
447 + gst_gl_viv_direct_bind_data(params->parent.context, glmem->tex_id,
448 + GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
449 + GST_VIDEO_INFO_HEIGHT (info), memblk->vaddr, memblk->paddr);
455 +gst_gl_phymem_buffer_to_gstbuffer (GstGLContext * ctx,
456 + GstVideoInfo * info, GstBuffer *glbuf)
459 + GstGLBaseMemory *glmem;
461 + gst_gl_context_thread_add (ctx, (GstGLContextThreadFunc) _finish_texture, NULL);
463 + glmem = gst_buffer_peek_memory (glbuf, 0);
465 + buf = gst_buffer_new ();
466 + gst_buffer_append_memory (buf, (GstMemory *) glmem->user_data);
467 + gst_memory_ref ((GstMemory *)glmem->user_data);
469 + gst_buffer_add_video_meta_full (buf, 0,
470 + GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
471 + GST_VIDEO_INFO_HEIGHT (info), 1, info->offset, info->stride);
472 + GST_BUFFER_FLAGS (buf) = GST_BUFFER_FLAGS (glbuf);
473 + GST_BUFFER_PTS (buf) = GST_BUFFER_PTS (glbuf);
474 + GST_BUFFER_DTS (buf) = GST_BUFFER_DTS (glbuf);
475 + GST_BUFFER_DURATION (buf) = GST_BUFFER_DURATION (glbuf);
480 diff --git a/gst-libs/gst/gl/gstglphymemory.h b/gst-libs/gst/gl/gstglphymemory.h
482 index 0000000..b1a69e7
484 +++ b/gst-libs/gst/gl/gstglphymemory.h
488 + * Copyright (c) 2015, Freescale Semiconductor, Inc.
490 + * This library is free software; you can redistribute it and/or
491 + * modify it under the terms of the GNU Library General Public
492 + * License as published by the Free Software Foundation; either
493 + * version 2 of the License, or (at your option) any later version.
495 + * This library is distributed in the hope that it will be useful,
496 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
497 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
498 + * Library General Public License for more details.
500 + * You should have received a copy of the GNU Library General Public
501 + * License along with this library; if not, write to the
502 + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
503 + * Boston, MA 02110-1301, USA.
506 +#ifndef _GST_GL_PHY_MEMORY_H_
507 +#define _GST_GL_PHY_MEMORY_H_
509 +#include <gst/gst.h>
510 +#include <gst/gstmemory.h>
511 +#include <gst/video/video.h>
512 +#include <gst/imx-mm/gstallocatorphymem.h>
514 +#include <gst/gl/gl.h>
518 +#define GST_GL_PHY_MEM_ALLOCATOR "GLPhyMemory"
520 +GstAllocator *gst_phy_mem_allocator_obtain (void);
521 +gboolean gst_is_gl_physical_memory (GstMemory * mem);
522 +gboolean gst_is_gl_physical_memory_supported_fmt (GstVideoInfo * info);
523 +gboolean gst_gl_physical_memory_setup_buffer (GstAllocator * allocator, GstBuffer *buffer, GstGLVideoAllocationParams * params);
524 +GstBuffer * gst_gl_phymem_buffer_to_gstbuffer (GstGLContext * ctx, GstVideoInfo * info, GstBuffer *glbuf);
528 +#endif /* _GST_GL_PHY_MEMORY_H_ */
529 diff --git a/gst-libs/gst/gl/gstglvivdirecttexture.c b/gst-libs/gst/gl/gstglvivdirecttexture.c
530 index c19b617..e8e0b82 100644
531 --- a/gst-libs/gst/gl/gstglvivdirecttexture.c
532 +++ b/gst-libs/gst/gl/gstglvivdirecttexture.c
537 +#include <gst/imx-mm/gstallocatorphymem.h>
540 GST_DEBUG_CATEGORY_EXTERN (gst_gl_upload_debug);
541 @@ -37,17 +38,28 @@ typedef struct {
543 } GstVivDirectTexture;
546 + GstVideoFormat gst_fmt;
550 +static VIV_FMT_MAP viv_fmt_map_table[] = {
551 + {GST_VIDEO_FORMAT_I420, GL_VIV_I420},
552 + {GST_VIDEO_FORMAT_YV12, GL_VIV_YV12},
553 + {GST_VIDEO_FORMAT_NV12, GL_VIV_NV12},
554 + {GST_VIDEO_FORMAT_NV21, GL_VIV_NV21},
555 + {GST_VIDEO_FORMAT_YUY2, GL_VIV_YUY2},
556 + {GST_VIDEO_FORMAT_UYVY, GL_VIV_UYVY},
557 + {GST_VIDEO_FORMAT_RGBA, GL_RGBA},
558 + {GST_VIDEO_FORMAT_RGBx, GL_RGBA},
559 + {GST_VIDEO_FORMAT_BGRA, GL_BGRA_EXT},
560 + {GST_VIDEO_FORMAT_RGB16, GL_RGB565_OES}
564 gst_is_physical_buffer (GstBuffer *buffer)
569 - mem = gst_buffer_peek_memory (buffer, 0);
570 - if (!mem->allocator)
573 - return g_type_check_instance_is_a (mem->allocator, g_type_from_name("GstAllocatorPhyMem"));
574 + return gst_buffer_is_phymem (buffer);
578 @@ -65,32 +77,64 @@ _do_viv_direct_tex_bind_mem (GstGLContext * context, GstVivDirectTexture * viv_t
582 +gst_gl_is_directviv_supported_format (GstVideoFormat fmt)
585 + gboolean ret = FALSE;
587 + for (i=0; i<sizeof(viv_fmt_map_table)/sizeof(VIV_FMT_MAP); i++) {
588 + if (fmt == viv_fmt_map_table[i].gst_fmt) {
598 +gst_gl_viv_direct_bind_data (GstGLContext * context,
599 + guint tex_id, GstVideoFormat fmt, gint width, gint height,
600 + gpointer * vaddr, gpointer *paddr)
602 + guint viv_fmt = GL_NONE;
605 + for (i=0; i<sizeof(viv_fmt_map_table)/sizeof(VIV_FMT_MAP); i++) {
606 + if (fmt == viv_fmt_map_table[i].gst_fmt) {
607 + viv_fmt = viv_fmt_map_table[i].viv_fmt;
612 + if (viv_fmt == GL_NONE) {
613 + GST_ERROR ("Not supported format %d for viv direct texture upload.", fmt);
617 + GstVivDirectTexture viv_tex = {tex_id, width, height, viv_fmt, vaddr, paddr, FALSE};
618 + gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _do_viv_direct_tex_bind_mem, &viv_tex);
620 + return viv_tex.ret;
624 gst_gl_viv_direct_bind_gstbuffer (GstGLContext * context, guint tex_id, GstVideoInfo * info, GstBuffer * buffer)
631 - gpointer *user_data;
633 - //Note: structure PhyMemBlock is copied from gst1.0-fsl-plugin/libs/allocator/gstallocatorphymem.h
641 - //Note: structure GstMemoryPhy is copied from gst1.0-fsl-plugin/libs/allocator/gstallocatorphymem.c
643 - GstMemory *mem = gst_buffer_peek_memory (buffer, 0);
644 - GstMemoryPhy *memphy = (GstMemoryPhy*) mem;
645 - PhyMemBlock *memblk = &memphy->block;
647 - GstVideoFormat fmt = GST_VIDEO_INFO_FORMAT (info);
648 + PhyMemBlock *memblk;
649 + GstVideoMeta *vmeta;
650 + GstVideoFormat fmt;
652 - GstVideoMeta *vmeta = gst_buffer_get_video_meta (buffer);
654 + memblk = gst_buffer_query_phymem_block (buffer);
658 + width = GST_VIDEO_INFO_WIDTH (info);
659 + height = GST_VIDEO_INFO_HEIGHT (info);
661 + vmeta = gst_buffer_get_video_meta (buffer);
662 + fmt = GST_VIDEO_INFO_FORMAT (info);
663 if (vmeta && (fmt == GST_VIDEO_FORMAT_I420 || fmt == GST_VIDEO_FORMAT_NV12)) {
664 width = vmeta->stride[0];
665 height = vmeta->offset[1] / width;
666 @@ -100,44 +144,7 @@ gst_gl_viv_direct_bind_gstbuffer (GstGLContext * context, guint tex_id, GstVideo
667 height = GST_VIDEO_INFO_HEIGHT (info);
672 - case GST_VIDEO_FORMAT_I420:
673 - viv_fmt = GL_VIV_I420;
675 - case GST_VIDEO_FORMAT_YV12:
676 - viv_fmt = GL_VIV_YV12;
678 - case GST_VIDEO_FORMAT_NV12:
679 - viv_fmt = GL_VIV_NV12;
681 - case GST_VIDEO_FORMAT_NV21:
682 - viv_fmt = GL_VIV_NV21;
684 - case GST_VIDEO_FORMAT_YUY2:
685 - viv_fmt = GL_VIV_YUY2;
687 - case GST_VIDEO_FORMAT_UYVY:
688 - viv_fmt = GL_VIV_UYVY;
690 - case GST_VIDEO_FORMAT_RGBA:
693 - case GST_VIDEO_FORMAT_BGRA:
694 - viv_fmt = GL_BGRA_EXT;
696 - case GST_VIDEO_FORMAT_RGB16:
697 - viv_fmt = GL_RGB565_OES;
700 - GST_ERROR ("Not supported format %d for viv direct texture upload.", fmt);
705 - GstVivDirectTexture viv_tex = {tex_id, width, height, viv_fmt, memblk->vaddr, memblk->paddr, FALSE};
706 - gst_gl_context_thread_add (context, (GstGLContextThreadFunc) _do_viv_direct_tex_bind_mem, &viv_tex);
708 - return viv_tex.ret;
709 + return gst_gl_viv_direct_bind_data (context, tex_id, fmt, width, height, memblk->vaddr, memblk->paddr);
713 diff --git a/gst-libs/gst/gl/gstglvivdirecttexture.h b/gst-libs/gst/gl/gstglvivdirecttexture.h
714 index fa88e1a..9a2d123 100644
715 --- a/gst-libs/gst/gl/gstglvivdirecttexture.h
716 +++ b/gst-libs/gst/gl/gstglvivdirecttexture.h
720 gboolean gst_is_physical_buffer (GstBuffer *buffer);
721 +gboolean gst_gl_is_directviv_supported_format (GstVideoFormat fmt);
722 +gboolean gst_gl_viv_direct_bind_data (GstGLContext * context, guint tex_id, GstVideoFormat fmt, gint width, gint height,
723 + gpointer * vaddr, gpointer *paddr);
724 gboolean gst_gl_viv_direct_bind_gstbuffer (GstGLContext * context, guint tex_id, GstVideoInfo * info, GstBuffer * buffer);