Commit Graph

94 Commits

Author SHA1 Message Date
Michael Niedermayer
2f48d227c1
avcodec/eac3dec: avoid float noise in fixed mode addition to overflow
Fixes: 2.28595e+09 is outside the range of representable values of type 'int'
Fixes: 54644/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-4816961584627712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-01-11 12:12:25 +01:00
Lynne
4cee7ebd75
ac3: convert to lavu/tx 2022-11-06 14:39:27 +01:00
Andreas Rheinhardt
104abea646 avcodec/ac3: Move non-(de|en)coder-only parts out of ac3.h
Move AC3HeaderInfo into ac3_parser_internal.h and the rest
into a new header ac3defs.h.

This also breaks an include cycle of ac3.h and ac3tab.h
(the latter now only needs ac3defs.h).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-15 18:13:56 +02:00
Andreas Rheinhardt
996ec1cbe8 avcodec/ac3: Remove declaration of inexistent function
Removed in 7b11eead1b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-15 18:13:55 +02:00
Andreas Rheinhardt
636631d9db Remove unnecessary libavutil/(avutil|common|internal).h inclusions
Some of these were made possible by moving several common macros to
libavutil/macros.h.

While just at it, also improve the other headers a bit.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-24 12:56:49 +01:00
Andreas Rheinhardt
25c8507818 Remove/replace some unnecessary avcodec.h inclusions
Also remove other unnecessary headers and include headers directly while
at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:29:46 +02:00
Andreas Rheinhardt
968c158abd avcodec/ac3enc: Use actual size of buffer in init_put_bits()
Since the very beginning (since de6d9b6404)
the AC-3 encoder used AC3_MAX_CODED_FRAME_SIZE (namely 3840) for the
size of the output buffer (without any check at all).
This causes problems when encoding EAC-3 for which the maximum is too small,
smaller than the actual size of the buffer: One can run into asserts used
by the PutBits API. Ticket #8513 is about such a case and this commit
fixes it by using the real size of the buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-02 12:06:56 +02:00
Paul B Mahol
0b86ea03d8 avcodec/ac3: fix out of array access introduced previously
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-03-30 10:14:48 +02:00
Nikolas Bowe
96cd6f672e avcodec/(e)ac3: Fix target_level for EAC3.
Currently when using target_level with EAC3 it produces silence. This small patch fixes target_level for decoding EAC3.

Example:
ffmpeg -y -i /tmp/test.wav -acodec eac3 -dialnorm -14 -ac 6 -b:a 384000 /tmp/test.m2ts
ffmpeg -y -target_level -24 -i /tmp/test.m2ts -acodec pcm_s16le -f matroska /tmp/out.mkv
ffplay /tmp/out.mkv

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-15 12:18:55 +02:00
Ganesh Ajjanagadde
94565f3791 avcodec/ac3: use M_SQRT1_2, M_SQRT2
This uses M_SQRT1_2, M_SQRT2 instead of the actual literals. This yields
greater precision in some places in avcodec/ac3, while fixed point
values remain unchanged.

Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-22 16:16:16 -05:00
Ganesh Ajjanagadde
47eeb001e6 avcodec/ac3: 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:19:55 -05:00
James Almer
4a447e3e69 avcodec/ac3: sync AC3HeaderInfo struct with the fork
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2015-09-05 13:24:52 -03:00
Michael Niedermayer
cb9d40451c avcodec/ac3: add () to protect the macro arguments
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-16 23:59:39 +01:00
Jean-Francois Thibert
12df9b9a15 Improved AC3 decoder level support (heavy drc, dialnorm)
Added support for AC3 heavy dynamic range compression used
to restrict the output range and added a setting to specify
the output target level and use the dialog normalization
field to apply it in the digital domain.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-27 14:31:39 +02:00
Michael Niedermayer
b219142921 avcodec/ac3: rename identifier used to select the fixed point variant
the CONFIG_ prefix is used by configure, using it for other things
is potentially confusing to the reader

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Nedeljko Babic <nbabic@mips.com>
2014-04-01 19:58:31 +02:00
Nedeljko Babic
696e34a6e1 libavcodec: Implementation of AC3 fixedpoint decoder
Signed-off-by: Nedeljko Babic <nbabic@mips.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-01 19:01:57 +02:00
Michael Niedermayer
df6d21c1e7 avcodec/ac3: move new field to the end of AC3HeaderInfo
This structure is used in the interface between libs and thus cannot have
fields added in the middle without major bump

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-01 01:45:49 +01:00
Michael Niedermayer
fdf8b59b28 Merge commit '9c0e4b3395cad79c560d03d2a94595d89e017885'
* commit '9c0e4b3395cad79c560d03d2a94595d89e017885':
  ac3: update AC3PreferredStereoDownmixMode.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-16 01:56:31 +01:00
Tim Walker
9c0e4b3395 ac3: update AC3PreferredStereoDownmixMode.
'11b' is reserved in the A/52 specification,
but newer encoders use it to indicate a Dolby
Pro Logic II compatible Lt/Rt downmix.
2014-02-15 22:24:48 +01:00
Michael Niedermayer
3a5a039ade Merge commit 'c229f571fd3c7d7b567c27c87b2bbcdaee1b0e9f'
* commit 'c229f571fd3c7d7b567c27c87b2bbcdaee1b0e9f':
  (e)ac3: parse and store the Lt/Rt and LFE mix levels.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-19 21:37:06 +01:00
Tim Walker
c229f571fd (e)ac3: parse and store the Lt/Rt and LFE mix levels. 2014-01-19 19:12:42 +01:00
Michael Niedermayer
7b3c78b5e6 Merge commit '13345fc1f86fc3615789e196d5a339c1c27c9068'
* commit '13345fc1f86fc3615789e196d5a339c1c27c9068':
  (e)ac3: parse and store the Dolby Surround, Surround EX and Headphone mode flags.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-05 23:06:53 +01:00
Tim Walker
13345fc1f8 (e)ac3: parse and store the Dolby Surround, Surround EX and Headphone mode flags. 2014-01-05 16:41:56 +01:00
Michael Niedermayer
55c49afc42 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  yuv4mpeg: return proper error codes.
  Give all anonymously typedeffed structs in headers a name
  fate: Add parseutils test
  parseutils-test: Drop random colors from parsing test
  vf_pad/scale: use double precision for aspect ratios.
  build: error on variable-length arrays
  ppc: swscale: rework yuv2planeX_altivec()
  ppc: fmtconvert: kill VLA in float_to_int16_interleave_altivec()
  x86: dsputil: kill VLA in gmc_mmx()
  libspeexenc: Updated commentary to reflect recent changes
  libspeexenc: Add an option for enabling DTX
  doc/APIchanges: fill in missing dates and hashes.
  lavr: bump major to 1 and declare it stable.
  lavr: change the type of the data buffers to uint8_t**.
  lavc: deprecate the audio resampling API.

Conflicts:
	cmdutils.h
	configure
	doc/APIchanges
	ffplay.c
	libavcodec/dwt.h
	libavcodec/libspeexenc.c
	libavfilter/vf_pad.c
	libavfilter/vf_scale.c
	libavformat/asf.h
	tests/fate/libavutil.mak
	tests/ref/fate/parseutils

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-06 13:45:08 +02:00
Diego Biurrun
e4cbf7529b Give all anonymously typedeffed structs in headers a name
Anonymous structs cannot be forward declared and have no benefit.
2012-10-06 09:27:11 +02:00
Michael Niedermayer
022f8d27dd Merge remote-tracking branch 'qatar/master'
* qatar/master:
  swscale: Readd #define _SVID_SOURCE
  Fix av_get_channel_layout_string() for positions >31
  configure: Store vda lib flags in extralibs instead of ldflags
  Make channel layout masks unsigned
  dca: ARMv6 optimised decode_blockcode()
  nullenc: drop AVFMT_RAWPICTURE from the flags
  frame-mt: return consumed packet size in ff_thread_decode_frame
  aacdec: add more fate tests covering SBR and PS
  MK(BE)TAG: avoid undefined shifts

Conflicts:
	configure
	libavcodec/arm/dca.h
	libavcodec/dca.c
	libavcodec/mlp_parser.c
	libavcodec/version.h
	libavfilter/asrc_anullsrc.c
	libavfilter/avfilter.c
	libavfilter/avfilter.h
	libavfilter/defaults.c
	libavutil/audioconvert.c
	libavutil/avutil.h
	libswscale/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-11-26 01:12:08 +01:00
Mans Rullgard
cc276c85d1 Make channel layout masks unsigned
It makes more sense for a bit mask to use an unsigned type.
The change should be source and binary compatible on all
supported systems, hence micro version bump.

Fixes a few invalid shifts.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-11-25 13:19:54 +00:00
Michael Niedermayer
9f4d37f450 ac3enc: drop common fixed/float encoder
User applications should by now be able to support float encoders.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-08-12 17:20:57 +02:00
Michael Niedermayer
44187717c1 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  ppc: remove redundant setting of Altivec IDCT
  mpegvideo: initialise DSPContext in ff_dct_common_init()
  cosmetics: reindent
  eac3enc: support writing of basic mixing and info metadata
  dnxhdenc: fix declarations in for loops
  dsputil: remove stale bink prototypes and comments
  dsputil: move a bink-only function to binkdsp
  dsputil: remove some unused functions
  bink: make IDCT take 32-bit input

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-07-28 09:28:01 +02:00
Michael Niedermayer
cbfdfbe846 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  ARM: ac3: update ff_ac3_extract_exponents_neon per 8b7b2d6
  ARM: NEON optimised vector_clip_int32()
  swscale: disable full_chroma_int when converting to non-24/32bpp RGB.
  suggest to use av_get_bytes_per_sample() in av_get_bits_per_sample_format() doxy
  ffmpeg: use av_get_bytes_per_sample() in place of av_get_bits_per_sample_fmt()
  put_bits: remove ALT_BITSTREAM_WRITER
  put_bits: always use intreadwrite.h macros
  libavformat: Add an example how to use the metadata API
  doxygen: Prefer member groups over grouping into modules
  doxygen: be more permissive when searching for API examples
  avformat: doxify the Metadata API
  lavf: restore old behavior for custom AVIOContex with an AVFMT_NOFILE format.
  lavf: use the correct pointer in av_open_input_stream().
  avidec: infer absolute vs relative index from first packet

Conflicts:
	libavformat/Makefile
	libavformat/avidec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-07-03 03:14:10 +02:00
Reinhard Tartler
21a19b7912 doxygen: Prefer member groups over grouping into modules
Before this, almost all module groups have been used for grouping functions
and fields in structures semantically. This causes them to not appear
properly in the file documentation and needlessly clutters up the "Modules"
index.

Additionally, this commit streamlines some spelling and appearances.
2011-07-02 13:52:29 +02:00
Michael Niedermayer
d552f616a2 Merge remote-tracking branch 'qatar/master'
* qatar/master: (28 commits)
  Remove some non-compiling debug messages.
  ffplay: Fix non-compiling debug printf and replace it by av_dlog.
  H264: x86 predict init cosmetics.
  ac3enc: Fix linking of AC-3 encoder without the E-AC-3 encoder.
  Move E-AC-3 encoder functions to a separate eac3enc.c file.
  ac3enc: remove convenience macro, #define DEBUG
  ac3enc: remove unused #define
  vc1: re-initialize tables after width/height change.
  APIchanges: fill-in git commit hash for av_get_bytes_per_sample() addition
  samplefmt: add av_get_bytes_per_sample()
  iirfilter: fix biquad filter coefficients.
  swscale: remove duplicate conversion routine in swScale().
  swscale: add yuv2planar/packed function typedefs.
  swscale: integrate yuv2nv12X_C into yuv2yuvX() function pointers.
  swscale: reindent x86 init code.
  swscale: extract SWS_FULL_CHR_H_INT conditional into init code.
  swscale: cosmetics.
  swscale: remove alp/chr/lumSrcOffset.
  swscale: un-special-case yuv2yuvX16_c().
  shorten: Remove stray DEBUG #define and corresponding av_dlog statement.
  ...

Conflicts:
	doc/APIchanges
	libavcodec/ac3enc.c
	libavutil/avutil.h
	libavutil/samplefmt.c
	libswscale/swscale.c
	libswscale/swscale_internal.h
	libswscale/x86/swscale_template.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-06-08 05:25:28 +02:00
Michael Niedermayer
034fc7bf12 Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits)
  configure: enable memalign_hack automatically when needed
  swscale: unbreak the build on non-x86 systems.
  swscale: remove if(bitexact) branch from functions.
  swscale: remove if(canMMX2BeUsed) conditional.
  swscale: remove swScale_{c,MMX,MMX2} duplication.
  swscale: use emms_c().
  Move emms_c() from libavcodec to libavutil.
  tiff: set palette in the context when specified in TIFF_PAL tag
  rtsp: use strtoul to parse rtptime and seq values.
  pgssubdec: fix incorrect colors.
  dvdsubdec: fix incorrect colors.
  ape: Allow demuxing of files with metadata tags.
  swscale: remove dead macro WRITEBGR24OLD.
  swscale: remove AMD3DNOW "optimizations".
  swscale: remove duplicate code in ppc/ subdirectory.
  swscale: remove duplicated x86/ functions.
  swscale: force --enable-runtime-cpudetect and remove SWS_CPU_CAPS_*.
  vsrc_buffer.h: add file doxy
  vsrc_buffer: tweak error message in init()
  msmpeg4: reindent.
  ...

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-05-25 06:32:45 +02:00
Justin Ruggles
7f3a7b5c40 ac3enc: add channel coupling support
Channel coupling is an optional AC-3 feature that increases quality by
combining high frequency information from multiple channels into a
single channel. The per-channel high frequency information is sent with
less accuracy in both the frequency and time domains. This allows more
bits to be used for lower frequencies while preserving enough
information to reconstruct the high frequencies.
2011-05-24 07:52:31 +02:00
Michael Niedermayer
c3f5b81125 Merge remote branch 'qatar/master'
* qatar/master:
  ALPHA: Replace sized int_fast integer types with plain int/unsigned.
Duplicate  DPX image encoder
Duplicate  DPX decoder: read sample aspect ratio
Duplciate  DPX decoder: add buffer size checks.
  ac3enc: clip large coefficient values and negative exponents rather than using av_assert2().
  ac3enc: do not store a bandwidth code for each channel.
  ac3enc: remove bandwidth reduction as fallback for bit allocation failure.
  ac3enc: merge compute_exp_strategy_ch() into compute_exp_strategy()
  ac3enc: return error if frame+exponent bits are too large instead of using av_assert2().
  ac3enc: differentiate between current block and reference block in bit_alloc()
  ac3enc: simplify exponent_init() by calculating exponent_group_tab[] based on exponent group sizes.
  ac3enc: simplify stereo rematrixing decision options
Include both URLs:  Update URL to fate samples

Conflicts:
	Changelog
	doc/fate.txt
	libavcodec/ac3enc.c
	libavcodec/dpxenc.c
	libavcodec/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-05-02 03:45:58 +02:00
Michael Niedermayer
1aeb88b77d Correctly implement ac3 float/fixed encoder.
There is no need to have 2 encoders, the input sample format can,does and should choose which is used
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-04-16 23:24:10 +02:00
Michael Niedermayer
445fdc0140 Merge remote-tracking branch 'newdev/master'
* newdev/master:
  ac3enc: move compute_mantissa_size() to ac3dsp
  ac3enc: move mant*_cnt and qmant*_ptr out of AC3EncodeContext
  Remove support for stripping executables
  ac3enc: NEON optimised float_to_fixed24
  ac3: move ff_ac3_bit_alloc_calc_bap to ac3dsp
  dfa: protect pointer range checks against overflows.
Duplicate:  mimic: implement multithreading.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-03-30 03:09:08 +02:00
Mans Rullgard
6d9f52b2cd ac3: move ff_ac3_bit_alloc_calc_bap to ac3dsp
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-03-29 19:31:45 +01:00
Michael Niedermayer
25d8099beb Merge remote-tracking branch 'newdev/master'
* newdev/master:
  ac3enc: Add codec-specific options for writing AC-3 metadata.
NOT MERGED:  Remove arrozcru URL from documentation
  sndio support for playback and record

Conflicts:
	doc/faq.texi
	doc/general.texi

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-03-28 01:50:36 +02:00
Justin Ruggles
991f3de1bb ac3enc: Add codec-specific options for writing AC-3 metadata. 2011-03-27 11:30:09 -04:00
Michael Niedermayer
27ef7b1bcd Merge remote-tracking branch 'newdev/master'
* newdev/master:
  mov: set audio service type for AC-3 from bitstream mode in the 'dac3' atom.
  Get audio_service_type for AC-3 based on bitstream mode in the AC-3 parser and decoder, and vice-versa for the AC-3 encoder.
  Use audio_service_type to set stream disposition.
  Add APIchanges entry for audio_service_type.
  Add audio_service_type field to AVCodecContext for encoding and reporting of the service type in the audio bitstream.
  configure: in check_ld, place new -l flags before existing ones
  support @heading, @subheading, @subsubheading, and @subsubsection in texi2pod.pl
  doc: update build system documentation
  aacenc: indentation
  aacenc: fix the side calculation in search_for_ms
  vp8.c: rename EDGE_* to VP8_EDGE_*.

Conflicts:
	doc/APIchanges
	libavcodec/avcodec.h
	libavcodec/version.h
	libavcodec/vp8.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-03-26 03:06:30 +01:00
Justin Ruggles
be18738801 Get audio_service_type for AC-3 based on bitstream mode in the AC-3 parser
and decoder, and vice-versa for the AC-3 encoder.
2011-03-25 16:59:00 -04: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
12dffc4502 ac3: define AC3_MAX_CPL_BANDS and use it in ac3dec.h
(cherry picked from commit b35743ffb4)
2011-03-05 02:29:33 +01:00
Justin Ruggles
b35743ffb4 ac3: define AC3_MAX_CPL_BANDS and use it in ac3dec.h 2011-03-04 16:48:09 -05:00
Justin Ruggles
dff80041e3 Add ff_ prefix to ac3_common_init().
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 4c57cde942)
2011-01-28 03:15:33 +01:00
Justin Ruggles
4c57cde942 Add ff_ prefix to ac3_common_init().
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-26 15:35:27 +00:00
Diego Elio Pettenò
a172126c38 Remove unused ac3_parametric_bit_allocation function.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 362bfe2997)
2011-01-26 03:43:30 +01:00
Diego Elio Pettenò
362bfe2997 Remove unused ac3_parametric_bit_allocation function.
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-25 15:09:46 +00:00
Justin Ruggles
e0b9f94b39 cosmetics: use some size macros in ac3tab.c/h
Originally committed as revision 25969 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-12-14 14:51:47 +00:00