mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 21:18:52 +00:00
v4l2: fix copying of encoded buffers
The existence of a GstVideoFormatInfo does not guarantee, that the buffer contains video frames, so the format must be checked. Also, for encoded buffers the length is variable and must be set. https://bugzilla.gnome.org/show_bug.cgi?id=698949
This commit is contained in:
parent
3466796f10
commit
fd0123800c
1 changed files with 5 additions and 1 deletions
|
@ -2528,7 +2528,10 @@ gboolean
|
||||||
gst_v4l2_object_copy (GstV4l2Object * v4l2object, GstBuffer * dest,
|
gst_v4l2_object_copy (GstV4l2Object * v4l2object, GstBuffer * dest,
|
||||||
GstBuffer * src)
|
GstBuffer * src)
|
||||||
{
|
{
|
||||||
if (v4l2object->info.finfo) {
|
const GstVideoFormatInfo *finfo = v4l2object->info.finfo;
|
||||||
|
|
||||||
|
if (finfo && (finfo->format != GST_VIDEO_FORMAT_UNKNOWN ||
|
||||||
|
finfo->format != GST_VIDEO_FORMAT_ENCODED)) {
|
||||||
GstVideoFrame src_frame, dest_frame;
|
GstVideoFrame src_frame, dest_frame;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (v4l2object->element, "copy video frame");
|
GST_DEBUG_OBJECT (v4l2object->element, "copy video frame");
|
||||||
|
@ -2554,6 +2557,7 @@ gst_v4l2_object_copy (GstV4l2Object * v4l2object, GstBuffer * dest,
|
||||||
gst_buffer_map (src, &map, GST_MAP_READ);
|
gst_buffer_map (src, &map, GST_MAP_READ);
|
||||||
gst_buffer_fill (dest, 0, map.data, map.size);
|
gst_buffer_fill (dest, 0, map.data, map.size);
|
||||||
gst_buffer_unmap (src, &map);
|
gst_buffer_unmap (src, &map);
|
||||||
|
gst_buffer_resize (dest, 0, map.size);
|
||||||
}
|
}
|
||||||
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, v4l2object->element,
|
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, v4l2object->element,
|
||||||
"slow copy into buffer %p", dest);
|
"slow copy into buffer %p", dest);
|
||||||
|
|
Loading…
Reference in a new issue