[v4l2videodecoder] Add new property to enable TBM output buffer
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2allocator.c
index 5f6f554..a06c822 100644 (file)
@@ -692,7 +692,8 @@ gst_v4l2_allocator_new (GstObject * parent, GstV4l2Object * v4l2object)
   GST_OBJECT_FLAG_SET (allocator, flags);
 
 #ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
-  if (!V4L2_TYPE_IS_OUTPUT (v4l2object->type) &&
+  if (v4l2object->tbm_output &&
+      !V4L2_TYPE_IS_OUTPUT (v4l2object->type) &&
       v4l2object->mode == GST_V4L2_IO_DMABUF) {
     tbm_surface_h tmp_surface = NULL;
     int width = GST_VIDEO_INFO_WIDTH (&v4l2object->info);
@@ -974,9 +975,11 @@ gst_v4l2_allocator_alloc_dmabuf (GstV4l2Allocator * allocator,
           group->planes[i].length - group->planes[i].data_offset, i, NULL,
           expbuf.fd, group);
 #ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
-      bos[i] = tbm_bo_import_fd (allocator->bufmgr, expbuf.fd);
-      GST_INFO_OBJECT (allocator, "obj[%p,i:%d]: fd[%d] -> bo[%p]",
-        obj, expbuf.index, expbuf.fd, bos[i]);
+      if (obj->tbm_output) {
+        bos[i] = tbm_bo_import_fd (allocator->bufmgr, expbuf.fd);
+        GST_INFO_OBJECT (allocator, "obj[%p,i:%d]: fd[%d] -> bo[%p]",
+            obj, expbuf.index, expbuf.fd, bos[i]);
+      }
 #endif /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */
     } else {
       /* Take back the allocator reference */
@@ -1000,7 +1003,7 @@ gst_v4l2_allocator_alloc_dmabuf (GstV4l2Allocator * allocator,
   }
 
 #ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
-  if (!group->surface) {
+  if (obj->tbm_output && !group->surface) {
     group->surface = tbm_surface_internal_create_with_bos (&allocator->s_info, bos, group->n_mem);
     GST_INFO_OBJECT (allocator, "new surface[%p] in memory group[%p]", group->surface, group);
   }