Search
SailfishOS Open Build Service
>
Projects
>
home:sledge
:
branches:nemo:devel:hw:ti:omap4:common
>
gst-plugins-base
> 0035-video-add-qdata-based-crop-interface.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File 0035-video-add-qdata-based-crop-interface.patch of Package gst-plugins-base
From 66561ca66f29c011cc8e0e3478bf466f2a149c9f Mon Sep 17 00:00:00 2001 From: Rob Clark <rob@ti.com> Date: Tue, 12 Jun 2012 18:48:57 -0500 Subject: [PATCH] video: add qdata based crop interface Add a qdata based crop interface that can be used to attach and retrieve cropping info from buffers --- gst-libs/gst/video/Makefile.am | 6 +- gst-libs/gst/video/video-crop.c | 171 +++++++++++++++++++++++++++++++++++++++ gst-libs/gst/video/video-crop.h | 104 ++++++++++++++++++++++++ 3 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 gst-libs/gst/video/video-crop.c create mode 100644 gst-libs/gst/video/video-crop.h diff --git a/gst-libs/gst/video/Makefile.am b/gst-libs/gst/video/Makefile.am index 7306995..f8d3f1c 100644 --- a/gst-libs/gst/video/Makefile.am +++ b/gst-libs/gst/video/Makefile.am @@ -20,13 +20,15 @@ CLEANFILES = $(BUILT_SOURCES) # video-blend.h should be disted but not installed into the includedir libgstvideo_@GST_MAJORMINOR@_la_SOURCES = \ video.c gstvideosink.c gstvideofilter.c convertframe.c \ - video-blend.c video-blend.h video-overlay-composition.c + video-blend.c video-blend.h video-overlay-composition.c \ + video-crop.c nodist_libgstvideo_@GST_MAJORMINOR@_la_SOURCES = \ $(built_sources) $(built_headers) \ $(ORC_NODIST_SOURCES) libgstvideo_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/video libgstvideo_@GST_MAJORMINOR@include_HEADERS = \ - video.h gstvideosink.h gstvideofilter.h video-overlay-composition.h + video.h gstvideosink.h gstvideofilter.h video-overlay-composition.h \ + video-crop.h nodist_libgstvideo_@GST_MAJORMINOR@include_HEADERS = $(built_headers) libgstvideo_@GST_MAJORMINOR@_la_CFLAGS = \ diff --git a/gst-libs/gst/video/video-crop.c b/gst-libs/gst/video/video-crop.c new file mode 100644 index 0000000..be9055e --- /dev/null +++ b/gst-libs/gst/video/video-crop.c @@ -0,0 +1,171 @@ +/* GStreamer video crop + * + * Copyright (c) 2012, Texas Instruments Incorporated + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/** + * SECTION:gstvideocrop + * @short_description: GStreamer video cropping support + * + * Since: 0.10.? + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <unistd.h> + +#include "video-crop.h" + +struct _GstVideoCrop +{ + GstMiniObject parent; + + gint top, left, width, height; +}; + +struct _GstVideoCropClass +{ + GstMiniObjectClass parent_class; +}; + +#define GST_VIDEO_CROP_QUARK gst_video_crop_quark_get_type() +static GST_BOILERPLATE_QUARK (GstVideoCrop, gst_video_crop_quark); + +#define VIDEO_CROP_QUARK video_crop_quark_get_type() +static GST_BOILERPLATE_QUARK (VideoCrop, video_crop_quark); + +/** + * gst_buffer_set_video_crop: + * @buf: a #GstBuffer + * @crop: (allow-none): a #GstVideoCrop, or NULL to clear a + * previously-set crop + * + * Sets an video crop on a buffer. The buffer will obtain its own + * reference to the crop, meaning this function does not take ownership + * of @crop. + * + * Since: 0.10.? + */ +void +gst_buffer_set_video_crop (GstBuffer * buf, GstVideoCrop * crop) +{ + gst_buffer_set_qdata (buf, GST_VIDEO_CROP_QUARK, + gst_structure_id_new (GST_VIDEO_CROP_QUARK, + VIDEO_CROP_QUARK, GST_TYPE_VIDEO_CROP, crop, NULL)); +} + +/** + * gst_buffer_get_video_crop: + * @buf: a #GstBuffer + * + * Get the video crop that has previously been attached to a buffer + * with gst_buffer_set_video_crop(), usually by another element + * upstream. + * + * Returns: (transfer none): the #GstVideoCrop attached to + * this buffer, or NULL. Does not return a reference to the crop, + * caller must obtain her own ref via gst_video_crop_ref() + * if needed. + * + * Since: 0.10.? + */ +GstVideoCrop * +gst_buffer_get_video_crop (GstBuffer * buf) +{ + const GstStructure *s; + const GValue *val; + + s = gst_buffer_get_qdata (buf, GST_VIDEO_CROP_QUARK); + if (s == NULL) + return NULL; + + val = gst_structure_id_get_value (s, VIDEO_CROP_QUARK); + if (val == NULL) + return NULL; + + return GST_VIDEO_CROP (gst_value_get_mini_object (val)); +} + +static void +gst_video_crop_finalize (GstMiniObject * mini_obj) +{ + /* not chaining up to GstMiniObject's finalize for now, we know it's empty */ +} + +static void +gst_video_crop_class_init (GstVideoCropClass * klass) +{ + GST_MINI_OBJECT_CLASS (klass)->finalize = gst_video_crop_finalize; +} + +GST_BOILERPLATE_MINI_OBJECT (GstVideoCrop, gst_video_crop); + +/** + * gst_video_crop_new: + * @top: top coordinate of cropping region + * @left: left coordinate of cropping region + * @width: width of cropping region + * @height: height of cropping region + * + * Creates a new crop object. + * + * Returns: (transfer full): a new #GstVideoCrop. Unref with + * gst_video_crop_unref() when no longer needed. + * + * Since: 0.10.? + */ +GstVideoCrop * +gst_video_crop_new (guint top, guint left, guint width, guint height) +{ + GstVideoCrop *crop; + + crop = (GstVideoCrop *) gst_mini_object_new (GST_TYPE_VIDEO_CROP); + + crop->top = top; + crop->left = left; + crop->width = width; + crop->height = height; + + return crop; +} + +guint +gst_video_crop_top (GstVideoCrop * crop) +{ + return crop->top; +} + +guint +gst_video_crop_left (GstVideoCrop * crop) +{ + return crop->left; +} + +guint +gst_video_crop_width (GstVideoCrop * crop) +{ + return crop->width; +} + +guint +gst_video_crop_height (GstVideoCrop * crop) +{ + return crop->height; +} diff --git a/gst-libs/gst/video/video-crop.h b/gst-libs/gst/video/video-crop.h new file mode 100644 index 0000000..bfc7cfe --- /dev/null +++ b/gst-libs/gst/video/video-crop.h @@ -0,0 +1,104 @@ +/* GStreamer video-crop + * + * Copyright (c) 2012, Texas Instruments Incorporated + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_VIDEO_CROP_H__ +#define __GST_VIDEO_CROP_H__ + +#include <gst/gst.h> + +G_BEGIN_DECLS + +/** + * GstVideoCrop: + * + * Crop coordinates for a video buffer. + * + * Since: 0.10.? + */ +#define GST_TYPE_VIDEO_CROP \ + (gst_video_crop_get_type ()) +#define GST_VIDEO_CROP(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_CROP, GstVideoCrop)) +#define GST_IS_VIDEO_CROP(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_CROP)) + +typedef struct _GstVideoCrop GstVideoCrop; +typedef struct _GstVideoCropClass GstVideoCropClass; + +/** + * gst_video_crop_ref: + * @crop: a a #GstVideoCrop. + * + * Increases the refcount by one. + * + * Returns: (transfer full): @crop + * + * Since: 0.10.? + */ +#ifdef _FOOL_GTK_DOC_ +G_INLINE_FUNC GstVideoCrop * +gst_video_crop_ref (GstVideoCrop * crop); +#endif + +static inline GstVideoCrop * +gst_video_crop_ref (GstVideoCrop * crop) +{ + return (GstVideoCrop *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (crop)); +} + +/** + * gst_video_crop_unref: + * @crop: (transfer full): a #GstVideoCrop. + * + * Decreases the refcount. If the refcount reaches 0, the crop will be + * freed. + * + * Since: 0.10.? + */ +#ifdef _FOOL_GTK_DOC_ +G_INLINE_FUNC void +gst_video_crop_unref (GstVideoCrop * crop); +#endif + +static inline void +gst_video_crop_unref (GstVideoCrop * crop) +{ + gst_mini_object_unref (GST_MINI_OBJECT_CAST (crop)); +} + +GType gst_video_crop_get_type (void); + +GstVideoCrop * gst_video_crop_new (guint top, guint left, guint width, guint height); + +guint gst_video_crop_top (GstVideoCrop * crop); +guint gst_video_crop_left (GstVideoCrop * crop); +guint gst_video_crop_width (GstVideoCrop * crop); +guint gst_video_crop_height (GstVideoCrop * crop); + +/* attach/retrieve crop from buffers */ + +void gst_buffer_set_video_crop (GstBuffer * buf, + GstVideoCrop * crop); + +GstVideoCrop * gst_buffer_get_video_crop (GstBuffer * buf); + +G_END_DECLS + +#endif /* __GST_VIDEO_CROP_H__ */ -- 1.7.9.5