Fix calculation of best camera framerate
When the algorithm iterates over all the available v4l2 capabilities it tries to determine the best framerate for each one of YUYV (video/x-raw) modes presented by the hardware (best_fraction, line 357 in device.vala). Regardless of what's determined to be the "best" YUYV mode from within the conditional right after (line 385) the best fractional framerate will always point to the last iterated framerate, which might be an extremely low one, like 7 or 5 FPS. When the framerate is then stored in the Gst.Structure (line 394) the fractional framerate will always be that last value which might be different than the correct one as calculated by best_fps (line 386). This workaround solves this issue by only updating best_fraction when the conditional in line 385 is satisfied. from issue #1195
This commit is contained in:
parent
99c076254a
commit
186361fd8a
|
@ -354,6 +354,7 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
|
||||||
int best_height = 0;
|
int best_height = 0;
|
||||||
for (int i = 0; i < device.caps.get_size(); i++) {
|
for (int i = 0; i < device.caps.get_size(); i++) {
|
||||||
unowned Gst.Structure? that = device.caps.get_structure(i);
|
unowned Gst.Structure? that = device.caps.get_structure(i);
|
||||||
|
Value? best_fraction_now = null;
|
||||||
if (!that.has_name("video/x-raw")) continue;
|
if (!that.has_name("video/x-raw")) continue;
|
||||||
int num = 0, den = 0, width = 0, height = 0;
|
int num = 0, den = 0, width = 0, height = 0;
|
||||||
if (!that.has_field("framerate")) continue;
|
if (!that.has_field("framerate")) continue;
|
||||||
|
@ -369,7 +370,7 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
|
||||||
int fps = den > 0 ? (num/den) : 0;
|
int fps = den > 0 ? (num/den) : 0;
|
||||||
int in_fps = in_den > 0 ? (in_num/in_den) : 0;
|
int in_fps = in_den > 0 ? (in_num/in_den) : 0;
|
||||||
if (in_fps > fps) {
|
if (in_fps > fps) {
|
||||||
best_fraction = fraction;
|
best_fraction_now = fraction;
|
||||||
num = in_num;
|
num = in_num;
|
||||||
den = in_den;
|
den = in_den;
|
||||||
}
|
}
|
||||||
|
@ -386,6 +387,7 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
|
||||||
best_width = width;
|
best_width = width;
|
||||||
best_height = height;
|
best_height = height;
|
||||||
best_index = i;
|
best_index = i;
|
||||||
|
best_fraction = best_fraction_now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Gst.Caps res = caps_copy_nth(device.caps, best_index);
|
Gst.Caps res = caps_copy_nth(device.caps, best_index);
|
||||||
|
|
Loading…
Reference in a new issue