summaryrefslogtreecommitdiff
path: root/libavcodec/ac3enc.h
Commit message (Collapse)AuthorAge
* avcodec/ac3: Move non-(de|en)coder-only parts out of ac3.hAndreas Rheinhardt2022-05-15
| | | | | | | | | | 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-21
| | | | | | | 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-21
| | | | | | | | | | 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-15
| | | | | | 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-04
| | | | | | | | | | | | | | | | | 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-22
| | | | | | | 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-08
| | | | | | | | 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-07
| | | | | | | | | | 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-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/[e]ac3enc: Don't invade CONFIG_ namespaceAndreas Rheinhardt2021-01-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ac3enc: Set function pointers earlierAndreas Rheinhardt2021-01-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* ac3enc: drop a global variableAnton Khirnov2020-02-07
| | | | | | | | 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-29
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Merge commit 'cc4992aaf3dbb0af88d9727983d75636baf1f8cc'Michael Niedermayer2014-09-26
|\ | | | | | | | | | | | | * 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-26
| | | | | | | | This is actually defined in the A/52 specification.
* | Merge commit '4c2fd4b262347273afe97865ba451a1abde43ae6'Michael Niedermayer2014-09-26
|\| | | | | | | | | | | | | * 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-26
| | | | | | | | | | Some encoders already use this value even though it's reserved in the A/52 specification.
* | Merge commit '2d60444331fca1910510038dd3817bea885c2367'Michael Niedermayer2014-07-17
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-17
| |
* | Merge commit '9a9e2f1c8aa4539a261625145e5c1f46a8106ac2'Michael Niedermayer2014-06-22
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-22
| |
* | Merge commit '27631796c9d1b8146ad4a16e6539ecc08afa7565'Michael Niedermayer2014-06-13
|\| | | | | | | | | | | | | * 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-13
| |
* | Merge remote-tracking branch 'qatar/master'Michael Niedermayer2014-03-04
|\| | | | | | | | | | | | | | | | | | | * 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-04
| | | | | | | | | | This requires adding includes to other files that relied on these being included implicitly.
* | Reinstate proper FFmpeg license for all files.Thilo Borgmann2013-08-30
|/
* Add a float DSP framework to libavutilJustin Ruggles2012-06-08
| | | | Move vector_fmul() from DSPContext to AVFloatDSPContext.
* ac3enc: update to AVCodec.encode2()Justin Ruggles2012-03-20
| | | | Update FATE references due to encoder delay.
* Make channel layout masks unsignedMans Rullgard2011-11-25
| | | | | | | | | | 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-11
| | | | | | 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-05
| | | | Update FATE references accordingly.
* ac3enc: add macros for option names to make them more understandable.Justin Ruggles2011-08-11
|
* ac3enc: allow new coupling coordinates to be sent independently for eachJustin Ruggles2011-08-09
| | | | channel.
* ac3enc: separate exponent bit counting from exponent grouping.Justin Ruggles2011-08-09
| | | | | | 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-27
|
* eac3enc: use different numbers of blocks per frame to allow higher bitratesJustin Ruggles2011-07-21
|
* eac3enc: use frame exponent strategy when applicable.Justin Ruggles2011-07-19
| | | | | | | This checks if the set of selected exponent strategies for all blocks in a channel are in the frame exponent strategy table, and if so, writes the table index instead of each strategy. This saves up to 7 bits per channel per frame, so the overall effect on quality is small.
* ac3enc: merge AC3MDCTContext with AC3EncodeContext.Justin Ruggles2011-07-13
| | | | | | Since both the fixed-point and floating-point encoders use the FFTContext, this no longer needs to be in a separate context. Also, when a short-transform context is added, the same MDCT window will be used.
* ac3enc: prefer passing AC3EncodeContext rather than AVCodecContextJustin Ruggles2011-07-13
|
* ac3enc: clip coefficients after MDCT.Justin Ruggles2011-07-01
| | | | | This ensures that any processing between the MDCT and exponent extraction will be using clipped coefficients.
* ac3enc: move ff_ac3_encode_frame() to ac3enc_template.cJustin Ruggles2011-06-27
| | | | | This avoids using function pointers for quite a few small functions, most of which just call DSP functions.
* ac3enc: avoid masking output in asym_quant() by using signed values forJustin Ruggles2011-06-22
| | | | quantized mantissas.
* ac3enc: fix allocation of floating point samples.Justin Ruggles2011-06-13
| | | | sizeof(SampleType) is different for fixed and float encoders.
* ac3enc: remove empty ac3_float function that is never calledJustin Ruggles2011-06-13
|
* ac3enc: split templated float vs. fixed functions into a separate file.Justin Ruggles2011-06-13
| | | | | Function pointers are used for templated functions instead of needlessly duplicating many functions.
* ac3enc: dynamically allocate AC3EncodeContext fields windowed_samples and mdctJustin Ruggles2011-06-13
| | | | | This will allow the same struct to be used for both the fixed and float ac3 encoders.
* ac3enc: use function pointer to choose between AC-3 and E-AC-3 header outputJustin Ruggles2011-06-13
| | | | functions.
* Move E-AC-3 encoder functions to a separate eac3enc.c file.Justin Ruggles2011-06-07
|
* preparing integration of new AC3 decoderFabrice Bellard2002-10-28
| | | | Originally committed as revision 1089 to svn://svn.ffmpeg.org/ffmpeg/trunk