FFmpeg git repo
Go to file
Ganesh Ajjanagadde dd68cde28a lavu/libm: add erf hack and make dynaudnorm available everywhere
Source code is from Boost:
http://www.boost.org/doc/libs/1_46_1/boost/math/special_functions/erf.hpp
with appropriate modifications for FFmpeg.

Tested on interval -6 to 6 (beyond which it saturates), +/-NAN, +/-INFINITY
under -fsanitize=undefined on clang to test for possible undefined behavior.

This function turns out to actually be essentially as accurate and faster than the
libm (GNU/BSD's/Mac OS X), and I can think of 3 reasons why upstream
does not use this:
1. They are not aware of it.
2. They are concerned about licensing - this applies especially to GNU
libm.
3. They do not know and/or appreciate the benefits of rational
approximations over polynomial approximations. Boost uses them to great
effect, see e.g swr/resample for bessel derived from them, which is also
similarly superior to libm variants.

First, performance.
sample benchmark (clang -O3, Haswell, GNU/Linux):

3e8 values evenly spaced from 0 to 6
time (libm):
./test  13.39s user 0.00s system 100% cpu 13.376 total
time (boost based):
./test  9.20s user 0.00s system 100% cpu 9.190 total

Second, accuracy.
1e8 eval pts from 0 to 6
maxdiff (absolute): 2.2204460492503131e-16
occuring at point where libm erf is correctly rounded, this is not.

Illustration of superior rounding of this function:
arg   : 0.83999999999999997
erf   : 0.76514271145499457
boost : 0.76514271145499446
real  : 0.76514271145499446

i.e libm is actually incorrectly rounded. Note that this is clear from:
https://github.com/JuliaLang/openlibm/blob/master/src/s_erf.c (the Sun
implementation used by both BSD and GNU libm's), where only 1 ulp is
guaranteed.

Reasons it is not easy/worthwhile to create a "correctly rounded"
variant of this function (i.e 0.5ulp):
1. Upstream libm's don't do it anyway, so we can't guarantee this unless
we force this implementation on all platforms. This is not easy, as the
linker would complain unless measures are taken.
2. Nothing in FFmpeg cares or can care about such things, due to the
above and FFmpeg's nature.
3. Creating a correctly rounded function will in practice need some use of long
double/fma. long double, although C89/C90, unfortunately has problems on
ppc. This needs fixing of toolchain flags/configure. In any case this
will be slower for miniscule gain.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 09:03:11 -08:00
compat
doc avfilter/avf_showfreqs: make it possible to split channels 2015-12-20 19:52:51 +01:00
libavcodec lavc/libvpxenc: replace round by lrint 2015-12-21 08:20:26 -08:00
libavdevice lavd/pulse_audio_enc: replace lround by lrint 2015-12-21 08:25:30 -08:00
libavfilter lavfi/vf_histogram: replace round by lrint 2015-12-21 08:23:21 -08:00
libavformat lavf/avformat: add av_warn_unused_result to avformat_write_header 2015-12-21 08:39:57 -08:00
libavresample
libavutil lavu/libm: add erf hack and make dynaudnorm available everywhere 2015-12-21 09:03:11 -08:00
libpostproc
libswresample
libswscale swscale/arm/yuv2rgb: add ff_yuv420p_to_{argb,rgba,abgr,bgra}_neon_{16,32} 2015-12-19 22:09:28 +01:00
presets
tests lavc: add text encoder 2015-12-21 11:14:02 +01:00
tools
.gitattributes
.gitignore
.travis.yml
arch.mak
Changelog
cmdutils_common_opts.h
cmdutils_opencl.c
cmdutils.c
cmdutils.h
common.mak
configure lavu/libm: add erf hack and make dynaudnorm available everywhere 2015-12-21 09:03:11 -08:00
COPYING.GPLv2
COPYING.GPLv3
COPYING.LGPLv2.1
COPYING.LGPLv3
CREDITS
ffmpeg_dxva2.c
ffmpeg_filter.c
ffmpeg_opt.c
ffmpeg_qsv.c
ffmpeg_vdpau.c
ffmpeg_videotoolbox.c
ffmpeg.c Merge commit 'e63e3797a1ed9346f529848e6ba3d27fd2d2cc8d' 2015-12-17 13:20:37 +01:00
ffmpeg.h
ffplay.c ffplay: remove existing AVPicture usage 2015-12-19 14:09:26 +01:00
ffprobe.c
ffserver_config.c
ffserver_config.h
ffserver.c ffserver: refactor build_feed_streams() 2015-12-19 01:52:20 -08:00
INSTALL.md
library.mak
LICENSE.md
MAINTAINERS
Makefile
README.md
RELEASE
version.sh

FFmpeg README

FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata.

Libraries

  • libavcodec provides implementation of a wider range of codecs.
  • libavformat implements streaming protocols, container formats and basic I/O access.
  • libavutil includes hashers, decompressors and miscellaneous utility functions.
  • libavfilter provides a mean to alter decoded Audio and Video through chain of filters.
  • libavdevice provides an abstraction to access capture and playback devices.
  • libswresample implements audio mixing and resampling routines.
  • libswscale implements color conversion and scaling routines.

Tools

  • ffmpeg is a command line toolbox to manipulate, convert and stream multimedia content.
  • ffplay is a minimalistic multimedia player.
  • ffprobe is a simple analysis tool to inspect multimedia content.
  • ffserver is a multimedia streaming server for live broadcasts.
  • Additional small tools such as aviocat, ismindex and qt-faststart.

Documentation

The offline documentation is available in the doc/ directory.

The online documentation is available in the main website and in the wiki.

Examples

Coding examples are available in the doc/examples directory.

License

FFmpeg codebase is mainly LGPL-licensed with optional components licensed under GPL. Please refer to the LICENSE file for detailed information.

Contributing

Patches should be submitted to the ffmpeg-devel mailing list using git format-patch or git send-email. Github pull requests should be avoided because they are not part of our review process. Few developers follow pull requests so they will likely be ignored.