I'm pretty sure you shouldn't use approximate numbers (floats or doubles) for this.

There's a bunch of AVRational related and exact-precision arithmetic functions in libavutil for this purpose. see libavutil/mathematics.h libavutil/rational.h.

On 29/06/12 21:51, Hector Alonso wrote:
Hi,
I've made myself one LibAvUtils class with this two functions
implemented like this:


int64_t  LibAvUtils::frameNumberToPts(uint  uiFrameNum,  float  fFps)

{

     if  (fFps  <=  0)  return  0;

     return  (int64_t)uiFrameNum  *  (int64_t)(((float)AV_TIME_BASE)  /  fFps);

}

//-----------------------------------------------------------------------------

uint  LibAvUtils::ptsToFrameNumber(int64_t  iPts,  float  fFps)

{

     if  (fFps  <=  0)  return  0;

     return  (uint)(iPts  /  (((float)AV_TIME_BASE)  /  fFps));

}
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to