Commit Graph

50 Commits

Author SHA1 Message Date
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
Andreas Rheinhardt 08aa791d20 avcodec/lpc: Don't use AAC defines directly
It leads to defines for the AAC decoder being included
outside of the AAC decoder.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-04 02:11:19 +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 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
Michael Niedermayer 70874e024a avcodec/lpc: check for zero err in normalization in compute_lpc_coefs()
Fixes: floating point division by 0
Fixes: Ticket8213

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-07-03 18:03:35 +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
Michael Niedermayer e95fcfe8fb avcodec/lpc: signed integer overflow in compute_lpc_coefs() (aacdec_fixed)
Fixes: runtime error: signed integer overflow: -1575818955 + -915383657 cannot be represented in type 'int'
Fixes: 2224/clusterfuzz-testcase-minimized-6208559949807616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-06-21 02:25:23 +02: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 fafb10c30c avcodec/lpc: replace #define by typedef
See e.g https://stackoverflow.com/questions/1666353/are-typedef-and-define-the-same-in-c
for rationale.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-20 08:20:13 -05: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
Djordje Pesut f85bc147fb avcodec: Implementation of AAC_fixed_decoder (SBR-module)
Add fixed poind code.

Signed-off-by: Nedeljko Babic <nedeljko.babic@imgtec.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-20 17:20:16 +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 85929b9caa avcodec/lpc: remove unneeded {}
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-15 02:08:20 +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 1e6816dcda libavcodec/lpc.h: Fix duplicate words
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-12 19:40:29 +02:00
Michael Niedermayer a984efd104 Merge commit 'c242bbd8b6939507a1a6fb64101b0553d92d303f'
* commit 'c242bbd8b6939507a1a6fb64101b0553d92d303f':
  Remove unnecessary dsputil.h #includes

Conflicts:
	libavcodec/ffv1.c
	libavcodec/h261dec.c
	libavcodec/h261enc.c
	libavcodec/h264pred.c
	libavcodec/lpc.h
	libavcodec/mjpegdec.c
	libavcodec/rectangle.h
	libavcodec/x86/idct_sse2_xvid.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-02-26 13:05:10 +01:00
Diego Biurrun c242bbd8b6 Remove unnecessary dsputil.h #includes 2013-02-26 00:51:34 +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
Justin Ruggles 39ef66f530 lpc: Add a function for calculating reflection coefficients from autocorrelation coefficients
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-10-29 21:53:13 +02:00
Michael Niedermayer a6cac64f69 compute_lpc_coefs: assert that normalize and fail have a supported combination
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-14 22:16:31 +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 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
Diego Biurrun 32f3c541bc doxygen: Do not include license boilerplates in Doxygen comment blocks. 2012-02-06 19:39:24 +01:00
Michael Niedermayer 7fad19a63d Merge remote-tracking branch 'qatar/master'
* qatar/master:
  x86: cabac: replace explicit memory references with "m" operands
  avplay: don't request a stereo downmix
  wmapro: use av_float2int()
  lavc: avoid invalid memcpy() in avcodec_default_release_buffer()
  lavu: replace int/float punning functions
  lavfi: install libavfilter/vsrc_buffer.h
  Remove extraneous semicolons
  sdp: Restore the original mp4 format h264 extradata if converted
  rtpenc: Add support for mp4 format h264
  rtpenc: Simplify code by introducing a separate end pointer
  movenc: Use the actual converted sample for RTP hinting
  Fix a bunch of common typos.

Conflicts:
	doc/developer.texi
	doc/eval.texi
	doc/filters.texi
	doc/protocols.texi
	ffmpeg.c
	ffplay.c
	libavcodec/mpegvideo.h
	libavcodec/x86/cabac.h
	libavfilter/Makefile
	libavformat/avformat.h
	libavformat/cafdec.c
	libavformat/flvdec.c
	libavformat/flvenc.c
	libavformat/gxfenc.c
	libavformat/img2.c
	libavformat/movenc.c
	libavformat/mpegts.c
	libavformat/rtpenc_h264.c
	libavformat/utils.c
	libavformat/wtv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-12 01:25:37 +01:00
Diego Biurrun da9cea77e3 Fix a bunch of common typos. 2011-12-11 00:32:25 +01:00
Michael Niedermayer 59eb12faff Merge remote branch 'qatar/master'
* qatar/master: (30 commits)
  AVOptions: make default_val a union, as proposed in AVOption2.
  arm/h264pred: add missing argument type.
  h264dsp_mmx: place bracket outside #if/#endif block.
  lavf/utils: fix ff_interleave_compare_dts corner case.
  fate: add 10-bit H264 tests.
  h264: do not print "too many references" warning for intra-only.
  Enable decoding of high bit depth h264.
  Adds 8-, 9- and 10-bit versions of some of the functions used by the h264 decoder.
  Add support for higher QP values in h264.
  Add the notion of pixel size in h264 related functions.
  Make the h264 loop filter bit depth aware.
  Template dsputil_template.c with respect to pixel size, etc.
  Template h264idct_template.c with respect to pixel size, etc.
  Preparatory patch for high bit depth h264 decoding support.
  Move some functions in dsputil.c into a new file dsputil_template.c.
  Move the functions in h264idct into a new file h264idct_template.c.
  Move the functions in h264pred.c into a new file h264pred_template.c.
  Preparatory patch for high bit depth h264 decoding support.
  Add pixel formats for 9- and 10-bit yuv420p.
  Choose h264 chroma dc dequant function dynamically.
  ...

Conflicts:
	doc/APIchanges
	ffmpeg.c
	ffplay.c
	libavcodec/alpha/dsputil_alpha.c
	libavcodec/arm/dsputil_init_arm.c
	libavcodec/arm/dsputil_init_armv6.c
	libavcodec/arm/dsputil_init_neon.c
	libavcodec/arm/dsputil_iwmmxt.c
	libavcodec/arm/h264pred_init_arm.c
	libavcodec/bfin/dsputil_bfin.c
	libavcodec/dsputil.c
	libavcodec/h264.c
	libavcodec/h264.h
	libavcodec/h264_cabac.c
	libavcodec/h264_cavlc.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_ps.c
	libavcodec/h264_refs.c
	libavcodec/h264dsp.c
	libavcodec/h264idct.c
	libavcodec/h264pred.c
	libavcodec/mlib/dsputil_mlib.c
	libavcodec/options.c
	libavcodec/ppc/dsputil_altivec.c
	libavcodec/ppc/dsputil_ppc.c
	libavcodec/ppc/h264_altivec.c
	libavcodec/ps2/dsputil_mmi.c
	libavcodec/sh4/dsputil_align.c
	libavcodec/sh4/dsputil_sh4.c
	libavcodec/sparc/dsputil_vis.c
	libavcodec/utils.c
	libavcodec/version.h
	libavcodec/x86/dsputil_mmx.c
	libavformat/options.c
	libavformat/utils.c
	libavutil/pixfmt.h
	libswscale/swscale.c
	libswscale/swscale_internal.h
	libswscale/swscale_template.c
	tests/ref/seek/lavf_avi

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-05-11 05:47:02 +02:00
Anton Khirnov 188dea1dbf lavc: move some flac-specific options to its private context. 2011-05-10 07:42:33 +02:00
Mans Rullgard 2912e87a6c Replace FFmpeg with Libav in licence headers
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-03-19 13:33:20 +00:00
Justin Ruggles 7101b18508 Separate window function from autocorrelation.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 77a78e9bdc)
2011-01-23 19:32:06 +01:00
Justin Ruggles 0d8837bdda Move lpc_compute_autocorr() from DSPContext to a new struct LPCContext.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 56f8952b25)
2011-01-23 19:32:06 +01:00
Justin Ruggles 77a78e9bdc Separate window function from autocorrelation.
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-21 19:59:08 +00:00
Justin Ruggles 56f8952b25 Move lpc_compute_autocorr() from DSPContext to a new struct LPCContext.
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-21 19:58:59 +00:00
Justin Ruggles 23940f1405 Add AVCodecContext.lpc_type and Add AVCodecContext.lpc_passes fields.
Add AVLPCType enum.
Deprecate AVCodecContext.use_lpc.

Originally committed as revision 24199 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-11 16:56:20 +00:00
Måns Rullgård 49bd8e4b84 Fix grammar errors in documentation
Originally committed as revision 23904 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-30 15:38:06 +00:00
Måns Rullgård 3da1180409 Move some prototypes from dsputil.c to reasonable header files
Originally committed as revision 22260 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-06 22:36:45 +00:00
Vitor Sessak 82ab49dc41 Cosmetics: s/LPC_type/LPC_TYPE/
Originally committed as revision 15202 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-09-04 22:17:27 +00:00
Vitor Sessak 1be0fc2909 Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
Originally committed as revision 15193 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-09-04 11:03:14 +00:00
Stefano Sabatini 987903826b Globally rename the header inclusion guard names.
Consistently apply this rule: the guard name is obtained from the
filename by stripping the leading "lib", converting '/' and '.'  to
'_' and uppercasing the resulting name. Guard names in the root
directory have to be prefixed by "FFMPEG_".

Originally committed as revision 15120 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-31 07:39:47 +00:00
Diego Biurrun ee8cc834ae Add missing header includes to fix 'make checkheaders'.
Originally committed as revision 14817 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-17 19:26:13 +00:00
Justin Ruggles 38c1a5c4d9 update my email address to one which does not depend on my service provider
Originally committed as revision 14797 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-16 22:42:59 +00:00
Justin Ruggles 9045f5e72d cosmetics: adjust line breaks and vertical alignment
Originally committed as revision 14795 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-16 21:32:03 +00:00
Justin Ruggles 56c07e2989 use limited range of lpc orders when quantizing coefficients
Originally committed as revision 14794 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-16 21:24:06 +00:00
Ramiro Polla e9e3c9801e lpc: cosmetics: vertically align declarations and definitions.
Originally committed as revision 14792 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-16 17:28:29 +00:00
Ramiro Polla c50da3ad6c flacenc, lpc: Move LPC code from flacenc.c to new lpc.[ch] files.
Originally committed as revision 14790 to svn://svn.ffmpeg.org/ffmpeg/trunk
2008-08-16 17:18:20 +00:00