summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc.c
Commit message (Collapse)AuthorAge
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-05
| | | | | | | | | | | This is possible, because every given FFCodec has to implement exactly one of these. Doing so decreases sizeof(FFCodec) and therefore decreases the size of the binary. Notice that in case of position-independent code the decrease is in .data.rel.ro, so that this translates to decreased memory consumption. 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/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-21
| | | | | | | | | | | | | | | | Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean. Reviewed-by: Anton Khirnov <anton@khirnov.net> 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>
* libavcodec: Split version.hMartin Storsjö2022-03-16
| | | | | | | | | | | | | | This avoids including version.h in all source files, avoiding unnecessary rebuilds when the version number is bumped. Only version_major.h is included by the main header, which defines availability of e.g. FF_API_* macros, and which is bumped much less often. This isn't done for libavutil/version.h, because that header needs to be included essentially everywhere due to LIBAVUTIL_VERSION_INT being used wherever an AVClass is constructed. Signed-off-by: Martin Storsjö <martin@martin.st>
* aac: convert to new channel layout APIAnton Khirnov2022-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/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_ratesAndreas Rheinhardt2022-01-04
| | | | | | | | | | | | | | | | | | | | | avpriv_mpeg4audio_sample_rates has a size of 64B and it is currently avpriv; a clone of it exists in aacenctab.h and from there it is inlined in aacenc.c (which also uses the avpriv version) and in the FLV muxer. This means that despite it being avpriv both libavformat as well as libavcodec have copies already. This situation is clearly suboptimal. Given the overhead of exporting symbols (for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn, 8B .got, 4B hash + twice the size of the name (here 31B)) the object is unavprived, i.e. duplicated into libavformat when creating a shared build; but the duplicates in the AAC encoder and FLV muxer are removed. This involves splitting of the sample rate table into a file of its own; this allowed to break some spurious dependencies (e.g. both the AAC encoder as well as the Matroska demuxer actually don't need the mpeg4audio_get_config stuff). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/avcodec: Stop including channel_layout.h in avcodec.hAndreas Rheinhardt2021-07-22
| | | | | | Also include channel_layout.h directly wherever used. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/encode: Always use intermediate buffer in ff_alloc_packet2()Andreas Rheinhardt2021-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, ff_alloc_packet2() has a min_size parameter: It is supposed to be a lower bound on the final size of the packet to allocate. If it is not too far from the upper bound (namely, if it is at least half the upper bound), then ff_alloc_packet2() already allocates the final, already refcounted packet; if it is not, then the packet is not refcounted and its data only points to a buffer owned by the AVCodecContext (in this case, the packet will be made refcounted in encode_simple_internal() in libavcodec/encode.c). The goal of this was to avoid data copies and intermediate buffers if one has a precise lower bound. Yet those encoders for which precise lower bounds exist have recently been switched to ff_get_encode_buffer() (which automatically allocates final buffers), leaving only two encoders to actually set the min_size to something else than zero (namely aliaspixenc and hapenc). Both of these encoders use a very low lower bound that is not helpful in any nontrivial case. This commit therefore removes the min_size parameter as well as the codepath in ff_alloc_packet2() for the allocation of final buffers. Furthermore, the function has been renamed to ff_alloc_packet() and moved to encode.h alongside ff_get_encode_buffer(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacenc: Do not divide by lambda_count if it is 0Michael Niedermayer2021-06-02
| | | | | | | | Avoids Floating point division by 0 Fixes: Ticket8011 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/aacenc: Use FLT_EPSILON for lambda minimumMichael Niedermayer2021-06-02
|
* avcodec/aacenc: Avoid 0 lambdaMichael Niedermayer2021-05-29
| | | | | | | Fixes: Ticket8003 Fixes: CVE-2020-20453 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* aacenc: make the twoloop coder the defaultLynne2021-05-21
| | | | | | | | This used to be the default, but was reverted as it was slower than the 'fast' coder by around 25%. Since our encoder is still not very good, change back to the twoloop coder by default. It has much better rate control management as well, making it closer to CBR, and it sounds much better.
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-27
| | | | | | | | | | Given that the AVCodec.next pointer has now been removed, most of the AVCodecs are not modified at all any more and can therefore be made const (as this patch does); the only exceptions are the very few codecs for external libraries that have a init_static_data callback. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* Avoid intermediate bitcount for number of bytes in PutBitContextAndreas Rheinhardt2021-03-30
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/aac: Share common init code of float decoder and encoderAndreas Rheinhardt2020-12-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/aac*: Make initializing ff_aac_pow*sf_tab thread-safeAndreas Rheinhardt2020-11-24
| | | | | | | | | | | | | | This table is currently initialized up to three times: Once by the encoder and twice by the decoders (once by the fixed and once by the floating-point decoder); each of these initializations is guarded by an AVOnce, yet the fact that there are three of them implies that there might be data races (the fact that each entry is only written to once (to its final value) when initializing means that this is safe in practice, yet it is still undefined behaviour). Fix this by only initializing the table from one place that is guarded by a single AVOnce. This also avoids unnecessary duplications of the init code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* put_bits: make avpriv_put_string() lavc-localAnton Khirnov2020-10-28
| | | | | It has not been used outside of libavcodec since 20f325f320c6e18ee88983870d2a1fee94257293
* put_bits: make avpriv_align_put_bits() inlineAnton Khirnov2020-10-28
| | | | | | | | | This function is so extremely simple that it is preferable to make it inline rather than deal with all the complications arising from it being an exported symbol. Keep avpriv_align_put_bits() around until the next major bump to preserve ABI compatibility.
* avcodec/aacenc: remove FF_ALLOCZ_ARRAY_OR_GOTO and gotos labelLimin Wang2020-06-13
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec/aacenc: add FF_CODEC_CAP_INIT_CLEANUPLimin Wang2020-06-13
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avcodec: move aacenc profiles to profiles.hMarton Balint2020-05-22
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec/aacenc: report channel layout by nameMoritz Barsnick2018-09-09
| | | | | | | Possibly useful in the error case. Signed-off-by: Moritz Barsnick <barsnick@gmx.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* aacenc: use the fast coder as the defaultRostislav Pehlivanov2018-01-13
| | | | | | | | | | | | The twoloop coder sounds decent at low bitrates, however at higher bitrates it sounds worse than the fast coder (which used to be the old twoloop coder before October 2015) and needs quite a lot more CPU. Change the default to fast. It has been well tested and has had little changes over the years so its been confirmed to be quite stable. Also change its description (not valid for more than a year) and the documentation. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* aacenc: use the PCE comment field for encoder IDRostislav Pehlivanov2017-11-09
| | | | | | Also handle extradata of variable size (for bitexact/if PCEs aren't used). Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* aacenc: support extended channel layouts using PCEsRostislav Pehlivanov2017-11-09
| | | | | | | | | | | | This commit implements support for PCE (Program Configuration Elements) in the AAC encoder, and as such allows for encoding of channel layouts not present in the presets defined by the spec (which only lists the 8 most common ones). This has been a highly requested feature and is also the first open source encoder to support this many layouts. Many thanks to pkviet <pkv.stream@gmail.com> who implemented support for and verified all channel layouts.
* Merge commit '97cfe1d8bd1968143e2ba9aa46ebe9504a835e24'James Almer2017-11-01
|\ | | | | | | | | | | | | * commit '97cfe1d8bd1968143e2ba9aa46ebe9504a835e24': Convert all AVClass struct declarations to designated initializers. Merged-by: James Almer <jamrial@gmail.com>
| * Convert all AVClass struct declarations to designated initializers.Diego Biurrun2017-06-12
| |
| * Mark some arrays that never change as const.Anton Khirnov2017-02-01
| |
* | avcodec: stop using deprecated codec flagsJames Almer2017-03-25
| | | | | | | | Signed-off-by: James Almer <jamrial@gmail.com>
* | aacenc: quit when the audio queue reaches 0 rather than keeping track of ↵Rostislav Pehlivanov2016-11-08
| | | | | | | | | | | | | | | | | | empty frames The libopus encoder does the same thing and its better than keeping track of when the empty flush frames appear. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: add SIMD optimizations for abs_pow34 and quantizationRostislav Pehlivanov2016-10-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Performance improvements: quant_bands: with: 681 decicycles in quant_bands, 8388453 runs, 155 skips without: 1190 decicycles in quant_bands, 8388386 runs, 222 skips Around 42% for the function Twoloop coder: abs_pow34: with/without: 7.82s/8.17s Around 4% for the entire encoder Both: with/without: 7.15s/8.17s Around 12% for the entire encoder Fast coder: abs_pow34: with/without: 3.40s/3.77s Around 10% for the entire encoder Both: with/without: 3.02s/3.77s Around 20% faster for the entire encoder Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com> Tested-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: James Almer <jamrial@gmail.com>
* | aacenc: use the decoder's lcg PRNGRostislav Pehlivanov2016-10-12
| | | | | | | | | | | | | | | | Using lfg was an overkill in this case where the random numbers were only used for encoder descisions. Should increase result uniformity between different FPUs and gives a slight speedup. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | avcodec/aacenc: Tighter input checksMichael Niedermayer2016-08-23
| | | | | | | | | | | | | | | | Fixes occurance of NaN/Inf leading to assertion failures and out of array access Fixes: d1c38a09acc34845c6be3a127a5aacaf/signal_sigsegv_3982225_6121_d18bd5451d4245ee09408f04badd1b83.wmv Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | aacenc: fix various typos and an error messageRostislav Pehlivanov2016-08-13
| | | | | | | | | | | | Too much copy and pasting. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: unmark the fast coder as experimentalRostislav Pehlivanov2016-08-13
| | | | | | | | | | | | | | This version has had much testing so there's little point in keeping it maked as experimental. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | AAC encoder: fix valgrind errorsClaudio Freire2016-04-05
| | | | | | | | | | | | Move wi.clipping computation outside of psy_lame_window, LFE channels don't even call that, and make the LFE path also initialize window_type[1] which is needed by analyze_channel
* | aacenc: use generational cache instead of resetting.Reimar Döffinger2016-03-08
| | | | | | | | | | | | | | Approximately 11% faster transcoding from mp3 with default settings. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* | aacenc: temporarily disable Mid/Side coding with multichannel filesRostislav Pehlivanov2016-02-13
| | | | | | | | | | | | | | | | Results in dropping out in channels, usually on EIGHT_SHORT windows. Will be reenabled once the cause has been investigated and a fix has been made. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: make a better estimate for the audio bitrate if not providedRostislav Pehlivanov2016-02-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Takes into account whether there's pairing and if there's an LFE channel. An SCE has more bits than CPE/2 since IS and M/S save quite a lot of bits when channels are paired. And most of the SCEs we have are in surround layouts which map it to the center channel, which usually carries all of the dialogue and compression artifacts there are easily audiable. Also refactors the init function a little bit and labels some parts of it. Fixes bug #5233 Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | avcodec/aacenc: Check all coefficients for finitenessMichael Niedermayer2016-01-20
| | | | | | | | | | | | | | | | | | | | | | | | | | This is needed as near infinite values on the input side result in only some output to be non finite. Also it may still be insufficient if subsequent computations overflow Fixes null pointer dereference Fixes: ae66c0f6c12ac1cd5c2c237031240f57/signal_sigsegv_2618c99_9516_6007026f2185a26d7afea895fbed6e38.ogg Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Reviewed-by: Claudio Freire <klaussfreire@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | aacenc: remove FAAC-like coderRostislav Pehlivanov2016-01-20
| | | | | | | | | | | | | | Has been marked for removal for over a month and has not been improved or touched at all since it was implemented. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: mark LTP mode as experimentalRostislav Pehlivanov2016-01-20
| | | | | | | | | | | | | | Too many crashes observed. Can't be helped until the autocorrelation function is massively checked for sanity. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | avcodec/aacenc: Check both channels for finitenessMichael Niedermayer2016-01-16
| | | | | | | | | | | | | | | | Fixes null pointer dereference Fixes: 10412fc52ecc6eab40ed67f82ca7b372/signal_sigsegv_2618c99_2129_f808373959e46afb165593332799ffbc.aif Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | lavc/aacenc: use isfinite to simplify isnan/isinf logicGanesh Ajjanagadde2016-01-14
| | | | | | | | | | Reviewed-by: Claudio Freire <klaussfreire@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* | avcodec/aacenc: Check for +-Inf tooMichael Niedermayer2016-01-13
| | | | | | | | | | | | | | | | Fixes out of array read Fixes: 04442da73d935b776d2236282588d4f9/signal_sigsegv_2625a69_8790_ae85ffc889070663319b3417ede777b0.mov Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/aacenc: mark output as const as its not written toMichael Niedermayer2016-01-13
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/aacenc: Fix NAN checkMichael Niedermayer2016-01-13
| | | | | | | | | | | | | | | | | | All MDCT outputs must be checked in case of 128point MDCTs Fixes: out of array read Fixes: 04442da73d935b776d2236282588d4f9/signal_sigsegv_2625a69_351_52ca6226eb83547a2d26e322ce84ed84.mov Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | AAC encoder: don't apply MS on special bandsClaudio Freire2016-01-13
| | | | | | | | | | | | | | | | | | Change the condition for application of the M/S transform to match that of the decoder. Namely, that no special coding books must be in use in either channel. While the condition ought to be equivalent to the current one when the invariant of is_mask is kept, matching the decoder's condition is safer and easier to maintain.
* | acenc: remove deprecated avctx->frame_bits useRostislav Pehlivanov2015-12-18
| | | | | | | | | | | | | | | | | | The type of last_frame_pb_count was chosen to be an int since overflow is impossible (the spec says the maximum bits per frame is 6144 per channel and the encoder checks for that). Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com>