aboutsummaryrefslogtreecommitdiffstats
path: root/libAACenc
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-02-15 03:18:33 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-02-15 03:18:33 +0000
commit4422539a921bc39694a2ae210ce69e4410d2c235 (patch)
tree44d6676c2975eec965bb3e6c2562e1632eaf4385 /libAACenc
parent67aa964d429b7bfe242b28cd223ae1dddf8e3a78 (diff)
parente016635f0d3a5c7532b00711ce461f97a13f7bc2 (diff)
downloadfdk-aac-4422539a921bc39694a2ae210ce69e4410d2c235.tar.gz
fdk-aac-4422539a921bc39694a2ae210ce69e4410d2c235.tar.bz2
fdk-aac-4422539a921bc39694a2ae210ce69e4410d2c235.zip
Snap for 6210127 from e016635f0d3a5c7532b00711ce461f97a13f7bc2 to rvc-release
Change-Id: Icca87a4feea92b453adc049922c543eb3bf048fd
Diffstat (limited to 'libAACenc')
-rw-r--r--libAACenc/include/aacenc_lib.h45
-rw-r--r--libAACenc/src/aacEnc_ram.cpp4
-rw-r--r--libAACenc/src/aacEnc_ram.h4
-rw-r--r--libAACenc/src/aacenc.cpp11
-rw-r--r--libAACenc/src/aacenc_lib.cpp30
-rw-r--r--libAACenc/src/adj_thr.cpp8
-rw-r--r--libAACenc/src/bandwidth.cpp12
-rw-r--r--libAACenc/src/qc_main.cpp17
8 files changed, 74 insertions, 57 deletions
diff --git a/libAACenc/include/aacenc_lib.h b/libAACenc/include/aacenc_lib.h
index 01a9d36..71f7556 100644
--- a/libAACenc/include/aacenc_lib.h
+++ b/libAACenc/include/aacenc_lib.h
@@ -436,31 +436,32 @@ audio quality.
\subsection vbrmode Variable Bitrate Mode
-The encoder provides various Variable Bitrate Modes that differ in audio quality
-and average overall bitrate. The given values are averages over time, different
-encoder settings and strongly depend on the type of audio signal. The VBR
-configurations can be adjusted via ::AACENC_BITRATEMODE encoder parameter.
+The variable bitrate (VBR) mode coding adapts the bit consumption to the
+psychoacoustic requirements of the signal. The encoder ignores the user-defined
+bit rate and selects a suitable pre-defined configuration based on the provided
+AOT. The VBR mode 1 is tuned for HE-AACv2, for VBR mode 2, HE-AACv1 should be
+used. VBR modes 3-5 should be used with Low-Complexity AAC. When encoding
+AAC-ELD, the best mode is selected automatically.
+
+The bitrates given in the table are averages over time and different encoder
+settings. They strongly depend on the type of audio signal. The VBR
+configurations can be adjusted with the ::AACENC_BITRATEMODE encoder parameter.
\verbatim
---------------------------------------------
- VBR_MODE | Approx. Bitrate in kbps/channel
- | AAC-LC | AAC-LD/AC_ELD
-----------+---------------+-----------------
- VBR_1 | 32 - 48 | 32 - 56
- VBR_2 | 40 - 56 | 40 - 64
- VBR_3 | 48 - 64 | 48 - 72
- VBR_4 | 64 - 80 | 64 - 88
- VBR_5 | 96 - 120 | 112 - 144
+-----------------------------------------------
+ VBR_MODE | Approx. Bitrate in kbps for stereo
+ | AAC-LC | AAC-ELD
+----------+---------------+--------------------
+ VBR_1 | 32 (HE-AACv2) | 48
+ VBR_2 | 72 (HE-AACv1) | 56
+ VBR_3 | 112 | 72
+ VBR_4 | 148 | 148
+ VBR_5 | 228 | 224
--------------------------------------------
\endverbatim
-The bitrate ranges apply for individual audio channels. In case of multichannel
-configurations the average bitrate might be estimated by multiplying with the
-number of effective channels. This corresponds to all audio input channels
-exclusively the low frequency channel. At configurations which are making use of
-downmix modules the AAC core channels respectively downmix channels shall be
-considered. For ::AACENC_AOT which are using SBR, the average bitrate can be
-estimated by using the ratio of 0.5 for dualrate SBR and 0.75 for downsampled
-SBR configurations.
-
+Note that these figures are valid for stereo encoding only. VBR modes 2-5 will
+yield much lower bit rates when encoding single-channel input. For
+configurations which are making use of downmix modules the AAC core channels
+respectively downmix channels shall be considered.
\subsection encQual Audio Quality Considerations
The default encoder configuration is suggested to be used. Encoder tools such as
diff --git a/libAACenc/src/aacEnc_ram.cpp b/libAACenc/src/aacEnc_ram.cpp
index 77b1131..25e2aec 100644
--- a/libAACenc/src/aacEnc_ram.cpp
+++ b/libAACenc/src/aacEnc_ram.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -204,5 +204,5 @@ QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel(int n, UCHAR *dynamic_RAM) {
* (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL)) is sufficiently aligned,
* so the cast is safe */
return reinterpret_cast<QC_OUT_CHANNEL *>(reinterpret_cast<void *>(
- dynamic_RAM + P_BUF_0 + n * sizeof(QC_OUT_CHANNEL)));
+ dynamic_RAM + P_BUF_0 + n * ALIGN_SIZE(sizeof(QC_OUT_CHANNEL))));
}
diff --git a/libAACenc/src/aacEnc_ram.h b/libAACenc/src/aacEnc_ram.h
index 0775aae..f24eef1 100644
--- a/libAACenc/src/aacEnc_ram.h
+++ b/libAACenc/src/aacEnc_ram.h
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -198,7 +198,7 @@ struct AAC_ENC {
+++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
-#define BUF_SIZE_0 (ALIGN_SIZE(sizeof(QC_OUT_CHANNEL) * (8)))
+#define BUF_SIZE_0 (ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)) * (8))
#define BUF_SIZE_1 \
(ALIGN_SIZE(maxSize(maxSize(sizeof(PSY_DYNAMIC), \
(BIT_LOOK_UP_SIZE + MERGE_GAIN_LOOK_UP_SIZE)), \
diff --git a/libAACenc/src/aacenc.cpp b/libAACenc/src/aacenc.cpp
index 8b8a1ad..b6f733d 100644
--- a/libAACenc/src/aacenc.cpp
+++ b/libAACenc/src/aacenc.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -114,6 +114,8 @@ amm-info@iis.fraunhofer.de
#include "genericStds.h"
+#define BITRES_MIN \
+ 300 /* default threshold for using reduced/disabled bitres mode */
#define BITRES_MAX_LD 4000
#define BITRES_MIN_LD 500
#define BITRATE_MAX_LD 70000 /* Max assumed bitrate for bitres calculation */
@@ -550,7 +552,8 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(
(config->minBitsPerFrame != -1) ? config->minBitsPerFrame : 0;
qcInit.minBits = fixMin(qcInit.minBits, averageBitsPerFrame & ~7);
} else {
- INT bitreservoir = -1; /* default bitrservoir size*/
+ INT bitreservoir = -1; /* default bitreservoir size*/
+ bitresMin = BITRES_MIN;
if (isLowDelay(config->audioObjectType)) {
INT brPerChannel = config->bitRate / config->nChannels;
brPerChannel = fMin(BITRATE_MAX_LD, fMax(BITRATE_MIN_LD, brPerChannel));
@@ -601,9 +604,9 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(
qcInit.nSubFrames = config->nSubFrames;
qcInit.padding.paddingRest = config->sampleRate;
- if (qcInit.bitRes >= bitresMin * config->nChannels) {
+ if (qcInit.maxBits - qcInit.averageBits >= bitresMin * config->nChannels) {
qcInit.bitResMode = AACENC_BR_MODE_FULL; /* full bitreservoir */
- } else if (qcInit.bitRes > 0) {
+ } else if (qcInit.maxBits > qcInit.averageBits) {
qcInit.bitResMode = AACENC_BR_MODE_REDUCED; /* reduced bitreservoir */
} else {
qcInit.bitResMode = AACENC_BR_MODE_DISABLED; /* disabled bitreservoir */
diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp
index 0f0094f..2c2010f 100644
--- a/libAACenc/src/aacenc_lib.cpp
+++ b/libAACenc/src/aacenc_lib.cpp
@@ -110,7 +110,7 @@ amm-info@iis.fraunhofer.de
/* Encoder library info */
#define AACENCODER_LIB_VL0 4
#define AACENCODER_LIB_VL1 0
-#define AACENCODER_LIB_VL2 0
+#define AACENCODER_LIB_VL2 1
#define AACENCODER_LIB_TITLE "AAC Encoder"
#ifdef __ANDROID__
#define AACENCODER_LIB_BUILD_DATE ""
@@ -446,6 +446,24 @@ static SBR_PS_SIGNALING getSbrSignalingMode(
return sbrSignaling;
}
+static inline INT getAssociatedChElement(SBR_ELEMENT_INFO *elInfoSbr,
+ CHANNEL_MAPPING *channelMapping) {
+ ELEMENT_INFO *elInfo = channelMapping->elInfo;
+ INT nElements = channelMapping->nElements;
+ INT associatedChElement = -1;
+ int i;
+
+ for (i = 0; i < nElements; i++) {
+ if (elInfoSbr->elType == elInfo[i].elType &&
+ elInfoSbr->instanceTag == elInfo[i].instanceTag) {
+ associatedChElement = i;
+ break;
+ }
+ }
+
+ return associatedChElement;
+}
+
/****************************************************************************
Allocate Encoder
****************************************************************************/
@@ -1921,7 +1939,15 @@ AACENC_ERROR aacEncEncode(const HANDLE_AACENCODER hAacEncoder,
{
hAacEncoder->extPayload[nExtensions].dataSize =
hAacEncoder->pSbrPayload->dataSize[nPayload][i];
- hAacEncoder->extPayload[nExtensions].associatedChElement = i;
+ hAacEncoder->extPayload[nExtensions].associatedChElement =
+ getAssociatedChElement(
+ &hAacEncoder->hEnvEnc->sbrElement[i]->elInfo,
+ &hAacEncoder->hAacEnc->channelMapping);
+ if (hAacEncoder->extPayload[nExtensions].associatedChElement ==
+ -1) {
+ err = AACENC_ENCODE_ERROR;
+ goto bail;
+ }
}
hAacEncoder->extPayload[nExtensions].dataType =
EXT_SBR_DATA; /* Once SBR Encoder supports SBR CRC set
diff --git a/libAACenc/src/adj_thr.cpp b/libAACenc/src/adj_thr.cpp
index 226d003..239abd0 100644
--- a/libAACenc/src/adj_thr.cpp
+++ b/libAACenc/src/adj_thr.cpp
@@ -1302,14 +1302,6 @@ static void FDKaacEnc_reduceThresholdsVBR(
if (sfbThrReducedLdData < FL2FXCONST_DBL(-0.5f))
sfbThrReducedLdData = FL2FXCONST_DBL(-1.f);
- /* minimum of 29 dB Ratio for Thresholds */
- if ((sfbEnLdData + FL2FXCONST_DBL(1.0f)) >
- FL2FXCONST_DBL(9.6336206 / LD_DATA_SCALING)) {
- sfbThrReducedLdData = fixMax(
- sfbThrReducedLdData,
- sfbEnLdData - FL2FXCONST_DBL(9.6336206 / LD_DATA_SCALING));
- }
-
sfbThrReducedLdData = fixMax(MIN_LDTHRESH, sfbThrReducedLdData);
qcOutChan->sfbThresholdLdData[sfbGrp + sfb] = sfbThrReducedLdData;
diff --git a/libAACenc/src/bandwidth.cpp b/libAACenc/src/bandwidth.cpp
index 36cd64d..e814f05 100644
--- a/libAACenc/src/bandwidth.cpp
+++ b/libAACenc/src/bandwidth.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -151,11 +151,11 @@ typedef struct {
static const BANDWIDTH_TAB_VBR bandWidthTableVBR[] = {
{AACENC_BR_MODE_CBR, 0, 0},
- {AACENC_BR_MODE_VBR_1, 13050, 13050},
- {AACENC_BR_MODE_VBR_2, 13050, 13050},
- {AACENC_BR_MODE_VBR_3, 14260, 14260},
- {AACENC_BR_MODE_VBR_4, 15500, 15500},
- {AACENC_BR_MODE_VBR_5, 48000, 48000},
+ {AACENC_BR_MODE_VBR_1, 13000, 13000},
+ {AACENC_BR_MODE_VBR_2, 13000, 13000},
+ {AACENC_BR_MODE_VBR_3, 15750, 15750},
+ {AACENC_BR_MODE_VBR_4, 16500, 16500},
+ {AACENC_BR_MODE_VBR_5, 19293, 19293},
{AACENC_BR_MODE_SFR, 0, 0},
{AACENC_BR_MODE_FF, 0, 0}
diff --git a/libAACenc/src/qc_main.cpp b/libAACenc/src/qc_main.cpp
index ba3bc7e..bcfaa23 100644
--- a/libAACenc/src/qc_main.cpp
+++ b/libAACenc/src/qc_main.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -121,20 +121,15 @@ typedef struct {
static const TAB_VBR_QUAL_FACTOR tableVbrQualFactor[] = {
{QCDATA_BR_MODE_VBR_1,
- FL2FXCONST_DBL(0.160f)}, /* Approx. 32 - 48 (AC-LC), 32 - 56
- (AAC-LD/ELD) kbps/channel */
+ FL2FXCONST_DBL(0.150f)}, /* Approx. 32 kbps mono AAC-LC + SBR + PS */
{QCDATA_BR_MODE_VBR_2,
- FL2FXCONST_DBL(0.148f)}, /* Approx. 40 - 56 (AC-LC), 40 - 64
- (AAC-LD/ELD) kbps/channel */
+ FL2FXCONST_DBL(0.162f)}, /* Approx. 64 kbps stereo AAC-LC + SBR */
{QCDATA_BR_MODE_VBR_3,
- FL2FXCONST_DBL(0.135f)}, /* Approx. 48 - 64 (AC-LC), 48 - 72
- (AAC-LD/ELD) kbps/channel */
+ FL2FXCONST_DBL(0.176f)}, /* Approx. 96 kbps stereo AAC-LC */
{QCDATA_BR_MODE_VBR_4,
- FL2FXCONST_DBL(0.111f)}, /* Approx. 64 - 80 (AC-LC), 64 - 88
- (AAC-LD/ELD) kbps/channel */
+ FL2FXCONST_DBL(0.120f)}, /* Approx. 128 kbps stereo AAC-LC */
{QCDATA_BR_MODE_VBR_5,
- FL2FXCONST_DBL(0.070f)} /* Approx. 96 - 120 (AC-LC), 112 - 144
- (AAC-LD/ELD) kbps/channel */
+ FL2FXCONST_DBL(0.070f)} /* Approx. 192 kbps stereo AAC-LC */
};
static INT isConstantBitrateMode(const QCDATA_BR_MODE bitrateMode) {