Commit Graph

4245 Commits

Author SHA1 Message Date
Michael Niedermayer
c4ac30909e avutil/hwcontext: Remove duplicate ;
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-17 21:16:14 +01:00
Derek Buitenhuis
d779d8d771 Merge commit 'a001ce31bc2bcf875a39b5fb22dae49120293b42'
* commit 'a001ce31bc2bcf875a39b5fb22dae49120293b42':
  hwcontext: add a VDPAU implementation

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-17 16:16:34 +00:00
Derek Buitenhuis
1a708780f3 Merge commit '89923e418b494e337683442ab896d754bc07341a'
* commit '89923e418b494e337683442ab896d754bc07341a':
  lavu: add a framework for handling hwaccel frames

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-17 16:12:25 +00:00
Derek Buitenhuis
26abd5149e Merge commit '721a4efc0545548a241080b53ab480e34f366240'
* commit '721a4efc0545548a241080b53ab480e34f366240':
  buffer: add support for pools using caller data in allocation

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-17 16:07:16 +00:00
Derek Buitenhuis
73bd20c4d2 Merge commit '6695f178a5929eab91d3da7e9023999f1774bd0e'
* commit '6695f178a5929eab91d3da7e9023999f1774bd0e':
  pixdesc: Use AV_CEIL_RSHIFT in documentation

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-16 16:55:28 +00:00
Derek Buitenhuis
3f462fcf76 Merge commit '1546a41adae818b340acdd9b5dacd6d0a92b6507'
* commit '1546a41adae818b340acdd9b5dacd6d0a92b6507':
  pixdesc: Drop unneeded deprecation warning guards

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-16 16:54:12 +00:00
James Almer
70d685a77f x86: use the new helper macros where useful
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-02-14 20:00:21 -03:00
James Almer
73a4589d4b x86: add some more helper macros to check for slow cpuflags
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-02-14 20:00:17 -03:00
Anton Khirnov
ad884d1002 hwcontext: add a CUDA implementation 2016-02-14 22:08:33 +01:00
Anton Khirnov
7bc780cd44 pixfmt: add a CUDA hwaccelled format 2016-02-14 22:08:22 +01:00
Anton Khirnov
a001ce31bc hwcontext: add a VDPAU implementation 2016-02-14 22:06:04 +01:00
Anton Khirnov
89923e418b lavu: add a framework for handling hwaccel frames 2016-02-14 21:36:59 +01:00
Michael Niedermayer
0eb4092c1b avutil/imgutils: remove special case for aligning the palette
This was suggested by wm4 and stefano.
After this patch using align=1 the size used by various functions would not
contain padding, while the palette would be aligned at align>1

This patch makes it required to use align>=4 if the palette is to be accessed
as uint32

As a side-effect It fixes storing pal8 in nut with odd with&height

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-14 21:30:32 +01:00
Anton Khirnov
721a4efc05 buffer: add support for pools using caller data in allocation
This should allow using more complex allocators than simple malloc
wrappers.
2016-02-14 21:24:39 +01:00
Marton Balint
ae51f9bd6c avutil/parseutils: remove 2112 date from fate test
It is not supported on 32bit.

Signed-off-by: Marton Balint <cus@passwd.hu>
2016-02-14 20:13:15 +01:00
Marton Balint
f834f0cab6 avutil/parseutils: accept everything in av_parse_time that ff_iso8601_to_unix_time accepts
Also parse timezone information previously ignored in ff_iso8601_to_unix_time.

Signed-off-by: Marton Balint <cus@passwd.hu>
2016-02-14 01:46:35 +01:00
Marton Balint
3235241061 avutil/parseutils: use microsecond precision when parsing "now" in av_parse_time()
Use av_gettime() instead of time(0) for querying current time.

Signed-off-by: Marton Balint <cus@passwd.hu>
2016-02-14 01:46:35 +01:00
Timothy Gu
123ff81a45 avutil: Remove x86_cpu.h
It is private (uninstalled) and unused.
2016-02-13 16:30:26 -08:00
Michael Niedermayer
4099e4a77d avutil/frame: Free destination qp_table_buf in frame_copy_props()
Fixes memleak
Fixes: Ticket4899

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-13 20:57:26 +01:00
Michael Niedermayer
4c920ce777 avutil/imgutils: only align the palette in av_image_copy_to_buffer() if there is enough space
This allows disabling the alignment by using a compact buffer

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-13 19:49:34 +01:00
Michael Niedermayer
a9b81bfd1c avutil/avstring: add a "ALL" entry and the possibility to negate matches to av_match_name()
This will extend the whitelist features to allow blacklisting individual protocols and to
explicitly force everything to be enabled.

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-13 16:40:11 +01:00
Michael Niedermayer
d18df8beb0 avutil/imgutils: do not ignore align parameter for pseudo-pal in av_image_get_buffer_size()
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-13 16:22:45 +01:00
James Almer
be22bd32fe x86/cpu: set avxslow cpuflag on btver2 CPUs
They are also slow when using 256 bit wide registers

Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-02-07 16:39:21 -03:00
James Almer
b3b0ecee15 x86/emms: empty the mmx state unconditionally on supported targets
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-02-04 01:49:01 -03:00
James Almer
0711c5bfb8 avutil/aes_crt: free AVAESCTR struct properly
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-02-03 19:33:23 -03:00
Derek Buitenhuis
74f5cb0189 Merge commit 'd336bfcf69fee159e9dba5e5e486ddb1aba61aab'
* commit 'd336bfcf69fee159e9dba5e5e486ddb1aba61aab':
  pixdesc: fix and extend doxy for av_pix_fmt_get_chroma_sub_sample()

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-03 16:59:06 +00:00
Derek Buitenhuis
66e9d2f44e avutil: Add GOP timecode frame side data
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-01 18:18:17 +00:00
Timothy Gu
180f9a0958 all: Make header guard names consistent 2016-01-31 15:44:11 -08:00
Neil Birkbeck
c323c98ee3 libavutil/mastering_display_metadata.h: change fields to be rationals as this is how they are typically coded.
(this structure is not referenced anywhere yet)

Signed-off-by: Neil Birkbeck <neil.birkbeck@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-29 19:08:52 +01:00
Timothy Gu
44304ae322 all: Add missing header guards 2016-01-28 19:49:48 -08:00
James Almer
b624f0660b x86: Add ymm_reg struct
Needed to declare 32-byte long constants

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2016-01-28 00:41:19 +01:00
Derek Buitenhuis
21f9468402 avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPAT
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>
2016-01-27 16:36:46 +00:00
Michael Niedermayer
f3ace85d88 avutil/opt: check for and handle errors in av_opt_set_dict2()
Previously errors could result in random entries to be lost.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-26 17:36:08 +01:00
Hendrik Leppkes
c2869b4640 avutil: add P010 pixel format
P010 is the 10-bit variant of NV12 (planar luma, packed chroma), using two
bytes per component to store 10-bit data plus 6-bit zeroes in the LSBs.
2016-01-26 11:54:01 +01:00
Vittorio Giovara
6695f178a5 pixdesc: Use AV_CEIL_RSHIFT in documentation 2016-01-25 12:02:20 -05:00
Vittorio Giovara
1546a41ada pixdesc: Drop unneeded deprecation warning guards 2016-01-25 12:01:12 -05:00
Geza Lore
cc602061ee x86inc: Add debug symbols indicating sizes of compiled functions
Some debuggers/profilers use this metadata to determine which function a
given instruction is in; without it they get can confused by local labels
(if you haven't stripped those). On the other hand, some tools are still
confused even with this metadata. e.g. this fixes `gdb`, but not `perf`.

Currently only implemented for ELF.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-01-23 20:46:28 +01:00
Henrik Gramner
002c47798d x86inc: Avoid creating unnecessary local labels
The REP_RET workaround is only needed on old AMD cpus, and the labels clutter
up the symbol table and confuse debugging/profiling tools, so use EQU to
create SHN_ABS symbols instead of creating local labels. Furthermore, skip
the workaround completely in functions that definitely won't run on such cpus.

Note that EQU is just creating a local label when using nasm instead of yasm.
This is probably a bug, but at least it doesn't break anything.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-01-23 20:44:25 +01:00
Henrik Gramner
fd6ecac38e x86inc: Simplify AUTO_REP_RET
cpuflags is never undefined any more, it's set to 0 instead.

Also fix an incorrect comment.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-01-23 20:43:39 +01:00
Henrik Gramner
5ca8e195e5 x86inc: Use more consistent indentation
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-01-23 20:42:59 +01:00
Henrik Gramner
91ed050f42 x86inc: Preserve arguments when allocating stack space
When allocating stack space with a larger alignment than the known stack
alignment a temporary register is used for storing the stack pointer.
Ensure that this isn't one of the registers used for passing arguments.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-01-23 20:41:59 +01:00
Henrik Gramner
715eb7ca24 x86inc: Improve FMA instruction handling
* Correctly handle FMA instructions with memory operands.
 * Print a warning if FMA instructions are used without the correct cpuflag.
 * Simplify the instantiation code.
 * Clarify documentation.

Only the last operand in FMA3 instructions can be a memory operand. When
converting FMA4 instructions to FMA3 instructions we can utilize the fact
that multiply is a commutative operation and reorder operands if necessary
to ensure that a memory operand is used only as the last operand.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-01-23 20:30:30 +01:00
Henrik Gramner
f60f06d989 x86inc: Be more verbose in assertion failures
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-01-23 20:30:07 +01:00
Henrik Gramner
7adcd4e841 x86inc: Make cpuflag() and notcpuflag() return 0 or 1
Makes it possible to use them in arithmetic expressions.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-01-23 20:19:19 +01:00
Anton Khirnov
d336bfcf69 pixdesc: fix and extend doxy for av_pix_fmt_get_chroma_sub_sample()
The parameters in the docs are currently swapped.
2016-01-23 20:16:42 +01:00
Neil Birkbeck
17399f6a9f Add missing conversions from side data enum to name
Add names for recently added enums to av_frame_side_data_name.

Signed-off-by: Neil Birkbeck <neil.birkbeck@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-22 01:58:59 +01:00
Geza Lore
d39c229e54 x86inc: Add debug symbols indicating sizes of compiled functions
Some debuggers/profilers use this metadata to determine which function a
given instruction is in; without it they get can confused by local labels
(if you haven't stripped those). On the other hand, some tools are still
confused even with this metadata. e.g. this fixes `gdb`, but not `perf`.

Currently only implemented for ELF.
2016-01-21 23:19:46 +01:00
Henrik Gramner
d3662777e0 x86inc: Avoid creating unnecessary local labels
The REP_RET workaround is only needed on old AMD cpus, and the labels clutter
up the symbol table and confuse debugging/profiling tools, so use EQU to
create SHN_ABS symbols instead of creating local labels. Furthermore, skip
the workaround completely in functions that definitely won't run on such cpus.

Note that EQU is just creating a local label when using nasm instead of yasm.
This is probably a bug, but at least it doesn't break anything.
2016-01-21 23:19:46 +01:00
Henrik Gramner
87b587d4fe x86inc: Simplify AUTO_REP_RET
cpuflags is never undefined any more, it's set to 0 instead.

Also fix an incorrect comment.
2016-01-21 23:19:46 +01:00
Henrik Gramner
2d60b18cf0 x86inc: Use more consistent indentation 2016-01-21 23:19:46 +01:00
Henrik Gramner
dfe771dc5a x86inc: Preserve arguments when allocating stack space
When allocating stack space with a larger alignment than the known stack
alignment a temporary register is used for storing the stack pointer.
Ensure that this isn't one of the registers used for passing arguments.
2016-01-21 23:19:46 +01:00
Henrik Gramner
b1496008ee x86inc: Improve FMA instruction handling
* Correctly handle FMA instructions with memory operands.
 * Print a warning if FMA instructions are used without the correct cpuflag.
 * Simplify the instantiation code.
 * Clarify documentation.

Only the last operand in FMA3 instructions can be a memory operand. When
converting FMA4 instructions to FMA3 instructions we can utilize the fact
that multiply is a commutative operation and reorder operands if necessary
to ensure that a memory operand is used only as the last operand.
2016-01-21 23:19:46 +01:00
Henrik Gramner
6cbd0fdf28 x86inc: Be more verbose in assertion failures 2016-01-21 23:19:46 +01:00
James Almer
a2e1b66460 x86/intmath: disable sse av_clip functions when using ICC
It seems to miscompile them

Should fix fate-ra-288 and fate-twinvq

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-01-21 16:50:51 -03:00
Clément Bœsch
d96f0fbe59 lavu: add pthread asserts if ASSERT_LEVEL>1 2016-01-20 21:08:50 +01:00
Neil Birkbeck
d91718107c libavutil: add mastering display metadata sidedata
Adding mastering display metadata struct to avutil. The mastering display metadata contains information
about the mastering display color volume (SMPTE 2086:2014).

This info comes from HEVC in the SEI_TYPE_MASTERING_DISPLAY_INFO and is soon to be included in MKV:
https://mailarchive.ietf.org/arch/search/?email_list=cellar&gbt=1&index=sZyfPTM-QY69P-0omfOIiTN622o
so it is similar to SEI FPA / stereo_mode in MKV and as such this patch follows how AVStereo3D is implemented.

I'll add support to HEVC in a follow-up (and MKV when spec is approved).

Signed-off-by: Neil Birkbeck <neil.birkbeck@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-19 16:43:31 +01:00
Hendrik Leppkes
a04a9434b5 Merge commit '73c8c0341cce9e1a6c4169721f5123f97fc4be2f'
* commit '73c8c0341cce9e1a6c4169721f5123f97fc4be2f':
  arm: Fix vfp dead code elimination with have_vfp_vm

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-01-19 08:51:12 +01:00
James Almer
dee579ffcd x86/fixed_dsp: add ff_butterflies_fixed_sse2
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-01-16 21:09:38 -03:00
Ganesh Ajjanagadde
5989add4ab lavu/x86/lls: add fma3 optimizations for update_lls
This improves accuracy (very slightly) and speed for processors having
fma3.

Sample benchmark (fate flac-16-lpc-cholesky, Haswell):
old:
5993610 decicycles in ff_lpc_calc_coefs,      64 runs,      0 skips
5951528 decicycles in ff_lpc_calc_coefs,     128 runs,      0 skips

new:
5252410 decicycles in ff_lpc_calc_coefs,      64 runs,      0 skips
5232869 decicycles in ff_lpc_calc_coefs,     128 runs,      0 skips

Tested with FATE and --disable-fma3, also examined contents of
lavu/lls-test.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2016-01-15 16:46:13 -05:00
James Almer
36778627e2 x86/intmath: add missing early clobber to output operands
Signed-off-by: James Almer <jamrial@gmail.com>
2016-01-15 13:32:58 -03:00
Andreas Cadhalpun
f8bc0137bd lavu: prevent overflow in av_clip_intp2_c
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>
2016-01-15 00:32:54 +01:00
Ganesh Ajjanagadde
a0a47a09b0 lavu/libm: add isfinite fallback
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2016-01-13 20:00:19 -05:00
Michael Niedermayer
9ca64c31d2 avutil/common: Protect GET_BYTE in GET_UTF8() by ()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-13 03:09:08 +01:00
Timothy Gu
d64d6edfc7 Correct two build/built typos
Found-by: Leo Izen <leo.izen@gmail.com> as thebombzen on IRC
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
2016-01-11 20:53:11 -08:00
Clément Bœsch
e8bc642202 lavu: add AV_CEIL_RSHIFT and use it in various places
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-01-11 15:32:56 -05:00
Martin Storsjö
73c8c0341c arm: Fix vfp dead code elimination with have_vfp_vm
This fixes builds with --disable-vfp.

Checking for the armv6 cpu flag is incorrect, since vfpv2 isn't
armv6 specific.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-01-08 23:52:59 +02:00
James Almer
dc79824deb x86/float_dsp: zero extend offset from ff_scalarproduct_float_sse
Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-01-08 16:14:32 -03:00
James Almer
4ee38ed7f9 x86/float_dsp: zero extend len from ff_butterflies_float_sse implicitly
Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-01-08 16:14:27 -03:00
James Almer
7f520524f6 x86/float_dsp: remove len check from ff_butterflies_float_sse
The function documentation explicitly mentions it needs to be a multiple of 4.

Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-01-08 16:14:24 -03:00
James Almer
28d5a3a74a lavu: rename and move ff_parity to av_parity
av_popcount is not defined in intmath.h.

Reviewed-by: ubitux
Signed-off-by: James Almer <jamrial@gmail.com>
2016-01-07 20:04:24 -03:00
Clément Bœsch
2ce29d1765 lavu: add ff_parity() 2016-01-07 22:51:31 +01:00
Clément Bœsch
04826b7ff0 lavu/common: add an explanation to FF_CEIL_RSHIFT() 2016-01-07 22:34:04 +01:00
Clément Bœsch
84a967df03 lavu/common: fix FF_CEIL_RSHIFT() range comment 2016-01-07 22:20:22 +01:00
James Almer
f4c1a48483 x86/intmath: add sse optimized av_clipf and av_clipd
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2016-01-07 14:24:01 -03:00
Hendrik Leppkes
957667d198 avutil/cpu: add missing entry for vfp_vm to av_parse_cpu_caps 2016-01-02 19:07:08 +01:00
Hendrik Leppkes
e754c8e8ca Merge commit 'e2710e790c09e49e86baa58c6063af0097cc8cb0'
* commit 'e2710e790c09e49e86baa58c6063af0097cc8cb0':
  arm: add a cpu flag for the VFPv2 vector mode

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-01-02 11:01:29 +01:00
Hendrik Leppkes
af2e6f3215 Merge commit '64034849dad8410bedbe1def4c533490fb85cc4a'
* commit '64034849dad8410bedbe1def4c533490fb85cc4a':
  arm64: add cycle counter support

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-01-02 10:26:42 +01:00
Hendrik Leppkes
4cf66a8193 Merge commit '50078c1c8070dd8d1c329e8117ff30ec72489039'
* commit '50078c1c8070dd8d1c329e8117ff30ec72489039':
  libavutil: move FFALIGN macro from common.h to macros.h

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-01-02 10:25:12 +01:00
Ganesh Ajjanagadde
0e9fe3e3c9 lavu/eval: replace pow(10,x) by ff_exp10(x)
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-25 10:48:13 -08:00
Ganesh Ajjanagadde
11388b5a8f lavu/internal: add ff_exp10
Fast, reasonably accurate 10^x. Alternative of detection of libm exp10 at configure
time is not worth the trouble, since it is anyway not POSIX or ISO C,
and currently only the GNU libm has it. Furthermore, GNU libm's variant
is ~ 2x slower, and is ironically not correctly rounded (2 ulp off) to justify all
that slowdown.

Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-25 10:12:49 -08:00
Ganesh Ajjanagadde
73616b1f21 lavu/libm,configure: remove exp10, exp10f detection
Subsequent commit introduces ff_exp10 instead.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-25 10:12:49 -08:00
Ganesh Ajjanagadde
5630ed5be6 lavu/libm: misc, minor changes
Addition of comments marking the end of ifdef blocks, correction of an
incorrect (at double precision) M_LN2, removal of an unnecessary undef.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-25 09:25:20 -08:00
Ganesh Ajjanagadde
e29db08cf7 lavu/libm: add exp10 support
exp10 is a function available in GNU libm. Looks like no other common
libm has it. This adds support for it to FFmpeg.

There are essentially 2 ways of handling the fallback:
1. Using pow(10, x)
2. Using exp2(M_LOG2_10 * x).

First one represents a Pareto improvement, with no speed or accuracy
regression anywhere, but speed improvement limited to GNU libm.

Second one represents a slight accuracy loss (relative error ~ 1e-13)
for non GNU libm. Speedup of > 2x is obtained on non GNU libm platforms,
~30% on GNU libm. These are "average case numbers", another benefit is
the lack of triggering of the well-known terrible worst case paths
through pow.

Based on reviews, second one chosen. Comment added accordingly.

Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-23 09:22:59 -08:00
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
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
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
Marton Balint
752ab408b4 lavu/error: add missing error messages for errors supported on all platforms
We need these if we have no strerror_r.

Descriptions are taken from doc/errno.txt except for ENOMEM.

Signed-off-by: Marton Balint <cus@passwd.hu>
2015-12-18 04:04:14 +01:00
Ganesh Ajjanagadde
39f8c7961d lavu/random_seed: use arc4random() when available
arc4random() was designed as a superior interface for system random
number generation, designed for OpenBSD and subsequently incorporated by
other BSD's, Mac OS X, and some non-standard libc's. It is thus an improvement to
use it whenever available.

As a side note, this may or may not get included in glibc, and there is
a proposal to create a posix_random family based on these ideas:
http://austingroupbugs.net/view.php?id=859.

Tested on Mac OS X.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-17 08:12:41 -08:00
Ganesh Ajjanagadde
4fa6f09c2c lavu/eval: remove pow and exp2 for postfixes
These postfixes can be computed statically, and there is no need to
waste runtime resources.

Tested with FATE.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-16 07:56:54 -05:00
erankor
23ac99dc17 libavutil: add aes-ctr support
for supporting mp4 cenc encoding/decoding

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-15 14:16:28 +01:00
Janne Grunau
e2710e790c arm: add a cpu flag for the VFPv2 vector mode
The vector mode was deprecated in ARMv7-A/VFPv3 and various cpu
implementations do not support it in hardware. Vector mode code will
depending the OS either be emulated in software or result in an illegal
instruction on cpus which does not support it. This was not really
problem in practice since NEON implementations of the same functions are
preferred. It will however become a problem for checkasm which tests
every cpu flag separately.

Since this is a cpu feature newer cpu do not support anymore the
behaviour of this flag differs from the other flags. It can be only
activated by runtime cpu feature selection.
2015-12-14 16:42:35 +01:00
Janne Grunau
64034849da arm64: add cycle counter support
The ISB (instruction synchronization barrier) might be too heavy for
START/STOPTIMER use but should be more accurate in checkasm where the
timing overhead is subtracted.
2015-12-14 16:42:35 +01:00
Janne Grunau
50078c1c80 libavutil: move FFALIGN macro from common.h to macros.h
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.
2015-12-14 16:16:55 +01:00
Michael Niedermayer
5e8b9e746f avutil/softfloat: Assert that the exponent did not overflow the legal range in av_normalize1_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-11 13:39:21 +01:00
Michael Niedermayer
bc8b1e694c avutil/mathematics: Fix division by 0
Fixes: CID1341571

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-09 17:39:38 +01:00
Clément Bœsch
503d8bf74a lavu/frame: use AVPALETTE_SIZE instead of 1024 2015-12-08 17:50:40 +01:00
Clément Bœsch
dd1d9b80c9 lavu/opencl: restore #if HAVE_THREADS
Fix regression since a8bb81a.

Spotted-by: RiCON
2015-12-07 20:28:30 +01:00
Timothy Gu
006d3e97fc cosmetics: Fix weird indentations 2015-12-07 10:43:43 -08:00
Clément Bœsch
a8bb81a05c lavc, lavu: use avutil/thread.h instead of redundant conditional includes 2015-12-07 17:25:51 +01:00
Clément Bœsch
5e0c47d41c avutil/threadmessage: fix build without HAVE_THREADS, new attempt 2015-12-07 16:39:57 +01:00
Clément Bœsch
d4b1b33e69 avutil/threadmessage: fix build without HAVE_THREADS 2015-12-07 14:28:34 +01:00
Clément Bœsch
bd5c860fdb avutil/threadmessage: split the pthread condition in two
Fix a dead lock under certain conditions. Let's assume we have a queue of 1
message max, 2 senders, and 1 receiver.

Scenario (real record obtained with debug added):
    [...]
    SENDER #0: acquired lock
    SENDER #0: queue is full, wait
    SENDER #1: acquired lock
    SENDER #1: queue is full, wait
    RECEIVER: acquired lock
    RECEIVER: reading a msg from the queue
    RECEIVER: signal the cond
    RECEIVER: acquired lock
    RECEIVER: queue is empty, wait
    SENDER #0: writing a msg the queue
    SENDER #0: signal the cond
    SENDER #0: acquired lock
    SENDER #0: queue is full, wait
    SENDER #1: queue is full, wait

Translated:
 - initially the queue contains 1/1 message with 2 senders blocking on
   it, waiting to push another message.
 - Meanwhile the receiver is obtaining the lock, read the message,
   signal & release the lock. For some reason it is able to acquire the
   lock again before the signal wakes up one of the sender. Since it
   just emptied the queue, the reader waits for the queue to fill up
   again.
 - The signal finally reaches one of the sender, which writes a message
   and then signal the condition. Unfortunately, instead of waking up
   the reader, it actually wakes up the other worker (signal = notify
   the condition just for 1 waiter), who can't push another message in
   the queue because it's full.
 - Meanwhile, the receiver is still waiting. Deadlock.

This scenario can be triggered with for example:
    tests/api/api-threadmessage-test 1 2 100 100 1 1000 1000

One working solution is to make av_thread_message_queue_{send,recv}()
call pthread_cond_broadcast() instead of pthread_cond_signal() so both
senders and receivers are unlocked when work is done (be it reading or
writing).

This second solution replaces the condition with two: one to notify the
senders, and one to notify the receivers. This prevents senders from
notifying other senders instead of a reader, and the other way around.
It also avoid broadcasting to everyone like the first solution, and is,
as a result in theory more optimized.
2015-12-07 11:39:28 +01:00
Clément Bœsch
f98abe0ee7 avutil/threadmessage: add av_thread_message_flush() 2015-12-07 11:39:28 +01:00
Reynaldo H. Verdejo Pinochet
21c34cb261 libavutil: add version component accessor macros
Pretty standard macros, these should help libav*
users avoid repeating ver.si.on parsing code,
which aids in compatibility-checking tasks like
identifying FFmpeg from Libav (_MICRO >= 100 check).
Something many are doing since we are not
intercompatible anymore.

Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
2015-12-06 01:01:51 -08:00
Hendrik Leppkes
d6b988b505 libavutil/tablegen: add missing math.h include 2015-12-04 14:49:35 +01:00
Michael Niedermayer
b46dcd5209 avutil/timecode: Fix fps check
The fps variable is explicitly set to -1 in case of some errors, the check must
thus be signed or the code setting it needs to use 0 as error code
the type of the field could be changed as well but its in an installed header

Fixes: integer overflow
Fixes: 9982cc157b1ea90429435640a989122f/asan_generic_3ad004a_3799_22cf198d9cd09928e2d9ad250474fa58.mov

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-03 04:09:48 +01:00
Ganesh Ajjanagadde
1bb7db217d avutil/crc: avoid needless space wastage of hardcoded crc table
There was no reason AFAIK for making AV_CRC_24_IEEE 12. This simply
resulted in wasted space under --enable-hardcoded-tables:
dynamic: 1318672 libavutil/libavutil.so.55
old    : 1330680 libavutil/libavutil.so.55
new    : 1326488 libavutil/libavutil.so.55

Minor version number is bumped, with ifdefry due to API breakage.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-02 18:31:56 -05:00
Michael Niedermayer
97b8db334a avutil/rational: Test av_rescale_rnd() with combinations of "special" values
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-02 21:38:11 +01:00
Michael Niedermayer
f03c2ceec1 avutil/mathematics: return INT64_MIN (=AV_NOPTS_VALUE) from av_rescale_rnd() for overflows
Fixes integer overflow
Fixes: mozilla bug 1229167

Found-by: Tyson Smith
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-02 21:38:11 +01:00
Ganesh Ajjanagadde
538e8ab512 avutil/tablegen: add tablegen libm compatibility shims
This is useful for build-time table generation (--enable-hardcoded-tables),
by providing compat shims for hosts that have broken libms.

This file is deliberately kept minimal; functions can always be added on
an as-needed basis.

Reviewed-by: Clément Bœsch <u@pkh.me>
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-01 19:05:19 -05:00
Michael Niedermayer
25e37f5ea9 avutil/mathematics: Do not treat INT64_MIN as positive in av_rescale_rnd
The code expects actual positive numbers and gives completely wrong
results if INT64_MIN is treated as positive
Instead clip it into the valid range that is add 1 and treat it as
negative

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-01 13:26:12 +01:00
Michael Niedermayer
3a9cb18855 avutil/integer: Fix av_mod_i() with negative dividend
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-01 13:26:12 +01:00
Ganesh Ajjanagadde
68e79b27a5 avutil/lls: speed up performance of solve_lls
This is a trivial rewrite of the loops that results in better
prefetching and associated cache efficiency. Essentially, the problem is
that modern prefetching logic is based on finite state Markov memory, a reasonable
assumption that is used elsewhere in CPU's in for instance branch
predictors.

Surrounding loops all iterate forward through the array, making the
predictor think of prefetching in the forward direction, but the
intermediate loop is unnecessarily in the backward direction.

Speedup is nontrivial. Benchmarks obtained by 10^6 iterations within
solve_lls, with START/STOP_TIMER. File is tests/data/fate/flac-16-lpc-cholesky.err.
Hardware: x86-64, Haswell, GNU/Linux.

new:
  17291 decicycles in solve_lls, 2096706 runs,    446 skips
  17255 decicycles in solve_lls, 4193657 runs,    647 skips
  17231 decicycles in solve_lls, 8384997 runs,   3611 skips
  17189 decicycles in solve_lls,16771010 runs,   6206 skips
  17132 decicycles in solve_lls,33544757 runs,   9675 skips
  17092 decicycles in solve_lls,67092404 runs,  16460 skips
  17058 decicycles in solve_lls,134188213 runs,  29515 skips

old:
  18009 decicycles in solve_lls, 2096665 runs,    487 skips
  17805 decicycles in solve_lls, 4193320 runs,    984 skips
  17779 decicycles in solve_lls, 8386855 runs,   1753 skips
  18289 decicycles in solve_lls,16774280 runs,   2936 skips
  18158 decicycles in solve_lls,33548104 runs,   6328 skips
  18420 decicycles in solve_lls,67091793 runs,  17071 skips
  18310 decicycles in solve_lls,134187219 runs,  30509 skips

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-26 09:20:46 -05:00
Ganesh Ajjanagadde
29af74e4e3 avutil/libm: fix isnan compatibility hack
Commit 14ea4151d7 had a bug in that the
conversion of the uint64_t result to an int (the return signature) would
lead to implementation defined behavior, and in this case simply
returned 0 for NAN. A fix via AND'ing the result with 1 does the trick,
simply by ensuring a 0 or 1 return value.

Patch tested with FATE on x86-64, GNU/Linux by forcing the compatibility
code via an ifdef hack suggested by Michael.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-24 21:33:13 -05:00
Timothy Gu
7c91b3021c imgutils: Use designated initializers for AVClass
More readable and less breakable.
2015-11-23 18:30:25 -08:00
Matt Oliver
e9ec28c95e avutil/x86/bswap: Remove warning about bswap intrinsics with msvc.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-11-23 23:03:32 +11:00
Clément Bœsch
56bdf61baa avutil/motion_vector: export subpel motion information
FATE test changes because of the switch from shift to division.
2015-11-23 10:55:15 +01:00
Derek Buitenhuis
e12f403678 Merge commit '588b6215b4c74945994eb9636b0699028c069ed2'
* commit '588b6215b4c74945994eb9636b0699028c069ed2':
  rtmpcrypt: Do the xtea decryption in little endian mode
  xtea: Add functions for little endian mode

  Conflicts:
      libavutil/xtea.c

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2015-11-22 14:29:09 +00:00
Ganesh Ajjanagadde
401c93ddb7 avutil/eval: change sqrt to hypot
This improves the mathematical behavior of hypotenuse computation.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-21 08:51:49 -05:00
Ganesh Ajjanagadde
275aca8fba configure+libm.h: add hypot emulation
It is known that the naive sqrt(x*x + y*y) approach for computing the
hypotenuse suffers from overflow and accuracy issues, see e.g
http://www.johndcook.com/blog/2010/06/02/whats-so-hard-about-finding-a-hypotenuse/.
This adds hypot support to FFmpeg, a C99 function.

On platforms without hypot, this patch does a reaonable workaround, that
although not as accurate as GNU libm, is readable and does not suffer
from the overflow issue. Improvements can be made separately.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-21 08:51:49 -05:00
Ganesh Ajjanagadde
14ea4151d7 avutil/libm: correct isnan, isinf compat hacks
isnan and isinf are actually macros as per the standard. In particular,
the existing implementation has incorrect signature. Furthermore, this
results in undefined behavior for e.g double values outside float range
as per the standard.

This patch corrects the undefined behavior for all usage within FFmpeg.

Note that long double is not handled as it is not used in FFmpeg.
Furthermore, even if at some point long double gets used, it is likely
not needed to modify the macro in practice for usage in FFmpeg. See
below for analysis.

Getting long double to work strictly per the spec is significantly harder
since a long double may be an IEEE 128 bit quad (very rare), 80 bit
extended precision value (on GCC/Clang), or simply double (on recent Microsoft).
On the other hand, any potential future usage of long double is likely
for precision (when a platform offers extra precision) and not for range, since
the range anyway varies and is not as portable as IEEE 754 single/double
precision. In such cases, the implicit cast to a double is well defined
and isinf and isnan should work as intended.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-21 08:51:49 -05:00
Derek Buitenhuis
3d2363fbf9 Merge commit '1fc94724f1fd52944bb5ae571475c621da4b77a0'
* commit '1fc94724f1fd52944bb5ae571475c621da4b77a0':
  xtea: Clarify that the current API works in big endian mode

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2015-11-19 14:14:20 +00:00
Michael Niedermayer
fc91eeab0b avutil/mem: Add av_fast_mallocz()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-18 22:05:16 +01:00
Michael Niedermayer
5c3dee7dad avutil: Move av_rint64_clip_* to internal.h
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>
2015-11-15 03:47:09 +01:00
Ganesh Ajjanagadde
6f520ce1a6 avutil/common: add av_rint64_clip
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>
2015-11-13 21:48:16 -05:00
Martin Storsjö
92d107a171 xtea: Add functions for little endian mode
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-11-13 21:53:54 +02:00
Martin Storsjö
1fc94724f1 xtea: Clarify that the current API works in big endian mode
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-11-13 21:53:51 +02:00
Matt Oliver
58d32c00be avutil/x86/intmath: Fix intrinsic header include when using newer gcc with older icc.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-11-12 16:54:08 +11:00
Matt Oliver
9b9c9ef3b4 avutil/x86/bswap: Add msvc bswap instrinsics.
This adds msvc optimisations as well as fixing an error in icl whereby it will generate invalid code otherwise.

Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-11-12 16:53:44 +11:00
Matt Oliver
9105399060 avutil/x86/intmath: Disable use of tzcnt on older intel compilers.
ICC versions older than atleast 12.1.6 dont have the tzcnt intrinsics.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-11-11 10:18:08 +11:00
James Almer
9f4a41bf99 avutil/softfloat: use abort() instead of av_assert0(0)
Fixes compilation of host tool aacps_fixed_tablegen.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-11-10 13:37:24 -03:00
Matt Oliver
f984174512 avutil/x86/intmath: Correct intrinsic headers for older compilers.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-11-09 21:40:33 +11:00
Andreas Cadhalpun
9ac61e73d0 softfloat: handle INT_MIN correctly in av_int2sf
Otherwise v=INT_MIN doesn't get normalized and thus triggers av_assert2
in other functions.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-11-08 21:06:40 +01:00
Andreas Cadhalpun
f3866a14c3 softfloat: assert when the argument of av_sqrt_sf is negative
The correct result can't be expressed in SoftFloat.
Currently it returns a random value from an out of bounds read.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-11-08 21:05:21 +01:00
Michael Niedermayer
955cdc43a3 avutil/softfloat: Include negative numbers in cmp/gt tests
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 15:04:05 +01:00
Michael Niedermayer
05b05a7a84 avutil/softfloat: Fix av_gt_sf() with large exponents try #2
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 15:03:28 +01:00
Michael Niedermayer
791ea23e57 avutil/softfloat: Add test for av_gt_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 15:02:05 +01:00
Michael Niedermayer
ecfb076141 avutil/softfloat: Extend the av_cmp_sf() test to cover a wider range of exponents
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:55:22 +01:00
Michael Niedermayer
cee3c9d29a avutil/softfloat: Fix overflows in shifts in av_cmp_sf() and av_gt_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:54:51 +01:00
Michael Niedermayer
df2a2117d2 avutil/softfloat: Add test for av_cmp_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:39:46 +01:00
Michael Niedermayer
596dfe7d6c avutil/softfloat: Add tests for exponent underflows
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:23:38 +01:00
Michael Niedermayer
046218b212 avutil/softfloat: Fix exponent underflow in av_div_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:23:38 +01:00
Michael Niedermayer
a1e3303fc0 avutil/softfloat: Fix exponent underflow in av_mul_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:23:38 +01:00
Michael Niedermayer
4135a2bfd6 avutil/softfloat: Fix typo in av_mul_sf() doxy
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 14:23:37 +01:00
Michael Niedermayer
4b6ad23609 Revert "avutil/softfloat: Check for MIN_EXP in av_sqrt_sf()"
This case should not be possible if the input has a exponent within
the valid range

This reverts commit 0269fb11e3.
2015-11-08 14:23:37 +01:00
Michael Niedermayer
0269fb11e3 avutil/softfloat: Check for MIN_EXP in av_sqrt_sf()
Otherwise the exponent could eventually underflow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 13:39:06 +01:00
Michael Niedermayer
107db5abf3 avutil/softfloat: Correctly set the exponent for 0.0 in av_sqrt_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 13:39:06 +01:00
Michael Niedermayer
a66b243d52 avutil/softfloat: FLOAT_0 should use MIN_EXP
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-08 03:57:02 +01:00
Nicolas George
47ea04ff10 lavu/opt: enhance printing durations.
Trim unneeded leading components and trailing zeros.
Move the formating code in a separate function.
Use the function also to format the default value, it was currently
printed as plain integer, inconsistent to the way it is parsed.
2015-11-07 16:04:09 +01:00
Michael Niedermayer
c9bfd6a8c3 libavutil/channel_layout: Check strtol*() for failure
Fixes assertion failure
Fixes: 4f5814bb15d2dda6fc18ef9791b13816/signal_sigabrt_7ffff6ae7cc9_65_7209d160d168b76f311be6cd64a548eb.wv

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-05 19:28:19 +01:00
Ganesh Ajjanagadde
265f83fd35 avutil/common: add FFDIFFSIGN macro
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>
2015-11-03 16:28:12 -05:00
Tobias Rapp
4746653466 avutil/file_open: avoid file handle inheritance on Windows
Avoids inheritance of file handles on Windows systems similar to the
O_CLOEXEC/FD_CLOEXEC flag on Linux.

Fixes file lock issues in Windows applications when a child process
is started with handle inheritance enabled (standard input/output
redirection) while a FFmpeg transcoding is running in the parent
process.

Links relevant to the subject:

https://msdn.microsoft.com/en-us/library/w7sa2b22.aspx

Describes the _wsopen() function and the O_NOINHERIT flag. File handles
opened by _wsopen() are inheritable by default.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx

Describes handle inheritance when creating new processes. Handle
inheritance must be enabled (bInheritHandles = TRUE) e.g. when you want
to pass handles for stdin/stdout via lpStartupInfo.

Signed-off-by: Tobias Rapp <t.rapp@noa-audio.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-02 17:40:49 +01:00
Ganesh Ajjanagadde
c03044c86a avutil/eval: minor typo
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-01 19:35:01 -05:00
Matt Oliver
bff009697d avutil/x86/intmath: Add missing header.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-11-01 02:11:29 +11:00
Ganesh Ajjanagadde
8a5b60a6b1 avutil/opencl_internal: add av_warn_unused_result
clSetKernelArg can return an error due to lack of memory (for instance):
https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetKernelArg.html.
Thus this error must be propagated.

Currently should not trigger warnings, but adds robustness.
Untested.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-31 10:40:54 -04:00
Matt Oliver
6c6ac9cb17 avutil/x86/intmath: Use tzcnt in place of bsf.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-10-31 23:11:32 +11:00
Ganesh Ajjanagadde
8d9f86bd37 avutil/rational: use frexp rather than ad-hoc log to get floating point exponent
This simplifies and cleans up the code.
Furthermore, it is much faster due to absence of the slow log computation.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-30 23:18:43 -04:00
Ganesh Ajjanagadde
191f611906 avutil/wchar_filename: add av_warn_unused_result
Current code is fine, this just adds robustness.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-30 13:47:28 -04: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
Ganesh Ajjanagadde
b7fb7c4542 avutil/mathematics: make av_gcd more robust
This ensures that no undefined behavior is invoked, while retaining
identical return values in all cases and at no loss of performance
(identical asm on clang and gcc).
Essentially, this patch exchanges undefined behavior with implementation
defined behavior, a strict improvement.

Rationale:
1. The ideal solution is to have the return type a uint64_t. This
unfortunately requires an API change.
2. The only pathological behavior happens if both arguments are
INT64_MIN, to the best of my knowledge. In such a case, the
implementation defined behavior is invoked in the sense that UINT64_MAX
is interpreted as INT64_MIN, which any reasonable implementation will
do. In any case, any usage where both arguments are INT64_MIN is a
fuzzer anyway.
3. Alternatives of checking, etc require branching and lose performance
for no concrete gain - no client cares about av_gcd's actual value when
both args are INT64_MIN. Even if it did, on sane platforms (e.g all the
ones FFmpeg cares about), it produces a correct gcd, namely INT64_MIN.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-29 19:13:55 -04:00
Ganesh Ajjanagadde
dd36749557 avutil/audio_fifo: add av_warn_unused_result
This one should not trigger any warnings, but will be useful for future
robustness.

Strictly speaking, one could check the size after the call by examining
the structure instead of the return value. Such a use case is highly
unusual, and this commit may be easily reverted if there is a legitimate
need of such use.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-28 23:05:31 -04:00
Ganesh Ajjanagadde
fab1562a50 avutil/ripemd: make rol macro more robust by adding parentheses
This ensures that the macro remains correct in the sense of allowing
expressions for value and bits, by placing the value and bits expressions within
parentheses.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-28 21:42:15 -04:00
Rodger Combs
cceed8389d lavu/aes: test CBC functionality 2015-10-28 09:38:21 -05:00
Rodger Combs
54cd1ab555 lavu/aes: align AVAES struct members 2015-10-28 04:23:14 -05:00
Rodger Combs
15ff5c7215 lavu/aes: add runtime dispatch for crypt function 2015-10-28 04:23:14 -05:00
Rodger Combs
ec588db56f lavu/aes: move AVAES to separate internal header 2015-10-28 04:23:14 -05:00
Rodger Combs
1e477a970f lavu: add AESNI CPU flag 2015-10-28 04:23:14 -05:00
Ganesh Ajjanagadde
a0e390e8ff avutil/avstring: add av_warn_unused_result
This does not trigger any warnings, but adds robustness.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-27 23:16:09 -04:00
Vittorio Giovara
63ea8e0610 timecode: Support HFR values 2015-10-26 15:05:26 +01:00
Vittorio Giovara
8c22148220 timecode: Do not fail for non-standard framerates
Instead just warn, and use the parse fps normally.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-10-26 15:05:05 +01:00
Clément Bœsch
6b5412cbfa avutil/opt: print more meaningful default flags values
Example:
% ./ffmpeg -h encoder=gif
[...]
GIF encoder AVOptions:
  -gifflags          <flags>      E..V.... set GIF flags (default offsetting+transdiff)
     offsetting                   E..V.... enable picture offsetting
     transdiff                    E..V.... enable transparency detection between frames
2015-10-25 22:47:16 +01:00
Ganesh Ajjanagadde
bbd6bc6bd0 avutil/tree: clean up pointer incompatibility warnings
Commit 7c8fcbbde3 introduced some warnings
that get triggered on the test build. This should fix them.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-25 12:45:10 -04:00
Michael Niedermayer
65ffca9f80 avutil/tree: Document the guaranteed ordering of compare arguments for av_tree_find()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-25 17:28:47 +01:00
Ganesh Ajjanagadde
7c8fcbbde3 avutil/tree: add additional const qualifier to the comparator
libc's qsort comparator has a const qualifier on both arguments. This
adds a missing const qualifier to exactly match the comparator API.

Existing usages of av_tree_find, av_tree_insert are appropriately
modified: type signature changes of the comparators, and removal of
unnecessary void * casts of function pointers.

Reviewed-by: Henrik Gramner <henrik@gramner.com>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 20:38:07 -04:00
Ganesh Ajjanagadde
94f333f9dc avutil/tree: improve documentation for av_tree_find, av_tree_insert
This documents the additional constness, and provides a useful libc
reference for the API specification of the comparator.

Reviewed-by: Henrik Gramner <henrik@gramner.com>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 20:38:06 -04:00
Ganesh Ajjanagadde
8ed79c45b4 avutil/qsort: use the do while form for AV_QSORT, AV_MSORT
Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-23 08:41:16 -04:00
Michael Niedermayer
00efaa7983 avutil/intmath: fix undefined behavior in ff_ctzll_c()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-22 14:10:42 +02:00
Andreas Cadhalpun
451b6a990a avutil: merge avpriv_float_dsp_init into avpriv_float_dsp_alloc
Also replace the last two usages of avpriv_float_dsp_init with
avpriv_float_dsp_alloc.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-10-21 00:24:58 +02:00
Andreas Cadhalpun
95687dc310 avutil: install des.h, rc4.h and tree.h as public headers
These headers contain functions supposed to be public.

libavutil/des.h:
 av_des_alloc
 av_des_crypt
 av_des_init
 av_des_mac
libavutil/rc4.h:
 av_rc4_alloc
 av_rc4_crypt
 av_rc4_init
libavutil/tree.h
 av_tree_destroy
 av_tree_enumerate
 av_tree_find
 av_tree_insert
 av_tree_node_alloc
 av_tree_node_size

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-10-21 00:23:10 +02:00
Matt Oliver
b0bb1dc62d lavu/intmath.h: Move x86 only msvc/icl functions to x86 specific header.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-10-19 13:40:51 +11:00
Matt Oliver
216cc1f6fe lavu/intmath.h: Add msvc/icl ctzll optimisations.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-10-19 13:40:27 +11:00
Clément Bœsch
ce0a117ed4 avutil/opt: display a better default value for int/int64 options
Example:

% ./ffmpeg -h encoder=aac
  -aac_coder         <int>        E...A... Coding algorithm (from -1 to 3) (default twoloop)
     faac                         E...A... FAAC-inspired method
     anmr                         E...A... ANMR method
     twoloop                      E...A... Two loop searching method
     fast                         E...A... Constant quantizer
[...]
2015-10-19 00:04:33 +02:00
Ganesh Ajjanagadde
07d4fe3a87 avutil: use EINVAL instead of -1 for the return code of crypto related init functions
These functions return an error typically when the key size is an
incorrect number. AVERROR(EINVAL) is more specific than -1.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-18 15:17:58 -04:00
Timothy Gu
801eca1372 opencl: Force the use of 1.2 APIs
Silences warnings regarding `clCreateCommandQueue` being deprecated.

Only a very limited number of products support 2.0. Since the
replacement API (`clCreateCommandQueueWithProperties`) is only available
in 2.0, we should not update it just yet.
2015-10-17 01:16:50 -07:00
Timothy Gu
17c68933f4 opencl: Use "opencl" as log context name
All other classes use lowercase names.
2015-10-17 01:16:50 -07:00
Timothy Gu
893a648182 opencl: Print compilation log
Useful when debugging.
2015-10-17 01:16:50 -07:00
Timothy Gu
d2a1029724 opencl: Print error string when compilation fails 2015-10-17 01:16:50 -07:00
Ganesh Ajjanagadde
cf52ae003b avutil/mem: add av_warn_unused_result
This adds av_warn_unused_result to functions whose return codes need to
be checked.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-16 19:53:55 -04:00
James Almer
3d1690b8c6 avutil: undo FF_API_CRYPTO_CONTEXT deprecation
It's been argued that the benefits of the current implementation far outweight
those of making the structs opaque.

This deprecation is not present in any release, so it can be safely removed.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-10-16 19:13:38 -03:00
Ganesh Ajjanagadde
a0b079ac25 avutil/file: add av_warn_unused_result to av_file_map
The return code here should be checked.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-16 17:18:39 -04:00
Ganesh Ajjanagadde
31ed189d5c avutil/internal: add av_warn_unused_result to avpriv_open
The open syscall can obviously fail, and its return code needs to be
checked.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-16 17:18:21 -04:00
Ganesh Ajjanagadde
0418541d5d avutil/cast5: update Doxygen for av_cast5_init with return information
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-15 22:32:58 -04:00
Michael Niedermayer
d6f6e98eb1 avutil/crc: use EINVAL instead of -1 for the return code of av_crc_init()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-16 03:24:36 +02:00
wang-bin
0861862b89 winrt: multithreading support
_beginthreadex is for desktop only. CreateThread is available for windows store apps on windows (and phone) 8.1 and later. http://msdn.microsoft.com/en-us/library/ms682453%28VS.85%29.aspx

Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2015-10-16 00:54:57 +11:00
Hendrik Leppkes
f05021f3f4 Merge commit 'c53e796f8b69799b7ad6d28fbab981d37edf1bc9'
* commit 'c53e796f8b69799b7ad6d28fbab981d37edf1bc9':
  thread: Provide no-op variants for pthread_once

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-14 23:02:35 +02:00
Zhang Rui
87ff61b9ab avutil/fifo: add function av_fifo_generic_peek_at()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-14 20:23:58 +02:00
Ganesh Ajjanagadde
55d3e97970 avutil/intmath: use de Bruijn based ff_ctz
It has already been demonstrated that the de Bruijn method has benefits
over the current implementation: commit 971d12b7f9.
That commit implemented it for long long, this extends it to the int version.

Tested with FATE.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2015-10-14 13:39:42 -04:00
Luca Barbato
c53e796f8b thread: Provide no-op variants for pthread_once 2015-10-14 14:35:34 +02:00
Hendrik Leppkes
b994788353 Merge commit '11c5f438ff83da5040e85bfa6299f56b321d32ef'
* commit '11c5f438ff83da5040e85bfa6299f56b321d32ef':
  dict: Change return type of av_dict_copy()

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-14 14:01:11 +02:00
Michael Niedermayer
147b12162d avutil/fifo: Fix thread saftey of av_fifo_generic_peek()
changing the context state and restoring it is not safe if another
thread writes data into the fifo

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-13 19:08:42 +02:00
Vittorio Giovara
11c5f438ff dict: Change return type of av_dict_copy()
av_dict_set() could return an error, so forward it appropriately.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-10-12 13:35:01 +02:00
Ronald S. Bultje
93866c2aa2 intmath: remove av_ctz.
It's a non-installed header and only used in one place (flacenc).
Since ff_ctz is static inline, it's fine to use that instead.
2015-10-11 18:03:10 -04:00
Michael Niedermayer
2a4d1a66e8 avutil/intmath: Change debruijn_ctz64 to use 8bit elements
This reduces the memory & cache need from 256 to 64 bytes
the code also seems faster with this change

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-11 04:21:01 +02:00
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>
2015-10-11 04:08:41 +02:00
Rodger Combs
0562f95902 lavu/opt: add flag to return NULL when applicable in av_opt_get
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-09 04:12:57 -05:00
Rodger Combs
f36baeebc5 lavu/opt: switch AV_OPT flags to shift-based formatting 2015-10-09 04:12:57 -05:00
Ganesh Ajjanagadde
1d4af04adf avutil/attributes: add av_warn_unused_result
GCC 3.4 introduced an attribute warn_unused_result to warn when a programmer
discards the return value. Applying this judiciously across the codebase can help
in fixing a lot of problems. At a high level, functions which return error codes
should always be checked. More concretely, consider the functions ff_add_format
and the like in avfilter/formats.h. A quick examination shows that a large portion
of libavfilter fails to handle the associated errors, usually AVERROR(ENOMEM).
The above example was where I observed the utility of this, but it should be
useful in many places across the code base.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-05 19:30:20 +02:00
Henrik Gramner
2c3dbff1d8 avutil/avstring: Inline some tiny functions
They're short enough that inlining them actually reduces code size due to
all the overhead associated with making a function call.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2015-10-03 13:45:37 +02:00
Hendrik Leppkes
5fa5e73e81 Merge commit '1aa24df74c052a73175c43e57d35b4835e537ec8'
* commit '1aa24df74c052a73175c43e57d35b4835e537ec8':
  lavu: Deprecate AVFrame.error[]

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-03 09:52:39 +02:00
Henrik Gramner
17710550c4 x86inc: Make cpuflag() and notcpuflag() return 0 or 1
Makes it possible to use them in arithmetic expressions.
2015-10-01 18:14:12 +02:00
Vittorio Giovara
1aa24df74c lavu: Deprecate AVFrame.error[]
These field are difficult to interpret, and are provided by a single
encoder (mpegvideoenc). In general they do not belong to a structure
containing raw data only, so remove them from AVFrame.

Mpegvideoenc now uses a private field in Picture for its internal
computations.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-30 16:44:33 +02:00
Vicente Olivert Riera
d00bb8addc mips: intreadwrite: Only execute that code for mips r1 or r2
MIPS R6 supports unaligned memory access and does not have
the load/store-left/right family of instructions.

Signed-off-by: Vicente Olivert Riera <Vincent.Riera at imgtec.com>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-09-29 11:10:37 +02:00
Henrik Gramner
ad9a543e93 avutil/avstring: Inline some tiny functions
They're short enough that inlining them actually reduces code size due to
all the overhead associated with making a function call.
2015-09-26 22:08:02 +02:00
Timo Rothenpieler
31ee86cd98 avutil/opencl: Fix volatile pointer
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2015-09-26 20:28:29 +02:00
James Almer
36e1665d3d avutil/attributes: add AV_GCC_VERSION_AT_MOST
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-09-18 12:41:29 -03:00
Ganesh Ajjanagadde
63cdb6e4a5 avutil/log: fix zero length gnu_printf format string warning
This should fix warning reported by fate client:
http://fate.ffmpeg.org/report.cgi?time=20150917113121&slot=x86_32-linux-gnu-gcc-4.5.1-have_6regs.
Untested.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-17 18:58:01 +02:00
Kevin Wheatley
4a66422450 pixfmt: Add new SMPTE color primaries and transfer characteristic values
Appeared in ITU-T Rec H.265 10/2014.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-17 10:31:43 +02:00
Rodger Combs
8e924629eb lavu/avstring: switch AV_ESCAPE_FLAGs to shift-based formatting
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-15 00:00:57 +02:00
Hendrik Leppkes
eadf6cb2c4 Merge commit '7b02cb29d9d60cdd5ef321043d11d02023e7dc8f'
* commit '7b02cb29d9d60cdd5ef321043d11d02023e7dc8f':
  pixdesc: Document the component order

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-12 13:03:04 +02:00
Hendrik Leppkes
ba42096d9a Merge commit 'e336c51e6ffcdb93fbcf3c6153d378400608526b'
* commit 'e336c51e6ffcdb93fbcf3c6153d378400608526b':
  pixdesc: Consistently order components

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-12 12:54:25 +02:00
James Almer
d5f8a642f6 x86: port PSIGNW to cpuflags
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-09-11 23:27:03 -03:00
Michael Niedermayer
77d03b0ebb avutil/version: Bump for avpriv_get_trc_function_from_trc() and AVCOL_PRI/TRC_SMPTEST428_1 and AVCOL_TRC_SMPTEST2084
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-11 01:12:28 +02:00
Kevin Wheatley
bac9048265 avutil/color_utils: Add basic transfer functions for each AVColorTransferCharacteristic
Most functions are valid over a domain and range of [0.0-1.0] but
some are defined over greater. This patch does not deal with
AVColorRange and assumes AVCOL_RANGE_JPEG for the returned values.

Signed-off-by: Kevin Wheatley <kevin.j.wheatley@gmail.com>
2015-09-10 23:53:05 +02:00
Michael Niedermayer
24426172d3 avutil/pixfmt: Name "SMPTE ST 428-1" in AVColorPrimaries the same as in AVColorTransferCharacteristic
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-10 22:50:42 +02:00
Michael Niedermayer
b5939ba09c avutil/pixdesc: Use "-" in color_primaries_names to be consistent with color_transfer_names
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-10 22:47:51 +02:00
Kevin Wheatley
6d4b394b5d avutil/pixdesc: Add SMPTE ST 2084 and ST 428-1 pixel descriptions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-10 22:34:47 +02:00
Kevin Wheatley
c3cd6dd106 avutil/pixfmt: Add additional primaries and transfer characteristic enumerations from ITU-T Rec H.265
Signed-off-by: Kevin Wheatley <kevin.j.wheatley@gmail.com>
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-10 22:32:52 +02:00
Luca Barbato
7b02cb29d9 pixdesc: Document the component order 2015-09-10 12:08:57 +02:00
Hendrik Leppkes
e336c51e6f pixdesc: Consistently order components
Ensure that the components are ordered consistently, ie. always
RGB(A) and YUV(A). This allows to identify a specific plane on a given
pixel format without hard-coding knowledge of the plane order.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-09-10 12:08:57 +02:00
Hendrik Leppkes
c7ed26ad60 pixdesc: Add missing alpha flag for yuva420p9be
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-09-10 12:08:57 +02:00
Clément Bœsch
9571a56009 avutil/opt: refactor pixel/sample fmt common case 2015-09-08 22:49:33 +02:00
Clément Bœsch
9117748cff avutil/opt: add AV_OPT_TYPE_BOOL 2015-09-08 22:39:20 +02:00
Hendrik Leppkes
5d8e836d0e Replace all remaining occurances of step/depth_minus1 and offset_plus1 2015-09-08 17:10:48 +02:00
Hendrik Leppkes
151aa2ebff Merge commit '2268db2cd052674fde55c7d48b7a5098ce89b4ba'
* commit '2268db2cd052674fde55c7d48b7a5098ce89b4ba':
  lavu: Drop the {minus,plus}1 suffix from AVComponentDescriptor fields

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-08 16:35:28 +02:00
Hendrik Leppkes
f53569a93f Merge commit '6b3ef7f080293956b2e5212b83135c6b051212e9'
* commit '6b3ef7f080293956b2e5212b83135c6b051212e9':
  lavu: Remove bit packing from AVComponentDescriptor

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-08 14:53:34 +02:00
Hendrik Leppkes
c734b34b04 Merge commit 'b8b5d8274471129f122858bc74ad09284dae6ab7'
* commit 'b8b5d8274471129f122858bc74ad09284dae6ab7':
  lavu: extend size of the AVPixFmtDescriptor.flags field

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-08 14:53:13 +02:00
Vittorio Giovara
2268db2cd0 lavu: Drop the {minus,plus}1 suffix from AVComponentDescriptor fields
The new fields can be accessed directly and are more intelligible.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-07 12:37:47 +02:00
Vittorio Giovara
6b3ef7f080 lavu: Remove bit packing from AVComponentDescriptor
There is no practical benefit in having this structure elements
bit packed given the size of the structure and its usage.
Change types from uint16_t (packed) to plain int in order to simplify
modifying the structure and accessing its fields.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-07 12:36:56 +02:00
wm4
b8b5d82744 lavu: extend size of the AVPixFmtDescriptor.flags field
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-07 12:36:04 +02:00
Hendrik Leppkes
b7601b5f3d Merge commit 'a686e58165ca0f83966431a9166cb6e17bf6095c'
* commit 'a686e58165ca0f83966431a9166cb6e17bf6095c':
  des: Add missing include

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-07 12:28:25 +02:00
Hendrik Leppkes
160e92c8bf Merge commit 'e88103a7f92cf27a2868b50acc8a9912f6088249'
* commit 'e88103a7f92cf27a2868b50acc8a9912f6088249':
  Bump major versions of all libraries

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-05 21:35:46 +02:00
James Almer
c956cb2c02 avutil/pixfmt: remove duplicate AVPixelFormat values
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-09-05 15:51:55 -03:00
Hendrik Leppkes
d83dd630a0 lavu: Drop FF_API_GET_CHANNEL_LAYOUT_COMPAT cruft
FATE refs changed to accomodate for the new default behavior of the function.
Numbers are now interpreted as a channel layout, instead of a number of channels.
2015-09-05 20:36:19 +02:00
Hendrik Leppkes
237cf3786e lavu: Drop old deprecated AVOption API
Deprecated in 2011/10
2015-09-05 18:30:35 +02:00
Hendrik Leppkes
137f075993 lavu/hmac: remove deprecated type ids 2015-09-05 18:07:20 +02:00
Hendrik Leppkes
545559e43d Remove FF_CONST_AVUTIL55 cruft 2015-09-05 17:56:28 +02:00
Hendrik Leppkes
2df52088ef Merge commit '4e649debcf7f71d35c6b38cdb7ee715eba95d64a'
* commit '4e649debcf7f71d35c6b38cdb7ee715eba95d64a':
  Postpone API-incompatible changes until the next bump

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-05 17:52:10 +02:00
Hendrik Leppkes
6f6c025d6d Merge commit '3d89373fae281053154772d5e3e4370da09d3880'
* commit '3d89373fae281053154772d5e3e4370da09d3880':
  lavu: Drop deprecated private lls functions

Previously removed in ffmpeg

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-05 17:46:47 +02:00
Hendrik Leppkes
f940931995 Merge commit '2f9b652e8c646eabef74a6742f0d7d4c9118fd0e'
* commit '2f9b652e8c646eabef74a6742f0d7d4c9118fd0e':
  lavu: Drop deprecated context size variables

These variables had been previously un-deprecated in ffmpeg, not removed.

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-05 17:44:55 +02:00
Hendrik Leppkes
a991526832 lavu/frame: put frame QP elements under a new version guard
These fields are still used, removal postponed until a replacement functionality is available.
2015-09-05 17:35:31 +02:00