video-frame: Mapping a frame with inconsistent values between GstVideoMeta and GstVideoInfo is a bug

It will cause the frame to be initialized with inconsistent values that then
later can cause crashes or any other kind of interesting and hard to debug
bugs.
This commit is contained in:
Sebastian Dröge 2014-11-28 10:27:28 +01:00
parent 1ec4d764fc
commit afcc0b3c50

View file

@ -72,13 +72,19 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
frame->info = *info;
if (meta) {
/* All these values must be consistent */
g_return_val_if_fail (info->finfo->format == meta->format, FALSE);
g_return_val_if_fail (info->width == meta->width, FALSE);
g_return_val_if_fail (info->height == meta->height, FALSE);
g_return_val_if_fail (info->finfo->n_planes == meta->n_planes, FALSE);
frame->info.finfo = gst_video_format_get_info (meta->format);
frame->info.width = meta->width;
frame->info.height = meta->height;
frame->id = meta->id;
frame->flags = meta->flags;
for (i = 0; i < info->finfo->n_planes; i++) {
for (i = 0; i < meta->n_planes; i++) {
frame->info.offset[i] = meta->offset[i];
if (!gst_video_meta_map (meta, i, &frame->map[i], &frame->data[i],
&frame->info.stride[i], flags))