gstreamer: Fix width and height range handling
This changes is fixing critical error message "gst_value_set_int_range_step: assertion 'start < end' failed" observed when building GStreamer caps from a stream configuration whose size range holds a single size. GStreamer range step definition requires distinct min and max values definitions, otherwise above error message is output. libcamera SizeRange instance may return a single size leading to identical min and max values. Add a conditional check where the min and max of the range are distinct during iterating the supported sizes for each pixelformat. To prevent appending structures that are already expressed with this update, gst_caps_merge_structure() is used in place of gst_caps_append_structure(). Signed-off-by: Hou Qi <qi.hou@nxp.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
9c40320763
commit
c9152bad5c
1 changed files with 13 additions and 5 deletions
|
@ -359,13 +359,21 @@ gst_libcamera_stream_formats_to_caps(const StreamFormats &formats)
|
|||
GValue val = G_VALUE_INIT;
|
||||
|
||||
g_value_init(&val, GST_TYPE_INT_RANGE);
|
||||
gst_value_set_int_range_step(&val, range.min.width, range.max.width, range.hStep);
|
||||
gst_structure_set_value(s, "width", &val);
|
||||
gst_value_set_int_range_step(&val, range.min.height, range.max.height, range.vStep);
|
||||
gst_structure_set_value(s, "height", &val);
|
||||
if (range.min.width == range.max.width) {
|
||||
gst_structure_set(s, "width", G_TYPE_INT, range.min.width, nullptr);
|
||||
} else {
|
||||
gst_value_set_int_range_step(&val, range.min.width, range.max.width, range.hStep);
|
||||
gst_structure_set_value(s, "width", &val);
|
||||
}
|
||||
if (range.min.height == range.max.height) {
|
||||
gst_structure_set(s, "height", G_TYPE_INT, range.min.height, nullptr);
|
||||
} else {
|
||||
gst_value_set_int_range_step(&val, range.min.height, range.max.height, range.vStep);
|
||||
gst_structure_set_value(s, "height", &val);
|
||||
}
|
||||
g_value_unset(&val);
|
||||
|
||||
gst_caps_append_structure(caps, s);
|
||||
caps = gst_caps_merge_structure(caps, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue