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.
This commit is contained in:
Michael Olbrich 2024-11-26 10:28:46 +01:00 committed by Wim Taymans
parent 669f53946e
commit e76e057038

View file

@ -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);