videometa: add videoscale metadata transform

This commit is contained in:
Wim Taymans 2012-03-02 13:04:26 +01:00
parent df004b586e
commit 337eed6e91
2 changed files with 67 additions and 12 deletions

View file

@ -29,20 +29,27 @@ gst_video_meta_transform (GstBuffer * dest, GstMeta * meta,
smeta = (GstVideoMeta *) meta;
if (GST_META_TRANSFORM_IS_COPY (type)) {
dmeta =
(GstVideoMeta *) gst_buffer_add_meta (dest, GST_VIDEO_META_INFO, NULL);
dmeta->buffer = dest;
GstMetaTransformCopy *copy = data;
dmeta->flags = smeta->flags;
dmeta->id = smeta->id;
dmeta->format = smeta->format;
dmeta->width = smeta->width;
dmeta->height = smeta->height;
if (!copy->region) {
/* only copy if the complete data is copied as well */
dmeta =
(GstVideoMeta *) gst_buffer_add_meta (dest, GST_VIDEO_META_INFO,
NULL);
dmeta->buffer = dest;
dmeta->n_planes = smeta->n_planes;
for (i = 0; i < dmeta->n_planes; i++) {
dmeta->offset[i] = smeta->offset[i];
dmeta->stride[i] = smeta->stride[i];
GST_DEBUG ("copy video metadata");
dmeta->flags = smeta->flags;
dmeta->id = smeta->id;
dmeta->format = smeta->format;
dmeta->width = smeta->width;
dmeta->height = smeta->height;
dmeta->n_planes = smeta->n_planes;
for (i = 0; i < dmeta->n_planes; i++) {
dmeta->offset[i] = smeta->offset[i];
dmeta->stride[i] = smeta->stride[i];
}
}
}
return TRUE;
@ -310,10 +317,14 @@ gst_video_crop_meta_transform (GstBuffer * dest, GstMeta * meta,
smeta = (GstVideoCropMeta *) meta;
dmeta = gst_buffer_add_video_crop_meta (dest);
GST_DEBUG ("copy crop metadata");
dmeta->x = smeta->x;
dmeta->y = smeta->y;
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");
}
return TRUE;
}
@ -344,3 +355,21 @@ gst_video_crop_meta_get_info (void)
}
return video_crop_meta_info;
}
/**
* gst_video_meta_transform_scale_get_quark:
*
* Get the #GQuark for the "gst-video-scale" metadata transform operation.
*
* Returns: a #GQuark
*/
GQuark
gst_video_meta_transform_scale_get_quark (void)
{
static GQuark _value = 0;
if (_value == 0) {
_value = g_quark_from_static_string ("gst-video-scale");
}
return _value;
}

View file

@ -115,6 +115,32 @@ 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 */
GQuark gst_video_meta_transform_scale_get_quark (void);
/**
* gst_video_meta_transform_scale:
*
* GQuark for the video "gst-video-scale" transform.
*/
#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
*
* Extra data passed to a video "scale" transform #GstMetaTransformFunction.
*/
typedef struct {
gint old_width;
gint old_height;
gint new_width;
gint new_height;
} GstVideoMetaTransformScale;
G_END_DECLS
#endif /* __GST_VIDEO_META_H__ */