Commit Graph

82 Commits

Author SHA1 Message Date
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
James Almer 65ddc74988 avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUT
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
James Almer 223c70cf1d swresample/swresample: add a used channel layout option using the new API
Replaces the "used channel count" option, which is now deprecated.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-19 18:28:45 -03:00
James Almer c79b16306f swresample/rematrix: support mixing top front left/right channels
Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-03 19:39:52 -03:00
Andreas Rheinhardt 40e6575aa3 all: Replace if (ARCH_FOO) checks by #if ARCH_FOO
This is more spec-compliant because it does not rely
on dead-code elimination by the compiler. Especially
MSVC has problems with this, as can be seen in
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296373.html
or
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/297022.html

This commit does not eliminate every instance where we rely
on dead code elimination: It only tackles branching to
the initialization of arch-specific dsp code, not e.g. all
uses of CONFIG_ and HAVE_ checks. But maybe it is already
enough to compile FFmpeg with MSVC with whole-programm-optimizations
enabled (if one does not disable too many components).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-15 04:56:37 +02:00
James Almer 5ee198f9aa swresample/rematrix: fix typo in clean_layout()
av_channel_layout_index_from_channel() takes an AVChannel value, not a mask.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-28 00:07:42 -03:00
James Almer 8a5896ec1f swresample: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:46 -03:00
Jan Ekström 1c7e55dd50 swresample/rematrix: handle 22.2 as a 9 channel layout
This is as far as 22.2 follows the same channel order as
WaveFormatExtensible's channel mask (and the AV_CH_* defines).

After LFE2 the side channels would follow, but that offset of
one stops us from utilizing them without further tweaks.

This change was verified by using swresample to downmix to 5.1,
and then feeding that to WASAPI.
2020-08-18 22:47:35 +03:00
Jan Ekström f5390a9f86 swresample/rematrix: treat 22.2 as 5.1 (back) when mixing
Only this sub-set of channels actually follows the bit mask order
in the official 22.2 channel mapping. Additionally, the 5.1 channels
are there for backwards compatibility with the previous system.

This enables the utilization of 22.2 content until a proper down/up
matrix is added into swresample.
2020-08-04 00:17:56 +03:00
Jan Ekström 2fd8add1ba swresample/matrix: switch internal clean_layout function to not drop high bits
These bits are utilized by channel layouts such as 22.2. If those
are dropped, the returned channel layout is no longer a match
against the AV_CH_LAYOUT define when returned from this function.
2020-08-04 00:17:56 +03:00
Marcin Gorzel 8b710ea5e7 swresample: Use channel count in rematrix initialization
Rematrixing supports up to 64 channels. However, there is only a limited number of channel layouts defined. Since the in/out channel count is currently obtained from the channel layout, for undefined layouts (e.g. for 9, 10, 11 channels etc.) the rematrixing fails.

This patch changes rematrix init methods to use in (used) and out channel count directly instead of computing it from channel layout.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-07-26 02:42:42 +02:00
Tobias Rapp 6325bd3717 swresample/rematrix: fix update of channel matrix if input or output layout is undefined
Prefer direct in/out channel count values over channel layout, when
available. Fixes a pan filter bug (ticket #6790).

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-02-19 08:32:25 +01:00
Carl Eugen Hoyos ff994c2aaa lswr/rematrix: Support s32p.
Fixes ticket #6785.
2017-11-01 01:04:43 +01:00
Diego Biurrun fd502f4f5f build: Generalize yasm/nasm-related variable names
None of them are specific to the YASM assembler.

(Cherry-picked from libav commit 39e208f4d4)

Signed-off-by: James Almer <jamrial@gmail.com>
2017-06-21 17:00:29 -03:00
Carl Eugen Hoyos 353f509ee3 lswr/rematrix: Remove an aggressive loop optimization.
Fixes undefined behaviour and a gcc warning:
libswresample/rematrix.c:376:47: warning: iteration 64 invokes undefined behavior
2017-02-25 18:53:34 +01:00
Vodyannikov Aleksandr 9445e7e6d5 swresample/rematrix: Fix float part of swr_set_matrix()
Fixes Ticket #5897.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-26 19:27:22 +02:00
Michael Niedermayer 23c0779cda swresample: Add swr_build_matrix()
API and Doxy documentation is taken from avresample_build_matrix()
Fixes: Ticket5780

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-27 12:54:00 +02:00
Michael Niedermayer 740f5105d5 swresample: Use double and float for matrixes for best quality and speed
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-27 12:53:25 +02:00
Michael Niedermayer 2f76157eb0 swresample/rematrix: Use clipping s16 rematrixing if overflows are possible
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-15 22:25:34 +02:00
Michael Niedermayer 7fe81bc4f8 swresample/rematrix: Use error diffusion to avoid error in the DC component of the matrix
This fixes the sum of the integer coefficients ending up summing to a value
larger than the value representing unity.

This issue occurs with qN0.dts when converting to stereo

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-15 18:36:53 +02: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
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
Michael Niedermayer 80a28c7509 swresample: Allow reinitialization without ever setting channel layouts 2015-04-12 22:21:34 +02: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
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 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
Nicolas George 4a640a6ac8 lswr: fix assert failure on unknown layouts. 2013-11-03 10:30:37 +01: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
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 6e29f39252 swr/rematrix: use av_calloc()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-15 20:31:06 +02:00
Clément Bœsch 5e68bf9b92 swr/rematrix: move templating parameters to template itself. 2012-11-15 21:24:49 +01:00
Paul B Mahol 1acd2f6ba7 Replace rest of libavutil/audioconvert.h with libavutil/channel_layout.h
Also remove it in once case when it is not needed.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2012-11-13 13:21:21 +00:00
Michael Niedermayer 555f352f99 swr/rematrix: fix C99 left shift overflow
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-14 03:48:05 +02:00
Michael Niedermayer 31a797eb28 swr: add av_cold to init/free functions
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-09 02:26:20 +02:00
Michael Niedermayer 0e78e575ed swr/auto_matrix: treat a single channel as mono instead of failing
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-08 21:32:24 +02:00
Michael Niedermayer f8d74cbdc3 swr/auto_matrix: treat stereo downmix like stereo.
Based on code by John Stebbins
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-08 21:12:40 +02:00
Michael Niedermayer c8ffab06f4 swr/auto_matrix: add clean layout function
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-08 21:10:19 +02:00
Michael Niedermayer ebc854e4e9 swr/auto_matrix: move layouts to local variables
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-08 20:58:57 +02:00
Michael Niedermayer c5278cb84f Add Dolby/DPLII downmix support to libswresample
Based on code by John Stebbins <jstebbins.hb@gmail.com>

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-07 00:41:49 +02:00
Michael Niedermayer 2dd2e42951 swr: update rematrix coeffs to match AC-3
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-07 00:29:06 +02:00
Michael Niedermayer 7309451d73 swr: fix warning: passing argument 2 of s->mix_any_f from incompatible pointer type
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-07-02 17:33:27 +02:00
Michael Niedermayer 04b5eb47a6 swr: fix mix* related function pointer warnings
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-07-02 17:23:22 +02:00
Stefano Sabatini 065851ffac lswr/rematrix: specify explicitly the name of the unsupported channel layouts
Help debugging.
2012-06-21 12:47:47 +02:00
Michael Niedermayer 728f86edfc swr: mix_2_1_int16_mmx/sse
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-06-12 17:49:12 +02:00