#include <gst/video/gstvideometa.h>
#include <gst/video/gstvideopool.h>
+#ifdef USE_TBM
+#include <gst/allocators/gsttizenbufferpool.h>
+#endif
+
#include <string.h>
GST_DEBUG_CATEGORY (videoconvert_debug);
};
#define CSP_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ";" \
- GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("ANY", GST_VIDEO_FORMATS_ALL)
+ GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("ANY", GST_VIDEO_FORMATS_ALL) ";" \
+ GST_VIDEO_CAPS_MAKE("{ SUYV , SYVY , S420 , ITLV }") ";" \
+ GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("ANY", "{ SUYV , SYVY , S420 , ITLV }")
+
+#define CSP_VIDEO_SRC_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ";" \
+ GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("ANY", GST_VIDEO_FORMATS_ALL) ";" \
+ GST_VIDEO_CAPS_MAKE("{ SUYV , SYVY , S420 , ITLV , SN12 }") ";" \
+ GST_VIDEO_CAPS_MAKE_WITH_FEATURES ("ANY", "{ SUYV , SYVY , S420 , ITLV , SN12 }")
static GstStaticPadTemplate gst_video_convert_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (CSP_VIDEO_CAPS)
+ GST_STATIC_CAPS (CSP_VIDEO_SRC_CAPS)
);
static GstStaticPadTemplate gst_video_convert_sink_template =
static GstFlowReturn gst_video_convert_transform_frame (GstVideoFilter * filter,
GstVideoFrame * in_frame, GstVideoFrame * out_frame);
+#ifdef USE_TBM
+static gboolean gst_video_convert_decide_allocation (GstBaseTransform * bsrc,
+ GstQuery * query);
+static GstFlowReturn gst_video_convert_prepare_output_buffer (GstBaseTransform * trans,
+ GstBuffer *input, GstBuffer **outbuf);
+#endif
+
/* copies the given caps */
static GstCaps *
gst_video_convert_caps_remove_format_info (GstCaps * caps)
{
GstVideoConvert *space = GST_VIDEO_CONVERT (obj);
+#ifdef USE_TBM
+ if (space->pool) {
+ gst_buffer_pool_set_active (space->pool, FALSE);
+ gst_object_unref (space->pool);
+ space->pool = NULL;
+ }
+#endif
+
if (space->convert) {
gst_video_converter_free (space->convert);
}
gstvideofilter_class->transform_frame =
GST_DEBUG_FUNCPTR (gst_video_convert_transform_frame);
+#ifdef USE_TBM
+ gstbasetransform_class->decide_allocation = gst_video_convert_decide_allocation;
+ gstbasetransform_class->prepare_output_buffer = gst_video_convert_prepare_output_buffer;
+#endif
+
g_object_class_install_property (gobject_class, PROP_DITHER,
g_param_spec_enum ("dither", "Dither", "Apply dithering while converting",
gst_video_dither_method_get_type (), DEFAULT_PROP_DITHER,
static void
gst_video_convert_init (GstVideoConvert * space)
{
+#ifdef USE_TBM
+ space->pool = NULL;
+#endif
space->dither = DEFAULT_PROP_DITHER;
space->dither_quantization = DEFAULT_PROP_DITHER_QUANTIZATION;
space->chroma_resampler = DEFAULT_PROP_CHROMA_RESAMPLER;
return GST_FLOW_OK;
}
+#ifdef USE_TBM
+static gboolean
+gst_video_convert_decide_allocation (GstBaseTransform * trans,
+ GstQuery * query)
+{
+ GstVideoConvert *vc = NULL;
+ GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
+ vc = GST_VIDEO_CONVERT_CAST(trans);
+
+ 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);
+ gst_video_info_init (&vinfo);
+ gst_video_info_from_caps (&vinfo, caps);
+
+ size = vinfo.size;
+
+ if (caps) {
+ vc->pool = gst_tizen_buffer_pool_new ();
+ config = gst_buffer_pool_get_config (vc->pool);
+
+ gst_buffer_pool_config_set_params (config, caps, size, 4, 10);
+ gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
+ gst_buffer_pool_set_config (vc->pool, config);
+
+ if (!gst_buffer_pool_set_active (vc->pool, TRUE)) {
+ gst_object_unref (vc->pool);
+ vc->pool = NULL;
+ GST_INFO ("Failed to activate internal pool");
+ }
+ } else {
+ GST_ERROR("Not using our internal pool and copying buffers for downstream");
+ return FALSE;
+ }
+ }
+ GST_DEBUG("[%s]Creating Tizen Buffer Pool", __FUNCTION__);
+
+ return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans, query);
+}
+
+static GstFlowReturn
+gst_video_convert_prepare_output_buffer (GstBaseTransform * trans,
+ GstBuffer *input, GstBuffer **outbuf)
+{
+ GstBuffer *buf = NULL;
+ GstVideoConvert *vc = NULL;
+ GstVideoFilter *filter = GST_VIDEO_FILTER_CAST (trans);
+
+ vc = GST_VIDEO_CONVERT_CAST (trans);
+
+ if (filter->out_info.finfo->format == GST_VIDEO_FORMAT_SN12 ) {
+ if (gst_buffer_pool_acquire_buffer (vc->pool, &buf, 0) != GST_FLOW_OK) {
+ GST_ERROR("[%s] memory prepare failed.",__FUNCTION__);
+ return GST_FLOW_ERROR;
+ }
+
+ if (input != buf)
+ GST_BASE_TRANSFORM_CLASS (parent_class)->copy_metadata (trans, input, buf);
+ *outbuf = buf;
+
+ return GST_FLOW_OK;
+ }
+ return GST_BASE_TRANSFORM_CLASS (parent_class)->prepare_output_buffer(trans, input, outbuf);
+}
+#endif
+
static gboolean
plugin_init (GstPlugin * plugin)
{