aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/aacsbr_template.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/aacsbr_template: Check ilbMichael Niedermayer5 days1-0/+6
| | | | | | | | | | Fixes: index 50 out of bounds for type 'INTFLOAT [40][2]' Fixes: 401661737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-4866055713652736 Someone knowing AAC well should review this, there is likely a nicer fix Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* all: fix typos found by codespellTimo Rothenpieler10 days1-1/+1
|
* avcodec/aacsbr_template: Clear n_q on errorMichael Niedermayer2025-01-081-0/+1
| | | | | | | | Fixes: index 5 out of bounds for type 'uint8_t [5]' Fixes: 377748135/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-5167109774049280 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/aacsbr_template: Remove unused-but-set variableAndreas Rheinhardt2024-06-301-2/+0
| | | | | | Also fixes a -Wdeclaration-after-statement. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* aacdec_usac, aacsbr: implement SBR support for USACLynne2024-06-231-15/+217
| | | | | Currently, no eSBR features are supported. Thankfully, no encoders exist for it yet.
* avcodec/aac/aacdec: Fix linking errors with only one decoder enabledAndreas Rheinhardt2024-05-071-1/+2
| | | | | | | | | | This is achieved by using function pointers for AAC SBR functions. This unfortunately necessitated to use void* in ff_aac_sbr_apply(_fixed). Fixes ticket #10999. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* aacsbr: constify the only SBR tableLynne2024-04-231-10/+0
|
* aacdec: remove AAC-specific MIPS optimizationsLynne2024-04-231-6/+0
| | | | | | The code was written in 2012, but seems to have been broken for just as long. Compilation is broken on every MIPS/MIPS64 system with an FPU (which the code depends on).
* aacdec: move aacdec.h into libavcodec/aacLynne2024-04-231-1/+1
|
* avcodec/aacdec: PredictorState array out of SingleChannelElementAndreas Rheinhardt2024-04-231-0/+3
| | | | | | | | | | | | | sizeof(PredictorState) is different for the floating-point and the fixed-point AAC decoders; this is an obstacle for deduplicating code between these decoders. So don't include this array in SingleChannelElement, instead add a union of pointers to the fixed-point PredictorState and the floating-point PredictorState. The actual arrays are part of the extended ChannelElement to be allocated by ff_aac_sbr_ctx_alloc_init(); it also sets the pointers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacdec: Split SBR context from ChannelElementAndreas Rheinhardt2024-04-231-7/+21
| | | | | | | | | | | | | | | | | | | | | The AAC fixed-point and floating-point decoders have a lot of duplicated code; the main obstacle to deduplicating it is that several structures with the same name are actually different types, because they contain INTFLOATs (int or float) and AAC_FLOATs (SoftFloat or float). SoftFloat and float typically have different sizes, so dealing with it is the more complicated of the two. AAC_FLOAT is mainly used in the sbr code and structures, so one can still deduplicate the code by only exposing the common part of ChannelElement (without SBR context) to the common decoder part. One prerequisite of this is to move allocating the whole ChannelElement to code that will stay unduplicated. It is most natural to move said allocation to ff_aac_sbr_ctx_init(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacsbr: Make ff_aac_sbr_* funcs accept ChannelElement*Andreas Rheinhardt2024-04-231-6/+11
| | | | | | | | | | | | | | | | | | | | | | Each ChannelElement contains exactly one SpectralBandReplication structure; the latter structure contains lots of buffers whose size depend upon USE_FIXED (i.e. AAC_FLOAT arrays). This complicates deduplicating the parts of the AAC decoder that are duplicated between the fixed-point and the floating point decoder. In order to fix this, the SpectralBandReplication structure will be moved from the part of ChannelElement visible to the common code. Therefore the ff_aac_sbr_* functions are ported to accept a ChannelElement*; they will then have to translate that to the corresponding SpectralBandReplication* themselves (which is possible, because there are floating-point and fixed-point versions of these functions). While just at it, also ensure that these functions are properly namespaced. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* aacsbr_template: include mem.hLynne2024-04-231-0/+1
| | | | Future AAC changes remove the need to include this header.
* aacdec: move aacdec_common to aac/aacdec_tabLynne2024-04-231-1/+1
| | | | | Start to clean up the decoder. Also renames a confusingly named file.
* avcodec/sbr: Remove unused AACDecContext* parameter from sbr_lf_gen_mipsAndreas Rheinhardt2024-02-271-2/+2
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacdec: Rename AACContext to AACDecContextAndreas Rheinhardt2024-02-271-17/+17
| | | | | | | | | | It is decoder-only; furthermore, there is already an AACContext in use by libfdk-aacenc. Also make aacdec.h provide the typedef for AACContext; up until now, this has been done by sbr.h. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacsbr: Remove unused parameter from sbr_gain_calcAndreas Rheinhardt2024-02-271-1/+1
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avocdec/aac: Move decoder-only stuff to new header aacdec.hAndreas Rheinhardt2024-02-271-0/+2
| | | | | | | AACContext is not used by the encoder at all. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacdec_common: Apply offset for SBR VLCs during initAndreas Rheinhardt2023-10-311-20/+6
| | | | | | This avoids having to apply it later after every get_vlc2(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacdec_common: Avoid superfluous VLC structures for SBR VLCsAndreas Rheinhardt2023-10-311-12/+12
| | | | | | | | | | For all VLCs here, the number of bits of the VLC is write-only, because it is hardcoded at the call site. Therefore one can replace these VLC structures with the only thing that is actually used: The pointer to the VLCElem table. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacsbr_template: Deduplicate VLCsAndreas Rheinhardt2023-10-311-40/+13
| | | | | | | | The VLCs, their init code and the tables used for initialization are currently duplicated for the floating- and fixed-point decoders. This commit stops doing so and moves this stuff to aacdec_common.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacps: Remove unused AVCodecContext* parameter from ff_ps_applyAndreas Rheinhardt2023-10-311-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* definesAndreas Rheinhardt2023-09-071-1/+1
| | | | | | | | | These defines are also used in other contexts than just AVCodecContext ones, e.g. in libavformat. Furthermore, given that these defines are public, the AV-prefix is the right one, so deprecate (and not just move) the FF-macros. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* aacsbr: convert to lavu/txLynne2022-11-061-17/+39
|
* avcodec/aacdec: print a log message when treating mono HE-AAC as stereoJames Almer2022-07-301-0/+2
| | | | | | | Since this behavior is intentional, use the VERBOSE level instead of WARNING as it's nothing the user should worry about. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/vlc: Use structure instead of VLC_TYPE array as VLC elementAndreas Rheinhardt2022-06-171-2/+2
| | | | | | | | | | | | | | | | | | In C, qualifiers for arrays are broken: const VLC_TYPE (*foo)[2] is a pointer to an array of two const VLC_TYPE elements and unfortunately this is not compatible with a pointer to a const array of two VLC_TYPE, because the latter does not exist as array types are never qualified (the qualifier applies to the base type instead). This is the reason why get_vlc2() doesn't accept a const VLC table despite not modifying the table at all, as there is no automatic conversion from VLC_TYPE (*)[2] to const VLC_TYPE (*)[2]. Fix this by using a structure VLCElem for the VLC table. This also has the advantage of making it clear which element is which. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* all: Replace if (ARCH_FOO) checks by #if ARCH_FOOAndreas Rheinhardt2022-06-151-2/+3
| | | | | | | | | | | | | | | | | | This is more spec-compliant because it does not rely on dead-code elimination by the compiler. Especially MSVC has problems with this, as can be seen in https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296373.html or https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/297022.html This commit does not eliminate every instance where we rely on dead code elimination: It only tackles branching to the initialization of arch-specific dsp code, not e.g. all uses of CONFIG_ and HAVE_ checks. But maybe it is already enough to compile FFmpeg with MSVC with whole-programm-optimizations enabled (if one does not disable too many components). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/aacps: Factor out code shared by float and fixed point decoderAndreas Rheinhardt2020-12-311-2/+2
| | | | | | | Saves about 7KiB. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/aacsbr_template: Remove pointless runtime initializationAndreas Rheinhardt2020-12-311-4/+0
| | | | | | | | | | | | | | | | | The sbr_qmf_window_us array is basically symmetric around its middle element and therefore the latter half is currently initialized from the first half at runtime. Yet because the first half is initialized, the array can't be placed in .bss at all, so that one gains nothing from not already initializing the whole array statically. Therefore this commit does exactly this. (There are two exceptions to the symmetry: Elements 384 and 512 are the negations of their mirror element; for the fixed-point decoder, Q31(-x) does not equal -Q31(x). In order to keep the array exactly the same, the latter form has been used for these two elements.) Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavc/aacsbr: fix make checkheaders warningJun Zhao2018-06-101-0/+12
| | | | | | | move the the function aacsbr_tableinit definition from header file to .c file to fix make checkheaders warning. Signed-off-by: Jun Zhao <mypopydev@gmail.com>
* Merge commit 'ba30b74686f0cb6c9dd465ac4820059c48bf9d08'James Almer2017-09-271-7/+7
| | | | | | | | | * commit 'ba30b74686f0cb6c9dd465ac4820059c48bf9d08': aac: Validate the sbr sample rate before using the value See cf5f4c5169639349262aa221ae485a0de188afb1 Merged-by: James Almer <jamrial@gmail.com>
* avcodec/aacsbr_template: Do not change bs_num_env before its checkedMichael Niedermayer2017-05-131-13/+15
| | | | | | | | Fixes: 1489/clusterfuzz-testcase-minimized-5075102901207040 Fixes: out of array access Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/aacsbr_template: Do not leave bs_num_env invalidMichael Niedermayer2017-05-061-0/+2
| | | | | | | | Fixes out of array read Fixes: 1349/clusterfuzz-testcase-minimized-5370707196248064 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* aacsbr: Turnoff in the event of over read.Alex Converse2017-03-211-0/+1
| | | | | | | | | | Aliased compressed AAC bytes are almost certainly not meaningful SBR data. In the wild this causes harsh artifacts switching HE-AAC streams that don't have SBR headers aligned with segment boundaries. Turning off SBR falls back to a default set of upsampling parameters that can function as a sort of error concealment. This is consistent with how the decoder handles other sorts of errors.
* Merge commit '42c4c2d2a6dc48adb0e901ef5617acfba0a3a18e'Clément Bœsch2017-03-191-6/+0
| | | | | | | * commit '42c4c2d2a6dc48adb0e901ef5617acfba0a3a18e': aac: Drop broken cruft Merged-by: Clément Bœsch <u@pkh.me>
* aacsbr: Associate SBR data with AAC elements on initAlex Converse2017-02-131-1/+2
| | | | | | Quiets some log spam on pure upsampling mode. Fixes ticket 5163.
* aacsbr: reduce element type mismatch warning severityRostislav Pehlivanov2016-06-081-1/+1
| | | | | | | | | | | | All HE-AAC samples with an LFE channel make this warning get spammed on every frame. Turning off SBR for LFE channels makes sense (since it has much less coefficients than normal channels do), so this error print is of no value in this case. It makes sense to keep the error in other cases, hence why it's still around, degraded to warning severity since the decoder will still attempt to decode without SBR. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
* avcodec/aacsbr_template: Add Check to read_sbr_envelope()Michael Niedermayer2015-12-121-8/+33
| | | | | | | The limit is a conservative guess, the spec does not seem to specify a limit Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/aacsbr: Split the env_facs tableMichael Niedermayer2015-12-121-34/+8
| | | | | | | This also removes a #ifdef and special case for the fixed point case Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* sbr_qmf_analysis: sanitize input for 32-bit imdctAndreas Cadhalpun2015-12-111-0/+18
| | | | | | | | | | | | | If the input contains too many too large values, the imdct can overflow. Even if it didn't, the output would be larger than the valid range of 29 bits. Note that this is a very delicate limit: Allowing values up to 1<<25 does not prevent input larger than 1<<29 from arriving at sbr_sum_square, while limiting values to 1<<23 breaks the fate-aac-fixed-al_sbr_hq_cm_48_5.1 test. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* aacsbr: ensure strictly monotone time bordersAndreas Cadhalpun2015-12-111-2/+2
| | | | | | This fixes a division by zero in the aac_fixed decoder. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* aacsbr: don't call sbr_dequant twice without intermediate read_sbr_dataAndreas Cadhalpun2015-11-201-0/+10
| | | | | | | | Doing that doesn't make sense, because the only purpose of sbr_dequant is to process the data from read_sbr_data. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* avcodec/aacsbr_template: Check values read in read_sbr_noise()Michael Niedermayer2015-11-191-8/+28
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/aacsbr: Split pre dequantization noise factors tableMichael Niedermayer2015-11-191-19/+6
| | | | | | | This allows removing a special case for the fixed point decoder and will make error checks simpler Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/aacsbr: Use FLOAT_0Michael Niedermayer2015-11-081-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/aacsbr_template: replace qsort with AV_QSORTGanesh Ajjanagadde2015-11-041-6/+8
| | | | | | | | | | | | | | When sbr->reset is set in encode_frame, a bunch of qsort calls might get made. Thus, there is the potential of calling qsort whenever the spectral contents change. AV_QSORT is substantially faster due to the inlining of the comparison callback. Thus, the increase in performance should be worth the increase in binary size. Tested with FATE. Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* avcodec: Implementation of AAC_fixed_decoder (PS-module)Djordje Pesut2015-07-221-4/+4
| | | | | | | Add fixed point implementation. Signed-off-by: Nedeljko Babic <nedeljko.babic@imgtec.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Implementation of AAC_fixed_decoder (SBR-module)Djordje Pesut2015-07-201-43/+168
| | | | | | | Add fixed poind code. Signed-off-by: Nedeljko Babic <nedeljko.babic@imgtec.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: Template creation for AAC decoder (SBR-module)Djordje Pesut2015-07-201-0/+1410
Move the existing code to a new template file. Signed-off-by: Nedeljko Babic <nedeljko.babic@imgtec.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>