aboutsummaryrefslogtreecommitdiffstats
path: root/libswresample/rematrix.c
Commit message (Collapse)AuthorAgeFilesLines
* all: fix typos found by codespellTimo Rothenpieler21 hours1-2/+2
|
* swresample/rematrix: ConstifyAndreas Rheinhardt2025-07-031-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swresample/rematrix: Use correct function pointer types for callsAndreas Rheinhardt2025-07-031-15/+15
| | | | | | | | | | | | | | | | | | Calling a function via a different function pointer type is undefined behavior (C11, 6.3.2.3 8); two pointer parameters of different type are not equivalent in this regard, although it happens to work in practice; the current code relies on this. This patch brings the code in line with the spec. This fixes the following FATE-tests when run with Clang-UBSan: ac3-fixed-encode-2 audiomatch-afconvert-{16000,44100}-mono-he-{adts,m4a} audiomatch-dolby-44100-mono-he-mp4 filter-metadata-avf-aphase-meter-mono filter-pan-{downmix1,downmix2,mono2,stereo2,stereo3,stereo4,upmix1,upmix2} lavf-dv_{pal,ntsc} matroska-encoding-delay The error was something like src/libswresample/rematrix.c:621:17: runtime error: call to function sum2_float through pointer to incorrect function type 'void (*)(void *, const void *, const void *, void *, int, int, int) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libswresample/rematrix: add support for custom order channel layoutsJames Almer2025-02-051-12/+17
| | | | | | Limited to the same channels as a native layout, but not constrained by channel ordering. Signed-off-by: James Almer <jamrial@gmail.com>
* swresample/rematrix: split filling the matrix array into its own functionJames Almer2025-02-041-96/+106
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-311-0/+1
| | | | | | | | | | | 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>
* avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUTJames Almer2024-03-071-46/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swresample/swresample: add a used channel layout option using the new APIJames Almer2023-02-191-1/+1
| | | | | | Replaces the "used channel count" option, which is now deprecated. Signed-off-by: James Almer <jamrial@gmail.com>
* swresample/rematrix: support mixing top front left/right channelsJames Almer2022-11-031-0/+24
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* all: Replace if (ARCH_FOO) checks by #if ARCH_FOOAndreas Rheinhardt2022-06-151-2/+3
| | | | | | | | | | | | | | | | | | 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>
* swresample/rematrix: fix typo in clean_layout()James Almer2022-03-281-1/+1
| | | | | | av_channel_layout_index_from_channel() takes an AVChannel value, not a mask. Signed-off-by: James Almer <jamrial@gmail.com>
* swresample: convert to new channel layout APIJames Almer2022-03-151-79/+153
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swresample/rematrix: handle 22.2 as a 9 channel layoutJan Ekström2020-08-181-1/+1
| | | | | | | | | | | 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.
* swresample/rematrix: treat 22.2 as 5.1 (back) when mixingJan Ekström2020-08-041-0/+10
| | | | | | | | | 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.
* swresample/matrix: switch internal clean_layout function to not drop high bitsJan Ekström2020-08-041-1/+1
| | | | | | 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.
* swresample: Use channel count in rematrix initializationMarcin Gorzel2018-07-261-2/+2
| | | | | | | | 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>
* swresample/rematrix: fix update of channel matrix if input or output layout ↵Tobias Rapp2018-02-191-2/+4
| | | | | | | | | 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>
* lswr/rematrix: Support s32p.Carl Eugen Hoyos2017-11-011-5/+14
| | | | Fixes ticket #6785.
* build: Generalize yasm/nasm-related variable namesDiego Biurrun2017-06-211-1/+1
| | | | | | | | None of them are specific to the YASM assembler. (Cherry-picked from libav commit 39e208f4d4756367c7cd2d581847e0c1b8a429c1) Signed-off-by: James Almer <jamrial@gmail.com>
* lswr/rematrix: Remove an aggressive loop optimization.Carl Eugen Hoyos2017-02-251-3/+4
| | | | | Fixes undefined behaviour and a gcc warning: libswresample/rematrix.c:376:47: warning: iteration 64 invokes undefined behavior
* swresample/rematrix: Fix float part of swr_set_matrix()Vodyannikov Aleksandr2016-10-261-4/+2
| | | | | | Fixes Ticket #5897. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample: Add swr_build_matrix()Michael Niedermayer2016-09-271-71/+86
| | | | | | | API and Doxy documentation is taken from avresample_build_matrix() Fixes: Ticket5780 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample: Use double and float for matrixes for best quality and speedMichael Niedermayer2016-09-271-1/+10
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample/rematrix: Use clipping s16 rematrixing if overflows are possibleMichael Niedermayer2016-05-151-3/+16
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample/rematrix: Use error diffusion to avoid error in the DC component ↵Michael Niedermayer2016-05-151-3/+9
| | | | | | | | | | | 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>
* swresample: slightly nicer debug output for auto matrixwm42015-10-151-2/+7
| | | | This is the matrix that will be used for up/downmixing.
* libswresample/rematrix: Check for malloc errorsMichael Niedermayer2015-06-041-0/+8
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: Allow reinitialization without ever setting channel layoutsMichael Niedermayer2015-04-121-2/+2
|
* swresample/x86/rematrix_init: Check av_malloc* return codes, forward errorsMichael Niedermayer2015-02-091-1/+2
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* libswresample: move condition to start of loop.Reimar Döffinger2014-09-071-4/+6
| | | | | | | | | 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>
* Remove pointless if.Reimar Döffinger2014-09-071-3/+1
| | | | | | A branch to avoid some calculation seems unlikely to have any benefits. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* libswresample: Avoid needlessly large on-stack array.Reimar Döffinger2014-09-071-5/+9
| | | | | | | | 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>
* swresample: fix AV_CH_LAYOUT_STEREO_DOWNMIX inputMichael Niedermayer2014-04-241-0/+5
| | | | | | Fixes Ticket 3542 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* lswr: fix assert failure on unknown layouts.Nicolas George2013-11-031-2/+2
|
* swr/rematrix: Fix handling of AV_CH_LAYOUT_STEREO_DOWNMIX outputMichael Niedermayer2013-08-201-3/+5
| | | | | | | | | | 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>
* swr: clean layouts before checking sanityMichael Niedermayer2013-08-201-1/+2
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: fix negative rematrix volumnsMichael Niedermayer2013-07-221-1/+1
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: Make rematrix maxvalue user settableMichael Niedermayer2013-07-221-2/+11
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr: add native_simd_oneMichael Niedermayer2013-06-041-0/+1
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample/rematrix: add S32 mixing codeMichael Niedermayer2013-06-041-0/+15
| | | | | | Needed for dithering S32 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr/rematrix: use av_calloc()Michael Niedermayer2013-04-151-3/+3
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr/rematrix: move templating parameters to template itself.Clément Bœsch2012-11-151-33/+8
|
* Replace rest of libavutil/audioconvert.h with libavutil/channel_layout.hPaul B Mahol2012-11-131-1/+1
| | | | | | Also remove it in once case when it is not needed. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* swr/rematrix: fix C99 left shift overflowMichael Niedermayer2012-10-141-1/+1
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr: add av_cold to init/free functionsMichael Niedermayer2012-09-091-3/+3
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr/auto_matrix: treat a single channel as mono instead of failingMichael Niedermayer2012-09-081-0/+7
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr/auto_matrix: treat stereo downmix like stereo.Michael Niedermayer2012-09-081-0/+2
| | | | | Based on code by John Stebbins Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr/auto_matrix: add clean layout functionMichael Niedermayer2012-09-081-1/+9
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr/auto_matrix: move layouts to local variablesMichael Niedermayer2012-09-081-35/+37
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Add Dolby/DPLII downmix support to libswresampleMichael Niedermayer2012-09-071-6/+42
| | | | | | Based on code by John Stebbins <jstebbins.hb@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>