Search
SailfishOS Open Build Service
>
Projects
>
home:sledge
:
branches:nemo:devel:hw:ti:omap4:common
>
gst-plugins-base
> 0005-add-gst_stride_transform_transform_size.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File 0005-add-gst_stride_transform_transform_size.patch of Package gst-plugins-base
From 42c298657f749379bae876e2ce69bd7639f53e21 Mon Sep 17 00:00:00 2001 From: Rob Clark <rob@ti.com> Date: Sun, 16 Aug 2009 21:04:40 -0500 Subject: [PATCH 05/38] add gst_stride_transform_transform_size() input buffer size and output buffer size many not be multiples of a common unit size, so the transform_size() method should be used --- gst/stride/gststridetransform.c | 38 ++++++++++++++++++++++++++++++++++++-- gst/stride/gststridetransform.h | 34 +++++----------------------------- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/gst/stride/gststridetransform.c b/gst/stride/gststridetransform.c index a911cd0..adc22ce 100644 --- a/gst/stride/gststridetransform.c +++ b/gst/stride/gststridetransform.c @@ -62,7 +62,7 @@ GST_ELEMENT_DETAILS ("Stride transform", /* TODO: add rgb formats too! */ #define SUPPORTED_CAPS \ - GST_VIDEO_CAPS_YUV_STRIDED ("{ I420, YV12, YUY2 }", "[ 0, max ]") + GST_VIDEO_CAPS_YUV_STRIDED ("{ I420, YV12, YUY2, UYVY }", "[ 0, max ]") static GstStaticPadTemplate src_template = @@ -89,6 +89,10 @@ static void gst_stride_transform_dispose (GObject *obj); /* GstBaseTransform functions */ static gboolean gst_stride_transform_get_unit_size (GstBaseTransform *base, GstCaps *caps, guint *size); +static gboolean gst_stride_transform_transform_size (GstBaseTransform *base, + GstPadDirection direction, + GstCaps *caps, guint size, + GstCaps *othercaps, guint *othersize); static GstCaps *gst_stride_transform_transform_caps (GstBaseTransform *base, GstPadDirection direction, GstCaps *caps); static gboolean gst_stride_transform_set_caps (GstBaseTransform *base, @@ -126,6 +130,8 @@ gst_stride_transform_class_init (GstStrideTransformClass *klass) basetransform_class->get_unit_size = GST_DEBUG_FUNCPTR (gst_stride_transform_get_unit_size); + basetransform_class->transform_size = + GST_DEBUG_FUNCPTR (gst_stride_transform_transform_size); basetransform_class->transform_caps = GST_DEBUG_FUNCPTR (gst_stride_transform_transform_caps); basetransform_class->set_caps = @@ -176,6 +182,34 @@ gst_stride_transform_get_unit_size (GstBaseTransform *base, return TRUE; } +/** + * Default transform_size function is no good, as it assumes that the output + * buffer size is a multiple of the unit size.. which doesn't hold true. + */ +static gboolean +gst_stride_transform_transform_size (GstBaseTransform *base, + GstPadDirection direction, + GstCaps *caps, guint size, + GstCaps *othercaps, guint *othersize) +{ + GstStrideTransform *self = GST_STRIDE_TRANSFORM (base); + guint idx = (direction == GST_PAD_SINK) ? 0 : 1; + + if (self->cached_caps[idx] != othercaps) + { + if (!gst_stride_transform_get_unit_size (base, othercaps, + &(self->cached_size[idx]))) + { + return FALSE; + } + } + + *othersize = self->cached_size[idx]; + + return TRUE; +} + + /** * helper to add all fields, other than rowstride to @caps, copied from @s. @@ -187,7 +221,7 @@ add_all_fields (GstCaps *caps, const gchar *name, GstStructure *s, gboolean rows GstStructure *new_s = gst_structure_new (name, NULL); if (rowstride) { - gst_structure_set (new_s, "rowstride", GST_TYPE_INT_RANGE, 1, 1000, NULL); // TODO + gst_structure_set (new_s, "rowstride", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL); } idx = gst_structure_n_fields (s) - 1; diff --git a/gst/stride/gststridetransform.h b/gst/stride/gststridetransform.h index d80197f..481959e 100644 --- a/gst/stride/gststridetransform.h +++ b/gst/stride/gststridetransform.h @@ -59,6 +59,10 @@ struct _GstStrideTransform { gint width, height; gint in_rowstride; gint out_rowstride; + + /* for caching the tranform_size() results.. */ + GstCaps *cached_caps[2]; + guint cached_size[2]; }; struct _GstStrideTransformClass { @@ -70,35 +74,7 @@ GType gst_stride_transform_get_type (void); G_END_DECLS - - -/* note: in case this is a build with TTIF logging, we can optimize slightly - * and avoid the gst_caps_to_string() in case logging isn't enabled by using - * the TTIF_TRACE_ARG_PROCESSOR feature of ttif_trace_fprintf(): - */ -#ifdef GST_LOG_OVER_TTIF -# define LOG_CAPS(obj, caps) G_STMT_START { \ - if (caps) { \ - static TTIF_TRACE_ARG_PROCESSOR proc = { \ - .convert = (char (*)(void *))gst_caps_to_string, \ - .free = (void (*)(char *))g_free \ - }; \ - GST_DEBUG_OBJECT (obj, "%s: %qs", #caps, &proc, (caps)); \ - } else { \ - GST_DEBUG_OBJECT (obj, "null"); \ - } \ - } G_STMT_END -#else -# define LOG_CAPS(obj, caps) G_STMT_START { \ - if (caps) { \ - gchar *capstr = gst_caps_to_string (caps); \ - GST_DEBUG_OBJECT (obj, "%s: %s", #caps, capstr); \ - g_free (capstr); \ - } else { \ - GST_DEBUG_OBJECT (obj, "null"); \ - } \ - } G_STMT_END -#endif +#define LOG_CAPS(obj, caps) GST_DEBUG_OBJECT (obj, "%s: %"GST_PTR_FORMAT, #caps, caps) #endif /* __GSTSTRIDETRANSFORM_H__ */ -- 1.7.5.4