Ganesh Ajjanagadde
971d12b7f9
avutil/mathematics: speed up av_gcd by using Stein's binary GCD algorithm
...
This uses Stein's binary GCD algorithm:
https://en.wikipedia.org/wiki/Binary_GCD_algorithm
to get a roughly 4x speedup over Euclidean GCD on standard architectures
with a compiler intrinsic for ctzll, and a roughly 2x speedup otherwise.
At the moment, the compiler intrinsic is used on GCC and Clang due to
its easy availability.
Quick note regarding overflow: yes, subtractions on int64_t can, but the
llabs takes care of that. The llabs is also guaranteed to be safe, with
no annoying INT64_MIN business since INT64_MIN being a power of 2, is
shifted down before being sent to llabs.
The binary GCD needs ff_ctzll, an extension of ff_ctz for long long (int64_t). On
GCC, this is provided by a built-in. On Microsoft, there is a
BitScanForward64 analog of BitScanForward that should work; but I can't confirm.
Apparently it is not available on 32 bit builds; so this may or may not
work correctly. On Intel, per the documentation there is only an
intrinsic for _bit_scan_forward and people have posted on forums
regarding _bit_scan_forward64, but often their documentation is
woeful. Again, I don't have it, so I can't test.
As such, to be safe, for now only the GCC/Clang intrinsic is added, the rest
use a compiled version based on the De-Bruijn method of Leiserson et al:
http://supertech.csail.mit.edu/papers/debruijn.pdf .
Tested with FATE, sample benchmark (x86-64, GCC 5.2.0, Haswell)
with a START_TIMER and STOP_TIMER in libavutil/rationsl.c, followed by a
make fate.
aac-am00_88.err:
builtin:
714 decicycles in av_gcd, 4095 runs, 1 skips
de-bruijn:
1440 decicycles in av_gcd, 4096 runs, 0 skips
previous:
2889 decicycles in av_gcd, 4096 runs, 0 skips
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
9 years ago
Vittorio Giovara
cdfe45ad37
lavu: Drop deprecated av_reverse function
...
Deprecated in 10/2012.
9 years ago
Michael Niedermayer
666e29fe9e
avutil/mathematics/av_add_stable: Avoid av_cmp_q() call
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Michael Niedermayer
e9add0d85b
av_add_stable: Add fast special case where step can be represented exactly
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Michael Niedermayer
4956d0e5a6
avutil/mathematics/av_add_stable: check for the common case of inc=1
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Michael Niedermayer
5b7519fbaa
avutil/mathematics/av_add_stable: avoid unneeded variable
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Luca Barbato
de69aedf99
mathematics: K&R formatting cosmetics
11 years ago
Michael Niedermayer
b317f9459f
avutil/mathematics: add av_add_stable()
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
11 years ago
Anton Khirnov
94a417acc0
mathematics: remove asserts from av_rescale_rnd()
...
It is a public function, it must not assert on its parameters.
11 years ago
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>
12 years ago
Michael Niedermayer
8766ad9eb1
lavu: add av_rescale_delta()
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Michael Niedermayer
90d4b07063
mathemathics: update copyright years
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 years ago
Diego Biurrun
d5c62122a7
Move av_reverse table to libavcodec
...
It is only used in that library.
12 years ago
Diego Biurrun
930c9d4373
avutil: Duplicate ff_log2_tab instead of sharing it across libs
...
The table is so small that the space gain is not worth the
performance overhead of cross-library access.
12 years ago
Diego Biurrun
9734b8ba56
Move avutil tables only used in libavcodec to libavcodec.
12 years ago
Michael Niedermayer
2f23a8ab17
libavutil/mathematics: use av_assert()
...
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
13 years ago
Justin Ruggles
0b42a9388c
avutil: add av_rescale_q_rnd() to allow different rounding
13 years ago
Diego Biurrun
bb00b15f9e
avutil: Remove unused arbitrary precision integer code.
14 years ago
Michael Niedermayer
a18eff49c0
av_compare_ts: Improve speed when calculations fit in 64bit.
...
about 110 cpu cycles before 60 cpu cycles afterwards.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
14 years ago
Mans Rullgard
2912e87a6c
Replace FFmpeg with Libav in licence headers
...
Signed-off-by: Mans Rullgard <mans@mansr.com>
14 years ago
Eli Friedman
b7cdddcd1f
Silence "comparison of unsigned expression >= 0 is always true" warning.
...
Patch by Eli Friedman, eli d friedman a gmail
Originally committed as revision 24022 to svn://svn.ffmpeg.org/ffmpeg/trunk
15 years ago
Michael Niedermayer
65db0587a8
Add av_compare_mod()
...
Originally committed as revision 23551 to svn://svn.ffmpeg.org/ffmpeg/trunk
15 years ago
Diego Biurrun
ba87f0801d
Remove explicit filename from Doxygen @file commands.
...
Passing an explicit filename to this command is only necessary if the
documentation in the @file block refers to a file different from the
one the block resides in.
Originally committed as revision 22921 to svn://svn.ffmpeg.org/ffmpeg/trunk
15 years ago
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
15 years ago
Michael Niedermayer
78b0182375
av_compare_ts()
...
Originally committed as revision 21671 to svn://svn.ffmpeg.org/ffmpeg/trunk
15 years ago
Francesco Lavra
91cc5d3767
Move ff_reverse in libavcodec to av_reverse in libavutil.
...
Patch by Francesco Lavra, francescolavra interfree it
Originally committed as revision 20484 to svn://svn.ffmpeg.org/ffmpeg/trunk
15 years ago
Diego Biurrun
082dea8e40
Remove all remaining code that was disabled through the major version bump.
...
Originally committed as revision 17903 to svn://svn.ffmpeg.org/ffmpeg/trunk
16 years ago
Diego Biurrun
bad5537e2c
Use full internal pathname in doxygen @file directives.
...
Otherwise doxygen complains about ambiguous filenames when files exist
under the same name in different subdirectories.
Originally committed as revision 16912 to svn://svn.ffmpeg.org/ffmpeg/trunk
16 years ago
Diego Biurrun
89c9ff504b
spelling/grammar/consistency review part I
...
Originally committed as revision 16840 to svn://svn.ffmpeg.org/ffmpeg/trunk
16 years ago
Aurelien Jacobs
eded5c4309
add a ff_gcd() function again, for compatibility with old libavcodec
...
Originally committed as revision 16814 to svn://svn.ffmpeg.org/ffmpeg/trunk
16 years ago
Diego Biurrun
dfcb6b56f9
Directly #include a bunch of indirectly #included headers.
...
Originally committed as revision 16748 to svn://svn.ffmpeg.org/ffmpeg/trunk
16 years ago
Aurelien Jacobs
9ce6c13879
export gcd function as av_gcd()
...
Originally committed as revision 16653 to svn://svn.ffmpeg.org/ffmpeg/trunk
16 years ago
Michael Niedermayer
c448a09624
Faster ff_sqrt()
...
Originally committed as revision 11586 to svn://svn.ffmpeg.org/ffmpeg/trunk
17 years ago
Diego Biurrun
f3635240b7
Fix a couple of 'return type defaults to int' and 'control reaches end of
...
non-void function' warnings in test code.
Originally committed as revision 11491 to svn://svn.ffmpeg.org/ffmpeg/trunk
17 years ago
Diego Biurrun
f0cb505aeb
Allow compilation of test programs when TEST is defined.
...
Originally committed as revision 11473 to svn://svn.ffmpeg.org/ffmpeg/trunk
17 years ago
Diego Biurrun
f8a80fd69d
main() --> main(void)
...
Originally committed as revision 11079 to svn://svn.ffmpeg.org/ffmpeg/trunk
17 years ago
Steve L'Homme
949b1a13bf
Replace most of the %lld and %llx by their (cleaner) PRI*64 counterparts.
...
patch by Steve Lhomme, slhomme divxcorp com
Originally committed as revision 6868 to svn://svn.ffmpeg.org/ffmpeg/trunk
18 years ago
Diego Biurrun
b78e7197a8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
...
and fix GPL/LGPL version mismatches.
Originally committed as revision 6577 to svn://svn.ffmpeg.org/ffmpeg/trunk
18 years ago
Michael Niedermayer
fc861443d3
improve selftest
...
Originally committed as revision 5424 to svn://svn.ffmpeg.org/ffmpeg/trunk
19 years ago
Michael Niedermayer
2bda41e5b2
extend range used for testing (larger range should work too but testing code overflows)
...
Originally committed as revision 5334 to svn://svn.ffmpeg.org/ffmpeg/trunk
19 years ago
Michael Niedermayer
5c1cb3792d
<= vs. >= 10l bug
...
Originally committed as revision 5333 to svn://svn.ffmpeg.org/ffmpeg/trunk
19 years ago
Måns Rullgård
d1c9b76287
add newline at end of file
...
Originally committed as revision 5330 to svn://svn.ffmpeg.org/ffmpeg/trunk
19 years ago
Michael Niedermayer
fdb3a34156
avoid AVInteger usage in av_rescale
...
disable integer.* (unused)
libavutil.a 45k -> 32k
Originally committed as revision 5311 to svn://svn.ffmpeg.org/ffmpeg/trunk
19 years ago
Diego Biurrun
5509bffa88
Update licensing information: The FSF changed postal address.
...
Originally committed as revision 4842 to svn://svn.ffmpeg.org/ffmpeg/trunk
19 years ago
Diego Biurrun
115329f160
COSMETICS: Remove all trailing whitespace.
...
Originally committed as revision 4749 to svn://svn.ffmpeg.org/ffmpeg/trunk
19 years ago
Alexander Strasser
c11c2bc20b
libavutil: Utility code from libavcodec moved to a separate library.
...
Originally committed as revision 4489 to svn://svn.ffmpeg.org/ffmpeg/trunk
20 years ago