aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/ac3enc.h
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/ac3enc: Move transient PutBitContext to stackAndreas Rheinhardt2024-05-201-3/+3
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Avoid copying samplesAndreas Rheinhardt2024-04-181-1/+1
| | | | | | | | | | | | | | Only the last 256 samples of each frame are used; the encoder currently uses a buffer for 1536 + 256 samples whose first 256 samples contain are the last 256 samples from the last frame and the next 1536 are the samples of the current frame. Yet since 238b2d4155d9779d770fccb3594076bb32742c82 all the DSP functions only need 256 contiguous samples and this can be achieved by only retaining the last 256 samples of each frame. Doing so saves 6KiB per channel. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Combine cpl_coord buffersAndreas Rheinhardt2024-04-181-2/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Avoid indirections, allocations of small arraysAndreas Rheinhardt2024-04-181-11/+11
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Avoid allocation for mdct_windowAndreas Rheinhardt2024-04-181-1/+4
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Avoid allocation for windowed_samplesAndreas Rheinhardt2024-04-181-1/+6
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Avoid function pointers to initialize MDCTAndreas Rheinhardt2024-04-111-3/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Deduplicate copying input samplesAndreas Rheinhardt2024-04-111-1/+1
| | | | | | | | | These memcpy operands only depend upon sizeof(SampleType) (and this size is actually the same for both the fixed-point and the floating-point encoders for most (all supported?) systems). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Deduplicate allocating buffersAndreas Rheinhardt2024-04-111-5/+2
| | | | | | | | | These allocations only depend upon sizeof(SampleType) (and this size is actually the same for both the fixed-point and the floating-point encoders for most (all supported?) systems). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Share more code between fixed/float encodersAndreas Rheinhardt2024-04-111-4/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Use common encode_frame functionAndreas Rheinhardt2024-04-111-11/+5
| | | | | | | This is in preparation for sharing even more stuff common to the fixed and floating-point encoders. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Remove disabled code for RealAudio variant of AC-3Andreas Rheinhardt2024-04-111-2/+0
| | | | | | | | Implicitly disabled by 4679a474f06c229b10976d7f0b4eee0613c2715a. Given that no one has ever complained about this, this commit removes the now dead code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUTJames Almer2024-03-071-3/+0
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* ac3: convert to lavu/txLynne2022-11-061-3/+4
|
* avcodec/ac3: Move non-(de|en)coder-only parts out of ac3.hAndreas Rheinhardt2022-05-151-0/+1
| | | | | | | | | | 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>
* avcodec/codec_internal: Rename AVCodecDefault->FFCodecDefaultAndreas Rheinhardt2022-03-211-1/+1
| | | | | | | This structure is no longer declared in a public header, so using an FF-prefix is more appropriate. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-211-1/+1
| | | | | | | | | | Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault. This reduces the amount of files that have to include internal.h (which comes with quite a lot of indirect inclusions), as e.g. most encoders don't need it. It is furthemore in preparation for moving the private part of AVCodec out of the public codec.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* ac3: convert to new channel layout APIVittorio Giovara2022-03-151-1/+3
| | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/ac3tab: Unavpriv ac3_channel_layout_tabAndreas Rheinhardt2022-01-041-0/+1
| | | | | | | | | | | | | | | | | It is small (16 B) and therefore the overhead of exporting it more than outweighs the size savings from not having duplicated symbols: When the symbol is no longer avpriv, one saves twice the size of the string containing the symbols name (2x30 byte), two entries in .dynsym (24 bytes each on x64), one entry in the importing libraries .got and .rela.dyn (8 + 24 bytes on x64) and two entries for the symbol version (2 bytes each) and one hash value in the exporting library (4 bytes). (The exact numbers are of course different for other platforms (e.g. when using dlls), but given that the strings saved alone more than outweigh the array size it can be presumed that this is beneficial for all platforms.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Remove/replace some unnecessary avcodec.h inclusionsAndreas Rheinhardt2021-07-221-0/+1
| | | | | | | Also remove other unnecessary headers and include headers directly while at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Deduplicate AVClassesAndreas Rheinhardt2021-07-081-0/+1
| | | | | | | | The child_class_next API relied on different AVCodecs to use different AVClasses; yet this API has been replaced by child_class_iterate. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/ac3enc: Share options and defaultsAndreas Rheinhardt2021-02-071-7/+2
| | | | | | | | | | Both AC-3 encoder share the same options, yet they are nevertheless duplicated in the binary; and the options applying to the EAC-3 encoder are a proper subset of the options for the AC-3 encoders, so that it can use the same options as the former by putting the options specific to AC-3 at the front. This commit implements this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* ac3enc_fixed: convert to 32-bit sample formatLynne2021-01-141-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The AC3 encoder used to be a separate library called "Aften", which got merged into libavcodec (literally, SVN commits and all). The merge preserved as much features from the library as possible. The code had two versions - a fixed point version and a floating point version. FFmpeg had floating point DSP code used by other codecs, the AC3 decoder including, so the floating-point DSP was simply replaced with FFmpeg's own functions. However, FFmpeg had no fixed-point audio code at that point. So the encoder brought along its own fixed-point DSP functions, including a fixed-point MDCT. The fixed-point MDCT itself is trivially just a float MDCT with a different type and each multiply being a fixed-point multiply. So over time, it got refactored, and the FFT used for all other codecs was templated. Due to design decisions at the time, the fixed-point version of the encoder operates at 16-bits of precision. Although convenient, this, even at the time, was inadequate and inefficient. The encoder is noisy, does not produce output comparable to the float encoder, and even rings at higher frequencies due to the badly approximated winow function. Enter MIPS (owned by Imagination Technologies at the time). They wanted quick fixed-point decoding on their FPUless cores. So they contributed patches to template the AC3 decoder so it had both a fixed-point and a floating-point version. They also did the same for the AAC decoder. They however, used 32-bit samples. Not 16-bits. And we did not have 32-bit fixed-point DSP functions, including an MDCT. But instead of templating our MDCT to output 3 versions (float, 32-bit fixed and 16-bit fixed), they simply copy-pasted their own MDCT into ours, and completely ifdeffed our own MDCT code out if a 32-bit fixed point MDCT was selected. This is also the status quo nowadays - 2 separate MDCTs, one which produces floating point and 16-bit fixed point versions, and one sort-of integrated which produces 32-bit MDCT. MIPS weren't all that interested in encoding, so they left the encoder as-is, and they didn't care much about the ifdeffery, mess or quality - it's not their problem. So the MDCT/FFT code has always been a thorn in anyone looking to clean up code's eye. Backstory over. Internally AC3 operates on 25-bit fixed-point coefficients. So for the floating point version, the encoder simply runs the float MDCT, and converts the resulting coefficients to 25-bit fixed-point, as AC3 is inherently a fixed-point codec. For the fixed-point version, the input is 16-bit samples, so to maximize precision the frame samples are analyzed and the highest set bit is detected via ac3_max_msb_abs_int16(), and the coefficients are then scaled up via ac3_lshift_int16(), so the input for the FFT is always at least 14 bits, computed in normalize_samples(). After FFT, the coefficients are scaled up to 25 bits. This patch simply changes the encoder to accept 32-bit samples, reusing the already well-optimized 32-bit MDCT code, allowing us to clean up and drop a large part of a very messy code of ours, as well as prepare for the future lavu/tx conversion. The coefficients are simply scaled down to 25 bits during windowing, skipping 2 separate scalings, as the hacks to extend precision are simply no longer necessary. There's no point in running the MDCT always at 32 bits when you're going to drop 6 bits off anyway, the headroom is plenty, and the MDCT rounds properly. This also makes the encoder even slightly more accurate over the float version, as there's no coefficient conversion step necessary. SIZE SAVINGS: ARM32: HARDCODED TABLES: BASE - 10709590 DROP DSP - 10702872 - diff: -6.56KiB DROP MDCT - 10667932 - diff: -34.12KiB - both: -40.68KiB DROP FFT - 10336652 - diff: -323.52KiB - all: -364.20KiB SOFTCODED TABLES: BASE - 9685096 DROP DSP - 9678378 - diff: -6.56KiB DROP MDCT - 9643466 - diff: -34.09KiB - both: -40.65KiB DROP FFT - 9573918 - diff: -67.92KiB - all: -108.57KiB ARM64: HARDCODED TABLES: BASE - 14641112 DROP DSP - 14633806 - diff: -7.13KiB DROP MDCT - 14604812 - diff: -28.31KiB - both: -35.45KiB DROP FFT - 14286826 - diff: -310.53KiB - all: -345.98KiB SOFTCODED TABLES: BASE - 13636238 DROP DSP - 13628932 - diff: -7.13KiB DROP MDCT - 13599866 - diff: -28.38KiB - both: -35.52KiB DROP FFT - 13542080 - diff: -56.43KiB - all: -91.95KiB x86: HARDCODED TABLES: BASE - 12367336 DROP DSP - 12354698 - diff: -12.34KiB DROP MDCT - 12331024 - diff: -23.12KiB - both: -35.46KiB DROP FFT - 12029788 - diff: -294.18KiB - all: -329.64KiB SOFTCODED TABLES: BASE - 11358094 DROP DSP - 11345456 - diff: -12.34KiB DROP MDCT - 11321742 - diff: -23.16KiB - both: -35.50KiB DROP FFT - 11276946 - diff: -43.75KiB - all: -79.25KiB PERFORMANCE (10min random s32le): ARM32 - before - 39.9x - 0m15.046s ARM32 - after - 28.2x - 0m21.525s Speed: -30% ARM64 - before - 36.1x - 0m16.637s ARM64 - after - 36.0x - 0m16.727s Speed: -0.5% x86 - before - 184x - 0m3.277s x86 - after - 190x - 0m3.187s Speed: +3%
* avcodec/ac3enc: Factor common end of float/fixed encode_frame outAndreas Rheinhardt2021-01-091-12/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/[e]ac3enc: Don't invade CONFIG_ namespaceAndreas Rheinhardt2021-01-091-3/+3
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ac3enc: Set function pointers earlierAndreas Rheinhardt2021-01-091-12/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* ac3enc: drop a global variableAnton Khirnov2020-02-071-0/+2
| | | | | | | | Log the warning message once per encoder instance instead. Reviewed-by: Kieran Kunhya <kierank@obe.tv> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/ac3enc: Use avpriv_float_dsp_alloc()Michael Niedermayer2014-11-291-1/+1
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Merge commit 'cc4992aaf3dbb0af88d9727983d75636baf1f8cc'Michael Niedermayer2014-09-261-0/+1
|\ | | | | | | | | | | | | * commit 'cc4992aaf3dbb0af88d9727983d75636baf1f8cc': ac3enc: allow Dolby Pro Logic IIz as the Dolby Surround EX mode. Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * ac3enc: allow Dolby Pro Logic IIz as the Dolby Surround EX mode.Tim Walker2014-09-261-0/+1
| | | | | | | | This is actually defined in the A/52 specification.
* | Merge commit '4c2fd4b262347273afe97865ba451a1abde43ae6'Michael Niedermayer2014-09-261-0/+1
|\| | | | | | | | | | | | | * commit '4c2fd4b262347273afe97865ba451a1abde43ae6': ac3enc: allow Dolby Pro Logic II as a preferred downmix mode. Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * ac3enc: allow Dolby Pro Logic II as a preferred downmix mode.Tim Walker2014-09-261-0/+1
| | | | | | | | | | Some encoders already use this value even though it's reserved in the A/52 specification.
* | Merge commit '2d60444331fca1910510038dd3817bea885c2367'Michael Niedermayer2014-07-171-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '2d60444331fca1910510038dd3817bea885c2367': dsputil: Split motion estimation compare bits off into their own context Conflicts: configure libavcodec/Makefile libavcodec/arm/Makefile libavcodec/dvenc.c libavcodec/error_resilience.c libavcodec/h264.h libavcodec/h264_slice.c libavcodec/me_cmp.c libavcodec/me_cmp.h libavcodec/motion_est.c libavcodec/motion_est_template.c libavcodec/mpeg4videoenc.c libavcodec/mpegvideo.c libavcodec/mpegvideo_enc.c libavcodec/x86/Makefile libavcodec/x86/me_cmp_init.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * dsputil: Split motion estimation compare bits off into their own contextDiego Biurrun2014-07-171-2/+2
| |
* | Merge commit '9a9e2f1c8aa4539a261625145e5c1f46a8106ac2'Michael Niedermayer2014-06-221-0/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '9a9e2f1c8aa4539a261625145e5c1f46a8106ac2': dsputil: Split audio operations off into a separate context Conflicts: configure libavcodec/takdec.c libavcodec/x86/Makefile libavcodec/x86/dsputil.asm libavcodec/x86/dsputil_init.c libavcodec/x86/dsputil_mmx.c libavcodec/x86/dsputil_x86.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * dsputil: Split audio operations off into a separate contextDiego Biurrun2014-06-221-0/+2
| |
* | Merge commit '27631796c9d1b8146ad4a16e6539ecc08afa7565'Michael Niedermayer2014-06-131-0/+1
|\| | | | | | | | | | | | | * commit '27631796c9d1b8146ad4a16e6539ecc08afa7565': ac3: Only initialize float_dsp for the float encoder variant Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * ac3: Only initialize float_dsp for the float encoder variantDiego Biurrun2014-06-131-0/+1
| |
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2014-03-041-1/+3
|\| | | | | | | | | | | | | | | | | | | * qatar/master: put_bits: Remove unused includes Conflicts: libavcodec/put_bits.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * put_bits: Remove unused includesVittorio Giovara2014-03-041-1/+3
| | | | | | | | | | This requires adding includes to other files that relied on these being included implicitly.
* | Reinstate proper FFmpeg license for all files.Thilo Borgmann2013-08-301-4/+4
|/
* Add a float DSP framework to libavutilJustin Ruggles2012-06-081-0/+3
| | | | Move vector_fmul() from DSPContext to AVFloatDSPContext.
* ac3enc: update to AVCodec.encode2()Justin Ruggles2012-03-201-4/+4
| | | | Update FATE references due to encoder delay.
* Make channel layout masks unsignedMans Rullgard2011-11-251-1/+1
| | | | | | | | | | 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>
* fix AC3ENC_OPT_MODE_ON/OFFJohn Stebbins2011-10-111-2/+2
| | | | | | The values were reversed. Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
* ac3enc: Add channel coupling support for the fixed-point AC-3 encoder.Justin Ruggles2011-09-051-0/+2
| | | | Update FATE references accordingly.
* ac3enc: add macros for option names to make them more understandable.Justin Ruggles2011-08-111-0/+17
|
* ac3enc: allow new coupling coordinates to be sent independently for eachJustin Ruggles2011-08-091-1/+1
| | | | channel.
* ac3enc: separate exponent bit counting from exponent grouping.Justin Ruggles2011-08-091-0/+2
| | | | | | Move bit counting to the bit allocation function. Move exponent grouping to after bit allocation. This will allow for adjustment of bandwidth parameters during bit allocation without having to do exponent grouping multiple times.
* eac3enc: support writing of basic mixing and info metadataJustin Ruggles2011-07-271-0/+2
|