1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
Commit Graph

77432 Commits

Author SHA1 Message Date
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
Ganesh Ajjanagadde
fc5e39544b lavf/avformat: add av_warn_unused_result to avformat_write_header
May be useful as a defense, see e.g c62d1780ff.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:39:57 -08:00
Ganesh Ajjanagadde
879b4a9d3e lavd/pulse_audio_enc: replace lround by lrint
Here it is mostly a cosmetic change, but there might be benefits in that
there are no compat hacks for lround, while there are for lrint.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:25:30 -08:00
Ganesh Ajjanagadde
ea2f04bffe lavfi/vf_histogram: replace round by lrint
lrint is at least as fast, uses a superior rounding mode, and avoids an
implicit cast.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:23:21 -08:00
Ganesh Ajjanagadde
ad795f6394 lavfi/af_dynaudnorm: replace round by lrint
lrint is at least as fast, uses a superior rounding mode, and avoids an
implicit cast.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:22:23 -08:00
Ganesh Ajjanagadde
2a486869d9 lavfi/vf_crop: replace round by lrint
lrint is at least as fast, avoids an implicit cast, and uses a superior
rounding mode.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:21:20 -08:00
Ganesh Ajjanagadde
b9c2ebeee4 lavc/libvpxenc: replace round by lrint
Mostly cosmetic here.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:20:26 -08:00
Ganesh Ajjanagadde
ff1442a51d lavfi/vf_drawtext: replace round by llrint
llrint is at least as fast, and avoids an implicit cast.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:18:12 -08:00
Ganesh Ajjanagadde
7af14b3726 lavfi/vf_colorlevels: replace round by lrint
lrint avoids an implicit cast, and is not slower on non-broken libm's. Thus this
represents a Pareto improvement.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:17:13 -08:00
Ganesh Ajjanagadde
cc37b31ad3 lavfi/vf_colorchannelmixer: replace round by lrint
lrint is faster here on -ftree-vectorize with GCC. This is likely simply
an artifact of GCC's rather terrible auto-vectorizer, since as per the
instruction set manuals cvtsd2si and cvttsd2si (or their vector equivalents)
have identical cycle timings.

Anyway, regardless of above, lrint is superior to round accuracy wise.

Safety guaranteed as long int has at least 32 bits.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:15:31 -08:00
Clément Bœsch
d3dbae1c71 lavfi/drawtext: fix shadow[xy] descriptions 2015-12-21 16:42:14 +01:00
Clément Bœsch
1d6308dbc6 lavfi/drawtext: hide first font load warning when fontconfig is present 2015-12-21 16:07:22 +01:00
Clément Bœsch
4cb26c3c35 lavfi/drawtext: fix crash when no text, file or timecode provided 2015-12-21 15:54:20 +01:00
Paul B Mahol
a142308dcd avfilter/af_ladspa: fix av_assert0()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-21 13:27:56 +01:00
Clément Bœsch
b4431c80ef lavf/img2enc: add atomic_writing option
This behaviour change caused a regression on our side recently, we might
want to disable the option by default.
2015-12-21 11:19:51 +01:00
Clément Bœsch
f122ba36cb lavc: add text encoder 2015-12-21 11:14:02 +01:00
Clément Bœsch
244766e407 lavfi/scale: add nb_slices debug option 2015-12-21 10:30:52 +01:00
Paul B Mahol
484cc66f57 avcodec/indeo2: use init_get_bits8
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-20 21:31:55 +01:00
James Almer
d4c47333e1 x86/hevc_sao: add ff_hevc_sao_edge_filter_{8,16}_{10,12}
Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-12-20 17:01:15 -03:00
James Almer
3ff2beff65 x86/hevc_sao: simplify sao_edge_filter 10/12bit
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-12-20 16:45:37 -03:00
James Almer
34b2bd03cf x86/hevc_sao: simplify sao_band_filter 10/12bit
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-12-20 16:42:36 -03:00
Paul B Mahol
9e569abe99 avfilter/avf_showfreqs: make it possible to split channels
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-20 19:52:51 +01:00
Paul B Mahol
367ffa0c15 avcodec/flacenc: use designated initializers for AVClass
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-20 17:47:21 +01:00
Paul B Mahol
db6e337b41 avcodec/s302menc: check if buf_size can actually be put into 16bit size
This disallows creating unplayable audio.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-20 16:05:37 +01:00
Paul B Mahol
577f057355 avcodec/s302menc: set supported channel layouts by codec
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-20 16:05:37 +01:00
Andreas Cadhalpun
f6830cf5ba nuv: sanitize negative fps rate
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-20 12:22:45 +01:00
Andreas Cadhalpun
699e68371e rawdec: only exempt BIT0 with need_copy from buffer sanity check
Otherwise the too small buffer is directly used in the frame, causing
segmentation faults, when trying to use the frame.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-20 12:15:56 +01:00
Andreas Cadhalpun
9fcfe4a3cd mlvdec: check that index_entries exist
This fixes NULL pointer dereferencing.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-20 11:57:54 +01:00
Michael Niedermayer
70f13abb4f avcodec/mpeg4videodec: also for empty partitioned slices
Fixes assertion failure
Fixes: id_acf3e47f864e1ee4c7b86c0653e0ff31e5bde56e.m4v

Found-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-19 23:54:10 +01:00
Ganesh Ajjanagadde
062e3e2382 lavu/libm: add copysign hack
For systems with broken libms.
Tested with NAN, -NAN, INFINITY, -INFINITY, +/-x for regular double x and
combinations of these.

Old versions of MSVC need some UINT64_C hackery.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-19 14:05:49 -08:00
James Almer
0f520e489a avcodec/Makefile: add missing dep for g723_1 encoder
Signed-off-by: James Almer <jamrial@gmail.com>
2015-12-19 18:50:47 -03:00
Paul B Mahol
7caf381a95 avfilter/af_dynaudnorm: use av_malloc_array()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-19 22:46:10 +01:00
Michael Niedermayer
b92b4775a0 avcodec/h264_refs: Fix long_idx check
Fixes out of array read
Fixes mozilla bug 1233606

Found-by: Tyson Smith
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-19 22:17:54 +01:00
Matthieu Bouron
b32a42295a swscale/arm/yuv2rgb: add ff_yuv420p_to_{argb,rgba,abgr,bgra}_neon_{16,32} 2015-12-19 22:09:28 +01:00
Matthieu Bouron
e0dc22b99e swscale/arm/yuv2rgb: disable neon if accurate_rnd is enabled
This disables the 32bit precision neon code path in favor of the
default C one and avoids breaking fate.
2015-12-19 22:09:28 +01:00
Michael Niedermayer
2d2b41d169 avcodec/ffv1enc: Fix 2 pass mode with the default rc table
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-19 20:42:54 +01:00
Paul B Mahol
ebe1ca01d1 avfilter/vf_stereo3d: add interleave columns input support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-19 19:23:47 +01:00
Ganesh Ajjanagadde
0dd8a3d71e lavu/intmath: add faster clz support
This should be useful for the sofalizer filter.

Reviewed-by: Kieran Kunhya <kierank@ob-encoder.com>
Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-19 09:35:34 -08:00
Ganesh Ajjanagadde
5484cbe9f7 lavfi/vsrc_mandelbrot: replace round by lrint
lrint is at least as fast, and is more accurate.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-19 09:34:26 -08:00
Ganesh Ajjanagadde
425c0685f2 lavfi/vf_cropdetect: replace round by lrint
lrint is at least as fast, and more accurate.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-19 09:34:08 -08:00
Ganesh Ajjanagadde
18bc3dc768 lavf/hlsenc: replace round by lrint
Mainly cosmetic here.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-19 09:33:49 -08:00
Ganesh Ajjanagadde
641cb77f50 lavfi/vf_idet: replace round and cast by lrint
lrint is faster and conveys the intent better here. It is safe as long int has
at least 32 bits.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-19 09:33:32 -08:00
Ganesh Ajjanagadde
def3c83e1b lavc/aacsbr: sbr_dequant optimization
This uses ff_exp2fi to get a speedup (~ 6x).

sample benchmark (Haswell, GNU/Linux):
old:
  19102 decicycles in sbr_dequant,    1023 runs,      1 skips
  19002 decicycles in sbr_dequant,    2045 runs,      3 skips
  17638 decicycles in sbr_dequant,    4093 runs,      3 skips
  15825 decicycles in sbr_dequant,    8189 runs,      3 skips
  16404 decicycles in sbr_dequant,   16379 runs,      5 skips

new:
   3063 decicycles in sbr_dequant,    1024 runs,      0 skips
   3049 decicycles in sbr_dequant,    2048 runs,      0 skips
   2968 decicycles in sbr_dequant,    4096 runs,      0 skips
   2818 decicycles in sbr_dequant,    8191 runs,      1 skips
   2853 decicycles in sbr_dequant,   16383 runs,      1 skips

Reviewed-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-19 09:32:53 -08:00
Andreas Cadhalpun
ce10f572c1 nutdec: reject negative value_len in read_sm_data
If it is negative, it can cause the byte position to move backwards in
avio_skip, which in turn makes sm_size negative and thus size larger
than the size of the packet buffer, causing invalid writes in avio_read.

Also fix potential overflow of avio_tell(bc) + value_len.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-19 17:57:56 +01:00
Andreas Cadhalpun
9d38f06d05 xwddec: prevent overflow of lsize * avctx->height
This is used to check if the input buffer is large enough, so if this
overflows it can cause a false negative leading to a segmentation fault
in bytestream2_get_bufferu.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-19 14:28:51 +01:00
Marton Balint
c413d9e635 ffplay: remove existing AVPicture usage
It is deprecated.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2015-12-19 14:09:26 +01:00
Andreas Cadhalpun
9f82506c79 nutdec: only copy the header if it exists
Fixes ubsan runtime error: null pointer passed as argument 2, which is
declared to never be null

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-19 12:30:59 +01:00
Reynaldo H. Verdejo Pinochet
ae2ed20b59 ffserver: refactor build_feed_streams()
* Avoid excesive nesting that made it really hard to follow
* Drop unneeded vars
* Factor out codec compatibility check routine
* Ensure inputs are closed and contexts are freed as needed
  before returning

Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
2015-12-19 01:52:20 -08:00
Reynaldo H. Verdejo Pinochet
4ba148a6ea ffserver: refactor build_file_streams()
Avoid unneeded nesting, drop redundant var

Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
2015-12-19 01:52:20 -08:00
Reynaldo H. Verdejo Pinochet
532a283383 ffserver: unify exit path from build_feed_streams()
Exit from main on build_feed_streams() failures & use
standard EXIT_ codes on error out/normal exit.

Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
2015-12-19 01:52:20 -08:00