[FFmpeg-devel] [PATCH 0/9] improve rounding across FFmpeg

Ganesh Ajjanagadde gajjanagadde at gmail.com
Wed Dec 2 01:27:49 CET 2015


Currently, there are numerous instances where the appropriate libm rounding
functions lrint, llrint, rint, etc are not used and instead ad-hoc, slow, and sometimes
risky floor(x + 0.5) and the like are being used. The risk comes from the fact
that such a thing is broken for negative values and values close to the 0.5 fractional
part boundary. The ad-hoc nature comes from the fact that we anyway have compat
hacks in avutil/libm for broken platforms, and they are not being used. The
slowness comes from the generate code, e.g llrint compiles down to a single asm
instruction cvttsd2si, while floor(x + 0.5) needs to do multiple things.

Note that the audit may have missed some things; essentially this was found by
doing a grep for 'floor' across the codebase and checking.

Patches split per file.

Ganesh Ajjanagadde (9):
  avfilter/vsrc_mptestsrc: use lrint instead of floor hack
  avfilter/vf_perspective: use lrint instead of floor hack
  avfilter/af_stereotools: use lrint instead of floor hack
  avfilter/af_flanger: use rint instead of floor hack
  avcodec/cos_tablegen: use rint instead of floor hack
  avcodec/kbdwin: use lrint instead of floor hack
  avcodec/mdct_template: use lrint instead of floor hack
  avcodec/wavpackenc: use lrint instead of floor hack
  avcodec/sonic: use lrint instead of floor hack

 libavcodec/cos_tablegen.c    |  4 ++--
 libavcodec/kbdwin.c          |  3 ++-
 libavcodec/mdct_template.c   |  5 +++--
 libavcodec/sonic.c           |  2 +-
 libavcodec/wavpackenc.c      |  4 ++--
 libavfilter/af_flanger.c     |  2 +-
 libavfilter/af_stereotools.c |  8 ++++----
 libavfilter/vf_perspective.c | 10 +++++-----
 libavfilter/vsrc_mptestsrc.c |  2 +-
 9 files changed, 21 insertions(+), 19 deletions(-)

-- 
2.6.2



More information about the ffmpeg-devel mailing list