fdk-aac/libAACenc/src
Fraunhofer IIS FDK e499f9485e Adjust VBR mode depending on given peak bitrate and fix crash recovery usage.
Operating the FDK encoder in A2DP with variable bitrate mode
configuration resulted in unexpected encoder return value AACENC_ENCODE_ERROR.

Due to peak bitrate restriction the encoder quite often runs into requantization.
In case the bitrate constraint is not fulfilled, the so-called crash recovery is
used as final emergency step. The crash recovery reduces the overall bit
consumption considering the given number of bits to be saved. The bit difference
is extracted from audio element structures. In VBR mode the element wise bit
consumption state was not updated since there is typically no bitrate limitation
required.

The patch solves the choppy audio problems and increases audio quality for
AAC VBR encoding.

The changes in FDKaacEnc_QCMain() ensure that audio element bit info is always
updated. This is achieved by always calling FDKaacEnc_BitResRedistribution()
and FDKaacEnc_prepareBitDistribution() with maxBitsPerFrame variable as total
bits parameter.
Furthermore, VBR assumes a certain target bitrate which is used for internal
configuration and limitations. In case the peak bitrate parameter is less than
the VBR mode target bitrate the maximum of both bitrate configurations was used.

The function FDKaacEnc_AdjustVBRBitrateMode() is added to adjust the encoder
internal VBR mode to a desired target bitrate less than given peak bitrate.
It is possible that the peak bitrate is very close to the desired target bitrate.
The virtual available bitreservoir is quite low and the encoder would run quite
often into requantization with needless audio quality reduction. In such a
configuration, it is a better choice to use the CBR targeted threshold adaption
to avoid audio quality reduction.

In FDKaacEnc_Initialize(), there was already a bitResMode selection depending
on available bitreservoir for CBR. This selection will now also be used for VBR.
In case the bitResMode is AACENC_BR_MODE_FULL and VBR mode is selected, the VBR
threshold adaption is used. Otherwise, CBR threshold adaption strategy is used
and therefore, no unnecessary fill bits are written.

Bug: 161400526
Test: see bug
Change-Id: I1865f817180150da6add2623a64f1a102622784a
2021-01-08 10:52:53 +08:00
..
aacEnc_ram.cpp Ensure that QC_OUT_CHANNEL struct in encoder always uses aligned memory 2020-02-13 14:39:47 -08:00
aacEnc_ram.h Ensure that QC_OUT_CHANNEL struct in encoder always uses aligned memory 2020-02-13 14:39:47 -08:00
aacEnc_rom.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
aacEnc_rom.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
aacenc.cpp Adjust VBR mode depending on given peak bitrate and fix crash recovery usage. 2021-01-08 10:52:53 +08:00
aacenc.h Adjust VBR mode depending on given peak bitrate and fix crash recovery usage. 2021-01-08 10:52:53 +08:00
aacenc_lib.cpp Adjust VBR mode depending on given peak bitrate and fix crash recovery usage. 2021-01-08 10:52:53 +08:00
aacenc_pns.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
aacenc_pns.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
aacenc_tns.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
aacenc_tns.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
adj_thr.cpp Enhance encoder audio quality for vbr (FDKenc v4.0.1). 2020-02-13 14:58:49 -08:00
adj_thr.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
adj_thr_data.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
band_nrg.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
band_nrg.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
bandwidth.cpp Enhance encoder audio quality for vbr (FDKenc v4.0.1). 2020-02-13 14:58:49 -08:00
bandwidth.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
bit_cnt.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
bit_cnt.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
bitenc.cpp Add FDK_FALLTHROUGH macro to prevent implicit-fallthrough compiler warnings 2018-12-27 14:17:51 -05:00
bitenc.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
block_switch.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
block_switch.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
channel_map.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
channel_map.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
chaosmeasure.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
chaosmeasure.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
dyn_bits.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
dyn_bits.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
grp_data.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
grp_data.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
intensity.cpp Fix integer overflow in FDKaacEnc_IntensityStereoProcessing(). 2019-05-15 12:31:19 -07:00
intensity.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
interface.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
line_pe.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
line_pe.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
metadata_compressor.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
metadata_compressor.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
metadata_main.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
metadata_main.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
mps_main.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
mps_main.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
ms_stereo.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
ms_stereo.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
noisedet.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
noisedet.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
pns_func.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
pnsparam.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
pnsparam.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
pre_echo_control.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
pre_echo_control.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
psy_configuration.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
psy_configuration.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
psy_const.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
psy_data.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
psy_main.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
psy_main.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
qc_data.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
qc_main.cpp Adjust VBR mode depending on given peak bitrate and fix crash recovery usage. 2021-01-08 10:52:53 +08:00
qc_main.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
quantize.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
quantize.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
sf_estim.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
sf_estim.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
spreading.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
spreading.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
tns_func.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
tonality.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
tonality.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
transform.cpp Upgrade to FDKv2 2018-04-19 11:21:15 -07:00
transform.h Upgrade to FDKv2 2018-04-19 11:21:15 -07:00