good:videoflip: Support SN12 format 55/293055/3 accepted/tizen/7.0/unified/20230523.155035 accepted/tizen/7.0/unified/20230524.220649
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 19 May 2023 02:29:15 +0000 (11:29 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 22 May 2023 01:05:53 +0000 (10:05 +0900)
[Version] 1.20.0-49
[Issue Type] New feature

Change-Id: I9193e1333e46b33955a8686951e8e8fc309c330f
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/gstreamer.spec
subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c
subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.h
subprojects/gst-plugins-good/gst/videofilter/meson.build
subprojects/gst-plugins-good/meson.build

index 7a832a8b368aa914f15f689ac1d4072ee013faab..ed66d090035381c5fcb30ae2980895542cd71694 100644 (file)
@@ -62,7 +62,7 @@
 
 Name:           %{_name}
 Version:        1.20.0
-Release:        48
+Release:        49
 Summary:        Streaming-Media Framework Runtime
 License:        LGPL-2.0+
 Group:          Multimedia/Framework
index 371f29171692f45876edca70b755ff595d2e579b..a759b38182fea17c37ec947a8f1cfb7e85e096e1 100644 (file)
@@ -47,6 +47,9 @@
 #include <string.h>
 #include <gst/gst.h>
 #include <gst/video/video.h>
+#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT
+#include <gst/allocators/gsttizenbufferpool.h>
+#endif
 
 /* GstVideoFlip properties */
 enum
@@ -58,6 +61,10 @@ enum
 };
 
 #define PROP_METHOD_DEFAULT GST_VIDEO_FLIP_METHOD_IDENTITY
+#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT
+#define TIZEN_BUFFER_POOL_MIN_BUFFERS   4
+#define TIZEN_BUFFER_POOL_MAX_BUFFERS   10
+#endif
 
 GST_DEBUG_CATEGORY_STATIC (video_flip_debug);
 #define GST_CAT_DEFAULT video_flip_debug
@@ -69,6 +76,9 @@ GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
             "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx, xBGR, BGRx, "
             "RGB, BGR, I420, YV12, IYUV, YUY2, UYVY, YVYU, NV12, NV21, "
+#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT
+            "SN12, "
+#endif
             "GRAY8, GRAY16_BE, GRAY16_LE }"))
     );
 
@@ -79,6 +89,9 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, "
             "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx, xBGR, BGRx, "
             "RGB, BGR, I420, YV12, IYUV, YUY2, UYVY, YVYU, NV12, NV21, "
+#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT
+            "SN12, "
+#endif
             "GRAY8, GRAY16_BE, GRAY16_LE }"))
     );
 
@@ -1014,6 +1027,9 @@ gst_video_flip_configure_process (GstVideoFlip * vf)
       break;
     case GST_VIDEO_FORMAT_NV12:
     case GST_VIDEO_FORMAT_NV21:
+#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT
+    case GST_VIDEO_FORMAT_SN12:
+#endif
       vf->process = gst_video_flip_semi_planar_yuv;
       break;
     default:
@@ -1366,6 +1382,93 @@ gst_video_flip_get_property (GObject * object, guint prop_id, GValue * value,
   }
 }
 
+#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT
+static gboolean
+gst_video_flip_decide_allocation (GstBaseTransform * trans,
+    GstQuery * query)
+{
+  GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans);
+  GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
+
+  GST_WARNING_OBJECT (videoflip, "format[%s]", filter->out_info.finfo->name);
+
+  if (filter->out_info.finfo->format == GST_VIDEO_FORMAT_SN12) {
+    guint size;
+    GstStructure *config;
+    GstCaps *caps = NULL;
+    GstVideoInfo vinfo;
+
+    gst_query_parse_allocation (query, &caps, NULL);
+    if (!caps) {
+      GST_WARNING_OBJECT (videoflip, "caps failed");
+      return FALSE;
+    }
+
+    gst_video_info_init (&vinfo);
+    gst_video_info_from_caps (&vinfo, caps);
+
+    size = vinfo.size;
+
+    videoflip->pool = gst_tizen_buffer_pool_new ();
+    config = gst_buffer_pool_get_config (videoflip->pool);
+
+    gst_buffer_pool_config_set_params (config, caps, size,
+      TIZEN_BUFFER_POOL_MIN_BUFFERS, TIZEN_BUFFER_POOL_MAX_BUFFERS);
+    gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
+    gst_buffer_pool_set_config (videoflip->pool, config);
+
+    if (!gst_buffer_pool_set_active (videoflip->pool, TRUE)) {
+      gst_object_unref (videoflip->pool);
+      videoflip->pool = NULL;
+      GST_WARNING_OBJECT (videoflip, "Failed to activate pool");
+      return FALSE;
+    }
+
+    GST_WARNING_OBJECT (videoflip, "new buffer pool[%p]", videoflip->pool);
+  }
+
+  return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans, query);
+}
+
+static GstFlowReturn
+gst_video_flip_prepare_output_buffer (GstBaseTransform * trans,
+    GstBuffer *input, GstBuffer **outbuf)
+{
+  GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans);
+  GstBuffer *buf = NULL;
+
+  if (!videoflip->pool)
+    return GST_BASE_TRANSFORM_CLASS (parent_class)->prepare_output_buffer (trans, input, outbuf);
+
+  if (gst_buffer_pool_acquire_buffer (videoflip->pool, &buf, 0) != GST_FLOW_OK) {
+    GST_ERROR_OBJECT (trans, "Buffer acquire failed");
+    return GST_FLOW_ERROR;
+  }
+
+  GST_DEBUG_OBJECT (videoflip, "acquired buffer[%p]", buf);
+
+  if (input != buf)
+    GST_BASE_TRANSFORM_CLASS (parent_class)->copy_metadata (trans, input, buf);
+
+  *outbuf = buf;
+
+  return GST_FLOW_OK;
+}
+
+static void
+gst_video_flip_finalize (GstVideoFlip * videoflip)
+{
+  if (videoflip->pool) {
+    GST_WARNING_OBJECT (videoflip, "free buffer pool[%p]", videoflip->pool);
+    gst_buffer_pool_set_active (videoflip->pool, FALSE);
+    gst_object_unref (videoflip->pool);
+    videoflip->pool = NULL;
+  }
+
+  G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT (videoflip));
+}
+#endif
+
 static void
 gst_video_flip_class_init (GstVideoFlipClass * klass)
 {
@@ -1412,6 +1515,11 @@ gst_video_flip_class_init (GstVideoFlipClass * klass)
   vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_video_flip_set_info);
   vfilter_class->transform_frame =
       GST_DEBUG_FUNCPTR (gst_video_flip_transform_frame);
+#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT
+  trans_class->decide_allocation = gst_video_flip_decide_allocation;
+  trans_class->prepare_output_buffer = gst_video_flip_prepare_output_buffer;
+  gobject_class->finalize = gst_video_flip_finalize;
+#endif
 
   gst_type_mark_as_plugin_api (GST_TYPE_VIDEO_FLIP_METHOD, 0);
 }
index 33201531812dbdd0bac3439279fc2a57b52fc122..8ceb89884993825f1438efda813d0b532a808186 100644 (file)
@@ -84,6 +84,9 @@ struct _GstVideoFlip {
   GstVideoOrientationMethod configuring_method;
   GstVideoOrientationMethod active_method;
   void (*process) (GstVideoFlip *videoflip, GstVideoFrame *dest, const GstVideoFrame *src);
+#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT
+  GstBufferPool *pool;
+#endif
 };
 
 struct _GstVideoFlipClass {
index acb5191f40e998453b022a38b6c17c5cac22ef77..71379d67252c3717305c844ae6293f3c7a3455a4 100644 (file)
@@ -6,11 +6,16 @@ vfilter_sources = [
   'gstvideomedian.c',
 ]
 
+extra_deps = [ ]
+if tbm_dep.found()
+ extra_deps = gstallocators_dep
+endif
+
 gstvideofilter = library('gstvideofilter',
   vfilter_sources,
   c_args : gst_plugins_good_args,
   include_directories : [configinc],
-  dependencies : [gstbase_dep, gstvideo_dep, libm],
+  dependencies : [gstbase_dep, gstvideo_dep, libm] + extra_deps,
   install : true,
   install_dir : plugins_install_dir,
 )
index 65b98aeae90028b800e17170271e4f0cdc1edc4b..ccafd77c86300372c008f3c7aaf6cd65db4a0108 100644 (file)
@@ -427,6 +427,7 @@ cdata.set('TIZEN_FEATURE_FIX_SEG_FAULT', true)
 tbm_dep = dependency('libtbm', required : get_option('tbm'))
 if tbm_dep.found()
   cdata.set('TIZEN_FEATURE_V4L2_TBM_SUPPORT', 1)
+  cdata.set('TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT', 1)
 endif
 cdata.set('TIZEN_FEATURE_V4L2SRC_AUTO_SCAN_DEVICE_NODE', true)
 cdata.set('TIZEN_FEATURE_V4L2SRC_SUPPORT_CAMERA_ID', true)