1
0
Fork 0
Commit Graph

84 Commits

Author SHA1 Message Date
Michael Niedermayer c2d897f356
avcodec/lpc: copy levenson coeffs only when they have been computed
Fixes: CID1473514 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-13 03:40:16 +02:00
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
Andreas Rheinhardt aaf26cffba avcodec/lpc: Split inline functions into a header of their own
And move compute_ref_coefs() to its only user: lpc.c
There is no overlap between the users of compute_lpc_coefs()
and lpc proper.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-04 02:11:38 +01:00
Rémi Denis-Courmont 272d0c164d lavc/lpc: R-V V apply_welch_window
apply_welch_window_even_c:       617.5
apply_welch_window_even_rvv_f64: 235.0
apply_welch_window_odd_c:        709.0
apply_welch_window_odd_rvv_f64:  256.5
2023-12-11 18:17:43 +02:00
James Almer 0627e6d74c avcodec/lpc: zero the middle odd sample in the output
Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-22 18:17:26 -03:00
James Almer c8c4a162fc avcodec/lpc: use ptrdiff_t for length parameters
Signed-off-by: James Almer <jamrial@gmail.com>
2022-09-22 18:17:26 -03:00
Lynne cc367a9b8a
lavc/lpc: do not explode when windowing a 1-length array
Divided by 0.
2022-09-21 07:09:36 +02: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
Michael Niedermayer 38d18fb578 avcodec/lpc: Avoid floating point division by 0
Fixes: Ticket7996
Fixes: CVE-2020-20445

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-29 20:14:24 +02:00
Anton Khirnov c8c2dfbc37 lavu: move LOCAL_ALIGNED from internal.h to mem_internal.h
That is a more appropriate place for it.
2021-01-01 14:11:01 +01:00
Jai Luthra 0c023d181e lavc/lpc: Add min_shift parameter in LPC
The min_shift parameter is needed by the MLP encoder

Signed-off-by: Jai Luthra <me@jailuthra.in>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-28 11:18:16 +02:00
Ganesh Ajjanagadde 66edd8656b lavc/lpc: exploit even symmetry of window function
Yields 2x improvement in function performance, and boosts aac encoding
speed by ~ 4% overall. Sample benchmark (Haswell+GCC under -march=native):
after:
ffmpeg -i sin.flac -acodec aac -y sin_new.aac  5.22s user 0.03s system 105% cpu 4.970 total

before:
ffmpeg -i sin.flac -acodec aac -y sin_new.aac  5.40s user 0.05s system 105% cpu 5.162 total

Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag@gmail.com>
2016-03-10 21:29:56 -05:00
Rostislav Pehlivanov 0cfdaf45c4 lpc: correctly apply windowing to the samples in the float-only lpc
Also change the window to Hamming (using coefficient which make it
a Hanning).

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2015-09-19 16:25:58 +01:00
Rostislav Pehlivanov 7591f8319b lpc: increase error array size of ff_lpc_calc_ref_coefs_f by one
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2015-09-05 08:51:19 +01:00
Rostislav Pehlivanov 0fc3a51353 lpc: add ff_lpc_calc_ref_coefs_f() function
This commit adds a function to get the reflection coefficients on
floating point samples. It's functionally identical to
ff_lpc_calc_ref_coefs() except it works on float samples and will
return the global prediction gain. The Welch window implementation
which is more optimized works only on int32_t samples so a slower
generic expression was used.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2015-09-01 06:34:50 +01:00
Rostislav Pehlivanov a70ee2bdcd lpc: remove unused ff_lpc_calc_levinson() function
Not needed anymore, it was only used by the AAC TNS
encoder and was replaced with a more suitable function
in the following commit.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2015-09-01 06:32:35 +01:00
Rostislav Pehlivanov 141d80ded7 lpc: rename ff_lpc_calc_levinsion to ff_lpc_calc_levinson
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2015-08-29 19:29:18 +01:00
Rostislav Pehlivanov 20962b567b lpc: create a simplified Levinson-Durbin LPC handling float samples
This commit simply duplicates the functionality of ff_lpc_calc_coefs()
for the case of a Levinson-Durbin LPC with the only difference being
that floating point samples are accepted and the resulting coefficients
are raw and unquantized.
The motivation behind doing this is the fact that the AAC encoder
requires LPC in TNS and LTP and converting non-normalized floating
point coefficients to int32_t using SWR and again back for the LPC
coefficients was very impractical.
The current LPC interfaces were designed for int32_t in mind possibly
because FLAC and ALAC use this type for most internal operations.
The mathematics in case of floats remains of course identical.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2015-08-29 06:14:13 +01:00
Michael Niedermayer a3a61d4663 avcodec/lpc: Fix lpc_apply_welch_window_c() for odd len
Also removes assert
this fixes an assertion failure on non-x86

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-06 19:11:42 +02:00
Reimar Döffinger 458aadf862 lpc: Reduce stack usage by allocating LLSModel in context.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2014-11-23 06:51:18 +01:00
Michael Niedermayer d4065a9f47 Merge commit '60e0ee7ca25bd3bea54043b0607efe4cd51acaf3'
* commit '60e0ee7ca25bd3bea54043b0607efe4cd51acaf3':
  lpc: always initialize ref and err

The initialization is not needed, its merged anyway as it might
help suppressing warnings and might make the code more robust against
future changes

See: c4a36b6f70
See: 0dd99628ea
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-15 02:05:25 +01:00
Vittorio Giovara 60e0ee7ca2 lpc: always initialize ref and err
CC: libav-stable@libav.org
Bug-Id: CID 29585 / CID 700759
2014-11-14 20:25:52 +01:00
Michael Niedermayer 70b8668fb5 drop LLS1, rename LLS2 to LLS
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-09 23:20:31 +02:00
Michael Niedermayer c3814ab654 rename new lls code to lls2 to avoid conflict with the old which has a different ABI
also remove failed attempt at a compatibility layer, the code simply cannot work

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-17 16:41:08 +01:00
Michael Niedermayer bbe66ef912 avutil: rename lls to lls2
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-17 16:30:23 +01:00
Michael Niedermayer 0dd99628ea ff_lpc_calc_coefs: assert that the type is levinson or cholesky
Otherwise the code could misbehave (and there are no other types anyway)
Fixes CID700759

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-09 11:57:45 +02:00
Loren Merritt 1221bb6239 x86: lpc: fix a segfault in av_evaluate_lls_sse2() 2013-06-30 23:11:19 +00:00
Michael Niedermayer e27be795f0 avcodec/lpc: Use a function pointer from an initialized context
Fixes null pointer dereference

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-30 12:40:16 +02:00
Michael Niedermayer 32a3955259 Merge commit 'c93ccf5a4cca722b39f05e9f5660b4cb75bc1740'
* commit 'c93ccf5a4cca722b39f05e9f5660b4cb75bc1740':
  lpc: use levinson for the first pass of multipass cholesky

Conflicts:
	libavcodec/lpc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-30 12:26:58 +02:00
Michael Niedermayer 78b5479633 Merge commit '502ab21af0ca68f76d6112722c46d2f35c004053'
* commit '502ab21af0ca68f76d6112722c46d2f35c004053':
  x86: lpc: simd av_update_lls

The versions are bumped due to changes in lls.h which is used across
libraries affecting intra library ABI
(This version bump also covers changes to lls.h in the immedeatly previous
 commits)

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-30 11:35:52 +02:00
Michael Niedermayer c93a424718 Merge commit '41578f70cf8aec8e7565fba1ca7e07f3dc46c3d2'
* commit '41578f70cf8aec8e7565fba1ca7e07f3dc46c3d2':
  lpc: use function pointers, in preparation for asm

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-30 11:23:43 +02:00
Michael Niedermayer d3bd320e63 Merge commit 'cc6714bb16b1f0716ba43701d47273dbe9657b8b'
* commit 'cc6714bb16b1f0716ba43701d47273dbe9657b8b':
  lpc: remove "decay" argument

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-30 10:54:20 +02:00
Loren Merritt c93ccf5a4c lpc: use levinson for the first pass of multipass cholesky
Levinson is faster, and cholesky is only needed if we want to apply different
weights to different samples, which doesn't happen on the first pass.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-06-29 13:26:52 +02:00
Loren Merritt 502ab21af0 x86: lpc: simd av_update_lls
4x-6x faster on sandybridge

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-06-29 13:23:57 +02:00
Loren Merritt 41578f70cf lpc: use function pointers, in preparation for asm
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-06-29 13:23:57 +02:00
Loren Merritt cc6714bb16 lpc: remove "decay" argument
We never used the rolling-average mode, and this makes av_update_lls 15% faster.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-06-29 13:23:57 +02:00
Michael Niedermayer 76f8d3c8d9 Merge commit '9d4da474f5f40b019cb4cb931c8499deee586174'
* commit '9d4da474f5f40b019cb4cb931c8499deee586174':
  lls: move to the private namespace

Conflicts:
	libavutil/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-01 13:19:00 +01:00
Luca Barbato 9d4da474f5 lls: move to the private namespace
The functions are private.
2013-02-28 17:39:24 +01:00
Michael Niedermayer e79c3858b3 Merge commit '14f031d7ecfabba0ef02776d4516aa3dcb7c40d8'
* commit '14f031d7ecfabba0ef02776d4516aa3dcb7c40d8':
  dv: use AVStream.index instead of abusing AVStream.id
  lavfi: add ashowinfo filter
  avcodec: Add a RFC 3389 comfort noise codec
  lpc: Add a function for calculating reflection coefficients from samples
  lpc: Add a function for calculating reflection coefficients from autocorrelation coefficients
  lavr: document upper bound on number of output samples.
  lavr: add general API usage doxy
  indeo3: remove duplicate capabilities line.
  fate: ac3: Add dependencies

Conflicts:
	Changelog
	doc/filters.texi
	libavcodec/Makefile
	libavcodec/allcodecs.c
	libavcodec/avcodec.h
	libavcodec/codec_desc.c
	libavcodec/version.h
	libavfilter/Makefile
	libavfilter/af_ashowinfo.c
	libavfilter/allfilters.c
	libavfilter/version.h
	libavutil/avutil.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-30 14:40:22 +01:00
Martin Storsjö 8b25a20efb lpc: Add a function for calculating reflection coefficients from samples
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-10-29 21:53:16 +02:00
Michael Niedermayer c4a36b6f70 lpc: check that lpc_type is valid in ff_lpc_calc_coefs
Fixes CID700759
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-28 03:27:16 +01:00
Michael Niedermayer 52dc18d414 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  x86: vc1: call ff_vc1dsp_init_x86() under if (ARCH_X86)
  x86: cavs: call ff_cavsdsp_init_x86() under if (ARCH_X86)
  x86: call most of the x86 dsp init functions under if (ARCH_X86)
  doc: support the new website layout
  doc: remove a warning from filters.texi
  doc: initial nut documentation
  segment: drop global headers setting
  lavu: fix typo in Makefile

Conflicts:
	doc/Makefile
	doc/filters.texi
	doc/t2h.init
	libavcodec/fmtconvert.c
	libavcodec/proresdsp.c
	libavcodec/x86/Makefile
	libavcodec/x86/vc1dsp_mmx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-08 21:46:34 +02:00
Janne Grunau f101eab1be x86: call most of the x86 dsp init functions under if (ARCH_X86)
Rename the called dsp init functions to *_init_x86.
2012-10-08 11:54:05 +02:00
Michael Niedermayer 104f42e694 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  doc/APIchanges: add an entry for codec descriptors.
  vorbisenc: set AVCodecContext.bit_rate to 0
  vorbisenc: fix quality parameter
  FATE: add ALAC encoding tests
  lpc: fix alignment of windowed samples for odd maximum LPC order
  alacenc: use s16p sample format as input
  alacenc: remove unneeded sample_fmt check
  alacenc: fix max_frame_size calculation for the final frame
  adpcm_swf: Use correct sample offsets when using trellis.
  rtmp: support strict rtmp servers
  mjpegdec: support AVRn interlaced
  x86: remove FASTDIV inline asm

Conflicts:
	doc/APIchanges
	libavcodec/mjpegdec.c
	libavcodec/vorbisenc.c
	libavutil/x86/intmath.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-23 14:33:33 +02:00
Justin Ruggles 4b0e0f31bf lpc: fix alignment of windowed samples for odd maximum LPC order
Fixes crash on x86 due to alignment requirements for w_data in
lpc_apply_welch_window_sse2().
2012-08-22 16:41:50 -04:00
Michael Niedermayer c581cb4e4f Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Fix even more missing includes after the common.h removal
  build: Factor out rangecoder dependencies to CONFIG_RANGECODER
  build: Factor out error resilience dependencies to CONFIG_ERROR_RESILIENCE
  x86: avcodec: Consistently name all init files
  Add more missing includes after removing the implicit common.h
  Add some more missing includes after removing the implicit common.h
  Don't include common.h from avutil.h
  rtmp: Automatically compute the hash for SWFVerification

Conflicts:
	configure
	doc/APIchanges
	doc/examples/decoding_encoding.c
	libavcodec/Makefile
	libavcodec/assdec.c
	libavcodec/audio_frame_queue.c
	libavcodec/avpacket.c
	libavcodec/dv_profile.c
	libavcodec/dwt.c
	libavcodec/libtheoraenc.c
	libavcodec/rawdec.c
	libavcodec/rv40dsp.c
	libavcodec/tiff.c
	libavcodec/tiffenc.c
	libavcodec/v210dec.h
	libavcodec/vc1dsp.c
	libavcodec/x86/Makefile
	libavfilter/asrc_anullsrc.c
	libavfilter/avfilter.c
	libavfilter/buffer.c
	libavfilter/formats.c
	libavfilter/vf_ass.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fade.c
	libavfilter/vf_select.c
	libavfilter/video.c
	libavfilter/vsrc_testsrc.c
	libavformat/version.h
	libavutil/audioconvert.c
	libavutil/error.h
	libavutil/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-16 16:20:30 +02:00
Martin Storsjö 1d9c2dc89a Don't include common.h from avutil.h
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-08-15 22:32:06 +03:00
Michael Niedermayer 894319e010 lpc: use default number of passes when lpc_passes is invalid
Should fix valgrind failure (uninitialized vars)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-07-06 04:04:10 +02:00
Michael Niedermayer b1a17953ec lpc: use av_assert
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-06-28 00:07:10 +02:00
Michael Niedermayer b479e01612 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Revert "v210enc: use FFALIGN()"
  doxygen: Do not include license boilerplates in Doxygen comment blocks.
  avplay: reset decoder flush state when seeking
  ape: skip packets with invalid size
  ape: calculate final packet size instead of guessing
  ape: stop reading after the last frame has been read
  ape: return AVERROR_EOF instead of AVERROR(EIO) when demuxing is finished
  ape: return error if seeking to the current packet fails in ape_read_packet()
  avcodec: Clarify AVFrame member documentation.
  v210dec: check for coded_frame allocation failure
  v210enc: use stride as it is already calculated
  v210enc: use FFALIGN()
  v210enc: return proper AVERROR codes instead of -1
  v210enc: do not set coded_frame->key_frame
  v210enc: check for coded_frame allocation failure
  drawtext: add 'fix_bounds' option on coords fixing
  drawtext: fix text_{w, h} expression vars
  drawtext: add missing braces around an if() block.

Conflicts:
	libavcodec/arm/vp8.h
	libavcodec/arm/vp8dsp_init_arm.c
	libavcodec/v210dec.c
	libavfilter/vf_drawtext.c
	libavformat/ape.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-02-07 01:40:29 +01:00