From 5ce73e15f24d604e489a3146860caba4fa634ef4 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Fri, 19 May 2023 11:29:15 +0900 Subject: [PATCH] good:videoflip: Support SN12 format [Version] 1.22.0-30 [Issue Type] New feature Change-Id: I9193e1333e46b33955a8686951e8e8fc309c330f Signed-off-by: Jeongmo Yang --- packaging/gstreamer.spec | 2 +- .../gst/videofilter/gstvideoflip.c | 112 ++++++++++++++++++++- .../gst/videofilter/gstvideoflip.h | 3 + .../gst-plugins-good/gst/videofilter/meson.build | 7 +- subprojects/gst-plugins-good/meson.build | 1 + 5 files changed, 121 insertions(+), 4 deletions(-) diff --git a/packaging/gstreamer.spec b/packaging/gstreamer.spec index 7480b73..3a0fc3f 100644 --- a/packaging/gstreamer.spec +++ b/packaging/gstreamer.spec @@ -62,7 +62,7 @@ Name: %{_name} Version: 1.22.0 -Release: 29 +Release: 30 Summary: Streaming-Media Framework Runtime License: LGPL-2.0+ Group: Multimedia/Framework diff --git a/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c b/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c index 07db899..df5bc99 100644 --- a/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c +++ b/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c @@ -47,6 +47,9 @@ #include #include #include +#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT +#include +#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 @@ -68,7 +75,10 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_ALWAYS, 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," + "RGB, BGR, I420, YV12, IYUV, YUY2, UYVY, YVYU, NV12, NV21, " +#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT + "SN12, " +#endif "GRAY8, GRAY16_BE, GRAY16_LE, I420_10LE, I420_10BE, I420_12LE, I420_12BE, " "I422_10LE, I422_10BE, I422_12LE, I422_12BE, Y444_10LE, Y444_10BE, Y444_12LE, Y444_12BE }")) ); @@ -79,7 +89,10 @@ GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_ALWAYS, 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," + "RGB, BGR, I420, YV12, IYUV, YUY2, UYVY, YVYU, NV12, NV21, " +#ifdef TIZEN_FEATURE_VIDEOFLIP_TBM_SUPPORT + "SN12, " +#endif "GRAY8, GRAY16_BE, GRAY16_LE, I420_10LE, I420_10BE, I420_12LE, I420_12BE, " "I422_10LE, I422_10BE, I422_12LE, I422_12BE, Y444_10LE, Y444_10BE, Y444_12LE, Y444_12BE }")) ); @@ -1502,6 +1515,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: @@ -1833,6 +1849,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) { @@ -1879,6 +1982,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); } diff --git a/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.h b/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.h index 3320153..8ceb898 100644 --- a/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.h +++ b/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.h @@ -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 { diff --git a/subprojects/gst-plugins-good/gst/videofilter/meson.build b/subprojects/gst-plugins-good/gst/videofilter/meson.build index d7b6788..3c5f2d7 100644 --- a/subprojects/gst-plugins-good/gst/videofilter/meson.build +++ b/subprojects/gst-plugins-good/gst/videofilter/meson.build @@ -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, ) diff --git a/subprojects/gst-plugins-good/meson.build b/subprojects/gst-plugins-good/meson.build index 5eb10d6..fb31a89 100644 --- a/subprojects/gst-plugins-good/meson.build +++ b/subprojects/gst-plugins-good/meson.build @@ -444,6 +444,7 @@ endif 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) -- 2.7.4