[FFmpeg-devel] [PATCH] Implement in lavc a flag which makes avcodec_open() to choose the best framerate

Stefano Sabatini stefano.sabatini-lala
Wed Sep 24 21:55:14 CEST 2008


On date Tuesday 2008-09-23 04:24:46 +0200, Michael Niedermayer encoded:
> On Mon, Sep 22, 2008 at 11:36:54PM +0200, Stefano Sabatini wrote:

> > Index: libavutil/rational.h
> > ===================================================================
> > --- libavutil/rational.h	(revision 15372)
> > +++ libavutil/rational.h	(working copy)
> > @@ -113,4 +113,17 @@
> >   */
> >  AVRational av_d2q(double d, int max) av_const;
> >  
> > +/**
> > + * @return 1 if \q1 is nearer to \p than \p q2, 0 if \p q1 and \p q2
> > + * have the same distance, -1 otherwise.
> > + */
> > +int av_near_cmp_q(AVRational q, AVRational q1, AVRational q2);
> 
> av_nearer_q()

Fixed.

[...]
> > +int av_near_cmp_q(AVRational q, AVRational q1, AVRational q2)
> > +{
> > +    /* N/D is q, A/B is the median between q1 and q2, A/B > N/D <=> A*D/B > N */
> > +    int64_t x = av_rescale_rnd(q1.num * (int64_t)q2.den + q2.num * (int64_t)q1.den, q.den, 2 * (int64_t)q1.den * q2.den, AV_ROUND_UP);
> > +
> > +    return (x > q.num ? 1 : x < q.num ? -1 : 0) * av_cmp_q(q2, q1);
> 
> I think only one of the 2 checks is correct for AV_ROUND_UP, the other would
> be correct for AV_ROUND_DOWN.
> 
> example:
> q=1/1
> q1= 0/1
> q2= 1/2
> 
> x= 1
> x == q.num

Yes, now it's obvious to me, now code and comments should be idiot
proof...

If it's fine to commit I'll strip the test and update minor version.

Thanks and regards.
-- 
FFmpeg = Fantastic and Friendly Multimedia Picky Enigmatic Game
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implement-nearest-q-06.patch
Type: text/x-diff
Size: 3234 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080924/4ca58b9c/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implement-force-fps-01.patch
Type: text/x-diff
Size: 2203 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080924/4ca58b9c/attachment-0001.patch>



More information about the ffmpeg-devel mailing list