summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc.c
Commit message (Collapse)AuthorAge
* 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>
* | Merge commit '16216b713f9a21865cc07993961cf5d0ece24916'Hendrik Leppkes2015-12-18
|\| | | | | | | | | | | | | * commit '16216b713f9a21865cc07993961cf5d0ece24916': lavc: Drop exporting 2-pass encoding stats Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * lavc: Drop exporting 2-pass encoding statsVittorio Giovara2015-12-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | These variables are coming from mpegvideoenc where are supposedly used as bit counters on various frame properties. However their use is unclear as they lack documentation, are available only from a very small subset of encoders, and they are hardly used in the wild. Also frame_bits in aacenc is employed in a similar way. Remove this functionality from AVCodecContex, these variable are mostly frame properties, and too few encoders support setting them with anything useful. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* | aacenc: switch to using the RNG from libavutilRostislav Pehlivanov2015-12-14
| | | | | | | | | | | | | | PSNR doesn't change as expected. The AAC spec doesn't really say anything about how exactly to generate noise. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: update max_sfb when num_swb changesAndreas Cadhalpun2015-12-08
| | | | | | | | | | | | | | This fixes out-of-bounds reads in avoid_clipping. Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* | Merge commit 'b805482b1fba1d82fbe47023a24c9261f18979b6'Hendrik Leppkes2015-12-08
|\| | | | | | | | | | | | | * commit 'b805482b1fba1d82fbe47023a24c9261f18979b6': aac: Provide more information on the failure message Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * aac: Provide more information on the failure messageLuca Barbato2015-12-05
| | | | | | | | Bug-Id: 761
* | aacenc: move the TNS search and filtering before PNSRostislav Pehlivanov2015-12-06
| | | | | | | | | | | | | | | | The original plan was to have TNS use data from the PNS search to better tune itself to noise but this was never used nor necessary. This should slightly boost the PNS accuracy if TNS was used. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: fix aac_pred option triggering an errorRostislav Pehlivanov2015-12-05
| | | | | | | | Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: remove the experimental flagRostislav Pehlivanov2015-12-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thiss commit removes the experimental flag from the native AAC Encoder and thus makes it the default. After a lot of work, done by myself and Claudio Freire, the quality of this encoder rivals and surpasses libfdk_aac in some situations. The encoder had instability issues earlier which prevented it from having its experimental flag removed, however the last commits done by Claudio removed the last known source of instability and solved a lot of problems which were previously observed. The issues were caused by the various coding tools interfering with the scalefactor indices. Thus, with these problems solved, it should now be possible to declare this encoder as the default and recommend that the users should use it instead of others provided by external libraries, as it is both faster and has a subjectively higher quality with selected tracks. The encoder has still yet to be fine tuned for every possible audio file type like music or voice, so it is hoped that with the experimental flag removed the users should be able to provide feedback and make the encoder better than the alternatives for every type of audio and at every bitrate. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: mark coders other than twoloop as experimentalRostislav Pehlivanov2015-12-05
| | | | | | | | | | | | | | ANMR has some interesting things coming up but is currently not in a shape fit for non-experimental usage. Same with "FAST". Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: mark the "faac"-like coder for removalRostislav Pehlivanov2015-12-05
| | | | | | | | | | | | | | | | | | | | | | This coder produces a much lower quality audio than the rest, is much slower and is unstable. Hasn't been updated for a very long time as well, hence it is more appropriate to remove it since it also depends on a big burden of a code (the encode_window_bands_info function which is just as old, just as unstable and bad and in no way modifiable or fixable). Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | mips: rename mipsdspr1 to mipsdspVicente Olivert Riera2015-12-04
| | | | | | | | | | Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | AAC encoder: improve SF range utilizationClaudio Freire2015-12-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does 4 things, all of which interact and thus it woudln't be possible to commit them separately without causing either quality regressions or assertion failures. Fate comparison targets don't all reflect improvements in quality, yet listening tests show substantially improved quality and stability. 1. Increase SF range utilization. The spec requires SF delta values to be constrained within the range -60..60. The previous code was applying that range to the whole SF array and not only the deltas of consecutive values, because doing so requires smarter code: zeroing or otherwise skipping a band may invalidate lots of SF choices. This patch implements that logic to allow the coders to utilize the full dynamic range of scalefactors, increasing quality quite considerably, and fixing delta-SF-related assertion failures, since now the limitation is enforced rather than asserted. 2. PNS tweaks The previous modification makes big improvements in twoloop's efficiency, and every time that happens PNS logic needs to be tweaked accordingly to avoid it from stepping all over twoloop's decisions. This patch includes modifications of the sort. 3. Account for lowpass cutoff during PSY analysis The closer PSY's allocation is to final allocation the better the quality is, and given these modifications, twoloop is now very efficient at avoiding holes. Thus, to compute accurate thresholds, PSY needs to account for the lowpass applied implicitly during twoloop (by zeroing high bands). This patch makes twoloop set the cutoff in psymodel's context the first time it runs, and makes PSY account for it during threshold computation, making PE and threshold computations closer to the final allocation and thus achieving better subjective quality. 4. Tweaks to RC lambda tracking loop in relation to PNS Without this tweak some corner cases cause quality regressions. Basically, lambda needs to react faster to overall bitrate efficiency changes since now PNS can be quite successful in enforcing maximum bitrates, when PSY allocates too many bits to the lower bands, suppressing the signals RC logic uses to lower lambda in those cases and causing aggressive PNS. This tweak makes PNS much less aggressive, though it can still use some further tweaks. Also update MIPS specializations and adjust fuzz Also in lavc/mips/aacpsy_mips.h: remove trailing whitespace
* | aacenc: fix broken build with hardcoded tablesRostislav Pehlivanov2015-11-27
| | | | | | | | | | | | | | | | ff_aac_tableinit is a macro in the case of hardcoded tables, so wrap that up in a function (similar to how the decoder template does it) and use that as the argument for ff_thread_once(). Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aac: temporarily un-share aac_table_init AVOnce variableRostislav Pehlivanov2015-11-27
| | | | | | | | | | | | | | AAC-Fixed decoder segfaulted. This commit makes the aac encoder and decoder init the table twice in case of transcoding again. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | aacenc: make threadsafeRostislav Pehlivanov2015-11-27
| | | | | | | | | | | | | | | | Since the ff_aac_tableinit() can be called by both the encoder and the decoder (in case of transcoding) this commit shares the AVOnce variable to prevent this. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* | AAC encoder: Fix application of M/S with PNSClaudio Freire2015-11-26
| | | | | | | | | | | | | | | | When both M/S coding and PNS are enabled, scalefactors and coding books would be mistakenly clobbered when setting the M/S flag on PNS'd bands. The flag needs to be set to signal the generation of correlated noise, but the scalefactors, coefficients and the coding books need to be kept intact.
* | avcodec/aacenc: Fix "libavcodec/aacenc.c:540:13: warning: ISO C90 forbids ↵Michael Niedermayer2015-10-17
| | | | | | | | | | | | mixed declarations and code" Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | aacenc_tns: enable Temporal Noise Shaping by defaultRostislav Pehlivanov2015-10-17
| | | | | | | | | | In light of the recent changes to the TNS system, it has been deemed worthy and robust enough to be turned on by default.
* | aacenc: partially revert previous commits to set options via a profileRostislav Pehlivanov2015-10-17
| | | | | | | | | | | | It didn't work out because of the exceptions that needed to be made for the "-1" cases and was overall more confusing that just manually checking and setting options for each profile.
* | aacenc: add support for encoding files using Long Term PredictionRostislav Pehlivanov2015-10-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Long Term Prediction allows for prediction of spectral coefficients via the previously decoded time-dependent samples. This feature works well with harmonic content 2 or more frames long, like speech, human or non-human, piano music or any constant tones at very low bitrates. It should be noted that the current coder is highly efficient and the rate control system is unable to encode files at extremely low bitrates (less than 14kbps seems to be impossible) so this extension isn't capable of optimum operation. Dramatic difference is observable with some types of audio and speech but for the most part the audiable differences are subtle. The spectrum looks better however so the encoder is able to harvest the additional bits that this feature provies, should the user choose to enable it. So it's best to enable this feature only if encoding at the absolutely lowest bitrate that the encoder is capable of.
* | aacenc: (re)enable Mid/Side coding by defaultRostislav Pehlivanov2015-10-17
| | | | | | | | | | | | | | Apparently it was set to be enabled by default but after the profile commits it was reverted to be off by default because I didn't notice. Works well so (re)enable it.