You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: libobs: obs_encoder_add_roi accepts upside-down rectangles and a NaN priority #1959
obs_encoder_add_roi() (libobs/obs-encoder.c.h) is meant to refuse ROIs smaller than one 16×16 block and ROIs with a priority outside [-1, 1]. Two inputs get past both checks:
Upside-down rectangles. If bottom is above top, or right is left of left, the uint32_t subtractions in the size check wrap to huge values, so the 16×16 minimum passes. The encoder then gets a rectangle with bottom < top in its QP map.
NaN priority.NaN < -1.0f and NaN > 1.0f are both false, so a NaN priority is accepted.
obs_encoder_enum_roi() scales each ROI with (uint32_t)((float)roi->top * scale_y). That conversion is undefined behaviour in C when the product is out of the uint32_t range: an ROI far outside the frame, combined with an upscaled output.
The ROI API is reached only from plugins and scripts. Upstream has the same code. Found while scoping the ROI code for a Rust port.
Plan (one PR)
Move the checks and the scaling into libobs/obs-encoder-roi.c.h as hidden helpers. This step changes no behaviour.
Add characterization through the exported API (test_encoder_roi), using a test video encoder with and without OBS_ENCODER_CAP_ROI. It pins:
the 16×16 minimum at 15, 16 and 17 in each direction;
priorities at -1, 1, just outside the range, and NaN;
an upside-down rectangle;
the enumeration order (last added first), with and without a scaled size, and with a video size of 0;
roi_increment after adding and clearing.
RED, then GREEN:
refuse bottom <= top, right <= left and a NaN priority before the size check;
saturate the scaled conversion to the uint32_t range.
No ROI that is valid today changes.
The Rust port of these helpers is a separate, later PR.
Activity
rdoupe commentedon Oct 23, 2026
Claiming: #1959.
libobs: Refuse upside-down encoder ROIs and NaN priorities
libobs: Refuse upside-down encoder ROIs and NaN priorities (obs-rust#…