summaryrefslogtreecommitdiff
path: root/libswresample/swresample.c
Commit message (Collapse)AuthorAge
* avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUTJames Almer2024-03-07
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swresample/swresample: Constify swr_convert()Andreas Rheinhardt2024-03-02
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swr/swresample: avoid reapplication of firstptsGyan Doshi2023-12-18
| | | | | | | | | | | | | | | | | | | | | | During a resampling operation where 1) user has specified first_pts 2) SWR_FLAG_RESAMPLE is not set initially (directly or otherwise) 3) first_pts has been fulfilled (always using hard compensation) then upon first encountering a delay where a soft compensation is required, swr_set_compensation will lead to another init of swr which will reset outpts to the specified firstpts thus leading to an output frame having its pts = firstpts. When the next input frame is received, swr will see a large delay and inject silence from firstpts to the current frame's pts. This can lead to severe desync and in worst case, loss of audio playback. Parameter firstpts initialized to AV_NOPTS_VALUE in swr_alloc and then checked in swr_init to avoid resetting outpts, thus avoiding reapplication of firstpts. Fixes #4131.
* libswresample/swresample: avoid s16p internal transfer formatPaul B Mahol2023-09-25
| | | | | | | | | | | | | | | | | | Instead use float one by default for sample rate conversions. The s16p internal transfer format produces visible and hearable quantization artifacts. Signed-off-by: Paul B Mahol <onemda@gmail.com> for S8 we continue to use S16 as it should have enough precision Fate is adjusted so bitexactness is maintained between mips/arm/x86 if more tests became bit-inexact on some platform, the same change can be done to them The use of higher precision and float intermediates inevitably leads to more differences between platforms. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libswresample: Prevent out of bounds.Eli Kobrin2023-08-02
| | | | | | | | | We've been fuzzing torchvision with [sydr-fuzz](https://github.com/ispras/oss-sydr-fuzz) and found out of bounds error in ffmpeg project at audioconvert.c:151. To prevent error we need to fix checks for in and out fmt in swr_init. Signed-off-by: Eli Kobrin <kobrineli@ispras.ru> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample/swresample: add a used channel layout option using the new APIJames Almer2023-02-19
| | | | | | Replaces the "used channel count" option, which is now deprecated. Signed-off-by: James Almer <jamrial@gmail.com>
* swsresample/swresample: error out on invalid layoutsJames Almer2022-09-14
| | | | | | | | | | | If it's unsupported or invalid, then there's no point trying to rebuild it using a value that may have been derived from the same layout to begin with. Move the checks before the attempts at copying the layout while at it. Fixes ticket #9908. Signed-off-by: James Almer <jamrial@gmail.com>
* lswr: take const AVChannelLayout* in swr_alloc_set_opts2()rcombs2022-08-24
| | | | | This is fully backwards-compatible in both ABI and API, so it's only a minor bump.
* swresample/swresample: fill the correct buffer to print the output layout stringJames Almer2022-08-21
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lib*/version: Move library version functions into files of their ownAndreas Rheinhardt2022-05-10
| | | | | | | This avoids having to rebuild big files every time FFMPEG_VERSION changes (which it does with every commit). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libswresample: Split version.hMartin Storsjö2022-03-16
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* swresample: convert to new channel layout APIJames Almer2022-03-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* libswresample/swresamplec: Err num(negative-size) was used as a function ↵Yu Yang2021-12-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parameter If memory allocation fails, ERROR(ENOMEM) '-12' will be returned. When resample() is done first, the negative size param would cause buffer-overflow and SEGV in swri_rematrix(). When swri_rematrix() is run first, resample() would not cause an error but Err num as a wrong parameter passing. Err num should be returned immediately. And remove an unneeded term from an assert. coredump info: #0 0x499517 in posix_memalign (/home/r1/ffmpeg/ffmpeg_4.4.1+0x499517) #1 0x6c1f0b4 in av_malloc /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:86:9 #2 0x6c208fe in av_mallocz /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:239:17 #3 0x6c207ad in av_mallocz_array /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavutil/mem.c:195:12 #4 0x654b2e5 in swri_realloc_audio /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:418:14 #5 0x654f9a1 in swr_convert_internal /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:601:17 #6 0x654d2c0 in swr_convert /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libswresample/swresample.c:766:19 #7 0x186cf56 in flush_frame /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/af_aresample.c:251:13 #8 0x186a454 in request_frame /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/af_aresample.c:288:20 #9 0x787d9c in ff_request_frame_to_filter /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:459:15 #10 0x7877f1 in forward_status_change /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1257:19 #11 0x77ed7e in ff_filter_activate_default /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1288:20 #12 0x77e4e1 in ff_filter_activate /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfilter.c:1441:11 #13 0x793b3f in ff_filter_graph_run_once /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfiltergraph.c:1403:12 #14 0x7a7bee in get_frame_internal /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/buffersink.c:131:19 #15 0x7a7287 in av_buffersink_get_frame_flags /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/buffersink.c:142:12 #16 0x792888 in avfilter_graph_request_oldest /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/libavfilter/avfiltergraph.c:1356:17 #17 0x5d07df in transcode_from_filter /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4639:11 #18 0x59e557 in transcode_step /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4729:20 #19 0x593970 in transcode /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:4805:15 #20 0x58f7a4 in main /home/r1/ffmpeg/ffmpeg-4.4.1/build/src/fftools/ffmpeg.c:5010:9 #21 0x7f6fd2dee0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16 SUMMARY: AddressSanitizer: negative-size-param (/home/r1/ffmpeg/ffmpeg_4.4.1+0x497e67) in __asan_memcpy Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample/swresample: Remove array size hint from swr_convert()Andreas Rheinhardt2021-12-03
| | | | | | | | | | | | | | SWR_CH_MAX is internal only and the arrays are therefore not required to have that many elements (and they typically don't do it). So remove this potentially confusing hint. (Newer versions of GCC emit -Warray-parameter= warnings for this, because the definition with explicit size differs from the declaration (which leaves the size unspecified); this is IMO a false-positive, because definition and declaration didn't conflict, but anyway it is fixed by this commit.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-20
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Silence "string-plus-int" warning shown by clang.Carl Eugen Hoyos2020-01-06
| | | | libswscale/utils.c:89:42: warning: adding 'unsigned long' to a string does not append to the string [-Wstring-plus-int]
* swresample/swresample: check for invalid sample ratesPaul B Mahol2019-05-26
|
* swresample/swresample: Fix input channel count in resample_first computationMichael Niedermayer2018-07-26
| | | | | | Found-by: Marcin Gorzel <gorzel@google.com> Reviewed-by: Marcin Gorzel <gorzel@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample/swresample: Fix for seg fault in swr_convert_internal() -> ↵Hendrik Schreiber2018-04-07
| | | | | | | | | sum2_float during dithering. Removed +len1 in call to s->mix_2_1_f() as I found no logical explanation for it. After removal, problem was gone. Signed-off-by: Hendrik Schreiber <hs@tagtraum.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lswr/swresample: Mention the actually supported formats when erroring out.Carl Eugen Hoyos2017-10-28
| | | | Fixes ticket #6779.
* swresample/swresample: do not use s32p internally by default when resamplingMuhammad Faiz2017-03-18
| | | | | | | | | | | | use fltp when doing s32 -> s32 resampling because s32p has no simd optimization benchmark: old 17.913s new 7.584s (use fma3) Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
* swresample/swresample: do not reset tsf on swr_alloc_set_optsMuhammad Faiz2017-03-13
| | | | | | | | | | | | so tsf option in aresample will have effect previously tsf/internal_sample_format had no effect fate is updated s32p previously used fltp internally dblp previously used fltp/dblp internally Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
* swresample/swresample: Check count before memcpy()Michael Niedermayer2016-12-10
| | | | | | | | Fixes undefined operation Fixes part of 668007-media Found-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample: add int64 sample formatPaul B Mahol2016-08-18
|
* swresample: Skip over dither steps if dithering scale is 0Michael Niedermayer2016-08-18
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample: move dither init upMichael Niedermayer2016-08-18
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample: add exact_rational optionMuhammad Faiz2016-06-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | give high quality resampling as good as with linear_interp=on as fast as without linear_interp=on tested visually with ffplay ffplay -f lavfi "aevalsrc='sin(10000*t*t)', aresample=osr=48000, showcqt=gamma=5" ffplay -f lavfi "aevalsrc='sin(10000*t*t)', aresample=osr=48000:linear_interp=on, showcqt=gamma=5" ffplay -f lavfi "aevalsrc='sin(10000*t*t)', aresample=osr=48000:exact_rational=on, showcqt=gamma=5" slightly speed improvement for fair comparison with -cpuflags 0 audio.wav is ~ 1 hour 44100 stereo 16bit wav file ffmpeg -i audio.wav -af aresample=osr=48000 -f null - old new real 13.498s 13.121s user 13.364s 12.987s sys 0.131s 0.129s linear_interp=on old new real 23.035s 23.050s user 22.907s 22.917s sys 0.119s 0.125s exact_rational=on real 12.418s user 12.298s sys 0.114s possibility to decrease memory usage if soft compensation is ignored Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
* swresample/swresample: Remove "less than" comparissions of enumsMichael Niedermayer2016-03-22
| | | | | Found-by: wm4 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swresample/swresample: Fix integer overflow in seed calculationMichael Niedermayer2015-09-03
| | | | | | Fixes CID1322333 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swr: Remember previously set int_sample_format from userMichael Niedermayer2015-06-22
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample/swresample: Clear delayed_samples_fixup in clear_context()Michael Niedermayer2015-06-22
| | | | | | This probably makes no difference but its more proper Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample/swresample: Print used int_sample_fmtMichael Niedermayer2015-06-21
| | | | | Suggested-by: wm4 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: Choose 16bit internally only if input and output is 16bit or lessMichael Niedermayer2015-06-21
| | | | | | | | | | | | | 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>
* swr: Fix ASSERT_LEVEL warningMichael Niedermayer2015-06-08
| | | | | Found-by: cehoyos Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: fix initilaize/initialize typoClément Bœsch2015-06-06
|
* swresample/swresample: Cleanup on init failure.Michael Niedermayer2015-06-04
| | | | | | | | 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>
* swresample: Add swr_get_out_samples()Michael Niedermayer2015-06-04
| | | | | | 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>
* swresample/dither: check memory allocationGanesh Ajjanagadde2015-06-03
| | | | | | check memory allocation in swri_get_dither() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: Check the return value of resampler->init()Michael Niedermayer2015-06-03
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swr: fix alignment issue caused by 8ch sse functionsRainer Hochecker2015-05-13
| | | | | | | | | 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>
* swresample: Check channel layouts and channels against each other and print ↵Michael Niedermayer2015-04-12
| | | | | | human readable error messages Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: Allow reinitialization without ever setting channel layoutsMichael Niedermayer2015-04-12
|
* swresample: Allow reinitialization without ever setting channel countsMichael Niedermayer2015-04-12
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample/swresample: Use av_mallocz_array()Michael Niedermayer2015-03-30
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: Add prefix to soxr_resamplerMichael Niedermayer2015-02-27
| | | | | | also move declaration to header Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Add FFMPEG_VERSION into the binary libsMichael Niedermayer2014-12-19
| | | | | | This simplifies identifying from which revision a binary of a lib came from Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: Fix swr_drop_output so it does not flush the buffersMichael Niedermayer2014-11-04
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample: do not put multiple statements in one lineMichael Niedermayer2014-10-16
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample/swresample: replace always true if() by av_assert0()Michael Niedermayer2014-10-06
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* swresample/swresample: fix sample drop loop end conditionMichael Niedermayer2014-10-06
| | | | | | Fixes Ticket3985 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>