summaryrefslogtreecommitdiff
path: root/libavutil/common.h
Commit message (Collapse)AuthorAge
* avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPATDerek Buitenhuis2016-01-27
| | | | | | | | | | Libav, for some reason, merged this as a public API function. This will aid in future merges. A define is left for backwards compat, just in case some person used it, since it is in a public header. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* lavu: prevent overflow in av_clip_intp2_cAndreas Cadhalpun2016-01-15
| | | | | | | | This fixes ubsan runtime error: signed integer overflow: 8388608 + 2140274688 cannot be represented in type 'int' Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* avutil/common: Protect GET_BYTE in GET_UTF8() by ()Michael Niedermayer2016-01-13
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavu: rename and move ff_parity to av_parityJames Almer2016-01-07
| | | | | | | av_popcount is not defined in intmath.h. Reviewed-by: ubitux Signed-off-by: James Almer <jamrial@gmail.com>
* lavu/common: add an explanation to FF_CEIL_RSHIFT()Clément Bœsch2016-01-07
|
* lavu/common: fix FF_CEIL_RSHIFT() range commentClément Bœsch2016-01-07
|
* Merge commit '50078c1c8070dd8d1c329e8117ff30ec72489039'Hendrik Leppkes2016-01-02
|\ | | | | | | | | | | | | * commit '50078c1c8070dd8d1c329e8117ff30ec72489039': libavutil: move FFALIGN macro from common.h to macros.h Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * libavutil: move FFALIGN macro from common.h to macros.hJanne Grunau2015-12-14
| | | | | | | | | | | | | | | | | | Include macros.h explicitly in common.h so that external code using FFALIGN does not break. It was already implicitly included through version.h. Include macros.h in lls.h and internal.h for FFALIGN. lls.h was including common.h only for FFALIGN and internal.h was missing the include for FFALIGN. `make checkheaders` did not catch it because it's an internal header.
* | avutil: Move av_rint64_clip_* to internal.hMichael Niedermayer2015-11-15
| | | | | | | | | | | | | | | | | | | | The function is renamed to ff_rint64_clip() This should avoid build failures on VS2012 Feel free to changes this to a different solution Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/common: add av_rint64_clipGanesh Ajjanagadde2015-11-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The rationale for this function is reflected in the documentation for it, and is copied here: Clip a double value into the long long amin-amax range. This function is needed because conversion of floating point to integers when it does not fit in the integer's representation does not necessarily saturate correctly (usually converted to a cvttsd2si on x86) which saturates numbers > INT64_MAX to INT64_MIN. The standard marks such conversions as undefined behavior, allowing this sort of mathematically bogus conversions. This provides a safe alternative that is slower obviously but assures safety and better mathematical behavior. API: @param a value to clip @param amin minimum value of the clip range @param amax maximum value of the clip range @return clipped value Note that a priori if one can guarantee from the calling side that the double is in range, it is safe to simply do an explicit/implicit cast, and that will be far faster. However, otherwise this function should be used. avutil minor version is bumped. Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avutil/common: add FFDIFFSIGN macroGanesh Ajjanagadde2015-11-03
| | | | | | | | | | | | | | | | | | | | | | This is of use for defining comparator callbacks. Common approaches like return x-y are not safe due to the risks of overflow. Furthermore, the (x > y) - (x < y) trick is optimized to branchless code. This also documents this macro accordingly. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | Merge commit 'cdfe45ad371b7a8e6135b6c063b6b2a93152cb3a'Hendrik Leppkes2015-09-05
|\| | | | | | | | | | | | | * commit 'cdfe45ad371b7a8e6135b6c063b6b2a93152cb3a': lavu: Drop deprecated av_reverse function Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * lavu: Drop deprecated av_reverse functionVittorio Giovara2015-08-28
| | | | | | | | Deprecated in 10/2012.
* | avutil/common: Add FFNABS()Michael Niedermayer2015-09-03
| | | | | | | | | | | | | | This macro avoids the undefined corner case with the *_MIN values Previous version Reviewed-by: Ganesh Ajjanagadde <gajjanag@mit.edu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avutil/common: Document FFABS() corner caseMichael Niedermayer2015-09-03
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | libavutil: add av_mod_uintp2James Almer2015-03-20
| | | | | | | | | | Reviewed-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: James Almer <jamrial@gmail.com>
* | avutil/common: minor simplification in av_clip_intp2_c()Michael Niedermayer2015-03-02
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avutil/common: Fix integer overflow in av_clip_int8/16_cMichael Niedermayer2015-02-25
| | | | | | | | | | | | | | Fixes: signal_sigsegv_30420a5_2388_cov_1489993561_integra_lavf.mp4 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'bf07d813f6c88b5a76980f321cf7272d799c4216'Michael Niedermayer2015-02-21
|\| | | | | | | | | | | | | * commit 'bf07d813f6c88b5a76980f321cf7272d799c4216': libavutil: Add av_clip_intp2 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * libavutil: Add av_clip_intp2Peter Meerwald2015-02-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there already is a function, av_clip_uintp2() that clips a signed integer to an unsigned power-of-two range, i.e. 0,2^p-1 this patch adds a function av_clip_intp2() that clips a signed integer to a signed power-of-two range, i.e. -(2^p),(2^p-1) the new function can be used as a special case for av_clip(), e.g. av_clip(x, -8192, 8191) can be rewritten as av_clip_intp2(x, 13) there are ARM instructions, usat and ssat resp., which map nicely to these functions (see next patch) Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2013-11-24
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: Add missing #includes for *INT64_MAX and *INT64_C Conflicts: ffmpeg.c ffmpeg_filter.c ffplay.c libavformat/assdec.c libavformat/avidec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * Add missing #includes for *INT64_MAX and *INT64_CDiego Biurrun2013-11-23
| |
| * Use the avstring.h locale-independent character type functionsReimar Döffinger2013-03-07
| | | | | | | | | | | | Make sure the behavior does not change with the locale. Signed-off-by: Martin Storsjö <martin@martin.st>
* | avutil/common: error out with clear message if __STDC_CONSTANT_MACROS is not ↵Michael Niedermayer2013-11-05
| | | | | | | | | | | | defined with c++ Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu/common: add warning to GET_UTF8 doxyStefano Sabatini2013-10-04
| | | | | | | | Should prevent wrong uses, or at least decrease their chance.
* | libavutil: cast truncated values to uint32_tAlfred E. Heggestad2013-08-27
| | | | | | | | | | | | | | | | | | programs using ffmpeg that are compiled with -Wshorten-64-to-32 gives a warning when using header files common.h and rational.h cast 64-bit truncated values to (uint32_t) to avoid the warning Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu/common: make FF_CEIL_RSHIFT faster when shift is constant.Clément Bœsch2013-05-13
| | | | | | | | | | See "[PATCH] lavfi/lut: use FF_CEIL_RSHIFT for chroma w/h rounding." thread for more information.
* | lavu: add FF_CEIL_RSHIFT and use it in various places.Clément Bœsch2013-05-09
| |
* | lavu: fix GET_UTF8 macro.Nicolas George2013-04-24
| | | | | | | | | | Prevent 0xFE and 0xFF from being considered the start of non-standard 7-bytes sequences. No noticeable effect on speed.
* | lavu: add av_clipd_cPaul B Mahol2013-04-18
| | | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com>
* | Remove incorrect use of ctype.h functions.Reimar Döffinger2013-03-03
| | | | | | | | | | | | | | As far as I can tell the code should not change behaviour depending on locale in any of these places. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | lavu: check that assert level is definedMichael Niedermayer2013-01-05
| | | | | | | | | | | | fix warning Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu: check av_clip*() limitsMichael Niedermayer2013-01-04
| | | | | | | | | | | | This code cannot use av_assert* due to circular header dependancies Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '3b4296f41473a5b39e84d7a49d480624c9c60040'Michael Niedermayer2012-11-15
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '3b4296f41473a5b39e84d7a49d480624c9c60040': avformat: clarify stream id for muxing fate: Add dependencies for aac, alac, amrnb, amrwb, atrac tests ppc: do not pass redundant compiler flags avutil: change GET_UTF8 to not use av_log2() segment: fix NULL pointer dereference in seg_write_header() Conflicts: tests/fate/aac.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avutil: change GET_UTF8 to not use av_log2()Mans Rullgard2012-11-14
| | | | | | | | | | | | | | This removes an inter-library dependency on ff_log2_tab causing linking errors in some configurations. Signed-off-by: Mans Rullgard <mans@mansr.com>
* | lavu: add av_clip64()Michael Niedermayer2012-10-27
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'd15c21e5fa3961f10026da1a3080a3aa3cf4cec9'Michael Niedermayer2012-10-21
|\| | | | | | | | | | | | | | | | | | | | | | | | | * commit 'd15c21e5fa3961f10026da1a3080a3aa3cf4cec9': avutil: Add a copy of ff_sqrt_tab back into avutil to restore ABI compatibility avutil: make some tables visible again avutil: remove inline av_log2 from public API celp_math: rename ff_log2 to ff_log2_q15 Conflicts: libavutil/libavutil.v Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avutil: remove inline av_log2 from public APIMans Rullgard2012-10-20
| | | | | | | | | | | | | | | | This removes inline av_log2 and av_log2_16bit from the public API, instead exporting them as regular functions. In-tree code still gets the inline and otherwise optimised variants. Signed-off-by: Mans Rullgard <mans@mansr.com>
* | Merge commit 'd5c62122a7b26704bf867a1262df358623bf5edf'Michael Niedermayer2012-10-13
|\| | | | | | | | | | | | | | | | | | | | | | | | | * commit 'd5c62122a7b26704bf867a1262df358623bf5edf': Move av_reverse table to libavcodec Conflicts: libavcodec/asvenc.c libavcodec/vble.c libavutil/common.h libavutil/mathematics.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * Move av_reverse table to libavcodecDiego Biurrun2012-10-12
| | | | | | | | It is only used in that library.
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2012-08-13
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: (22 commits) g723.1: do not pass large structs by value g723.1: do not bounce intermediate values via memory g723.1: declare a variable in the block it is used g723.1: avoid saving/restoring excitation g723.1: avoid unnecessary memcpy() in residual_interp() g723.1: make postfilter write directly to output buffer g723.1: drop unnecessary variable buf_ptr in formant_postfilter() g723.1: make scale_vector() output to a separate buffer g723.1: make autocorr_max() work on an arbitrary buffer g723.1: do not needlessly use int64_t g723.1: use saturating addition functions g723.1: optimise scale_vector() g723.1: remove useless uses of MUL64() g723.1: remove unnecessary argument 'shift' from dot_product() g723.1: deobfuscate "(x << 4) - x" to "15 * x" celp: optimise ff_celp_lp_synthesis_filter() libavutil: add saturating addition functions cllc: Implement ARGB support cllc: Add support for QRGB cllc: Rename some funcs to represent what they actually do ... Conflicts: LICENSE libavcodec/g723_1.c libavcodec/x86/Makefile Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * libavutil: add saturating addition functionsMans Rullgard2012-08-13
| | | | | | | | | | | | | | Fixed-point audio codecs often use saturating arithmetic, and special instructions for these operations are common. Signed-off-by: Mans Rullgard <mans@mansr.com>
* | Fixed warnings about int64 to int32 conversionMichael Bradshaw2012-05-25
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | lavu: document av_reverse.Nicolas George2012-02-22
| |
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2012-01-04
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: fate: add dxtory test adx_parser: rewrite. adxdec: Validate channel count to fix a division by zero. adxdec: Do not require extradata. cmdutils: K&R reformatting cosmetics alacdec: implement the 2-pass prediction type. alacenc: implement the 2-pass prediction type. alacenc: do not generate invalid multi-channel ALAC files alacdec: fill in missing or guessed info about the extradata format. utvideo: proper median prediction for interlaced videos lavu: bump lavu minor for av_popcount64 dca: K&R formatting cosmetics dct: K&R formatting cosmetics lavf: flush decoders in avformat_find_stream_info(). win32: detect number of CPUs using affinity Add av_popcount64 snow: Restore three mistakenly removed casts. Conflicts: cmdutils.c doc/APIchanges libavcodec/adx_parser.c libavcodec/adxdec.c libavcodec/alacenc.c libavutil/avutil.h tests/fate/screen.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * Add av_popcount64Daniel Verkamp2012-01-03
| | | | | | | | Signed-off-by: Janne Grunau <janne-libav@jannau.net>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2011-11-26
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: swscale: Readd #define _SVID_SOURCE Fix av_get_channel_layout_string() for positions >31 configure: Store vda lib flags in extralibs instead of ldflags Make channel layout masks unsigned dca: ARMv6 optimised decode_blockcode() nullenc: drop AVFMT_RAWPICTURE from the flags frame-mt: return consumed packet size in ff_thread_decode_frame aacdec: add more fate tests covering SBR and PS MK(BE)TAG: avoid undefined shifts Conflicts: configure libavcodec/arm/dca.h libavcodec/dca.c libavcodec/mlp_parser.c libavcodec/version.h libavfilter/asrc_anullsrc.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/defaults.c libavutil/audioconvert.c libavutil/avutil.h libswscale/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * MK(BE)TAG: avoid undefined shiftsMans Rullgard2011-11-25
| | | | | | | | | | | | | | | | Casting the left-most byte to unsigned avoids an undefined result of the shift by 24 if bit 7 is set. This affects the rm demuxer. Signed-off-by: Mans Rullgard <mans@mansr.com>
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2011-06-24
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * qatar/master: doxygen: Consistently use '@' instead of '\' for Doxygen markup. Use av_printf_format to check the usage of printf style functions Add av_printf_format, for marking printf style format strings and their parameters ARM: enable thumb for Cortex-M* CPUs nsvdec: Propagate error values instead of returning 0 in nsv_read_header(). build: remove SRC_PATH_BARE variable build: move basic rules and variables to main Makefile build: move special targets to end of main Makefile lavdev: improve feedback in case of invalid frame rate/size vfwcap: prefer "framerate_q" over "fps" in vfw_read_header() v4l2: prefer "framerate_q" over "fps" in v4l2_set_parameters() fbdev: prefer "framerate_q" over "fps" in device context bktr: prefer "framerate" over "fps" for grab_read_header() ALSA: implement channel layout for playback. alsa: support unsigned variants of already supported signed formats. alsa: add support for more formats. ARM: allow building in Thumb2 mode Conflicts: common.mak doc/APIchanges libavcodec/vdpau.h libavdevice/alsa-audio-common.c libavdevice/fbdev.c libavdevice/libdc1394.c libavutil/avutil.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * doxygen: Consistently use '@' instead of '\' for Doxygen markup.Diego Biurrun2011-06-24
| | | | | | | | Signed-off-by: Diego Biurrun <diego@biurrun.de>