video-frame: handle map errors
Error out when something failed
This commit is contained in:
parent
59e99e827e
commit
1ed29bdb90
@ -77,8 +77,9 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
|
|||||||
frame->flags = meta->flags;
|
frame->flags = meta->flags;
|
||||||
|
|
||||||
for (i = 0; i < info->finfo->n_planes; i++)
|
for (i = 0; i < info->finfo->n_planes; i++)
|
||||||
gst_video_meta_map (meta, i, &frame->map[i], &frame->data[i],
|
if (!gst_video_meta_map (meta, i, &frame->map[i], &frame->data[i],
|
||||||
&frame->info.stride[i], flags);
|
&frame->info.stride[i], flags))
|
||||||
|
goto frame_map_failed;
|
||||||
} else {
|
} else {
|
||||||
/* no metadata, we really need to have the metadata when the id is
|
/* no metadata, we really need to have the metadata when the id is
|
||||||
* specified. */
|
* specified. */
|
||||||
@ -97,7 +98,8 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
|
|||||||
frame->flags |= GST_VIDEO_FRAME_FLAG_ONEFIELD;
|
frame->flags |= GST_VIDEO_FRAME_FLAG_ONEFIELD;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_map (buffer, &frame->map[0], flags);
|
if (!gst_buffer_map (buffer, &frame->map[0], flags))
|
||||||
|
goto map_failed;
|
||||||
|
|
||||||
/* do some sanity checks */
|
/* do some sanity checks */
|
||||||
if (frame->map[0].size < info->size)
|
if (frame->map[0].size < info->size)
|
||||||
@ -119,6 +121,20 @@ no_metadata:
|
|||||||
GST_ERROR ("no GstVideoMeta for id %d", id);
|
GST_ERROR ("no GstVideoMeta for id %d", id);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
frame_map_failed:
|
||||||
|
{
|
||||||
|
GST_ERROR ("failed to map video frame plane %d", i);
|
||||||
|
do {
|
||||||
|
i--;
|
||||||
|
gst_video_meta_unmap (meta, i, &frame->map[i]);
|
||||||
|
} while (i > 0);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
map_failed:
|
||||||
|
{
|
||||||
|
GST_ERROR ("failed to map buffer");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
invalid_size:
|
invalid_size:
|
||||||
{
|
{
|
||||||
GST_ERROR ("invalid buffer size %" G_GSIZE_FORMAT " < %" G_GSIZE_FORMAT,
|
GST_ERROR ("invalid buffer size %" G_GSIZE_FORMAT " < %" G_GSIZE_FORMAT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user