Commit Graph

53 Commits

Author SHA1 Message Date
Michael Niedermayer 75918016ab
Move bessel_i0() from swresample/resample to avutil/mathematics
0th order modified bessel function of the first kind are used in multiple
places, lets avoid having 3+ different implementations
I picked this one as its accurate and quite fast, it can be replaced if
a better one is found

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-05-29 00:45:28 +02:00
James Almer 4d885271bb avutil/mathematics: add missing constants
Including float variants for all of them.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-19 17:10:58 -03:00
Marvin Scholz 3fbf8d6e1d avutil: Fix mismatching argument names 2022-10-17 09:51:47 +02:00
Michael Niedermayer e154353fdb avutil/mathematics: Document av_rescale_rnd() behavior on non int64 results
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-10-21 14:13:03 +02:00
Timothy Gu a4d7a6d1dd mathematics: Extend and edit Doxygen 2016-08-02 21:53:34 -07:00
Timothy Gu 1fcf243216 mathematics: Make function prototypes identical to definitions
Doxygen gets confused by this.
2016-08-02 09:01:09 -07:00
Ganesh Ajjanagadde 20a30077c3 avutil/mathematics: correct documentation for av_gcd
av_gcd is now always defined regardless of input. This documents this
change in the "documented API". Two benefits (closely related):
1. The function is robust, and there is no need to worry about INT64_MIN, etc.

2. Clients of av_gcd, like av_reduce, can now be made fully correct. Currently,
av_reduce can trigger undefined behavior if e.g num is INT64_MIN due to
integer overflow in the FFABS. Furthermore, this undefined behavior is
completely undocumented, and could be a fuzzer's paradise. The FFABS was needed in the past as
av_gcd was undefined for negative inputs. In order to make av_reduce
robust, it is essential to guarantee that av_gcd works for all int64_t.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-30 13:42:04 -04:00
Lou Logan 88f2586adb fix various typos
Signed-off-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-03 10:58:19 -08:00
Matt Oliver 3e309c5d18 Fix compilation with msvc/icl due to missing header and define.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-03 19:48:41 +01:00
Michael Niedermayer b317f9459f avutil/mathematics: add av_add_stable()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-04 15:10:09 +01:00
Michael Niedermayer 9c5260e73a avutil/mathematics: fix 2 typos in the doxy
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-03 18:01:49 +01:00
Clément Bœsch f263426eed lavu/math: fix than/then typo, and add a comma. 2013-01-03 00:02:51 +01:00
Michael Niedermayer 740e740895 av_rescale: support passing MIN/MAX through
Reviewed-by: Clément Bœsch <ubitux@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-03 00:02:22 +01:00
Michael Niedermayer 2bcbdd8456 lavu: add more doxy to av_rescale_delta
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-27 02:58:09 +02:00
Michael Niedermayer 8766ad9eb1 lavu: add av_rescale_delta()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-27 00:26:35 +02:00
Michael Niedermayer 90d4b07063 mathemathics: update copyright years
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-27 00:26:35 +02:00
Michael Niedermayer 5eb353e0cd Merge remote-tracking branch 'qatar/master'
* qatar/master:
  opt/eval: Include mathematics.h for NAN/INFINITY
  mathematics: Don't use division by zero in NAN/INFINITY macros
  wma: Lower the maximum number of channels to 2
  x86: cpu: clean up check for cpuid instruction support
  ARM: generate position independent code to access data symbols

Conflicts:
	libavutil/opt.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-07-01 22:43:09 +02:00
Ronald S. Bultje a1245d5ca1 mathematics: Don't use division by zero in NAN/INFINITY macros
Some compilers, MSVC among them, don't recognize the divisions by
zero as meaning infinity/nan.

These macros should, according to the standard, expand to constant
expressions, but this shouldn't matter for our usage.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-07-01 19:06:13 +03:00
Carl Eugen Hoyos 15bde06084 Revert "mathematics.h: remove a couple of math defines"
This reverts commit a2b186a188.

The defines were present for several years, removing
them without a version bump may break API.
(Fixes MPlayer compilation.)
2012-06-22 16:10:42 +02:00
Michael Niedermayer 4da42ebe44 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  MS Screen 1 decoder
  aacdec: Fix popping channel layouts.
  av_gettime: support Win32 without gettimeofday()
  Use av_gettime() in various places
  Move av_gettime() to libavutil
  dct-test: use emms_c() from libavutil instead of duplicating it
  mov: fix operator precedence bug
  mathematics.h: remove a couple of math defines
  Remove unnecessary inclusions of [sys/]time.h
  lavf: remove unnecessary inclusions of unistd.h
  bfin: libswscale: add const where appropriate to fix warnings
  bfin: libswscale: remove unnecessary #includes
  udp: Properly check for invalid sockets
  tcp: Check the return value from getsockopt
  network: Use av_strerror for getting error messages
  udp: Properly print error from getnameinfo
  mmst: Use AVUNERROR() to convert error codes to the right range for strerror
  network: Pass pointers of the right type to get/setsockopt/ioctlsocket on windows
  rtmp: Reduce the number of idle posts sent by sleeping 50ms

Conflicts:
	Changelog
	configure
	libavcodec/aacdec.c
	libavcodec/allcodecs.c
	libavcodec/avcodec.h
	libavcodec/dct-test.c
	libavcodec/version.h
	libavformat/riff.c
	libavformat/udp.c
	libavutil/Makefile
	libswscale/bfin/yuv2rgb_bfin.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-06-20 20:47:46 +02:00
Janne Grunau a2b186a188 mathematics.h: remove a couple of math defines
While these defines are not defined by the C standard they are
standardized as X/Open System Interfaces Extension. We use the
appropiate _XOPEN_SOURCE define to make them available. They
seem to be available on all FATE configs since the constants
are used in files where mathematics.h is not included.
2012-06-20 15:45:21 +02:00
Michael Niedermayer eadd4264ee Merge remote-tracking branch 'qatar/master'
* qatar/master: (36 commits)
  adpcmenc: Use correct frame_size for Yamaha ADPCM.
  avcodec: add ff_samples_to_time_base() convenience function to internal.h
  adx parser: set duration
  mlp parser: set duration instead of frame_size
  gsm parser: set duration
  mpegaudio parser: set duration instead of frame_size
  (e)ac3 parser: set duration instead of frame_size
  flac parser: set duration instead of frame_size
  avcodec: add duration field to AVCodecParserContext
  avutil: add av_rescale_q_rnd() to allow different rounding
  pnmdec: remove useless .pix_fmts
  libmp3lame: support float and s32 sample formats
  libmp3lame: renaming, rearrangement, alignment, and comments
  libmp3lame: use the LAME default bit rate
  libmp3lame: use avpriv_mpegaudio_decode_header() for output frame parsing
  libmp3lame: cosmetics: remove some pointless comments
  libmp3lame: convert some debugging code to av_dlog()
  libmp3lame: remove outdated comment.
  libmp3lame: do not set coded_frame->key_frame.
  libmp3lame: improve error handling in MP3lame_encode_init()
  ...

Conflicts:
	doc/APIchanges
	libavcodec/libmp3lame.c
	libavcodec/pcxenc.c
	libavcodec/pnmdec.c
	libavcodec/pnmenc.c
	libavcodec/sgienc.c
	libavcodec/utils.c
	libavformat/hls.c
	libavutil/avutil.h
	libswscale/x86/swscale_mmx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-02-21 05:10:12 +01:00
Justin Ruggles 0b42a9388c avutil: add av_rescale_q_rnd() to allow different rounding 2012-02-20 15:08:40 -05:00
Michael Niedermayer 0b9a69f244 Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits)
  aacdec: Fix PS in ADTS.
  avconv: Consistently use PIX_FMT_NONE.
  dsputil: use cpuflags in x86 emu_edge_core
  dsputil: use movups instead of movdqu in ff_emu_edge_core_sse()
  wma: initialize prev_block_len_bits, next_block_len_bits, and block_len_bits.
  mov: Remove some redundant and obsolete comments.
  Add libavutil/mathematics.h #includes for INFINITY
  doxy: structure libavformat groups
  doxy: introduce an empty structure in libavcodec
  doxy: provide a start page and document libavutil
  doxy: cleanup pixfmt.h
  regtest: split video encode/decode tests into individual targets
  ARM: add explicit .arch and .fpu directives to asm.S
  pthread: do not touch has_b_frames
  avconv: cleanup the transcoding loop in output_packet().
  avconv: split subtitle transcoding out of output_packet().
  avconv: split video transcoding out of output_packet().
  avconv: split audio transcoding out of output_packet().
  avconv: reindent.
  avconv: move streamcopy-only code out of decoding loop.
  ...

Conflicts:
	avconv.c
	libavcodec/aaccoder.c
	libavcodec/pthread.c
	libavcodec/version.h
	libavutil/audioconvert.h
	libavutil/avutil.h
	libavutil/mem.h
	tests/ref/vsynth1/dv
	tests/ref/vsynth1/mpeg2thread
	tests/ref/vsynth2/dv
	tests/ref/vsynth2/mpeg2thread

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-11-23 04:02:17 +01:00
Luca Barbato 757cd8d876 doxy: provide a start page and document libavutil
Introduce a basic layout, the subpages are currently left empty.

Split libavutil in multiple groups as example of the structure
2011-11-22 17:16:02 +01:00
Mans Rullgard 2912e87a6c Replace FFmpeg with Libav in licence headers
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-03-19 13:33:20 +00:00
Stefano Sabatini 448524777a Add the M_PHI constant, contains an approximation of the golden ratio
irrational number.

Originally committed as revision 24439 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-22 22:05:21 +00:00
Måns Rullgård 49bd8e4b84 Fix grammar errors in documentation
Originally committed as revision 23904 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-30 15:38:06 +00:00
Stefano Sabatini 297084275c Fix av_compare_mod() doxy.
Originally committed as revision 23593 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-13 09:06:50 +00:00
Michael Niedermayer 65db0587a8 Add av_compare_mod()
Originally committed as revision 23551 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-09 17:27:42 +00:00
Alex Converse b9f60bd8fd Add M_SQRT2 to the constants in mathematics.h.
Originally committed as revision 22825 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-04-09 23:29:47 +00:00
Benoit Fouet 32e543f866 Replace @returns by @return.
Originally committed as revision 22729 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-30 15:50:57 +00:00
Måns Rullgård 2ed6f39944 Replace many includes of libavutil/common.h with what is actually needed
This reduces the number of false dependencies on header files and
speeds up compilation.

Originally committed as revision 22407 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-09 17:39:19 +00:00
Måns Rullgård 94a5218c10 More accurate value for log2(10)
Originally committed as revision 21946 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-02-21 20:47:10 +00:00
Måns Rullgård e4a35244fa Replace log2f(10) with a constant
Originally committed as revision 21924 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-02-20 20:13:48 +00:00
Michael Niedermayer 78b0182375 av_compare_ts()
Originally committed as revision 21671 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-02-07 16:26:50 +00:00
Michael Niedermayer bac24dd2a5 2nd try on documenting av_gcd().
Originally committed as revision 20939 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-12-27 14:40:49 +00:00
Michael Niedermayer 03703cb3d1 Document av_gcd().
Originally committed as revision 20935 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-12-27 12:20:06 +00:00
Måns Rullgård bd41c06f18 Define INFINITIY and NAN in mathematics.h if missing
Originally committed as revision 19611 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-08-10 01:27:27 +00:00
Diego Biurrun b69201a82c Add common.h #include, necessary for av_const.
Originally committed as revision 16844 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-01-28 08:50:10 +00:00
Diego Biurrun 89c9ff504b spelling/grammar/consistency review part I
Originally committed as revision 16840 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-01-28 00:16:05 +00:00
Aurelien Jacobs 9ce6c13879 export gcd function as av_gcd()
Originally committed as revision 16653 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-01-17 11:13:33 +00:00
Stefano Sabatini 987903826b Globally rename the header inclusion guard names.
Consistently apply this rule: the guard name is obtained from the
filename by stripping the leading "lib", converting '/' and '.'  to
'_' and uppercasing the resulting name. Guard names in the root
directory have to be prefixed by "FFMPEG_".

Originally committed as revision 15120 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-31 07:39:47 +00:00
Aurelien Jacobs 5af4f1f3e3 move M_PI definition along with other math definitions
Originally committed as revision 14727 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-13 16:01:21 +00:00
Aurelien Jacobs d1a12956a0 define some math constants so as not to depend on _XOPEN_SOURCE
Originally committed as revision 14725 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-13 10:04:59 +00:00
Zuxy Meng 85074d3c93 Reapply r12489: Add pure, const and malloc attributes to proper functions
in libavutil.
Fix a compilation failure in r12489.

Originally committed as revision 12498 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-03-19 06:17:43 +00:00
Benoit Fouet 2119bb8f51 revert r12489.
Originally committed as revision 12490 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-03-18 16:29:47 +00:00
Zuxy Meng 6544f48f03 Pure, const and malloc attributes to libavutil.
Patch by Zuxy Meng: zuxy meng gmail com
Original thread:
[FFmpeg-devel] [PATCH] Pure, const and malloc attributes to libavutil
Date: 03/18/2008 6:09 AM

Originally committed as revision 12489 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-03-18 15:27:15 +00:00
Diego Biurrun 6ef2912879 Add missing stdint.h #include to headers that use it.
Originally committed as revision 12429 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-03-13 00:20:15 +00:00
Diego Biurrun 5b21bdabe4 Add FFMPEG_ prefix to all multiple inclusion guards.
Originally committed as revision 10765 to svn://svn.ffmpeg.org/ffmpeg/trunk
2007-10-17 09:37:46 +00:00