[v4l2videodecoder] Add new property to enable TBM output buffer 23/253323/1
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 4 Feb 2021 11:28:42 +0000 (20:28 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 8 Feb 2021 05:23:38 +0000 (14:23 +0900)
- In previous code, TBM output buffer was enabled for v4l2src plugin,
  and it caused unexpected error when it's used for camera.

[Version] 1.16.2-18
[Issue Type] Bug fix

Change-Id: Ia84f6f9bdb03567b380f263074af44dcc56810ab
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/gst-plugins-good.spec
sys/v4l2/gstv4l2allocator.c
sys/v4l2/gstv4l2bufferpool.c
sys/v4l2/gstv4l2object.c
sys/v4l2/gstv4l2object.h
sys/v4l2/gstv4l2videodec.c

index 5ce438a70f15ca0692f544200dddb83446d36eeb..ec3f091c755eebadaca9bb106e5a8200ed272b7a 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:           gst-plugins-good
 Version:        1.16.2
-Release:        17
+Release:        18
 License:        LGPL-2.1+
 Summary:        GStreamer Streaming-Media Framework Plug-Ins
 Url:            http://gstreamer.freedesktop.org/
index 5f6f554d97b0a9aced6531000ca87b86a134aa31..a06c822b6eca11e1a9ba04b989e4cfa7ab3e04c7 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);
   }
index a2ad8f996d7ed1a6c920ac38c104da699d2770a7..dce6daa3e63c7fa52285e912d3690b1cdf564d55 100644 (file)
@@ -771,7 +771,7 @@ gst_v4l2_buffer_pool_streamoff (GstV4l2BufferPool * pool)
     return;
 
 #ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
-  if (!V4L2_TYPE_IS_OUTPUT(pool->obj->type)) {
+  if (obj->tbm_output && !V4L2_TYPE_IS_OUTPUT(pool->obj->type)) {
     g_mutex_lock (&pool->buffer_lock);
 
     GST_INFO_OBJECT (pool, "live buffer[%d]", pool->live_buffer_count);
@@ -2020,7 +2020,7 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer ** buf)
               goto eos;
           }
 #ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
-          if (pool->obj->mode == GST_V4L2_IO_DMABUF) {
+          if (pool->obj->tbm_output && pool->obj->mode == GST_V4L2_IO_DMABUF) {
             gst_buffer_unref (*buf);
             *buf = tmp;
           } else {
index 9db4ae691faff902867f12ba7659f07bfcd6e29b..8cc1b9373afe7a36397dc8b553a049e8eebb6ce3 100644 (file)
@@ -831,10 +831,13 @@ gst_v4l2_get_driver_min_buffers (GstV4l2Object * v4l2object)
         "driver requires a minimum of %d buffers", control.value);
 #ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
 #define DEFAULT_DECODER_OUTPUT_BUFFER_COUNT 5
-    if (!V4L2_TYPE_IS_OUTPUT (v4l2object->type) && control.value == 1) {
+    if (v4l2object->tbm_output &&
+        !V4L2_TYPE_IS_OUTPUT (v4l2object->type) && control.value == 1) {
       v4l2object->min_buffers = DEFAULT_DECODER_OUTPUT_BUFFER_COUNT;
       GST_WARNING_OBJECT (v4l2object->dbg_obj, "but SET MIN BUFFER COUNT[%d] and it will be [%d] later",
           v4l2object->min_buffers, v4l2object->min_buffers + 1);
+    } else {
+      v4l2object->min_buffers = control.value;
     }
 #else /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */
     v4l2object->min_buffers = control.value;
index c12ff099c31452df9c0a532805777b636bb9cff0..63933494c9b759c7b7fbbbac5e412629edd39702 100644 (file)
@@ -131,6 +131,9 @@ struct _GstV4l2Object {
   /* auto scan device */
   gboolean auto_scan_device;
 #endif /* TIZEN_FEATURE_V4L2SRC_AUTO_SCAN_DEVICE_NODE */
+#ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
+  gboolean tbm_output;
+#endif /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */
 
   /* the video-device's file descriptor */
   gint video_fd;
index 4e4a5f341aadcb59bc7ad754edaf70ec0ddca40a..eb7d0d07aa64739ebb17cd0b1d8faca5c6e8d0e4 100644 (file)
@@ -51,6 +51,9 @@ enum
 {
   PROP_0,
   V4L2_STD_OBJECT_PROPS
+#ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
+  , PROP_TBM_OUTPUT
+#endif /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */
 };
 
 #define gst_v4l2_video_dec_parent_class parent_class
@@ -89,6 +92,13 @@ gst_v4l2_video_dec_set_property (GObject * object,
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       }
       break;
+#ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
+    case PROP_TBM_OUTPUT:
+      self->v4l2capture->tbm_output = g_value_get_boolean (value);
+      GST_INFO_OBJECT (self, "tbm output [%d]", self->v4l2capture->tbm_output);
+      break;
+#endif /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */
+
 
       /* By default, only set on output */
     default:
@@ -113,6 +123,12 @@ gst_v4l2_video_dec_get_property (GObject * object,
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       }
       break;
+#ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
+    case PROP_TBM_OUTPUT:
+      GST_INFO_OBJECT (self, "tbm output [%d]", self->v4l2capture->tbm_output);
+      g_value_set_boolean (value, self->v4l2capture->tbm_output);
+      break;
+#endif /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */
 
       /* By default read from output */
     default:
@@ -1005,6 +1021,9 @@ gst_v4l2_video_dec_subinstance_init (GTypeInstance * instance, gpointer g_class)
       GST_OBJECT (GST_VIDEO_DECODER_SRC_PAD (self)),
       V4L2_BUF_TYPE_VIDEO_CAPTURE, klass->default_device,
       gst_v4l2_get_input, gst_v4l2_set_input, NULL);
+#ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
+  self->v4l2capture->tbm_output = TRUE;
+#endif /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */
 }
 
 static void
@@ -1057,6 +1076,12 @@ gst_v4l2_video_dec_class_init (GstV4l2VideoDecClass * klass)
       GST_DEBUG_FUNCPTR (gst_v4l2_video_dec_change_state);
 
   gst_v4l2_object_install_m2m_properties_helper (gobject_class);
+#ifdef TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER
+  g_object_class_install_property (gobject_class, PROP_TBM_OUTPUT,
+      g_param_spec_boolean ("tbm-output", "Enable TBM for output buffer",
+          "It works for only DMABUF mode.",
+          TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif /* TIZEN_FEATURE_TBM_SUPPORT_FOR_V4L2_DECODER */
 }
 
 static void