From a64caea0bd53e4ba21c2da83abebc305ff7690f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 16 Jun 2009 19:38:17 +0200 Subject: [PATCH] videofilter: Add a default get_unit_size function This returns the correct values for all formats that are handled by GstVideoFormat and makes all the custom get_unit_size functions in many elements unnecessary. --- gst-libs/gst/video/gstvideofilter.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gst-libs/gst/video/gstvideofilter.c b/gst-libs/gst/video/gstvideofilter.c index 02c7a67..2913436 100644 --- a/gst-libs/gst/video/gstvideofilter.c +++ b/gst-libs/gst/video/gstvideofilter.c @@ -39,6 +39,8 @@ #include "gstvideofilter.h" +#include + GST_DEBUG_CATEGORY_STATIC (gst_video_filter_debug); #define GST_CAT_DEFAULT gst_video_filter_debug @@ -71,6 +73,26 @@ gst_video_filter_get_type (void) return video_filter_type; } +static gboolean +gst_video_filter_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, + guint * size) +{ + GstVideoFormat fmt; + gint width, height; + + if (!gst_video_format_parse_caps (caps, &fmt, &width, &height)) { + GST_WARNING_OBJECT (btrans, "Failed to parse caps %" GST_PTR_FORMAT, caps); + return FALSE; + } + + *size = gst_video_format_get_size (fmt, width, height); + + GST_DEBUG_OBJECT (btrans, "Returning size %u bytes for caps %" + GST_PTR_FORMAT, *size, caps); + + return TRUE; +} + static void gst_video_filter_class_init (gpointer g_class, gpointer class_data) { @@ -84,6 +106,9 @@ gst_video_filter_class_init (gpointer g_class, gpointer class_data) gstelement_class = (GstElementClass *) klass; trans_class = (GstBaseTransformClass *) klass; + trans_class->get_unit_size = + GST_DEBUG_FUNCPTR (gst_video_filter_get_unit_size); + parent_class = g_type_class_peek_parent (klass); GST_DEBUG_CATEGORY_INIT (gst_video_filter_debug, "videofilter", 0, -- 2.7.4