From d68f2d4694637489360fb6cda83c04a09f3405c2 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 23 Jun 2011 09:30:19 +0200 Subject: [PATCH] meta: add video crop metadata --- gst-libs/gst/video/gstmetavideo.c | 27 +++++++++++++++++++++++++++ gst-libs/gst/video/gstmetavideo.h | 28 +++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/video/gstmetavideo.c b/gst-libs/gst/video/gstmetavideo.c index 8f0df5cd04..9ff221a414 100644 --- a/gst-libs/gst/video/gstmetavideo.c +++ b/gst-libs/gst/video/gstmetavideo.c @@ -155,3 +155,30 @@ gst_meta_video_unmap (GstMetaVideo * meta, guint plane, gpointer data) return TRUE; } + +const GstMetaInfo * +gst_meta_video_crop_get_info (void) +{ + static const GstMetaInfo *meta_video_crop_info = NULL; + + if (meta_video_crop_info == NULL) { + meta_video_crop_info = + gst_meta_register (GST_META_API_VIDEO_CROP, "GstMetaVideoCrop", + sizeof (GstMetaVideoCrop), (GstMetaInitFunction) NULL, + (GstMetaFreeFunction) NULL, (GstMetaCopyFunction) NULL, + (GstMetaTransformFunction) NULL); + } + return meta_video_crop_info; +} + +GstMetaVideoCrop * +gst_buffer_add_meta_video_crop (GstBuffer * buffer) +{ + GstMetaVideoCrop *meta; + + meta = + (GstMetaVideoCrop *) gst_buffer_add_meta (buffer, + GST_META_INFO_VIDEO_CROP, NULL); + + return meta; +} diff --git a/gst-libs/gst/video/gstmetavideo.h b/gst-libs/gst/video/gstmetavideo.h index eb69b19fe1..a0401e555b 100644 --- a/gst-libs/gst/video/gstmetavideo.h +++ b/gst-libs/gst/video/gstmetavideo.h @@ -28,9 +28,12 @@ G_BEGIN_DECLS #define GST_META_API_VIDEO "GstMetaVideo" #define GST_META_INFO_VIDEO (gst_meta_video_get_info()) - typedef struct _GstMetaVideo GstMetaVideo; +#define GST_META_API_VIDEO_CROP "GstMetaVideoCrop" +#define GST_META_INFO_VIDEO_CROP (gst_meta_video_crop_get_info()) +typedef struct _GstMetaVideoCrop GstMetaVideoCrop; + /** * GstMetaVideo: * @meta: parent #GstMeta @@ -76,6 +79,29 @@ gpointer gst_meta_video_map (GstMetaVideo *meta, guint plane, gint GstMapFlags flags); gboolean gst_meta_video_unmap (GstMetaVideo *meta, guint plane, gpointer data); +/** + * GstMetaVideoCrop: + * @meta: parent #GstMeta + * @x: the horizontal offset + * @y: the vertical offset + * @width: the cropped width + * @height: the cropped height + * + * Extra buffer metadata describing image cropping. + */ +struct _GstMetaVideoCrop { + GstMeta meta; + + guint x; + guint y; + guint width; + guint height; +}; + +const GstMetaInfo * gst_meta_video_crop_get_info (void); + +#define gst_buffer_get_meta_video_crop(b) ((GstMetaVideoCrop*)gst_buffer_get_meta((b),GST_META_INFO_VIDEO_CROP)) +GstMetaVideoCrop * gst_buffer_add_meta_video_crop (GstBuffer *buffer); G_END_DECLS