videometa: Initialize all fields of all metas with default values

The metas are not allocated with all fields initialized to zeroes.

https://bugzilla.gnome.org/show_bug.cgi?id=764902
This commit is contained in:
Sebastian Dröge 2016-04-13 10:07:33 +03:00
parent c5ed98a35b
commit a82ef8983e
3 changed files with 66 additions and 4 deletions

View file

@ -42,6 +42,24 @@ ensure_debug_category (void)
#define ensure_debug_category() /* NOOP */
#endif /* GST_DISABLE_GST_DEBUG */
static gboolean
gst_video_meta_init (GstMeta * meta, gpointer params, GstBuffer * buffer)
{
GstVideoMeta *emeta = (GstVideoMeta *) meta;
emeta->buffer = NULL;
emeta->flags = GST_VIDEO_FRAME_FLAG_NONE;
emeta->format = GST_VIDEO_FORMAT_UNKNOWN;
emeta->id = 0;
emeta->width = emeta->height = emeta->n_planes = 0;
memset (emeta->offset, 0, sizeof (emeta->offset));
memset (emeta->stride, 0, sizeof (emeta->stride));
emeta->map = NULL;
emeta->unmap = NULL;
return TRUE;
}
static gboolean
gst_video_meta_transform (GstBuffer * dest, GstMeta * meta,
GstBuffer * buffer, GQuark type, gpointer data)
@ -113,7 +131,7 @@ gst_video_meta_get_info (void)
if (g_once_init_enter (&video_meta_info)) {
const GstMetaInfo *meta =
gst_meta_register (GST_VIDEO_META_API_TYPE, "GstVideoMeta",
sizeof (GstVideoMeta), (GstMetaInitFunction) NULL,
sizeof (GstVideoMeta), (GstMetaInitFunction) gst_video_meta_init,
(GstMetaFreeFunction) NULL, gst_video_meta_transform);
g_once_init_leave (&video_meta_info, meta);
}
@ -484,6 +502,25 @@ gst_video_gl_texture_upload_meta_api_get_type (void)
return type;
}
static gboolean
gst_video_gl_texture_upload_meta_init (GstMeta * meta, gpointer params,
GstBuffer * buffer)
{
GstVideoGLTextureUploadMeta *vmeta = (GstVideoGLTextureUploadMeta *) meta;
vmeta->texture_orientation =
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL;
vmeta->n_textures = 0;
memset (vmeta->texture_type, 0, sizeof (vmeta->texture_type));
vmeta->buffer = NULL;
vmeta->upload = NULL;
vmeta->user_data = NULL;
vmeta->user_data_copy = NULL;
vmeta->user_data_free = NULL;
return TRUE;
}
static void
gst_video_gl_texture_upload_meta_free (GstMeta * meta, GstBuffer * buffer)
{
@ -542,7 +579,7 @@ gst_video_gl_texture_upload_meta_get_info (void)
gst_meta_register (GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE,
"GstVideoGLTextureUploadMeta",
sizeof (GstVideoGLTextureUploadMeta),
NULL,
gst_video_gl_texture_upload_meta_init,
gst_video_gl_texture_upload_meta_free,
gst_video_gl_texture_upload_meta_transform);
g_once_init_leave (&info, meta);
@ -692,6 +729,7 @@ gst_video_region_of_interest_meta_init (GstMeta * meta, gpointer params,
GstBuffer * buffer)
{
GstVideoRegionOfInterestMeta *emeta = (GstVideoRegionOfInterestMeta *) meta;
emeta->roi_type = 0;
emeta->id = 0;
emeta->parent_id = 0;
emeta->x = emeta->y = emeta->w = emeta->h = 0;

View file

@ -418,6 +418,16 @@ gst_video_multiview_meta_api_get_type (void)
return type;
}
static gboolean
gst_video_multiview_meta_init (GstVideoMultiviewMeta * mview_meta,
gpointer params, GstBuffer * buffer)
{
mview_meta->n_views = 0;
mview_meta->view_info = NULL;
return TRUE;
}
static void
gst_video_multiview_meta_free (GstVideoMultiviewMeta * mview_meta,
GstBuffer * buffer)
@ -436,7 +446,7 @@ gst_video_multiview_meta_get_info (void)
gst_meta_register (GST_VIDEO_MULTIVIEW_META_API_TYPE,
"GstVideoMultiviewMeta",
sizeof (GstVideoMultiviewMeta),
(GstMetaInitFunction) NULL,
(GstMetaInitFunction) gst_video_multiview_meta_init,
(GstMetaFreeFunction) gst_video_multiview_meta_free,
NULL);
g_once_init_leave (&video_meta_info, meta);

View file

@ -186,6 +186,19 @@ gst_video_overlay_get_seqnum (void)
return (guint) g_atomic_int_add (&seqnum, 1);
}
static gboolean
gst_video_overlay_composition_meta_init (GstMeta * meta, gpointer params,
GstBuffer * buf)
{
GstVideoOverlayCompositionMeta *ometa;
ometa = (GstVideoOverlayCompositionMeta *) meta;
ometa->overlay = NULL;
return TRUE;
}
static void
gst_video_overlay_composition_meta_free (GstMeta * meta, GstBuffer * buf)
{
@ -251,7 +264,8 @@ gst_video_overlay_composition_meta_get_info (void)
const GstMetaInfo *meta =
gst_meta_register (GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE,
"GstVideoOverlayCompositionMeta",
sizeof (GstVideoOverlayCompositionMeta), (GstMetaInitFunction) NULL,
sizeof (GstVideoOverlayCompositionMeta),
(GstMetaInitFunction) gst_video_overlay_composition_meta_init,
(GstMetaFreeFunction) gst_video_overlay_composition_meta_free,
(GstMetaTransformFunction)
gst_video_overlay_composition_meta_transform);