[FFmpeg-devel] [PATCH] Implement in lavc a flag which makes avcodec_open() to choose the best framerate
Sat Sep 20 23:16:11 CEST 2008
On Sat, Sep 20, 2008 at 06:38:22PM +0200, Stefano Sabatini wrote:
> On date Friday 2008-09-19 01:13:51 +0200, Michael Niedermayer encoded:
> > This implementation isnt exact, it in many corner cases will not
> > return the correct element.
> > Examples would be, when it is farther away than INT_MAX
> > another example may be a list of
> > 1/INT_MAX, 1/(INT_MAX-1), ...
> > compared to INT_MAX
> > your code would fail to be to seperate them
> As for the second problem, in that case the error will be the same for
> all that values, but it is still possible to understand which is
> nearest to the value if they are both greater or lesser than q.
> q= target value
> q1= nearest value already found
> q2= new value to check
> 1) q1 ... q2 ... q
> q > q1 && q2 > q1 => choose q2
> 2) q ... q2 ... q1
> q < q1 && q2 < q1 => choose q2
> Both conditions are catched by the expression
> cmp(q1, q) * cmp(q2, q1) == 1
> In the case:
> 3) q1 ... q ... q2
> 4) q2 ... q ... q1
> always q2 is choosen.
> For these last two cases I'm not sure if we can do something better.
iam not sure if its worth it but it surely can be done, one way is ...
n1/d1 ... N/D ... n2/d2
you have to decide on which side of (n1/d1 + n2/d2)/2, N/D is.
(n1/d1 + n2/d2)/2 = (n1d2 + n2d1)/(2d1d2) = A/B
A and B here are 64bit
To know which of the 2 points is closer we need to awnser A/B < N/D
which is the same as
(AD)/B < N
(AD)/B can be calculated with av_rescale2() and is exact for our purpose
when the correct rounding mode is used.
But as said, iam not sure if this is worth it, in practice the simple
variant is likely sufficient, it mostly depends on how ugly above would
look in C ...
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
More information about the ffmpeg-devel