From e76e057038311acc9a0e320c82710eb5cf3094ad Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Tue, 26 Nov 2024 10:28:46 +0100 Subject: [PATCH] v4l2: ensure that the default frame rate is within the min/max bounds Without this for continuous frame intervals, the default is set to 25 fps even if that is outside the min/max bounds (e.g. defined by the peer). Clip the default with the min/max bound to avoid this. --- spa/plugins/v4l2/v4l2-utils.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index f76eed88f..31a71c5d6 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -853,8 +853,19 @@ do_frminterval_filter: n_fractions++; } else if (port->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS || port->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) { - if (n_fractions == 0) - spa_pod_builder_fraction(&b.b, 25, 1); + if (n_fractions == 0) { + struct spa_fraction f = { 25, 1 }; + if (compare_fraction(&port->frmival.stepwise.max, &f) > 0) { + f.denom = port->frmival.stepwise.max.numerator; + f.num = port->frmival.stepwise.max.denominator; + } + if (compare_fraction(&port->frmival.stepwise.min, &f) < 0) { + f.denom = port->frmival.stepwise.min.numerator; + f.num = port->frmival.stepwise.min.denominator; + } + + spa_pod_builder_fraction(&b.b, f.num, f.denom); + } spa_pod_builder_fraction(&b.b, port->frmival.stepwise.max.denominator, port->frmival.stepwise.max.numerator);