Commit Graph

678 Commits

Author SHA1 Message Date
Ganesh Ajjanagadde cf491a925e swresample/resample: speed up Blackman Nuttall filter
This may be a slightly surprising optimization, but is actually based on
an understanding of how math libraries compute trigonometric functions.
Explanation is given here so that future development uses libm more effectively
across the codebase.

All libm's essentially compute transcendental functions via some kind of
polynomial approximation, be it Taylor-Maclaurin or Chebyshev.
Correction terms are added via polynomial correction factors when needed
to squeeze out the last bits of accuracy. Lookup tables are also
inserted strategically.

In the case of trigonometric functions, periodicity is exploited via
first doing a range reduction to an interval around zero, and then using
some polynomial approximation.

This range reduction is the most natural way of doing things - else one
would need polynomials for ranges in different periods which makes no
sense whatsoever.

To avoid the need for the range reduction, it is helpful to feed in
arguments as close to the origin as possible for the trigonometric
functions. In fact, this also makes sense from an accuracy point of view:
IEEE floating point has far more resolution for small numbers than big ones.

This patch does this for the Blackman-Nuttall filter, and yields a
non-negligible speedup.

Sample benchmark (x86-64, Haswell, GNU/Linux)
test: fate-swr-resample-dblp-2626-44100
old:
18893514 decicycles in build_filter (loop 1000),     256 runs,      0 skips
18599863 decicycles in build_filter (loop 1000),     512 runs,      0 skips
18445574 decicycles in build_filter (loop 1000),    1000 runs,     24 skips

new:
16290697 decicycles in build_filter (loop 1000),     256 runs,      0 skips
16267172 decicycles in build_filter (loop 1000),     512 runs,      0 skips
16251105 decicycles in build_filter (loop 1000),    1000 runs,     24 skips

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-09 18:41:32 -05:00
Ganesh Ajjanagadde b87ca4bf25 swresample/resample: speed up upsampling by precomputing sines
When upsampling, factor is set to 1 and sines need to be evaluated only
once for each phase, and the complexity should not depend on the number
of filter taps. This does the desired precomputation, yielding
significant speedups. Hard guarantees on the gain are not possible, but gains
themselves are obvious and are illustrated below.

Sample benchmark (x86-64, Haswell, GNU/Linux)
test: fate-swr-resample-dblp-2626-44100
old:
29161085 decicycles in build_filter (loop 1000),     256 runs,      0 skips
28821467 decicycles in build_filter (loop 1000),     512 runs,      0 skips
28668201 decicycles in build_filter (loop 1000),    1000 runs,     24 skips

new:
14351936 decicycles in build_filter (loop 1000),     256 runs,      0 skips
14306652 decicycles in build_filter (loop 1000),     512 runs,      0 skips
14299923 decicycles in build_filter (loop 1000),    1000 runs,     24 skips

Note that this does not statically allocate the sin lookup table. This
may be done for the default 1024 phases, yielding a 512*8 = 4kB array
which should be small enough.
This should yield a small improvement. Nevertheless, this is separate from
this patch, is more ambiguous due to the binary increase, and requires a
lut to be generated offline.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-09 18:41:03 -05:00
Ganesh Ajjanagadde a5202bc968 swresample/resample: improve bessel function accuracy and speed
This improves accuracy for the bessel function at large arguments, and this in turn
should improve the quality of the Kaiser window. It also improves the
performance of the bessel function and hence build_filter by ~ 20%.
Details are given below.

Algorithm: taken from the Boost project, who have done a detailed
investigation of the accuracy of their method, as compared with e.g the
GNU Scientific Library (GSL):
http://www.boost.org/doc/libs/1_52_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/bessel/mbessel.html.
Boost source code (also cited and licensed in the code):
https://searchcode.com/codesearch/view/14918379/.

Accuracy: sample values may be obtained as follows. i0 denotes the old bessel code,
i0_boost the approach here, and i0_real an arbitrary precision result (truncated) from Wolfram Alpha:
type "bessel i0(6.0)" to reproduce. These are evaluation points that occur for
the default kaiser_beta = 9.

Some illustrations:
bessel(8.0)
i0      (8.000000) = 427.564115721804739678191254
i0_boost(8.000000) = 427.564115721804796521610115
i0_real (8.000000) = 427.564115721804785177396791

bessel(6.0)
i0      (6.000000) = 67.234406976477956163762428
i0_boost(6.000000) = 67.234406976477970374617144
i0_real (6.000000) = 67.234406976477975326188025

Reason for accuracy: Main accuracy benefits come at larger bessel arguments, where the
Taylor-Maclaurin method is not that good: 23+ iterations
(at large arguments, since the series is about 0) can cause
significant floating point error accumulation.

Benchmarks: Obtained on x86-64, Haswell, GNU/Linux via a loop calling
build_filter 1000 times:
test: fate-swr-resample-dblp-44100-2626

new:
995894468 decicycles in build_filter(loop 1000),     256 runs,      0 skips
1029719302 decicycles in build_filter(loop 1000),     512 runs,      0 skips
984101131 decicycles in build_filter(loop 1000),    1024 runs,      0 skips

old:
1250020763 decicycles in build_filter(loop 1000),     256 runs,      0 skips
1246353282 decicycles in build_filter(loop 1000),     512 runs,      0 skips
1220017565 decicycles in build_filter(loop 1000),    1024 runs,      0 skips

A further ~ 5% may be squeezed by enabling -ftree-vectorize. However,
this is a separate issue from this patch.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-08 21:18:16 -05:00
Ganesh Ajjanagadde 1bed09a30e swresample: allow double precision beta value for the Kaiser window
Kaiser windows inherently don't require beta to be an integer. This was
an arbitrary restriction. Moreover, soxr does not require it, and in
fact often estimates beta to a non-integral value.

Thus, this patch allows greater flexibility for swresample clients.
Micro version is updated.

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-08 21:11:07 -05:00
Ganesh Ajjanagadde c8780822ba swresample/resample: speed up build_filter for Blackman-Nuttall filter
This uses the trigonometric double and triple angle formulae to avoid
repeated (expensive) evaluation of libc's cos().

Sample benchmark (x86-64, Haswell, GNU/Linux)
test: fate-swr-resample-dblp-44100-2626
old:
1104466600 decicycles in build_filter(loop 1000),     256 runs,      0 skips
1096765286 decicycles in build_filter(loop 1000),     512 runs,      0 skips
1070479590 decicycles in build_filter(loop 1000),    1024 runs,      0 skips

new:
588861423 decicycles in build_filter(loop 1000),     256 runs,      0 skips
591262754 decicycles in build_filter(loop 1000),     512 runs,      0 skips
577355145 decicycles in build_filter(loop 1000),    1024 runs,      0 skips

This results in small differences with the old expression:
difference (worst case on [0, 2*M_PI]), argmax 0.008:
max diff (relative): 0.000000000000157289807188
blackman_old(0.008): 0.000363951585488813192382
blackman_new(0.008): 0.000363951585488755946507

These are judged to be insignificant for the performance gain. PSNR to
reference file is unchanged up to second decimal point for instance.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-05 21:52:40 -05:00
Ganesh Ajjanagadde 9bec6d71a2 swresample/resample: speed up build_filter by 50%
This speeds up build_filter by ~ 50%. This gain should be pretty
consistent across all architectures and platforms.

Essentially, this relies on a observation that the filters have some
even/odd symmetry that may be exploited during the construction of the
polyphase filter bank. In particular, phases (scaled to [0, 1]) in [0.5, 1] are
easily derived from [0, 0.5] and expensive reevaluation of function
points are unnecessary. This requires some rather annoying even/odd
bookkeeping as can be seen from the patch.

I vaguely recall from signal processing theory more general symmetries allowing even greater
optimization of the construction. At a high level, "even functions"
correspond to 2, and one can imagine variations. Nevertheless, for the sake
of some generality and because of existing filters, this is all that is
being exploited.

Currently, this patch relies on phase_count being even or (trivially) 1,
though this is not an inherent limitation to the approach. This
assumption is safe as phase_count is 1 << phase_bits, and is hence a
power of two. There is no way for user API to set it to a nontrivial odd
number. This assumption has been placed as an assert in the code.

To repeat, this assumes even symmetry of the filters, which is the most common
way to get generalized linear phase anyway and is true of all currently
supported filters.

As a side note, accuracy should be identical or perhaps slightly better
due to this "forcing" filter symmetries leading to a better phase
characteristic. As before, I can't test this claim easily, though it may
be of interest.

Patch tested with FATE.

Sample benchmark (x86-64, Haswell, GNU/Linux):

test: swr-resample-dblp-44100-2626

new:
527376779 decicycles in build_filter(loop 1000),     256 runs,      0 skips
524361765 decicycles in build_filter(loop 1000),     512 runs,      0 skips
516552574 decicycles in build_filter(loop 1000),    1024 runs,      0 skips

old:
974178658 decicycles in build_filter(loop 1000),     256 runs,      0 skips
972794408 decicycles in build_filter(loop 1000),     512 runs,      0 skips
954350046 decicycles in build_filter(loop 1000),    1024 runs,      0 skips

Note that lower level optimizations are entirely possible, I focussed on
getting the high level semantics correct. In any case, this should
provide a good foundation.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-04 17:05:57 -05:00
wm4 80580bb240 swr: do not reject channel layouts that use channel 63
Channel layouts are essentially uint64_t, and every value is valid.
2015-10-28 19:25:49 +01:00
Ganesh Ajjanagadde c7131762c0 all: add const-correctness to qsort comparators
This adds const-correctness when needed for the comparators.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-25 10:07:20 -04:00
Ganesh Ajjanagadde 8507b98c10 avfilter,swresample,swscale: use fabs, fabsf instead of FFABS
It is well known that fabs and fabsf are at least as fast and sometimes
faster than the FFABS macro, at least on the gcc+glibc combination.
For instance, see the reference:
http://patchwork.sourceware.org/patch/6735/.
This was a patch to glibc in order to remove their usages of a macro.

The reason essentially boils down to fabs using the __builtin_fabs of
the compiler, while FFABS needs to infer to not use a branch and to
simply change the sign bit. Usually the inference works, but sometimes
it does not. This may be easily checked by looking at the asm.

This also has the added benefit of reducing macro usage, which has
problems with side-effects.

Note that avcodec is not handled here, as it is huge and
most things there are integer arithmetic anyway.

Tested with FATE.

Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-22 16:13:26 -04:00
Ganesh Ajjanagadde ef62f573ca swresample/swresample_internal: add av_warn_unused_result
This will trigger a few warnings that need to be fixed.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-15 22:27:23 -04:00
wm4 cdf4a13f86 swresample: slightly nicer debug output for auto matrix
This is the matrix that will be used for up/downmixing.
2015-10-15 20:16:13 +02:00
Ganesh Ajjanagadde f3fc103c6a doc/resampler, swresample/options: use proper capitalization
Proper names should be capitalized in all user facing API as far as
possible. The option names themselves have not been changed since:
1. We consistently keep option names in lower case.
2. Changing them would break existing scripts.
3. I suspect that we want to be similar to Sox and its relevant options.

The converse is also true: improper names should not be capitalized
generally.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-10 20:49:54 +02:00
Michael Niedermayer 1bc873acd6 swresample/resample: manually unroll the main loop in bessel()
About 10% faster

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-07 18:00:58 +02:00
Michael Niedermayer 6024c865ef swresample/resample: merge first iteration into init in bessel()
speedup of about 1%

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-07 17:33:00 +02:00
James Almer acdd672506 x86/audio_convert: fix clobbering of xmm registers
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-10-01 22:40:50 -03:00
Michael Niedermayer 7d636d02b1 swresample/dither_template: Add missing license header
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-27 13:09:10 +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
Michael Niedermayer 32f53958b8 swresample/swresample: Fix integer overflow in seed calculation
Fixes CID1322333

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-03 09:32:43 +02:00
Michael Niedermayer fb42e77516 swresample/swresample-test: Make layouts static const
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-30 13:10:11 +02:00
Ganesh Ajjanagadde 24e6729a04 swresample/dither: use integer arithmetic
This fixes a -Wabsolute-value reported by clang 3.5+ complaining about misuse of fabs() for integer absolute value.
An additional benefit is the removal of floating point calculations.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-23 23:19:31 +02:00
James Almer 5750d6c5e9 x86: move XOP emulation code back to x86inc
Only two functions that use xop multiply-accumulate instructions where the
first operand is the same as the fourth actually took advantage of the macros.

This further reduces differences with x264's x86inc.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-08-03 17:11:13 -03:00
James Almer f37a5dcb55 swresample/x86: add missing colon to labels
Silences warnings with Nasm

Signed-off-by: James Almer <jamrial@gmail.com>
2015-07-26 02:51:13 -03:00
Carl Eugen Hoyos a77401e1f7 lswr: Allow 64 channels internally. 2015-07-17 00:17:08 +02:00
Michael Niedermayer d4325b2fea swr: Remember previously set int_sample_format from user
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-22 18:34:39 +02:00
Michael Niedermayer 0dd2790df5 swresample/swresample: Clear delayed_samples_fixup in clear_context()
This probably makes no difference but its more proper

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-22 18:34:39 +02:00
Rob Sykes c70c6be225 swresample: soxr implementation for swr_get_out_samples()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-21 23:38:44 +02:00
Michael Niedermayer 5de3a589f1 swresample/swresample: Print used int_sample_fmt
Suggested-by: wm4
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-21 18:12:56 +02:00
Michael Niedermayer 4977692461 swresample: Choose 16bit internally only if input and output is 16bit or less
or if no rematrix and no resampling is performed and the input is 16bit
note reampling and rematrix itself always use more than 16bit internally
the "internal" sampling format is the format between these steps

Its unlikely the difference from this commit is audible in any case
unless there is some bug either before or after the change.
but multiple people prefer this and it slightly improves the precission
of computations.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-21 17:33:46 +02:00
Michael Niedermayer 56f0fe6b84 swr: Fix ASSERT_LEVEL warning
Found-by: cehoyos
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-08 20:16:06 +02:00
Clément Bœsch c5a08956a3 swresample: fix initilaize/initialize typo 2015-06-06 12:16:18 +02:00
Michael Niedermayer b14361486b swresample/resample: fix typos
Found-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-04 13:04:09 +02:00
Michael Niedermayer c3f87f7545 swresample/swresample: Cleanup on init failure.
This avoids leaks if the user doest call swr_close() after a failed init

Found-by: James Almer <jamrial@gmail.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-04 12:35:04 +02:00
Michael Niedermayer cc17b43d8d swresample: Add swr_get_out_samples()
Previous version reviewed-by: Pavel Koshevoy <pkoshevoy@gmail.com>
Previous version reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-04 05:37:32 +02:00
Michael Niedermayer 52acd22a7d libswresample/rematrix: Check for malloc errors
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-04 02:36:30 +02:00
Ganesh Ajjanagadde 196b885a5f swresample/dither: check memory allocation
check memory allocation in swri_get_dither()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-03 11:46:37 +02:00
Michael Niedermayer 02915602d9 swresample: Check the return value of resampler->init()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-03 01:05:19 +02:00
James Almer c16e99e3b3 x86: check for AV_CPU_FLAG_AVXSLOW where useful
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-01 00:15:35 +02:00
Rainer Hochecker adb7372f74 swr: fix alignment issue caused by 8ch sse functions
Fix crash when doing 8 ch conversion from apps compiled with MSVS
Thanks to Ronald for giving this hint:
https://ffmpeg.org/pipermail/ffmpeg-devel/2015-May/173049.html

Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-13 22:44:06 +02:00
Michael Niedermayer 223a859853 swresample/dither_template: Do not define macro functions to nothing
This avoids potential warnings

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-07 01:07:30 +02:00
Michael Niedermayer ff50b1b13b swresample/swresample-test: Randomly wipe out channel counts
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-12 22:21:53 +02:00
Michael Niedermayer 3c77bb5f23 swresample: Check channel layouts and channels against each other and print human readable error messages
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-12 22:21:34 +02:00
Michael Niedermayer 80a28c7509 swresample: Allow reinitialization without ever setting channel layouts 2015-04-12 22:21:34 +02:00
Michael Niedermayer d7b9cb2f7a swresample: Allow reinitialization without ever setting channel counts
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-12 22:21:34 +02:00
James Almer 43482bd1a5 swr/resample: use av_clip functions
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-05 22:46:40 +02:00
Michael Niedermayer 1a10134e20 swresample/swresample: Use av_mallocz_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-30 23:24:33 +02:00
Michael Niedermayer e16592c42e swresample/resample: Fix undefined shifts
Found-by: Clang -fsanitize=shift
Reported-by: Thierry Foucu <tfoucu@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-14 01:15:37 +01:00
Michael Niedermayer 4d00860ac7 swresample: Add prefix to soxr_resampler
also move declaration to header

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-27 19:20:43 +01:00
Michael Niedermayer c0e3b46118 swresample: add av_cold to init functions
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-21 00:33:09 +01:00
Michael Niedermayer 0cb95f9082 swresample/resample_template: Add () to protect the arguments of the OUT() macro
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-17 00:36:35 +01:00
Michael Niedermayer 37013fd018 swresample/swresample-test: Add () to protect uint_rand() argument
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-16 23:09:09 +01:00
James Almer f7ed997a6d x86/swr: make pack_8ch functions work with compilers without aligned stack
Signed-off-by: James Almer <jamrial@gmail.com>
2015-02-15 13:57:37 -03:00
Michael Niedermayer b74ecb82fa swresample/x86/rematrix_init: Check av_malloc* return codes, forward errors
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-09 10:15:56 +01:00
Michael Niedermayer 48ffaaaaef swresample/x86/rematrix_init: Use av_mallocz_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-09 10:15:56 +01:00
Michael Niedermayer 9d7ae72725 swresample: Use int instead of enum for fields which are accessed through AVOptions as int
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-02 23:27:26 +01:00
Michael Niedermayer c77cc2c176 swresample/dither: Cleanup number suffixes
The <<31 case needs LL

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-01 20:00:10 +01:00
Reimar Döffinger 6efd0ba977 swresample_internal.h: Move struct declaration before first use.
It seems more logical and works with more restricted C compilers
like tinycc.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2015-01-27 21:29:51 +01:00
James Almer 59ac93f6af x86/swr: add SSE/AVX unpack_6ch functions
int32/float only

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-01-12 15:40:03 -03:00
James Almer 6abf00d615 x86/swr: load constants outside the loop in pack_6ch functions
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-01-11 01:11:46 -03:00
James Almer 975ff6a3c6 x86/swr: disable pack_8ch functions on msvc/icl x86_32
Until a proper fix is committed.

Signed-off-by: James Almer <jamrial@gmail.com>
2014-12-31 16:38:33 -03:00
James Almer 5f14f9e984 x86/swr: add missing alignment check to pack_6ch functions
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2014-12-31 13:35:11 -03:00
James Almer 37b35feb64 x86/swr: add SSE2/AVX pack_8ch functions
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2014-12-30 23:05:27 -03:00
Michael Niedermayer 649c158e8c Add FFMPEG_VERSION into the binary libs
This simplifies identifying from which revision a binary of a lib came from

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-19 19:32:40 +01:00
Rob Sykes 4b6f225374 swresample/soxr_resample: fix error handling
Fixes CID1257659

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-13 21:12:56 +01:00
James Almer edff061fb0 x86/swr: add ff_float_to_int32_a_avx2
13797 decicycles in ff_float_to_int32_a_sse2, 32768 runs, 0 skips
8603 decicycles in ff_float_to_int32_a_avx2, 32766 runs, 2 skips

Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2014-11-07 15:01:35 -03:00
James Almer b385c4c6a3 x86/swr: replace sse4 instructions in pack_6ch with sse ones
There's no benefit from using blendps here except on CPUs with AVX, where
it's faster than shufps according to Intel's documentation.
As such, rename the sse4 functions to sse/sse2 and use shufps instead.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
2014-11-06 20:54:00 -03:00
Michael Niedermayer e4f8a973aa swresample: Fix swr_drop_output so it does not flush the buffers
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-04 17:17:23 +01:00
Michael Niedermayer f6bb2cd1b0 swresample/resample: fix invert_initial_buffer() after flush
Fixes: asan_heap-uaf_2071250_7_139.ogg
Fixes: assertion failure
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-16 22:35:27 +02:00
Michael Niedermayer 080c846f59 swresample: do not put multiple statements in one line
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-16 18:18:40 +02:00
Michael Niedermayer 344f8d307a swresample/audioconvert: Fix undefined behavior (left shift of negative value)
Fixes: asan_heap-oob_4da4f3_8_asan_heap-oob_4da4f3_419_scene1a.mm

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-08 05:35:06 +02:00
Michael Niedermayer 6b347f519d swresample/swresample: replace always true if() by av_assert0()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-06 01:29:15 +02:00
Michael Niedermayer f9fefa499f swresample/swresample: fix sample drop loop end condition
Fixes Ticket3985

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-06 01:29:06 +02:00
Reimar Döffinger 2c5c37ade1 libswresample: move condition to start of loop.
This avoids several issue like calculating sum/maxcoef
incorrectly due to adding up matrix entries that will
be overwritten, as well as out-of-range writes to
s->matrix if the maximum allowed number of channels is used.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2014-09-07 11:31:34 +02:00
Reimar Döffinger 284123d7fd Remove pointless if.
A branch to avoid some calculation seems unlikely to have any benefits.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2014-09-07 11:31:33 +02:00
Reimar Döffinger 2231d5b671 libswresample: Avoid needlessly large on-stack array.
We only actually need to use a tiny part of it.
Unfortunately we seem to have no real test coverage on
the code, so this is a bit risky.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2014-09-07 11:31:33 +02:00
Michael Niedermayer 7c51f5bd39 swr: aarch64 audio_convert and neon clobber test
Ported from avresample
Code by:  Mans Rullgard, Janne Grunau, Martin Storsjo

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-27 20:06:37 +02:00
Michael Niedermayer b7d5e016a3 swresample: Add AVFrame based API
Based on commit fb1ddcdc8f by Luca Barbato <lu_zero@gentoo.org>
Adapted for libswresample by Michael Niedermayer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-16 20:39:37 +02:00
Michael Niedermayer f4e814f787 swresample: check av_opt_set for failure in swr_alloc_set_opts()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-11 01:34:34 +02:00
Luca Barbato c4ac48c5a1 swresample: document the need to configure the context using AVOptions
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-11 00:35:56 +02:00
Michael Niedermayer 97f8c7a03e bump libpostproc and libswresample
this is needed / avoids some headaches  as one of their dependancies
(libavutil) was bumped

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-10 01:17:02 +02:00
Michael Niedermayer 74be0f82a7 swresample-test: make it independant of the internal SWR_CH_MAX
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-10 01:15:43 +02:00
Michael Niedermayer 05ff1a2c05 swresample/swresample: Treat mono as planar
This might in some cases improve performance.

Idea from: fbc0b86599
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-04 03:05:05 +02:00
Andreas Cadhalpun 39a6e02fd4 fix spelling errors
Reviewed-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-12 22:33:27 +02:00
Michael Niedermayer 52fafaf474 swresample/libswresample.v: hide ff_*
Found-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-12 18:40:17 +02:00
Timothy Gu 5b58692ed4 swresample: misc. doxy improvements
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-08 01:36:56 +02:00
Timothy Gu 064945b3aa swresample: organize functions into doxy groups
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-06 22:07:15 +02:00
Timothy Gu 81f47e272d swresample: better doxy for configuration-returning functions
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-06 22:06:51 +02:00
Timothy Gu 2711b4708a swresample: improve Doxygen introduction
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-06 21:41:31 +02:00
Timothy Gu 77c5f546e7 swresample: add SwrContext doxy
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-06 20:58:58 +02:00
Timothy Gu fc71434e84 swresample: add SwrDitherType doxy
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-06 20:58:41 +02:00
Timothy Gu c0d9b026f9 swresample: group all the option constants in a section in doxy
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-06 20:58:34 +02:00
Timothy Gu 0c58388211 swresample: grammar/capitalization fixes
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-06 20:46:06 +02:00
Timothy Gu 37715b4594 swresample: split option table to a separate file
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-06 03:45:46 +02:00
James Almer 9937362c54 x86/swr: use lavu helper macros to check CPU extensions
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-04 02:12:16 +02:00
James Almer 8279a15284 x86/swr: split audioconvert and rematrix DSP into separate files
Also rename resample_x86_dsp.c to resample_init.c

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-04 02:00:11 +02:00
James Almer 857cd1f33b swr: initialize only the necessary resample dsp functions
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-04 01:37:41 +02:00
James Almer b5f0eac068 swr: rename swresample_dsp init functions to swri_resample_dsp
The swresample_ prefix is not for internal functions

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-02 13:18:30 +02:00
James Almer 42a92a240d swr: remove obsolete resample prototypes
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-02 03:14:45 +02:00
James Almer 23a9edf531 Partially revert "swr: add prototypes for resample dsp functions"
Prototypes are not needed anymore now that the x86 functions don't
include resample_template.c

The DO_RESAMPLE_ONE macro is removed for that same reason as well.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-02 03:14:36 +02:00
James Almer c45b7f0d80 x86/swr: add ff_resample_{common, linear}_int16_xop
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-02 01:11:20 +02:00
James Almer 1a69224f44 x86/swr: add ff_resample_{common, linear}_float_fma
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-02 01:09:53 +02:00
James Almer dd2c9034b1 x86/swr: convert resample_{common, linear}_double_sse2 to yasm
Signed-off-by: James Almer <jamrial@gmail.com>

312531 -> 311528 dezicycles

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-01 17:57:36 +02:00
Ronald S. Bultje 847bb638c0 swr: convert resample_common/linear_int16_mmx2/sse2 to yasm.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-30 20:11:50 +02:00
Michael Niedermayer 418e5768c6 swresample/resample_template: move division out of loop for float/double swri_resample_linear()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-30 04:30:10 +02:00
Michael Niedermayer c5a405c4f0 swresample/resample_template: flip order of operations in swri_resample_linear() for 32bit
Fixes integer overflow

Found-by: BBB
Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-29 22:19:57 +02:00
Ronald S. Bultje faa1471ffc swr: rewrite resample_common/linear_float_sse/avx in yasm.
Linear interpolation goes from 63 (llvm) or 58 (gcc) to 48 (yasm)
cycles/sample on 64bit, or from 66 (llvm/gcc) to 52 (yasm) cycles/
sample on 32bit. Bon-linear goes from 43 (llvm) or 38 (gcc) to
32 (yasm) cycles/sample on 64bit, or from 46 (llvm) or 44 (gcc) to
38 (yasm) cycles/sample on 32bit (all testing on OSX 10.9.2, llvm
5.1 and gcc 4.8/9).

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-28 17:06:47 +02:00
Ronald S. Bultje ddb7b4435a swr: move dst_size == 0 handling outside DSP function.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-28 15:30:01 +02:00
Ronald S. Bultje 0dae193d3e swr: remove another forgotten division in DSP function.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-22 05:20:22 +02:00
Ronald S. Bultje cbf21628a5 swr: remove div/mod from DSP functions.
Also fix a bug with resample_compensation resetting dst_incr.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-18 14:15:52 +02:00
Michael Niedermayer 0608bc6502 swresample/audioconvert: fix () in FMT_PAIR_FUNC()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-18 03:13:37 +02:00
Ronald S. Bultje edf930472b swr: reindent.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-16 01:33:32 +02:00
Ronald S. Bultje 083cd3d1f7 swr: compile mmx2 s16p functions only on x86-32.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-15 13:34:53 +02:00
James Almer 7f4dfbd080 swr: add prototypes for resample dsp functions
Should fix compilation failures with MSVC and any other compiler
without inline asm support.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-15 01:33:17 +02:00
Ronald S. Bultje ada8f9c046 swr: remove obsolete function prototypes.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-15 00:07:25 +02:00
Ronald S. Bultje 7128a35f8c swr: split out DSP functions.
DSP bits of swri_resample go into their own mini-DSP functions; DSP
init goes from a per-call branch in multiple_resample to a proper
DSP init routine; x86 bits go into x86/; swri_resample() moves out of
resample_template.c into resample.c because it's independent of DSP
code or sample type; multiple_resample() is simplified.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-14 20:21:39 +02:00
Michael Niedermayer 4411928c64 swresample/resample: replace assert by av_assert
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-14 16:33:09 +02:00
Ronald S. Bultje b785c62681 swr: handle initial negative sample index outside DSP function.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-14 14:36:18 +02:00
Ronald S. Bultje 6b9685de3a swr: remove unnecessary assignment.
I don't see dst_incr/dst_incr_frac ever being changed from their
initial value (which is the inverse of this operation), so it seems
to me that this is a no-op.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-14 04:30:53 +02:00
Ronald S. Bultje f341340552 swr: handle 64bit overflow check in multiple_resample().
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-09 15:24:51 +02:00
Lou Logan 88f2586adb fix various typos
Signed-off-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-03 10:58:19 -08:00
Ronald S. Bultje cdfd9717ed swr: move compensation_distance handling to swri_resample caller.
I think there's an off-by-one in terms of the switchpoint where we
switch from dst_incr to ideal_dst_incr, I don't think that's a massive
issue, but just be aware of that. It's probably trivial to prevent but
I don't care.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

I could not reproduce any off by 1 error, results are bit exact (michael)
2014-06-02 15:06:24 +02:00
Michael Niedermayer 2c23f87c85 swr/resample_template: prevent end_index from overflowing and add check for delta_frac overflow
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-02 00:57:08 +02:00
Ronald S. Bultje 9b53853756 Rewrite main resampling loop (common and linear).
This removes a branch at a performance-sensitive point (in the middle
of the loop). In fate-swr-resample-s32p-8000-2626, this makes the code
about 10% faster. It also simplifies the loops, allowing us to rewrite
it in yasm at some later point.

The compensation_distance != 0 code and index < 0 code are still kind
of hairy. For compensation_distance != 0, this should likely be handled
in the caller, so that it calls swri_resample twice (once until the
dst_incr switch-point, and once with the remainder of the samples). For
index < 0, the code should probably be rewritten to break out of the
loop once sample_index >= 0, and then resume (e.g. as a tail-call) to
the common or linear resampling loops.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-02 00:47:54 +02:00
James Almer a9bf713d35 swresample: add swri_resample_float_avx
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-16 05:27:03 +02:00
Michael Niedermayer 96cb4c8718 swresample: swr_close()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-15 18:27:23 +02:00
Matt Oliver 1898c2f49d inline asm: fix arrays as named constraints.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-07 15:02:45 +02:00
James Almer 4cdea92976 swresample/resample: add missing xmm clobbers
Might fix fate-swr on ICL

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-07 01:32:40 +02:00
Michael Niedermayer 68c3e6025f Fix convertion typos
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-29 00:09:08 +02:00
James Almer cdac3ab59f swresample: add swri_resample_double_sse2
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-25 16:46:07 +02:00
Michael Niedermayer 291d464161 swresample: fix AV_CH_LAYOUT_STEREO_DOWNMIX input
Fixes Ticket 3542

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-24 01:25:46 +02:00
Michael Niedermayer 2b58c9c945 swresample/resample_template: try to consider src_size more exactly
This should avoid slight differences in the output causes by input
size alignment differences between archs

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-15 06:35:35 +02:00
Michael Niedermayer 5e379cd3ee swresample/resample: simplify index/consumed calculation for the filter = 1 case
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-14 02:23:04 +02:00
Michael Niedermayer 6c8ee74af2 swresample/resample: Fix fractional part of index in the filter_size = 1 filters = 1 case
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-14 02:22:17 +02:00
Michael Niedermayer 5027f39712 swresample/resample: use av_malloc_array() where appropriate
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-08 00:29:26 +02:00
Michael Niedermayer a5290cb1ac swresample/dither: use av_malloc_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-08 00:29:20 +02:00
Michael Niedermayer f9158b01d0 swresample/resample: Limit filter length
Related to CID1197063

The limit choosen is arbitrary and much larger than what makes sense.
It avoids the need for checking arithmetic operations with the length for overflow

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-08 00:25:49 +02:00
James Almer 63dbba655e swresample/resample: sse float linear interpolation
About two times faster

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-24 02:34:02 +01:00
James Almer fa25c4c400 swresample/resample: mmx2/sse2 int16 linear interpolation
About three times faster

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-24 02:33:16 +01:00
James Almer 32291ba6ea swresample: add swri_resample_float_sse
At least two times faster than the C version.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-20 06:01:06 +01:00
Matt Oliver 8236747511 Automatically change MANGLE() into named inline asm operands when direct symbol reference in inline asm are not supported.
This is part of the patch-set for intel C inline asm on windows support

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-18 23:39:30 +01:00
James Almer 3d48cbc56c swresample: reuse COMMON_CORE asm where possible
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-18 16:08:34 +01:00
James Almer 7c8bf09edd swresample: change COMMON_CORE_INT16 asm from SSSE3 to SSE2
pshuf+paddd is slightly faster than phaddd.
The real gain is in pre-ssse3 processors like AMD K8 and K10, which get
a big boost in performance compared to the mmxext version

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-18 15:00:50 +01:00
Michael Niedermayer 6c6e4dd139 swr: check that the context for swr_convert() has been initialized
Reviewed-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-24 08:23:42 +01:00
Michael Niedermayer a66be60888 swresample: add swr_is_initialized()
Idea-from/based-on: 7e86c27b4e
Reviewed-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-24 08:23:22 +01:00
Michael Niedermayer f284e2a58a swresample: factorize clear_context() out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-22 21:36:30 +01:00
Reimar Döffinger e535897fad Fix libswresample compilation with Apple Neon assembler.
Signed-off-by: Carl Eugen Hoyos <cehoyos@ag.or.at>
2014-02-17 17:40:10 +01:00
Martin Storsjö 3dd04cbcf7 swresample: Add arm&x86 clobber tests
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-18 18:38:57 +01:00
Reimar Döffinger cbeaf67888 Avoid using empty macro arguments.
These are not supported by all compilers (gcc 2.95 but also older SPARC
compilers, see gcc bug #33304 for example), and there is no real need for them.
One use of this feature remains in libavdevice/v4l2.c which can't be
replaced quite as easily.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2013-12-31 12:19:59 +01:00
Stefano Sabatini 334e2e2363 lavu,lavc,lswr: do not hardcode AV_SAMPLE_FMT_NB value when setting sample format max value
The constant may change in libavutil but the library may be compiled
against an older version, thus rejecting a value which is otherwise
supported by the new libavutil.

INT_MAX is used here to denote the max allowed value for a sample format.

The opt-test code is changed to provide a valid reference example.
2013-12-26 11:35:27 +01:00
James Almer 56572787ae Add Windows resource file support for shared libraries
Originally written by James Almer <jamrial@gmail.com>

With the following contributions by Timothy Gu <timothygu99@gmail.com>

* Use descriptions of libraries from the pkg-config file generation function
* Use "FFmpeg Project" as CompanyName (suggested by Alexander Strasser)
* Use "FFmpeg" for ProductName as MSDN says "name of the product with which the
  file is distributed" [1].
* Use FFmpeg's version (N-xxxxx-gxxxxxxx) for ProductVersion per MSDN [1].
* Only build the .rc files when --enable-small is not enabled.

[1] http://msdn.microsoft.com/en-us/library/windows/desktop/aa381058.aspx

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-05 23:42:07 +01:00
Michael Niedermayer a6af5da7a2 swresample: use the internal buffer for resampling the last few samples
Fixes out of array read
Fixes Ticket3193

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-04 20:40:42 +01:00
Nicolas George 4a640a6ac8 lswr: fix assert failure on unknown layouts. 2013-11-03 10:30:37 +01:00
Stefano Sabatini 904c89ac1b lswr/swresample: convert ocl and icl options to AV_OPT_TYPE_CHANNEL_LAYOUT
Improve interface flexibility. In particular makes it possible to set
channel layout through symbolic names using the av_opt_set() interface.
2013-10-17 18:09:54 +02:00
Ronald S. Bultje ad75d2b590 x86: Fix compilation with nasm on PPC & OS/2
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-08 12:36:19 +02:00
Clément Bœsch a89e9ad1c8 swr: fix example code and doxy indent. 2013-09-29 23:37:46 +02:00
Michael Niedermayer 9078b40d35 swresample: replace 2 av_free() by av_freep()
avoids leaving stale pointers in memory

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-16 22:44:15 +02:00
Michael Niedermayer c56d4dab03 swr/rematrix: Fix handling of AV_CH_LAYOUT_STEREO_DOWNMIX output
Fixes Ticket2859

Note, testcases related to the downmix channels are welcome.
(id like to make sure this is working correctly now, as obviously it didnt
 work before ...)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-20 16:56:51 +02:00
Michael Niedermayer 6dfffe9200 swr: clean layouts before checking sanity
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-20 16:49:31 +02:00
Michael Niedermayer 7ac12599fe swresample: fix negative rematrix volumns
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-22 03:24:22 +02:00
Michael Niedermayer e2b718464e swresample: Make rematrix maxvalue user settable
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-22 03:23:54 +02:00
Timothy Gu a9bbf59be7 cosmetics: Fix "dont" "wont" "doesnt" typos
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-29 02:31:16 +02:00
Michael Niedermayer ca2818b881 swresample/x86/audio_convert: add emms to CONV
Might fix Ticket1874

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-18 02:26:36 +02:00
Michael Niedermayer d62030ffca swresample/rematrix_template: Fix integer overflow in mix8to2
Fixes: CID1030352
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-10 03:03:17 +02:00
Michael Niedermayer b04bbe6b86 swresample/rematrix_template: Fix integer overflow in mix6to2
Fixes: CID1030351
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-10 03:03:12 +02:00
Michael Niedermayer 3289670142 swr: dont treat 32 and 24 as equal in simple copy check
Fixes dithering from 32 to 24 bit

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-05 03:06:34 +02:00
Michael Niedermayer 6bc4e36ba7 swr: set scale for 32->32/24 dither
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-05 03:06:34 +02:00
Paul B Mahol 0804171104 swresample: set flags & description and add documentation for output_sample_bits
Allows users to actually use such option.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-06-04 21:57:25 +00:00
Michael Niedermayer 495bf1b685 swr: Fix dithering of s16 with SIMD
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-04 23:50:45 +02:00
Michael Niedermayer 4cfc92081d swr: add native_simd_one
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-04 23:50:45 +02:00
Michael Niedermayer b84de51f54 swresample/rematrix: add S32 mixing code
Needed for dithering S32

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-04 15:12:11 +02:00
Michael Niedermayer f3c638eac1 wresample/rematrix_template: fix internal types
Should make no difference, but future commits will need it

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-04 15:12:11 +02:00
Michael Niedermayer 6e29f39252 swr/rematrix: use av_calloc()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-15 20:31:06 +02:00
Michael Niedermayer 03148fd174 buildsys: only include log2_tab per library for shared builds
Fix linking failures with -all_load due to multiple log2_tabs

Signed-off-by: Carl Eugen Hoyos <cehoyos@ag.or.at>
2013-03-04 12:25:02 +01:00
Rob Sykes dc666d360b soxr: libsoxr 0.1.1 support
Libsoxr 0.1.1 will be out very soon; no changes planned beyond what's currently in git.
It includes a couple of fixes (not affecting FFmpeg's current usage) and a minor API change (but remains ABI compatible).

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-01 14:38:02 +01:00
Michael Niedermayer 35aaa306ac swr: make the default of nopts for first_pts actually work
Fixes Ticket2210

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-25 04:39:26 +01:00
Michael Niedermayer 8b3affda87 swr: support a seperate output sample bits.
This avoids user apps having to mangle dither scale. for pcm24

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-24 20:31:56 +01:00
Michael Niedermayer 2abbe6d07a swr: add duplicate cutoff for compatibility
Based on
	commit 50f4337a2f
	Author: Justin Ruggles <justin.ruggles@gmail.com>

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-24 20:31:56 +01:00
Michael Niedermayer 21cd905cd4 swr: check channel layouts before using them.
Fixes out of array accesses

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-13 17:50:24 +01:00
Michael Niedermayer b5f544a0f9 swr: Dont use floats for S32->S32 when possible
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-04 04:11:46 +01:00
Michael Niedermayer be989f9236 swr: reorder init code to make rematrix status available earlier
This also makes some other fields available earlier which may
be usefull one day

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-04 04:05:59 +01:00
Michael Niedermayer 24244cec2f swr-test: Fix clip to 32bit
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-04 04:05:59 +01:00
Michael Niedermayer b8c55590d5 swr/resample: fix integer overflow, add missing cast
The effects of this are limited to numeric errors in the output

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-04 04:05:59 +01:00
Michael Niedermayer 91debec976 swr/resample: fix filter rounding and cliping for s32
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-04 04:05:59 +01:00
Michael Niedermayer f9abeecd94 swr/ build_filter: use av_calloc() fix buffer overflow
Fixes integer & buffer overflow

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-27 05:58:47 +01:00
Michael Niedermayer 167af704ea swr: limit phase_shift to a less insane value.
This prevents potential crashes and out of memory issues if
the user manually sets such insane values.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-27 05:54:52 +01:00
Michael Niedermayer 00cae86754 swr: support first_pts
Trolled-by: Daemon404
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-21 00:52:14 +01:00
Michael Niedermayer cc4a41727e swr: fix "may be used uninitialized in this function" warnings
The uninitialized use implicates 0 channels, which is unlikely
to reach this function but fixed anyway in this commit.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-20 17:09:48 +01:00
Michael Niedermayer 55d0528669 swr/dither: fix division by 0
Found-by: Daemon404
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-14 02:57:00 +01:00
Michael Niedermayer d676598f87 swr: fix handling of timestamps that cause multiple drops or silence injections
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-13 18:39:06 +01:00
Michael Niedermayer a34aee4646 swr: limit buffer size for silence injection
This reduces memory usage for unreasonable large silence injections

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-13 16:04:41 +01:00
Michael Niedermayer b481d09bd9 swr: limit buffer size for discarding.
This prevents insane memory usage in case of insane input values.
Untested due to lack of a testcase that causes such insane allocation

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-13 16:04:41 +01:00
Michael Niedermayer db4e0ecaf0 swr: move silence buffer to context to avoid per use malloc/free
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-13 15:28:00 +01:00
Michael Niedermayer dc6588421e swr: move buffer used to discard sample to context
This avoids the need to allocate & free to repeatly

Fixes Ticket2122

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-13 15:28:00 +01:00
Michael Niedermayer c8737d348b swr: work with 4 noise shaping coeffs at a time
63->38 kcycles

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-12 19:17:08 +01:00
Michael Niedermayer 93bc0f0180 swr/noise_shaping_data: pad coeffs to multiple of 4 when they are 1 below
This allows using code working with 4 at a time

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-12 19:09:54 +01:00
Michael Niedermayer ef7fdc8cff swr: use a local variable for ns_coeffs
maybe a very tiny bit faster

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-12 17:43:29 +01:00
Michael Niedermayer 68ff7d265f swr: use local variable for ns_errors
71 -> 63 kcycles

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-12 17:43:29 +01:00
Michael Niedermayer b5d9e5d06c swr: minor simplification for the noise shaping pos update
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-12 17:43:29 +01:00
Michael Niedermayer a74548521b swr: check that allocation of in/out_convert succeeded
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-10 20:27:07 +01:00
Michael Niedermayer e5a736261b swr: Use a temporary buffer for dither/Noise shaping when the input is read only
This avoids copying the input

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-10 18:51:30 +01:00
Michael Niedermayer 2eec98125e swr: mark noise data for noise shaping as const
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-10 18:07:32 +01:00