glvideomixer: Implicit video scaling behaviour
Both GLVideoMixer and Compositor plugins scale picture size which is set by the user for each pad (GstCompositorPad for Compositor plugin).
I've noticed that the scaling behavior differs a lot dependent on the picture size. The code which handles scaling of width
and height
can be found here.
if (pad_height % dar_n == 0) {
pad_width = gst_util_uint64_scale_int (pad_height, dar_n, dar_d);
} else if (pad_width % dar_d == 0) {
pad_height = gst_util_uint64_scale_int (pad_width, dar_d, dar_n);
} else {
pad_width = gst_util_uint64_scale_int (pad_height, dar_n, dar_d);
}
Here are two examples to describe the issue. In both cases PAR is 16x11:
Example 1:
- Picture size is set to 880x704. Calculated DAR is 20x11
- According to the code above, first condition is
false
, second condition istrue
(880 / 11 = 80) - The resulting height is (880 * 11 / 20) = 484
- The resulting resolution is 880x484
Example 2:
- Picture size is set to 880x705 resolution. Calculated DAR is 256/141
- According to the code above, we go to the
else
case - The resulting width is (705 * 256 / 141) = 1280
- The resulting resolution is 1280x705
In the first example, video fits into the provided size, but in the second one it overflows. IMO, the resulting video size should not differ so much. Maybe there should be a property to choose the desired behavior. Maybe the video should always fit the provided size. At least I think it is more expected by the user.