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 os2threads: Add pthread_once() 2015-11-12 22:31:46 +01:00
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 Merge commit 'e2854e731f843906d9a9a5b882bed872341999fd' 2015-11-10 18:07:41 +01:00
libavutil lavu/libm: add erf hack and make dynaudnorm available everywhere 2015-12-21 09:03:11 -08:00
libpostproc Merge commit 'e88103a7f92cf27a2868b50acc8a9912f6088249' 2015-09-05 21:35:46 +02:00
libswresample swresample: use AV_OPT_TYPE_BOOL for linear_interp and cheby options 2015-12-04 15:43:33 +01:00
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 patcheck: Fix false detection of 'mergeable calls' when line is removed 2015-11-23 00:34:14 +01:00
.gitattributes
.gitignore gitignore: ignore object file temporaries 2015-10-10 20:30:41 +02:00
.travis.yml Merge commit 'eda183287489b2c705843aa373a19c4e46fb2fec' 2015-11-22 17:12:24 +00:00
COPYING.GPLv2
COPYING.GPLv3
COPYING.LGPLv2.1
COPYING.LGPLv3
CREDITS
Changelog movenc: support cenc (common encryption) 2015-12-15 14:16:28 +01:00
INSTALL.md
LICENSE.md avfilter: add rubberband wrapper 2015-09-20 19:54:57 +02:00
MAINTAINERS lavfi: remove astreamsync. 2015-11-07 16:43:36 +01:00
Makefile mips: rename mipsdspr1 to mipsdsp 2015-12-04 02:35:42 +01:00
README.md README: replace http with https 2015-10-06 13:27:29 +02:00
RELEASE RELEASE: update to 2.8.git 2015-09-09 23:53:15 -03:00
arch.mak mips: rename mipsdspr1 to mipsdsp 2015-12-04 02:35:42 +01:00
cmdutils.c cosmetics: Fix weird indentations 2015-12-07 10:43:43 -08:00
cmdutils.h cmdutils: remove sws_opts usage, simplify code 2015-08-08 16:51:25 +02:00
cmdutils_common_opts.h
cmdutils_opencl.c all: use FFDIFFSIGN to resolve possible undefined behavior in comparators 2015-11-03 16:28:30 -05:00
common.mak Merge commit '9f57f134c19773d54269b6cb9ee455ff87c2e9e1' 2015-12-05 12:21:33 +01:00
configure lavu/libm: add erf hack and make dynaudnorm available everywhere 2015-12-21 09:03:11 -08:00
ffmpeg.c Merge commit 'e63e3797a1ed9346f529848e6ba3d27fd2d2cc8d' 2015-12-17 13:20:37 +01:00
ffmpeg.h ffmpeg: Add basic support to mux multiple programs 2015-12-11 22:27:25 +01:00
ffmpeg_dxva2.c ffmpeg_dxva2: support vp9 hwaccel 2015-12-07 09:47:51 +01:00
ffmpeg_filter.c ffmpeg_filter: remove redundant null ptr check 2015-11-11 01:51:52 +01:00
ffmpeg_opt.c ffmpeg: Allow specifying the program number for created programs 2015-12-16 14:03:57 +01:00
ffmpeg_qsv.c Merge commit 'fb472e1a11a4e0caed2c3c91da01ea8e35d9e3f8' 2015-10-22 16:18:02 +02:00
ffmpeg_vdpau.c ffmpeg_vdpau: Ignore decoder's max supported level 2015-08-16 15:02:33 -07:00
ffmpeg_videotoolbox.c ffmpeg/videotoolbox: protect UTGetOSTypeFromString on both VDA and VT 2015-10-15 10:22:31 +02:00
ffplay.c ffplay: remove existing AVPicture usage 2015-12-19 14:09:26 +01:00
ffprobe.c ffprobe: use print_val to print the frame pkt_size value 2015-12-16 18:59:23 +01:00
ffserver.c ffserver: refactor build_feed_streams() 2015-12-19 01:52:20 -08:00
ffserver_config.c ffserver_config: check for INT_MIN before doing FFABS 2015-10-13 19:40:09 -04:00
ffserver_config.h
library.mak
version.sh version.sh: add note that ffversion.h is auto-generated 2015-10-25 10:14:44 -04:00

README.md

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.