mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
v4l2object: use S_SELECTION instead of S_CROP in gst_v4l2_object_set_crop
The S_CROP call doesn't work on mem2mem output queues. Use the S_SELECTION call to set the crop rectangle and only fall back to S_CROP for ancient kernels. This will allow v4l2videoenc to set the coded size on the output queue via S_FMT and then set the visible size via the crop rectangle, as required by the V4L2 codec API. https://bugzilla.gnome.org/show_bug.cgi?id=796672
This commit is contained in:
parent
58e9341384
commit
32fa1e7a65
1 changed files with 28 additions and 11 deletions
|
@ -3949,13 +3949,19 @@ unsupported_format:
|
|||
gboolean
|
||||
gst_v4l2_object_set_crop (GstV4l2Object * obj)
|
||||
{
|
||||
struct v4l2_selection sel = { 0 };
|
||||
struct v4l2_crop crop = { 0 };
|
||||
|
||||
sel.type = obj->type;
|
||||
sel.target = V4L2_SEL_TGT_CROP;
|
||||
sel.flags = 0;
|
||||
sel.r.left = obj->align.padding_left;
|
||||
sel.r.top = obj->align.padding_top;
|
||||
sel.r.width = obj->info.width;
|
||||
sel.r.height = obj->info.height;
|
||||
|
||||
crop.type = obj->type;
|
||||
crop.c.left = obj->align.padding_left;
|
||||
crop.c.top = obj->align.padding_top;
|
||||
crop.c.width = obj->info.width;
|
||||
crop.c.height = obj->info.height;
|
||||
crop.c = sel.r;
|
||||
|
||||
if (obj->align.padding_left + obj->align.padding_top +
|
||||
obj->align.padding_right + obj->align.padding_bottom == 0) {
|
||||
|
@ -3967,6 +3973,13 @@ gst_v4l2_object_set_crop (GstV4l2Object * obj)
|
|||
"Desired cropping left %u, top %u, size %ux%u", crop.c.left, crop.c.top,
|
||||
crop.c.width, crop.c.height);
|
||||
|
||||
if (obj->ioctl (obj->video_fd, VIDIOC_S_SELECTION, &sel) < 0) {
|
||||
if (errno != ENOTTY) {
|
||||
GST_WARNING_OBJECT (obj->dbg_obj,
|
||||
"Failed to set crop rectangle with VIDIOC_S_SELECTION: %s",
|
||||
g_strerror (errno));
|
||||
return FALSE;
|
||||
} else {
|
||||
if (obj->ioctl (obj->video_fd, VIDIOC_S_CROP, &crop) < 0) {
|
||||
GST_WARNING_OBJECT (obj->dbg_obj, "VIDIOC_S_CROP failed");
|
||||
return FALSE;
|
||||
|
@ -3977,6 +3990,10 @@ gst_v4l2_object_set_crop (GstV4l2Object * obj)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
sel.r = crop.c;
|
||||
}
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (obj->dbg_obj,
|
||||
"Got cropping left %u, top %u, size %ux%u", crop.c.left, crop.c.top,
|
||||
crop.c.width, crop.c.height);
|
||||
|
|
Loading…
Reference in a new issue