From 4da57f08a1d41d665766c5c07e71775629a960e3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 6 Mar 2012 12:52:01 +0100 Subject: [PATCH] videometa: make video metatransform Make more generic video meta transform data that can be used for many video transformations later. --- gst-libs/gst/video/gstvideometa.c | 22 ++++++++++++++++++++-- gst-libs/gst/video/gstvideometa.h | 21 +++++++++------------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/gst-libs/gst/video/gstvideometa.c b/gst-libs/gst/video/gstvideometa.c index 687e930..cfb150d 100644 --- a/gst-libs/gst/video/gstvideometa.c +++ b/gst-libs/gst/video/gstvideometa.c @@ -323,8 +323,26 @@ gst_video_crop_meta_transform (GstBuffer * dest, GstMeta * meta, dmeta->width = smeta->width; dmeta->height = smeta->height; } else if (GST_VIDEO_META_TRANSFORM_IS_SCALE (type)) { - /* FIXME, do something */ - GST_DEBUG ("scaling crop metadata"); + GstVideoMetaTransform *trans = data; + gint ow, oh, nw, nh; + + smeta = (GstVideoCropMeta *) meta; + dmeta = gst_buffer_add_video_crop_meta (dest); + + ow = GST_VIDEO_INFO_WIDTH (trans->in_info); + nw = GST_VIDEO_INFO_WIDTH (trans->out_info); + oh = GST_VIDEO_INFO_HEIGHT (trans->in_info); + nh = GST_VIDEO_INFO_HEIGHT (trans->out_info); + + GST_DEBUG ("scaling crop metadata %dx%d -> %dx%d", ow, oh, nw, nh); + dmeta->x = (smeta->x * nw) / ow; + dmeta->y = (smeta->y * nh) / oh; + dmeta->width = (smeta->width * nw) / ow; + dmeta->height = (smeta->height * nh) / oh; + GST_DEBUG ("crop offset %dx%d -> %dx%d", smeta->x, smeta->y, dmeta->x, + dmeta->y); + GST_DEBUG ("crop size %dx%d -> %dx%d", smeta->width, smeta->height, + dmeta->width, dmeta->height); } return TRUE; } diff --git a/gst-libs/gst/video/gstvideometa.h b/gst-libs/gst/video/gstvideometa.h index 6d52202..a9d77d7 100644 --- a/gst-libs/gst/video/gstvideometa.h +++ b/gst-libs/gst/video/gstvideometa.h @@ -115,7 +115,7 @@ const GstMetaInfo * gst_video_crop_meta_get_info (void); #define gst_buffer_get_video_crop_meta(b) ((GstVideoCropMeta*)gst_buffer_get_meta((b),GST_VIDEO_CROP_META_API_TYPE)) #define gst_buffer_add_video_crop_meta(b) ((GstVideoCropMeta*)gst_buffer_add_meta((b),GST_VIDEO_CROP_META_INFO, NULL)) -/* metadata transforms */ +/* video metadata transforms */ GQuark gst_video_meta_transform_scale_get_quark (void); /** @@ -126,20 +126,17 @@ GQuark gst_video_meta_transform_scale_get_quark (void); #define GST_VIDEO_META_TRANSFORM_IS_SCALE(type) ((type) == gst_video_meta_transform_scale_get_quark()) /** - * GstVideoMetaTransformScale: - * @old_width: the old width - * @old_height: the old height - * @new_width: the new width - * @new_height: the new height + * GstVideoMetaTransform: + * @old_info: the old #GstVideoInfo + * @new_info: the new #GstVideoInfo * - * Extra data passed to a video "scale" transform #GstMetaTransformFunction. + * Extra data passed to a video transform #GstMetaTransformFunction such as: + * "gst-video-scale". */ typedef struct { - gint old_width; - gint old_height; - gint new_width; - gint new_height; -} GstVideoMetaTransformScale; + GstVideoInfo *in_info; + GstVideoInfo *out_info; +} GstVideoMetaTransform; G_END_DECLS -- 2.7.4