Skip to content

Commit

Permalink
Merge branch 'feature/127' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Jan 15, 2024
2 parents 153bce7 + 440480f commit 95bcc82
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions FlashCap.Core/Devices/V4L2Devices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,19 @@ private static IEnumerable<FramesPerSecond> EnumerateFramesPerSecond(
}).
SelectMany(frmivalenum =>
{
// v4l2_fract is "interval", so makes fps to do reciprocal.
// (numerator <--> denominator)
static IEnumerable<FramesPerSecond> EnumerateStepWise(
v4l2_frmival_stepwise stepwise)
{
var min = new Fraction((int)stepwise.min.denominator, (int)stepwise.min.numerator);
var max = new Fraction((int)stepwise.max.denominator, (int)stepwise.max.numerator);
// v4l2_fract is "interval", so do reciprocal to make fps.
// (numerator <--> denominator)
// Since we're inverting the interval to get the FPS, we also need to swap the meaning of min/max
var min = new Fraction((int)stepwise.max.denominator, (int)stepwise.max.numerator);
var max = new Fraction((int)stepwise.min.denominator, (int)stepwise.min.numerator);
var step = new Fraction((int)stepwise.step.denominator, (int)stepwise.step.numerator);
return NativeMethods.DefactoStandardFramesPerSecond.
Where(fps =>
fps >= min && fps <= max &&
Expand All @@ -138,8 +143,13 @@ static IEnumerable<FramesPerSecond> EnumerateStepWise(
static IEnumerable<FramesPerSecond> EnumerateContinuous(
v4l2_frmival_stepwise stepwise)
{
var min = new Fraction((int)stepwise.min.denominator, (int)stepwise.min.numerator);
var max = new Fraction((int)stepwise.max.denominator, (int)stepwise.max.numerator);
// v4l2_fract is "interval", so do reciprocal to make fps.
// (numerator <--> denominator)
// Since we're inverting the interval to get the FPS, we also need to swap the meaning of min/max
var min = new Fraction((int)stepwise.max.denominator, (int)stepwise.max.numerator);
var max = new Fraction((int)stepwise.min.denominator, (int)stepwise.min.numerator);
return NativeMethods.DefactoStandardFramesPerSecond.
Where(fps => fps >= min && fps <= max).
OrderByDescending(fps => fps).
Expand Down

0 comments on commit 95bcc82

Please sign in to comment.