aboutsummaryrefslogtreecommitdiffstats
path: root/libAACenc
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2013-11-01 10:46:40 +0200
committerMartin Storsjo <martin@martin.st>2013-11-01 10:46:40 +0200
commit321233ee92e138f44294c7bb9a375eadad9d24fa (patch)
tree1de928ad26325302f64c56603157f50095dcf2b1 /libAACenc
parentfcb5f1b692cb8343de35e69f9084328c652cf690 (diff)
parentfa3eba16446cc8f2f5e2dfc20d86a49dbd37299e (diff)
downloadfdk-aac-321233ee92e138f44294c7bb9a375eadad9d24fa.tar.gz
fdk-aac-321233ee92e138f44294c7bb9a375eadad9d24fa.tar.bz2
fdk-aac-321233ee92e138f44294c7bb9a375eadad9d24fa.zip
Merge remote-tracking branch 'aosp/kitkat-release' into kitkat-merge
Conflicts: libAACenc/src/quantize.cpp
Diffstat (limited to 'libAACenc')
-rw-r--r--libAACenc/include/aacenc_lib.h194
-rw-r--r--libAACenc/src/aacEnc_ram.cpp20
-rw-r--r--libAACenc/src/aacEnc_ram.h6
-rw-r--r--libAACenc/src/aacEnc_rom.cpp2
-rw-r--r--libAACenc/src/aacEnc_rom.h2
-rw-r--r--libAACenc/src/aacenc.cpp13
-rw-r--r--libAACenc/src/aacenc.h8
-rw-r--r--libAACenc/src/aacenc_hcr.cpp2
-rw-r--r--libAACenc/src/aacenc_hcr.h2
-rw-r--r--libAACenc/src/aacenc_lib.cpp524
-rw-r--r--libAACenc/src/aacenc_pns.cpp2
-rw-r--r--libAACenc/src/aacenc_pns.h2
-rw-r--r--libAACenc/src/aacenc_tns.cpp6
-rw-r--r--libAACenc/src/aacenc_tns.h2
-rw-r--r--libAACenc/src/adj_thr.cpp617
-rw-r--r--libAACenc/src/adj_thr.h33
-rw-r--r--libAACenc/src/adj_thr_data.h4
-rw-r--r--libAACenc/src/band_nrg.cpp2
-rw-r--r--libAACenc/src/band_nrg.h2
-rw-r--r--libAACenc/src/bandwidth.cpp8
-rw-r--r--libAACenc/src/bandwidth.h2
-rw-r--r--libAACenc/src/bit_cnt.cpp2
-rw-r--r--libAACenc/src/bit_cnt.h2
-rw-r--r--libAACenc/src/bitenc.cpp4
-rw-r--r--libAACenc/src/bitenc.h2
-rw-r--r--libAACenc/src/block_switch.cpp36
-rw-r--r--libAACenc/src/block_switch.h5
-rw-r--r--libAACenc/src/channel_map.cpp53
-rw-r--r--libAACenc/src/channel_map.h2
-rw-r--r--libAACenc/src/chaosmeasure.cpp2
-rw-r--r--libAACenc/src/chaosmeasure.h2
-rw-r--r--libAACenc/src/dyn_bits.cpp2
-rw-r--r--libAACenc/src/dyn_bits.h2
-rw-r--r--libAACenc/src/grp_data.cpp2
-rw-r--r--libAACenc/src/grp_data.h2
-rw-r--r--libAACenc/src/intensity.cpp29
-rw-r--r--libAACenc/src/intensity.h2
-rw-r--r--libAACenc/src/interface.h12
-rw-r--r--libAACenc/src/line_pe.cpp2
-rw-r--r--libAACenc/src/line_pe.h2
-rw-r--r--libAACenc/src/metadata_compressor.cpp39
-rw-r--r--libAACenc/src/metadata_compressor.h2
-rw-r--r--libAACenc/src/metadata_main.cpp2
-rw-r--r--libAACenc/src/metadata_main.h2
-rw-r--r--libAACenc/src/ms_stereo.cpp2
-rw-r--r--libAACenc/src/ms_stereo.h2
-rw-r--r--libAACenc/src/noisedet.cpp2
-rw-r--r--libAACenc/src/noisedet.h2
-rw-r--r--libAACenc/src/pns_func.h2
-rw-r--r--libAACenc/src/pnsparam.cpp2
-rw-r--r--libAACenc/src/pnsparam.h2
-rw-r--r--libAACenc/src/pre_echo_control.cpp2
-rw-r--r--libAACenc/src/pre_echo_control.h2
-rw-r--r--libAACenc/src/psy_configuration.cpp2
-rw-r--r--libAACenc/src/psy_configuration.h2
-rw-r--r--libAACenc/src/psy_const.h3
-rw-r--r--libAACenc/src/psy_data.h2
-rw-r--r--libAACenc/src/psy_main.cpp29
-rw-r--r--libAACenc/src/psy_main.h6
-rw-r--r--libAACenc/src/qc_data.h14
-rw-r--r--libAACenc/src/qc_main.cpp50
-rw-r--r--libAACenc/src/qc_main.h4
-rw-r--r--libAACenc/src/quantize.cpp12
-rw-r--r--libAACenc/src/quantize.h2
-rw-r--r--libAACenc/src/sf_estim.cpp2
-rw-r--r--libAACenc/src/sf_estim.h2
-rw-r--r--libAACenc/src/spreading.cpp2
-rw-r--r--libAACenc/src/spreading.h2
-rw-r--r--libAACenc/src/tns_func.h2
-rw-r--r--libAACenc/src/tonality.cpp2
-rw-r--r--libAACenc/src/tonality.h2
-rw-r--r--libAACenc/src/transform.cpp2
-rw-r--r--libAACenc/src/transform.h4
73 files changed, 1251 insertions, 576 deletions
diff --git a/libAACenc/include/aacenc_lib.h b/libAACenc/include/aacenc_lib.h
index 862dcb5..8c0e1cd 100644
--- a/libAACenc/include/aacenc_lib.h
+++ b/libAACenc/include/aacenc_lib.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -316,7 +316,8 @@ if the parameter was not set from extern. The bitrate depends on the number of e
channels and sampling rate and is determined as follows.
\code
AAC-LC (AOT_AAC_LC): 1.5 bits per sample
-HE-AAC (AOT_SBR): 0.625 bits per sample
+HE-AAC (AOT_SBR): 0.625 bits per sample (dualrate sbr)
+HE-AAC (AOT_SBR): 1.125 bits per sample (downsampled sbr)
HE-AAC v2 (AOT_PS): 0.5 bits per sample
\endcode
@@ -341,6 +342,33 @@ increase which might be significant. If workload is not an issue in the applicat
we recommended to activate this feature.
\code aacEncoder_SetParam(hAacEncoder, AACENC_AFTERBURNER, 1); \endcode
+\subsection encELD ELD Auto Configuration Mode
+For ELD configuration a so called auto configurator is available which configures SBR and the SBR ratio by itself.
+The configurator is used when the encoder parameter ::AACENC_SBR_MODE and ::AACENC_SBR_RATIO are not set explicitely.
+
+Based on sampling rate and chosen bitrate per channel a reasonable SBR configuration will be used.
+\verbatim
+------------------------------------------------------------
+ Sampling Rate | Channel Bitrate | SBR | SBR Ratio
+-----------------+-----------------+------+-----------------
+ ]min, 16] kHz | min - 27999 | on | downsampled SBR
+ | 28000 - max | off | ---
+-----------------+-----------------+------+-----------------
+ ]16 - 24] kHz | min - 39999 | on | downsampled SBR
+ | 40000 - max | off | ---
+-----------------+-----------------+------+-----------------
+ ]24 - 32] kHz | min - 27999 | on | dualrate SBR
+ | 28000 - 55999 | on | downsampled SBR
+ | 56000 - max | off | ---
+-----------------+-----------------+------+-----------------
+ ]32 - 44.1] kHz | min - 63999 | on | dualrate SBR
+ | 64000 - max | off | ---
+-----------------+-----------------+------+-----------------
+ ]44.1 - 48] kHz | min - 63999 | on | dualrate SBR
+ | 64000 - max | off | ---
+------------------------------------------------------------
+\endverbatim
+
\section audiochCfg Audio Channel Configuration
The MPEG standard refers often to the so-called Channel Configuration. This Channel Configuration is used for a fixed Channel
@@ -349,16 +377,20 @@ For user defined Configurations the Channel Configuration is set to 0 and the Ch
Program Config Element. The present Encoder implementation does not allow the user to configure this Channel Configuration from
extern. The Encoder implementation supports fixed Channel Modes which are mapped to Channel Configuration as follow.
\verbatim
---------------------------------------------------------------------
- ChannelMode | ChCfg | front_El | side_El | back_El | lfe_El
------------------+--------+----------+----------+----------+--------
-MODE_1 | 1 | SCE | | |
-MODE_2 | 2 | CPE | | |
-MODE_1_2 | 3 | SCE, CPE | | |
-MODE_1_2_1 | 4 | SCE, CPE | | SCE |
-MODE_1_2_2 | 5 | SCE, CPE | | CPE |
-MODE_1_2_2_1 | 6 | SCE, CPE | | CPE | LFE
---------------------------------------------------------------------
+-------------------------------------------------------------------------------
+ ChannelMode | ChCfg | front_El | side_El | back_El | lfe_El
+-----------------------+--------+---------------+----------+----------+--------
+MODE_1 | 1 | SCE | | |
+MODE_2 | 2 | CPE | | |
+MODE_1_2 | 3 | SCE, CPE | | |
+MODE_1_2_1 | 4 | SCE, CPE | | SCE |
+MODE_1_2_2 | 5 | SCE, CPE | | CPE |
+MODE_1_2_2_1 | 6 | SCE, CPE | | CPE | LFE
+MODE_1_2_2_2_1 | 7 | SCE, CPE, CPE | | CPE | LFE
+-----------------------+--------+---------------+----------+----------+--------
+MODE_7_1_REAR_SURROUND | 0 | SCE, CPE | | CPE, CPE | LFE
+MODE_7_1_FRONT_CENTER | 0 | SCE, CPE, CPE | | CPE | LFE
+-------------------------------------------------------------------------------
- SCE: Single Channel Element.
- CPE: Channel Pair.
- SCE: Low Frequency Element.
@@ -374,16 +406,20 @@ Beside the Channel Element assignment the Channel Modes are resposible for audio
of the audio data depends on the selected ::AACENC_CHANNELORDER which can be MPEG or WAV like order.\n
Following Table describes the complete channel mapping for both Channel Order configurations.
\verbatim
----------------------------------------------------------------------------------
-ChannelMode | MPEG-Channelorder | WAV-Channelorder
------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---
-MODE_1 | 0 | | | | | | | | 0 | | | | | | |
-MODE_2 | 0 | 1 | | | | | | | 0 | 1 | | | | | |
-MODE_1_2 | 0 | 1 | 2 | | | | | | 2 | 0 | 1 | | | | |
-MODE_1_2_1 | 0 | 1 | 2 | 3 | | | | | 2 | 0 | 1 | 3 | | | |
-MODE_1_2_2 | 0 | 1 | 2 | 3 | 4 | | | | 2 | 0 | 1 | 3 | 4 | | |
-MODE_1_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | | | 2 | 0 | 1 | 4 | 5 | 3 | |
----------------------------------------------------------------------------------
+---------------------------------------------------------------------------------------
+ChannelMode | MPEG-Channelorder | WAV-Channelorder
+-----------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---
+MODE_1 | 0 | | | | | | | | 0 | | | | | | |
+MODE_2 | 0 | 1 | | | | | | | 0 | 1 | | | | | |
+MODE_1_2 | 0 | 1 | 2 | | | | | | 2 | 0 | 1 | | | | |
+MODE_1_2_1 | 0 | 1 | 2 | 3 | | | | | 2 | 0 | 1 | 3 | | | |
+MODE_1_2_2 | 0 | 1 | 2 | 3 | 4 | | | | 2 | 0 | 1 | 3 | 4 | | |
+MODE_1_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | | | 2 | 0 | 1 | 4 | 5 | 3 | |
+MODE_1_2_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 6 | 7 | 0 | 1 | 4 | 5 | 3
+-----------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---
+MODE_7_1_REAR_SURROUND | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 0 | 1 | 6 | 7 | 4 | 5 | 3
+MODE_7_1_FRONT_CENTER | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 6 | 7 | 0 | 1 | 4 | 5 | 3
+---------------------------------------------------------------------------------------
\endverbatim
The denoted mapping is important for correct audio channel assignment when using MPEG or WAV ordering. The incoming audio
@@ -416,8 +452,9 @@ determines the maximum allowed bitrate for AAC-LC. For HE-AAC and HE-AAC v2 a li
look-up table is used.
A good working point in terms of audio quality, sampling rate and bitrate, is at 1 to 1.5
-bits/audio sample for AAC-LC, 0.625 bits/audio sample for HE-AAC and 0.5 bits/audio sample
-for HE-AAC v2. For example for one channel with a sampling frequency of 48 kHz, the range from
+bits/audio sample for AAC-LC, 0.625 bits/audio sample for dualrate HE-AAC, 1.125 bits/audio sample
+for downsampled HE-AAC and 0.5 bits/audio sample for HE-AAC v2.
+For example for one channel with a sampling frequency of 48 kHz, the range from
48 kbit/s to 72 kbit/s achieves reasonable audio quality for AAC-LC.
For HE-AAC and HE-AAC v2 the lowest possible audio input sampling frequency is 16 kHz because then the
@@ -434,7 +471,7 @@ quality at that bitrate than HE-AAC or HE-AAC v2.
The following table provides an overview of recommended encoder configuration parameters
which we determined by virtue of numerous listening tests.
-\subsection reommendedConfigLC AAC-LC, HE-AAC, HE-AACv2.
+\subsection reommendedConfigLC AAC-LC, HE-AAC, HE-AACv2 in Dualrate SBR mode.
\verbatim
-----------------------------------------------------------------------------------
Audio Object Type | Bit Rate Range | Supported | Preferred | No. of
@@ -457,8 +494,8 @@ AAC LC + SBR | 64000 - 128000 | 32.00, 44.10, 48.00 | 48.00 |
-------------------+------------------+-----------------------+------------+-------
AAC LC + SBR | 64000 - 69999 | 32.00, 44.10, 48.00 | 32.00 | 5, 5.1
AAC LC + SBR | 70000 - 159999 | 32.00, 44.10, 48.00 | 44.10 | 5, 5.1
-AAC LC + SBR | 160000 - 319999 | 32.00, 44.10, 48.00 | 48.00 | 5, 5.1
-AAC LC + SBR | 320000 - 640000 | 64.00, 88.20, 96.00 | 96.00 | 5, 5.1
+AAC LC + SBR | 160000 - 245999 | 32.00, 44.10, 48.00 | 48.00 | 5
+AAC LC + SBR | 160000 - 265999 | 32.00, 44.10, 48.00 | 48.00 | 5.1
-------------------+------------------+-----------------------+------------+-------
AAC LC | 8000 - 15999 | 11.025, 12.00, 16.00 | 12.00 | 1
AAC LC | 16000 - 23999 | 16.00 | 16.00 | 1
@@ -481,7 +518,7 @@ AAC LC | 280000 - 800000 | 32.00, 44.10, 48.00 | 44.10 | 5,
-----------------------------------------------------------------------------------
\endverbatim \n
-\subsection reommendedConfigLD AAC-LD, AAC-ELD, AAC-ELD with SBR.
+\subsection reommendedConfigLD AAC-LD, AAC-ELD, AAC-ELD with SBR in Dualrate SBR mode.
\verbatim
-----------------------------------------------------------------------------------
Audio Object Type | Bit Rate Range | Supported | Preferred | No. of
@@ -489,18 +526,20 @@ Audio Object Type | Bit Rate Range | Supported | Preferred | No.
| | [kHz] | Rate |
| | | [kHz] |
-------------------+------------------+-----------------------+------------+-------
-ELD + SBR | 16000 - 24999 | 32.00 - 44.10 | 32.00 | 1
+ELD + SBR | 18000 - 24999 | 32.00 - 44.10 | 32.00 | 1
ELD + SBR | 25000 - 31999 | 32.00 - 48.00 | 32.00 | 1
ELD + SBR | 32000 - 64000 | 32.00 - 48.00 | 48.00 | 1
-------------------+------------------+-----------------------+------------+-------
ELD + SBR | 32000 - 51999 | 32.00 - 48.00 | 44.10 | 2
ELD + SBR | 52000 - 128000 | 32.00 - 48.00 | 48.00 | 2
-------------------+------------------+-----------------------+------------+-------
-ELD + SBR | 72000 - 192000 | 44.10 - 48.00 | 48.00 | 3
+ELD + SBR | 72000 - 160000 | 44.10 - 48.00 | 48.00 | 3
+-------------------+------------------+-----------------------+------------+-------
+ELD + SBR | 96000 - 212000 | 44.10 - 48.00 | 48.00 | 4
-------------------+------------------+-----------------------+------------+-------
-ELD + SBR | 96000 - 256000 | 44.10 - 48.00 | 48.00 | 4
+ELD + SBR | 120000 - 246000 | 44.10 - 48.00 | 48.00 | 5
-------------------+------------------+-----------------------+------------+-------
-ELD + SBR | 120000 - 320000 | 44.10 - 48.00 | 48.00 | 5
+ELD + SBR | 120000 - 266000 | 44.10 - 48.00 | 48.00 | 5.1
-------------------+------------------+-----------------------+------------+-------
LD, ELD | 16000 - 19999 | 16.00 - 24.00 | 16.00 | 1
LD, ELD | 20000 - 39999 | 16.00 - 32.00 | 24.00 | 1
@@ -531,13 +570,33 @@ LD, ELD | 340000 - 960000 | 44.10 - 48.00 | 48.00 |
-----------------------------------------------------------------------------------
\endverbatim \n
+\subsection reommendedConfigELD AAC-ELD with SBR in Downsampled SBR mode.
+\verbatim
+-----------------------------------------------------------------------------------
+Audio Object Type | Bit Rate Range | Supported | Preferred | No. of
+ | [bit/s] | Sampling Rates | Sampl. | Chan.
+ | | [kHz] | Rate |
+ | | | [kHz] |
+-------------------+------------------+-----------------------+------------+-------
+ELD + SBR | 18000 - 24999 | 16.00 - 22.05 | 22.05 | 1
+(downsampled SBR) | 25000 - 35999 | 22.05 - 32.00 | 24.00 | 1
+ | 36000 - 64000 | 32.00 - 48.00 | 32.00 | 1
+-----------------------------------------------------------------------------------
+\endverbatim \n
+
+
\page ENCODERBEHAVIOUR Encoder Behaviour
\section BEHAVIOUR_BANDWIDTH Bandwidth
The FDK AAC encoder usually does not use the full frequency range of the input signal, but restricts the bandwidth
according to certain library-internal settings. They can be changed in the table "bandWidthTable" in the
-file bandwidth.cpp (if available), or via command-line argument "-w" (see chapter \ref CommandLineUsage).
+file bandwidth.cpp (if available).
+
+The encoder API provides the ::AACENC_BANDWIDTH parameter to adjust the bandwidth explicitly.
+\code
+aacEncoder_SetParam(hAacEncoder, AACENC_BANDWIDTH, value);
+\endcode
However it is not recommended to change these settings, because they are based on numerious listening
tests and careful tweaks to ensure the best overall encoding quality.
@@ -638,7 +697,6 @@ an MPEG-2 AOT is choosen since PNS is an MPEG-4 AAC feature.
If SBR is activated, the encoder automatically deactivates PNS internally. If TNS is disabled but PNS is allowed,
the encoder deactivates PNS calculation internally.
-
*/
#ifndef _AAC_ENC_LIB_H_
@@ -858,8 +916,9 @@ typedef enum
AACENC_SAMPLERATE = 0x0103, /*!< Audio input data sampling rate. Encoder supports following sampling rates:
8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 */
- AACENC_SBR_MODE = 0x0104, /*!< Configure SBR independently of the chosen Audio Object Type ::AUDIO_OBJECT_TYPE:.
- This parameter is only available for ELD.
+ AACENC_SBR_MODE = 0x0104, /*!< Configure SBR independently of the chosen Audio Object Type ::AUDIO_OBJECT_TYPE.
+ This parameter is for ELD audio object type only.
+ - -1: Use ELD SBR auto configurator (default).
- 0: Disable Spectral Band Replication.
- 1: Enable Spectral Band Replication. */
@@ -869,12 +928,21 @@ typedef enum
- 480: Optional length in LD/ELD configuration. */
AACENC_CHANNELMODE = 0x0106, /*!< Set explicit channel mode. Channel mode must match with number of input channels.
- - 1-6: MPEG channel modes supported, see ::CHANNEL_MODE in FDK_audio.h. */
+ - 1-7 and 33,34: MPEG channel modes supported, see ::CHANNEL_MODE in FDK_audio.h. */
AACENC_CHANNELORDER = 0x0107, /*!< Input audio data channel ordering scheme:
- 0: MPEG channel ordering (e. g. 5.1: C, L, R, SL, SR, LFE). (default)
- 1: WAVE file format channel ordering (e. g. 5.1: L, R, C, LFE, SL, SR). */
+ AACENC_SBR_RATIO = 0x0108, /*!< Controls activation of downsampled SBR. With downsampled SBR, the delay will be
+ shorter. On the other hand, for achieving the same quality level, downsampled SBR
+ needs more bits than dual-rate SBR.
+ With downsampled SBR, the AAC encoder will work at the same sampling rate as the
+ SBR encoder (single rate).
+ Downsampled SBR is supported for AAC-ELD and HE-AACv1.
+ - 1: Downsampled SBR (default for ELD).
+ - 2: Dual-rate SBR (default for HE-AAC). */
+
AACENC_AFTERBURNER = 0x0200, /*!< This parameter controls the use of the afterburner feature.
The afterburner is a type of analysis by synthesis algorithm which increases the
audio quality but also the required processing power. It is recommended to always
@@ -906,14 +974,50 @@ typedef enum
- n: Frame count period. */
AACENC_SIGNALING_MODE = 0x0302, /*!< Signaling mode of the extension AOT:
- - 0: Implicit backward compatible signaling. (default)
- - 1: Explicit SBR and implicit PS signaling.
- - 2: Explicit hierarchical signaling.
-
- The use of backward-compatible implicit signaling is recommended if the user specically
- aims at preserving compatibility with decoders only capable of decoding AAC-LC. Otherwise
- use non-backward-compatible explicit signaling.
- Bitstream formats ADTS and ADIF can only do implicit signaling. */
+ - 0: Implicit backward compatible signaling (default for non-MPEG-4 based
+ AOT's and for the transport formats ADIF and ADTS)
+ - A stream that uses implicit signaling can be decoded by every AAC decoder, even AAC-LC-only decoders
+ - An AAC-LC-only decoder will only decode the low-frequency part of the stream, resulting in a band-limited output
+ - This method works with all transport formats
+ - This method does not work with downsampled SBR
+ - 1: Explicit backward compatible signaling
+ - A stream that uses explicit backward compatible signaling can be decoded by every AAC decoder, even AAC-LC-only decoders
+ - An AAC-LC-only decoder will only decode the low-frequency part of the stream, resulting in a band-limited output
+ - A decoder not capable of decoding PS will only decode the AAC-LC+SBR part.
+ If the stream contained PS, the result will be a a decoded mono downmix
+ - This method does not work with ADIF or ADTS. For LOAS/LATM, it only works with AudioMuxVersion==1
+ - This method does work with downsampled SBR
+ - 2: Explicit hierarchical signaling (default for MPEG-4 based AOT's and for all transport formats excluding ADIF and ADTS)
+ - A stream that uses explicit hierarchical signaling can be decoded only by HE-AAC decoders
+ - An AAC-LC-only decoder will not decode a stream that uses explicit hierarchical signaling
+ - A decoder not capable of decoding PS will not decode the stream at all if it contained PS
+ - This method does not work with ADIF or ADTS. It works with LOAS/LATM and the MPEG-4 File format
+ - This method does work with downsampled SBR
+
+ For making sure that the listener always experiences the best audio quality,
+ explicit hierarchical signaling should be used.
+ This makes sure that only a full HE-AAC-capable decoder will decode those streams.
+ The audio is played at full bandwidth.
+ For best backwards compatibility, it is recommended to encode with implicit SBR signaling.
+ A decoder capable of AAC-LC only will then only decode the AAC part, which means the decoded
+ audio will sound band-limited.
+
+ For MPEG-2 transport types (ADTS,ADIF), only implicit signaling is possible.
+
+ For LOAS and LATM, explicit backwards compatible signaling only works together with AudioMuxVersion==1.
+ The reason is that, for explicit backwards compatible signaling, additional information will be appended to the ASC.
+ A decoder that is only capable of decoding AAC-LC will skip this part.
+ Nevertheless, for jumping to the end of the ASC, it needs to know the ASC length.
+ Transmitting the length of the ASC is a feature of AudioMuxVersion==1, it is not possible to transmit the
+ length of the ASC with AudioMuxVersion==0, therefore an AAC-LC-only decoder will not be able to parse a
+ LOAS/LATM stream that was being encoded with AudioMuxVersion==0.
+
+ For downsampled SBR, explicit signaling is mandatory. The reason for this is that the
+ extension sampling frequency (which is in case of SBR the sampling frequqncy of the SBR part)
+ can only be signaled in explicit mode.
+
+ For AAC-ELD, the SBR information is transmitted in the ELDSpecific Config, which is part of the
+ AudioSpecificConfig. Therefore, the settings here will have no effect on AAC-ELD.*/
AACENC_TPSUBFRAMES = 0x0303, /*!< Number of sub frames in a transport frame for LOAS/LATM or ADTS (default 1).
- ADTS: Maximum number of sub frames restricted to 4.
diff --git a/libAACenc/src/aacEnc_ram.cpp b/libAACenc/src/aacEnc_ram.cpp
index 45bca93..be3eea2 100644
--- a/libAACenc/src/aacEnc_ram.cpp
+++ b/libAACenc/src/aacEnc_ram.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -89,7 +89,7 @@ amm-info@iis.fraunhofer.de
******************************************************************************/
/*!
\file
- \brief Memory layout
+ \brief Memory layout
\author Markus Lohwasser
*/
@@ -119,12 +119,12 @@ C_ALLOC_MEM (Ram_aacEnc_AacEncoder, AAC_ENC, 1)
PsyInputBuffer.
*/
-C_ALLOC_MEM2 (Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, (6))
+C_ALLOC_MEM2 (Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, (8))
C_ALLOC_MEM (Ram_aacEnc_PsyInternal, PSY_INTERNAL, 1)
-C_ALLOC_MEM2 (Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (6))
+C_ALLOC_MEM2 (Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (8))
-C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (6))
+C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (8))
PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic (int n, UCHAR* dynamic_RAM) {
FDK_ASSERT(dynamic_RAM!=0);
@@ -139,8 +139,8 @@ C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (6))
*/
C_ALLOC_MEM2 (Ram_aacEnc_PsyOut, PSY_OUT, 1, (1))
-C_ALLOC_MEM2 (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1)*(6))
-C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(6))
+C_ALLOC_MEM2 (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1)*(8))
+C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(8))
/*
@@ -155,8 +155,8 @@ C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(6))
C_ALLOC_MEM (Ram_aacEnc_QCstate, QC_STATE, 1)
C_ALLOC_MEM (Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE, 1)
-C_ALLOC_MEM2 (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, (6))
-C_ALLOC_MEM2 (Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, (6))
+C_ALLOC_MEM2 (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, (8))
+C_ALLOC_MEM2 (Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, (8))
C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1)
INT *GetRam_aacEnc_BitLookUp(int n, UCHAR* dynamic_RAM) {
@@ -175,7 +175,7 @@ C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1)
*/
C_ALLOC_MEM2 (Ram_aacEnc_QCout, QC_OUT, 1, (1))
-C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, 1, (1)*(6))
+C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, (1), (8))
QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel (int n, UCHAR* dynamic_RAM) {
FDK_ASSERT(dynamic_RAM!=0);
return ((QC_OUT_CHANNEL*) (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL)));
diff --git a/libAACenc/src/aacEnc_ram.h b/libAACenc/src/aacEnc_ram.h
index 918e279..cf7da7c 100644
--- a/libAACenc/src/aacEnc_ram.h
+++ b/libAACenc/src/aacEnc_ram.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -118,7 +118,7 @@ amm-info@iis.fraunhofer.de
*/
/* define hBitstream size: max AAC framelength is 6144 bits/channel */
-/*#define BUFFER_BITSTR_SIZE ((6400*(6)/bbWordSize) +((bbWordSize - 1) / bbWordSize))*/
+/*#define BUFFER_BITSTR_SIZE ((6400*(8)/bbWordSize) +((bbWordSize - 1) / bbWordSize))*/
struct AAC_ENC {
@@ -173,7 +173,7 @@ struct AAC_ENC {
++++++++++++++++++++++++++++++++++++++++++++
*/
-#define BUF_SIZE_0 ( ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)*(6)) )
+#define BUF_SIZE_0 ( ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)*(8)) )
#define BUF_SIZE_1 ( ALIGN_SIZE(maxSize(sizeof(PSY_DYNAMIC), \
(BIT_LOOK_UP_SIZE+MERGE_GAIN_LOOK_UP_SIZE))) )
diff --git a/libAACenc/src/aacEnc_rom.cpp b/libAACenc/src/aacEnc_rom.cpp
index 48ba668..0cdf5fe 100644
--- a/libAACenc/src/aacEnc_rom.cpp
+++ b/libAACenc/src/aacEnc_rom.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/aacEnc_rom.h b/libAACenc/src/aacEnc_rom.h
index f25d327..37e5012 100644
--- a/libAACenc/src/aacEnc_rom.h
+++ b/libAACenc/src/aacEnc_rom.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/aacenc.cpp b/libAACenc/src/aacenc.cpp
index d3f36aa..569662b 100644
--- a/libAACenc/src/aacenc.cpp
+++ b/libAACenc/src/aacenc.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -393,7 +393,7 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
/******************* sanity checks *******************/
/* check config structure */
- if (config->nChannels < 1 || config->nChannels > (6)) {
+ if (config->nChannels < 1 || config->nChannels > (8)) {
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}
@@ -558,6 +558,13 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
qcInit.channelMapping = &hAacEnc->channelMapping;
qcInit.sceCpe = 0;
+ if ((config->bitrateMode>=1) && (config->bitrateMode<=5)) {
+ qcInit.averageBits = (averageBitsPerFrame+7)&~7;
+ qcInit.bitRes = MIN_BUFSIZE_PER_EFF_CHAN*cm->nChannelsEff;
+ qcInit.maxBits = MIN_BUFSIZE_PER_EFF_CHAN*cm->nChannelsEff;
+ qcInit.minBits = 0;
+ }
+ else
{
int maxBitres;
qcInit.averageBits = (averageBitsPerFrame+7)&~7;
@@ -571,6 +578,8 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
qcInit.minBits = (config->minBitsPerFrame!=-1) ? fixMax(qcInit.minBits, config->minBitsPerFrame) : qcInit.minBits;
}
+ qcInit.sampleRate = config->sampleRate;
+ qcInit.advancedBitsToPe = isLowDelay(config->audioObjectType) ? 1 : 0 ;
qcInit.nSubFrames = config->nSubFrames;
qcInit.padding.paddingRest = config->sampleRate;
diff --git a/libAACenc/src/aacenc.h b/libAACenc/src/aacenc.h
index 517b0dc..ed167c2 100644
--- a/libAACenc/src/aacenc.h
+++ b/libAACenc/src/aacenc.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -113,7 +113,7 @@ typedef enum {
/* initialization errors */
aac_enc_init_error_start = 0x2000,
AAC_ENC_INVALID_HANDLE = 0x2020, /*!< The handle passed to the function call was invalid (probably NULL). */
- AAC_ENC_INVALID_FRAME_LENGTH = 0x2080, /*!< Invalid frame length (must be 1024 or 960). */
+ AAC_ENC_INVALID_FRAME_LENGTH = 0x2080, /*!< Invalid frame length. */
AAC_ENC_INVALID_N_CHANNELS = 0x20e0, /*!< Invalid amount of audio input channels. */
AAC_ENC_INVALID_SFB_TABLE = 0x2140, /*!< Internal encoder error. */
@@ -154,7 +154,7 @@ typedef enum {
#define ANC_DATA_BUFFERSIZE 1024 /* ancBuffer size */
-#define MAX_TOTAL_EXT_PAYLOADS (((6) * (1)) + (2+2))
+#define MAX_TOTAL_EXT_PAYLOADS (((8) * (1)) + (2+2))
typedef enum {
@@ -205,6 +205,8 @@ struct AACENC_CONFIG {
INT maxBitsPerFrame; /* maximum number of bits in AU */
INT bitreservoir; /* size of bitreservoir */
+ UINT sbrRatio; /* sbr sampling rate ratio: dual- or single-rate */
+
UCHAR useTns; /* flag: use temporal noise shaping */
UCHAR usePns; /* flag: use perceptual noise substitution */
UCHAR useIS; /* flag: use intensity coding */
diff --git a/libAACenc/src/aacenc_hcr.cpp b/libAACenc/src/aacenc_hcr.cpp
index 91c46a9..316623a 100644
--- a/libAACenc/src/aacenc_hcr.cpp
+++ b/libAACenc/src/aacenc_hcr.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/aacenc_hcr.h b/libAACenc/src/aacenc_hcr.h
index 257459c..934247a 100644
--- a/libAACenc/src/aacenc_hcr.h
+++ b/libAACenc/src/aacenc_hcr.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp
index a4291d5..95c08b3 100644
--- a/libAACenc/src/aacenc_lib.cpp
+++ b/libAACenc/src/aacenc_lib.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -97,8 +97,8 @@ amm-info@iis.fraunhofer.de
/* Encoder library info */
#define AACENCODER_LIB_VL0 3
-#define AACENCODER_LIB_VL1 3
-#define AACENCODER_LIB_VL2 3
+#define AACENCODER_LIB_VL1 4
+#define AACENCODER_LIB_VL2 12
#define AACENCODER_LIB_TITLE "AAC Encoder"
#define AACENCODER_LIB_BUILD_DATE __DATE__
#define AACENCODER_LIB_BUILD_TIME __TIME__
@@ -118,10 +118,12 @@ amm-info@iis.fraunhofer.de
#define SBL(fl) (fl/8) /*!< Short block length (hardcoded to 8 short blocks per long block) */
#define BSLA(fl) (4*SBL(fl)+SBL(fl)/2) /*!< AAC block switching look-ahead */
#define DELAY_AAC(fl) (fl+BSLA(fl)) /*!< MDCT + blockswitching */
-#define DELAY_AACELD(fl) ( (fl) + ((fl)/2) ) /*!< ELD FB delay */
+#define DELAY_AACELD(fl) ((fl)/2) /*!< ELD FB delay (no framing delay included) */
#define INPUTBUFFER_SIZE (1537+100+2048)
+#define DEFAULT_HEADER_PERIOD_REPETITION_RATE 10 /*!< Default header repetition rate used in transport library and for SBR header. */
+
////////////////////////////////////////////////////////////////////////////////////
/**
* Flags to characterize encoder modules to be supported in present instance.
@@ -164,7 +166,8 @@ typedef struct {
UCHAR userMetaDataMode; /*!< Meta data library configuration. */
- UCHAR userSbrEnabled;
+ UCHAR userSbrEnabled; /*!< Enable SBR for ELD. */
+ UINT userSbrRatio; /*!< SBR sampling rate ratio. Dual- or single-rate. */
} USER_PARAM;
@@ -212,8 +215,8 @@ struct AACENCODER
AACENC_EXT_PAYLOAD extPayload [MAX_TOTAL_EXT_PAYLOADS];
/* Extension payload */
- UCHAR extPayloadData [(1)][(6)][MAX_PAYLOAD_SIZE];
- UINT extPayloadSize [(1)][(6)]; /* payload sizes in bits */
+ UCHAR extPayloadData [(1)][(8)][MAX_PAYLOAD_SIZE];
+ UINT extPayloadSize [(1)][(8)]; /* payload sizes in bits */
ULONG InitFlags; /* internal status to treggier re-initialization */
@@ -227,12 +230,92 @@ struct AACENCODER
UINT encoder_modis;
- /* Capabity flags */
+ /* Capability flags */
UINT CAPF_tpEnc;
} ;
-////////////////////////////////////////////////////////////////////////////////////
+typedef struct
+{
+ ULONG samplingRate; /*!< Encoder output sampling rate. */
+ ULONG bitrateRange; /*!< Lower bitrate range for config entry. */
+
+ UCHAR lowDelaySbr; /*!< 0: ELD sbr off,
+ 1: ELD sbr on */
+
+ UCHAR downsampledSbr; /*!< 0: ELD with dualrate sbr,
+ 1: ELD with downsampled sbr */
+
+} ELD_SBR_CONFIGURATOR;
+
+/**
+ * \brief This table defines ELD/SBR default configurations.
+ */
+static const ELD_SBR_CONFIGURATOR eldSbrAutoConfigTab[] =
+{
+ { 48000, 0, 1, 0 },
+ { 48000, 64001, 0, 0 },
+
+ { 44100, 0, 1, 0 },
+ { 44100, 64001, 0, 0 },
+
+ { 32000, 0, 1, 0 },
+ { 32000, 28000, 1, 1 },
+ { 32000, 56000, 0, 0 },
+
+ { 24000, 0, 1, 1 },
+ { 24000, 40000, 0, 0 },
+
+ { 16000, 0, 1, 1 },
+ { 16000, 28000, 0, 0 }
+
+};
+
+/*
+ * \brief Configure SBR for ELD configuration.
+ *
+ * This function finds default SBR configuration for ELD based on sampling rate and channel bitrate.
+ * Outputparameters are SBR on/off, and SBR ratio.
+ *
+ * \param samplingRate Audio signal sampling rate.
+ * \param channelMode Channel configuration to be used.
+ * \param totalBitrate Overall bitrate.
+ * \param eldSbr Pointer to eldSbr parameter, filled on return.
+ * \param eldSbrRatio Pointer to eldSbrRatio parameter, filled on return.
+ *
+ * \return - AACENC_OK, all fine.
+ * - AACENC_INVALID_CONFIG, on failure.
+ */
+static AACENC_ERROR eldSbrConfigurator(
+ const ULONG samplingRate,
+ const CHANNEL_MODE channelMode,
+ const ULONG totalBitrate,
+ UINT * const eldSbr,
+ UINT * const eldSbrRatio
+ )
+{
+ AACENC_ERROR err = AACENC_OK;
+ int i, cfgIdx = -1;
+ const ULONG channelBitrate = totalBitrate / FDKaacEnc_GetChannelModeConfiguration(channelMode)->nChannelsEff;
+
+ for (i=0; i<(sizeof(eldSbrAutoConfigTab)/sizeof(ELD_SBR_CONFIGURATOR)); i++) {
+ if ( (samplingRate <= eldSbrAutoConfigTab[i].samplingRate)
+ && (channelBitrate >= eldSbrAutoConfigTab[i].bitrateRange) )
+ {
+ cfgIdx = i;
+ }
+ }
+
+ if (cfgIdx != -1) {
+ *eldSbr = (eldSbrAutoConfigTab[cfgIdx].lowDelaySbr==0) ? 0 : 1;
+ *eldSbrRatio = (eldSbrAutoConfigTab[cfgIdx].downsampledSbr==0) ? 2 : 1;
+ }
+ else {
+ err = AACENC_INVALID_CONFIG; /* no default configuration for eld-sbr available. */
+ }
+
+ return err;
+}
static inline INT isSbrActive(const HANDLE_AACENC_CONFIG hAacConfig)
{
@@ -253,6 +336,70 @@ static inline INT isSbrActive(const HANDLE_AACENC_CONFIG hAacConfig)
return ( sbrUsed );
}
+static inline INT isPsActive(const AUDIO_OBJECT_TYPE audioObjectType)
+{
+ INT psUsed = 0;
+
+ if ( (audioObjectType==AOT_PS)
+ || (audioObjectType==AOT_MP2_PS)
+ || (audioObjectType==AOT_DABPLUS_PS)
+ || (audioObjectType==AOT_DRM_MPEG_PS) )
+ {
+ psUsed = 1;
+ }
+
+ return ( psUsed );
+}
+
+static SBR_PS_SIGNALING getSbrSignalingMode(
+ const AUDIO_OBJECT_TYPE audioObjectType,
+ const TRANSPORT_TYPE transportType,
+ const UCHAR transportSignaling,
+ const UINT sbrRatio
+ )
+
+{
+ SBR_PS_SIGNALING sbrSignaling;
+
+ if (transportType==TT_UNKNOWN || sbrRatio==0) {
+ sbrSignaling = SIG_UNKNOWN; /* Needed parameters have not been set */
+ return sbrSignaling;
+ } else {
+ sbrSignaling = SIG_IMPLICIT; /* default: implicit signaling */
+ }
+
+ if ((audioObjectType==AOT_AAC_LC) || (audioObjectType==AOT_SBR) || (audioObjectType==AOT_PS) ||
+ (audioObjectType==AOT_MP2_AAC_LC) || (audioObjectType==AOT_MP2_SBR) || (audioObjectType==AOT_MP2_PS) ) {
+ switch (transportType) {
+ case TT_MP4_ADIF:
+ case TT_MP4_ADTS:
+ sbrSignaling = SIG_IMPLICIT; /* For MPEG-2 transport types, only implicit signaling is possible */
+ break;
+
+ case TT_MP4_RAW:
+ case TT_MP4_LATM_MCP1:
+ case TT_MP4_LATM_MCP0:
+ case TT_MP4_LOAS:
+ default:
+ if ( transportSignaling==0xFF ) {
+ /* Defaults */
+ if ( sbrRatio==1 ) {
+ sbrSignaling = SIG_EXPLICIT_HIERARCHICAL; /* For downsampled SBR, explicit signaling is mandatory */
+ } else {
+ sbrSignaling = SIG_IMPLICIT; /* For dual-rate SBR, implicit signaling is default */
+ }
+ } else {
+ /* User set parameters */
+ /* Attention: Backward compatible explicit signaling does only work with AMV1 for LATM/LOAS */
+ sbrSignaling = (SBR_PS_SIGNALING)transportSignaling;
+ }
+ break;
+ }
+ }
+
+ return sbrSignaling;
+}
+
/****************************************************************************
Allocate Encoder
****************************************************************************/
@@ -266,8 +413,12 @@ C_ALLOC_MEM (_AacEncoder, AACENCODER, 1)
/*
* Map Encoder specific config structures to CODER_CONFIG.
*/
-static
-void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CONFIG hAacConfig)
+static void FDKaacEnc_MapConfig(
+ CODER_CONFIG *const cc,
+ const USER_PARAM *const extCfg,
+ const SBR_PS_SIGNALING sbrSignaling,
+ const HANDLE_AACENC_CONFIG hAacConfig
+ )
{
AUDIO_OBJECT_TYPE transport_AOT = AOT_NULL_OBJECT;
FDKmemclear(cc, sizeof(CODER_CONFIG));
@@ -304,17 +455,26 @@ void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CON
}
/* Configure extension aot. */
- if (extCfg->userTpSignaling==0) {
+ if (sbrSignaling==SIG_IMPLICIT) {
cc->extAOT = AOT_NULL_OBJECT; /* implicit */
}
else {
- if ( (extCfg->userTpSignaling==1) && ( (transport_AOT==AOT_SBR) || (transport_AOT==AOT_PS) ) ) {
+ if ( (sbrSignaling==SIG_EXPLICIT_BW_COMPATIBLE) && ( (transport_AOT==AOT_SBR) || (transport_AOT==AOT_PS) ) ) {
cc->extAOT = AOT_SBR; /* explicit backward compatible */
}
else {
cc->extAOT = transport_AOT; /* explicit hierarchical */
}
}
+
+ if ( (transport_AOT==AOT_SBR) || (transport_AOT==AOT_PS) ) {
+ cc->sbrPresent=1;
+ if (transport_AOT==AOT_PS) {
+ cc->psPresent=1;
+ }
+ }
+ cc->sbrSignaling = sbrSignaling;
+
cc->extSamplingRate = extCfg->userSamplerate;
cc->bitRate = hAacConfig->bitRate;
cc->noChannels = hAacConfig->nChannels;
@@ -335,7 +495,7 @@ void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CON
case TT_MP4_ADTS:
case TT_MP4_LOAS:
case TT_MP4_LATM_MCP1:
- cc->headerPeriod = 10;
+ cc->headerPeriod = DEFAULT_HEADER_PERIOD_REPETITION_RATE;
break;
default:
cc->headerPeriod = 0;
@@ -351,7 +511,6 @@ void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CON
case AOT_MP2_SBR:
case AOT_MP2_PS:
cc->flags &= ~CC_MPEG_ID; /* Required for ADTS. */
- //config->userTpSignaling=0;
cc->extAOT = AOT_NULL_OBJECT;
break;
default:
@@ -411,7 +570,7 @@ AAC_ENCODER_ERROR aacEncDefaultConfig(HANDLE_AACENC_CONFIG hAacConfig,
/* make reasonable default settings */
FDKaacEnc_AacInitDefaultConfig (hAacConfig);
- /* clear confure structure and copy default settings */
+ /* clear configuration structure and copy default settings */
FDKmemclear(config, sizeof(USER_PARAM));
/* copy encoder configuration settings */
@@ -438,7 +597,7 @@ AAC_ENCODER_ERROR aacEncDefaultConfig(HANDLE_AACENC_CONFIG hAacConfig,
/* initialize transport parameters */
config->userTpType = TT_UNKNOWN;
config->userTpAmxv = 0;
- config->userTpSignaling = 0; /* default, implicit signaling */
+ config->userTpSignaling = 0xFF; /* choose signaling automatically */
config->userTpNsubFrames = 1;
config->userTpProtection = 0; /* not crc protected*/
config->userTpHeaderPeriod = 0xFF; /* header period in auto mode */
@@ -447,6 +606,14 @@ AAC_ENCODER_ERROR aacEncDefaultConfig(HANDLE_AACENC_CONFIG hAacConfig,
config->userAncDataRate = 0;
+ /* SBR rate is set to 0 here, which means it should be set automatically
+ in FDKaacEnc_AdjustEncSettings() if the user did not set a rate
+ expilicitely. */
+ config->userSbrRatio = 0;
+
+ /* SBR enable set to -1 means to inquire ELD audio configurator for reasonable configuration. */
+ config->userSbrEnabled = -1;
+
return AAC_ENC_OK;
}
@@ -481,6 +648,7 @@ INT aacEncoder_LimitBitrate(
INT bitRate,
const INT nSubFrames,
const INT sbrActive,
+ const INT sbrDownSampleRate,
const AUDIO_OBJECT_TYPE aot
)
{
@@ -490,8 +658,7 @@ INT aacEncoder_LimitBitrate(
FDKaacEnc_InitChannelMapping(channelMode, CH_ORDER_MPEG, &cm);
if (sbrActive) {
- /* Assume SBR rate ratio of 2:1 */
- coreSamplingRate = samplingRate / 2;
+ coreSamplingRate = samplingRate >> (sbrEncoder_IsSingleRatePossible(aot) ? (sbrDownSampleRate-1):1);
} else {
coreSamplingRate = samplingRate;
}
@@ -506,7 +673,7 @@ INT aacEncoder_LimitBitrate(
bitRate = FDKmin(576000*nChannels, bitRate);
/*bitRate = FDKmax(0*nChannels, bitRate);*/
}
-
+
/* Limit bit rate in respect to the core coder */
bitRate = FDKaacEnc_LimitBitrate(
@@ -525,56 +692,58 @@ INT aacEncoder_LimitBitrate(
/* Limit bit rate in respect to available SBR modes if active */
if (sbrActive)
{
- SBR_ELEMENT_INFO sbrElInfo[6];
- INT sbrBitRate = 0;
- int e, tooBig=-1;
+ int numIterations = 0;
+ INT initialBitrate, adjustedBitrate;
+ initialBitrate = adjustedBitrate = bitRate;
- FDK_ASSERT(cm.nElements <= (6));
+ /* Find total bitrate which provides valid configuration for each SBR element. */
+ do {
+ int e;
+ SBR_ELEMENT_INFO sbrElInfo[(8)];
+ FDK_ASSERT(cm.nElements <= (8));
- /* Get bit rate for each SBR element */
- aacEncDistributeSbrBits(&cm, sbrElInfo, bitRate);
+ initialBitrate = adjustedBitrate;
- for (e=0; e<cm.nElements; e++)
- {
- INT sbrElementBitRateIn, sbrBitRateOut;
+ /* Get bit rate for each SBR element */
+ aacEncDistributeSbrBits(&cm, sbrElInfo, initialBitrate);
- if (cm.elInfo[e].elType != ID_SCE && cm.elInfo[e].elType != ID_CPE) {
- continue;
- }
- sbrElementBitRateIn = sbrElInfo[e].bitRate;
- sbrBitRateOut = sbrEncoder_LimitBitRate(sbrElementBitRateIn , cm.elInfo[e].nChannelsInEl, coreSamplingRate, aot);
- if (sbrBitRateOut == 0) {
- return 0;
- }
- if (sbrElementBitRateIn < sbrBitRateOut) {
- FDK_ASSERT(tooBig != 1);
- tooBig = 0;
- if (e == 0) {
- sbrBitRate = 0;
- }
- }
- if (sbrElementBitRateIn > sbrBitRateOut) {
- FDK_ASSERT(tooBig != 0);
- tooBig = 1;
- if (e == 0) {
- sbrBitRate = 5000000;
- }
- }
- if (tooBig != -1)
+ for (e=0; e<cm.nElements; e++)
{
- INT sbrBitRateLimit = (INT)fDivNorm((FIXP_DBL)sbrBitRateOut, cm.elInfo[e].relativeBits);
- if (tooBig) {
- sbrBitRate = fMin(sbrBitRate, sbrBitRateLimit-16);
- FDK_ASSERT( (INT)fMultNorm(cm.elInfo[e].relativeBits, (FIXP_DBL)sbrBitRate) < sbrBitRateOut);
- } else {
- sbrBitRate = fMax(sbrBitRate, sbrBitRateLimit+16);
- FDK_ASSERT( (INT)fMultNorm(cm.elInfo[e].relativeBits, (FIXP_DBL)sbrBitRate) >= sbrBitRateOut);
+ INT sbrElementBitRateIn, sbrBitRateOut;
+
+ if (cm.elInfo[e].elType != ID_SCE && cm.elInfo[e].elType != ID_CPE) {
+ continue;
}
- }
- }
- if (tooBig != -1) {
- bitRate = sbrBitRate;
- }
+ sbrElementBitRateIn = sbrElInfo[e].bitRate;
+ sbrBitRateOut = sbrEncoder_LimitBitRate(sbrElementBitRateIn , cm.elInfo[e].nChannelsInEl, coreSamplingRate, aot);
+ if (sbrBitRateOut == 0) {
+ return 0;
+ }
+
+ /* If bitrates don't match, distribution and limiting needs to be determined again.
+ Abort element loop and restart with adapted bitrate. */
+ if (sbrElementBitRateIn != sbrBitRateOut) {
+
+ if (sbrElementBitRateIn < sbrBitRateOut) {
+ adjustedBitrate = fMax(initialBitrate, (INT)fDivNorm((FIXP_DBL)(sbrBitRateOut+8), cm.elInfo[e].relativeBits));
+ break;
+ }
+
+ if (sbrElementBitRateIn > sbrBitRateOut) {
+ adjustedBitrate = fMin(initialBitrate, (INT)fDivNorm((FIXP_DBL)(sbrBitRateOut-8), cm.elInfo[e].relativeBits));
+ break;
+ }
+
+ } /* sbrElementBitRateIn != sbrBitRateOut */
+
+ } /* elements */
+
+ numIterations++; /* restrict iteration to worst case of num elements */
+
+ } while ( (initialBitrate!=adjustedBitrate) && (numIterations<=cm.nElements) );
+
+ /* Unequal bitrates mean that no reasonable bitrate configuration found. */
+ bitRate = (initialBitrate==adjustedBitrate) ? adjustedBitrate : 0;
}
FDK_ASSERT(bitRate > 0);
@@ -624,26 +793,12 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
case AOT_MP2_SBR:
case AOT_MP2_PS:
hAacConfig->usePns = 0;
- if (config->userTpSignaling!=0) {
- return AACENC_INVALID_CONFIG; /* only implicit signaling allowed */
- }
case AOT_AAC_LC:
case AOT_SBR:
case AOT_PS:
config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_ADTS;
hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 1024;
- if (hAacConfig->framelength != 1024 && hAacConfig->framelength != 960) {
- return AACENC_INVALID_CONFIG;
- }
- break;
- case AOT_ER_AAC_LC:
- hAacConfig->epConfig = 0;
- hAacConfig->syntaxFlags |= AC_ER;
- hAacConfig->syntaxFlags |= ((config->userErTools & 0x1) ? AC_ER_VCB11 : 0);
- hAacConfig->syntaxFlags |= ((config->userErTools & 0x2) ? AC_ER_HCR : 0);
- config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_LOAS;
- hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 1024;
- if (hAacConfig->framelength != 1024 && hAacConfig->framelength != 960) {
+ if (hAacConfig->framelength != 1024) {
return AACENC_INVALID_CONFIG;
}
break;
@@ -665,7 +820,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
hAacConfig->syntaxFlags |= ((config->userErTools & 0x1) ? AC_ER_VCB11 : 0);
hAacConfig->syntaxFlags |= ((config->userErTools & 0x2) ? AC_ER_HCR : 0);
hAacConfig->syntaxFlags |= ((config->userErTools & 0x4) ? AC_ER_RVLC : 0);
- hAacConfig->syntaxFlags |= ((config->userSbrEnabled) ? AC_SBR_PRESENT : 0);
+ hAacConfig->syntaxFlags |= ((config->userSbrEnabled==1) ? AC_SBR_PRESENT : 0);
config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_LOAS;
hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 512;
if (hAacConfig->framelength != 512 && hAacConfig->framelength != 480) {
@@ -676,19 +831,6 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
break;
}
- /* We need the frame length to call aacEncoder_LimitBitrate() */
- hAacConfig->bitRate = aacEncoder_LimitBitrate(
- NULL,
- hAacConfig->sampleRate,
- hAacConfig->framelength,
- hAacConfig->nChannels,
- hAacConfig->channelMode,
- config->userBitrate,
- hAacConfig->nSubFrames,
- isSbrActive(hAacConfig),
- hAacConfig->audioObjectType
- );
-
switch ( hAacConfig->audioObjectType ) {
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
@@ -696,7 +838,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
hAacConfig->bitrateMode = 0;
}
if (config->userBitrateMode==0) {
- hAacConfig->bitreservoir = 50*config->nChannels; /* default, reduced bitreservoir */
+ hAacConfig->bitreservoir = 100*config->nChannels; /* default, reduced bitreservoir */
}
if (hAacConfig->bitrateMode!=0) {
return AACENC_INVALID_CONFIG;
@@ -706,24 +848,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
break;
}
- if (hAacConfig->epConfig >= 0) {
- hAacConfig->syntaxFlags |= AC_ER;
- if (((INT)hAacConfig->channelMode < 1) || ((INT)hAacConfig->channelMode > 7)) {
- return AACENC_INVALID_CONFIG; /* Cannel config 0 not supported. */
- }
- }
-
- if ( FDKaacEnc_DetermineEncoderMode(&hAacConfig->channelMode, hAacConfig->nChannels) != AAC_ENC_OK) {
- return AACENC_INVALID_CONFIG; /* nChannels doesn't match chMode, this is just a check-up */
- }
-
- if ( (hAacConfig->nChannels > hAacEncoder->nMaxAacChannels)
- || ( (FDKaacEnc_GetChannelModeConfiguration(hAacConfig->channelMode)->nChannelsEff > hAacEncoder->nMaxSbrChannels) &&
- isSbrActive(hAacConfig) )
- )
- {
- return AACENC_INVALID_CONFIG; /* not enough channels allocated */
- }
+ hAacConfig->bitRate = config->userBitrate;
/* get bitrate in VBR configuration */
if ( (hAacConfig->bitrateMode>=1) && (hAacConfig->bitrateMode<=5) ) {
@@ -734,25 +859,92 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
/* Set default bitrate if no external bitrate declared. */
- if (hAacConfig->bitRate==-1) {
+ if ( (hAacConfig->bitrateMode==0) && (config->userBitrate==(UINT)-1) ) {
INT bitrate = FDKaacEnc_GetChannelModeConfiguration(hAacConfig->channelMode)->nChannelsEff * hAacConfig->sampleRate;
- switch (hAacConfig->audioObjectType)
+
+ if ( isPsActive(hAacConfig->audioObjectType) ) {
+ hAacConfig->bitRate = (bitrate>>1); /* 0.5 bit per sample */
+ }
+ else if ( isSbrActive(hAacConfig) )
+ {
+ if ( (config->userSbrRatio==2) || ((config->userSbrRatio==0)&&(hAacConfig->audioObjectType!=AOT_ER_AAC_ELD)) ) {
+ hAacConfig->bitRate = (bitrate + (bitrate>>2))>>1; /* 0.625 bits per sample */
+ }
+ if ( (config->userSbrRatio==1) || ((config->userSbrRatio==0)&&(hAacConfig->audioObjectType==AOT_ER_AAC_ELD)) ) {
+ hAacConfig->bitRate = (bitrate + (bitrate>>3)); /* 1.125 bits per sample */
+ }
+ } else
{
- case AOT_AAC_LC:
hAacConfig->bitRate = bitrate + (bitrate>>1); /* 1.5 bits per sample */
- break;
- case AOT_SBR:
- hAacConfig->bitRate = (bitrate + (bitrate>>2))>>1; /* 0.625 bits per sample */
- break;
- case AOT_PS:
- hAacConfig->bitRate = (bitrate>>1); /* 0.5 bit per sample */
- break;
- default:
- hAacConfig->bitRate = bitrate;
- break;
}
}
+ /* Initialize SBR parameters */
+ if ( (hAacConfig->audioObjectType==AOT_ER_AAC_ELD)
+ && (config->userSbrEnabled == (UCHAR)-1) && (config->userSbrRatio==0) )
+ {
+ UINT eldSbr = 0;
+ UINT eldSbrRatio = 0;
+
+ if ( AACENC_OK!=(err=eldSbrConfigurator(
+ hAacConfig->sampleRate,
+ hAacConfig->channelMode,
+ hAacConfig->bitRate,
+ &eldSbr,
+ &eldSbrRatio)) )
+ {
+ return err;
+ }
+
+ hAacConfig->syntaxFlags |= ((eldSbr) ? AC_SBR_PRESENT : 0);
+ hAacConfig->sbrRatio = eldSbrRatio;
+ }
+ else
+ if ( (config->userSbrRatio==0) && (isSbrActive(hAacConfig)) ) {
+ /* Automatic SBR ratio configuration
+ * - downsampled SBR for ELD
+ * - otherwise always dualrate SBR
+ */
+ hAacConfig->sbrRatio = (hAacConfig->audioObjectType==AOT_ER_AAC_ELD) ? 1 : 2;
+ }
+ else {
+ /* SBR ratio has been set by the user, so use it. */
+ hAacConfig->sbrRatio = config->userSbrRatio;
+ }
+
+ {
+ UCHAR tpSignaling=getSbrSignalingMode(hAacConfig->audioObjectType, config->userTpType, config->userTpSignaling, hAacConfig->sbrRatio);
+
+ if ( (hAacConfig->audioObjectType==AOT_AAC_LC || hAacConfig->audioObjectType==AOT_SBR || hAacConfig->audioObjectType==AOT_PS) &&
+ (config->userTpType==TT_MP4_LATM_MCP1 || config->userTpType==TT_MP4_LATM_MCP0 || config->userTpType==TT_MP4_LOAS) &&
+ (tpSignaling==1) && (config->userTpAmxv==0) ) {
+ /* For backward compatible explicit signaling, AMV1 has to be active */
+ return AACENC_INVALID_CONFIG;
+ }
+
+ if ( (hAacConfig->audioObjectType==AOT_AAC_LC || hAacConfig->audioObjectType==AOT_SBR || hAacConfig->audioObjectType==AOT_PS) &&
+ (tpSignaling==0) && (hAacConfig->sbrRatio==1)) {
+ /* Downsampled SBR has to be signaled explicitely (for transmission of SBR sampling fequency) */
+ return AACENC_INVALID_CONFIG;
+ }
+ }
+
+
+
+ /* We need the frame length to call aacEncoder_LimitBitrate() */
+ hAacConfig->bitRate = aacEncoder_LimitBitrate(
+ NULL,
+ hAacConfig->sampleRate,
+ hAacConfig->framelength,
+ hAacConfig->nChannels,
+ hAacConfig->channelMode,
+ hAacConfig->bitRate,
+ hAacConfig->nSubFrames,
+ isSbrActive(hAacConfig),
+ hAacConfig->sbrRatio,
+ hAacConfig->audioObjectType
+ );
+
/* Configure PNS */
if ( ((hAacConfig->bitrateMode>=1) && (hAacConfig->bitrateMode<=5)) /* VBR without PNS. */
|| (hAacConfig->useTns == 0) ) /* TNS required. */
@@ -760,12 +952,32 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
hAacConfig->usePns = 0;
}
+ if (hAacConfig->epConfig >= 0) {
+ hAacConfig->syntaxFlags |= AC_ER;
+ if (((INT)hAacConfig->channelMode < 1) || ((INT)hAacConfig->channelMode > 7)) {
+ return AACENC_INVALID_CONFIG; /* Cannel config 0 not supported. */
+ }
+ }
+
+ if ( FDKaacEnc_DetermineEncoderMode(&hAacConfig->channelMode, hAacConfig->nChannels) != AAC_ENC_OK) {
+ return AACENC_INVALID_CONFIG; /* nChannels doesn't match chMode, this is just a check-up */
+ }
+
+ if ( (hAacConfig->nChannels > hAacEncoder->nMaxAacChannels)
+ || ( (FDKaacEnc_GetChannelModeConfiguration(hAacConfig->channelMode)->nChannelsEff > hAacEncoder->nMaxSbrChannels) &&
+ isSbrActive(hAacConfig) )
+ )
+ {
+ return AACENC_INVALID_CONFIG; /* not enough channels allocated */
+ }
+
/* Meta data restriction. */
switch (hAacConfig->audioObjectType)
{
/* Allow metadata support */
case AOT_AAC_LC:
case AOT_SBR:
+ case AOT_PS:
hAacEncoder->metaDataAllowed = 1;
if (((INT)hAacConfig->channelMode < 1) || ((INT)hAacConfig->channelMode > 7)) {
config->userMetaDataMode = 0;
@@ -849,10 +1061,8 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
((InitFlags & AACENC_INIT_CONFIG) || (InitFlags & AACENC_INIT_STATES)) )
{
INT sbrError;
- SBR_ELEMENT_INFO sbrElInfo[(6)];
+ SBR_ELEMENT_INFO sbrElInfo[(8)];
CHANNEL_MAPPING channelMapping;
-
- AUDIO_OBJECT_TYPE aot = hAacConfig->audioObjectType;
if ( FDKaacEnc_InitChannelMapping(hAacConfig->channelMode,
hAacConfig->channelOrder,
@@ -862,7 +1072,7 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
}
/* Check return value and if the SBR encoder can handle enough elements */
- if (channelMapping.nElements > (6)) {
+ if (channelMapping.nElements > (8)) {
return AACENC_INIT_ERROR;
}
@@ -881,15 +1091,17 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
&aacBufferOffset,
&hAacConfig->nChannels,
&hAacConfig->sampleRate,
+ &hAacConfig->sbrRatio,
&frameLength,
- &hAacConfig->audioObjectType,
+ hAacConfig->audioObjectType,
&hAacEncoder->nDelay,
(hAacConfig->audioObjectType == AOT_ER_AAC_ELD) ? 1 : TRANS_FAC,
+ (config->userTpHeaderPeriod!=0xFF) ? config->userTpHeaderPeriod : DEFAULT_HEADER_PERIOD_REPETITION_RATE,
initFlag
);
/* Suppress AOT reconfiguration and check error status. */
- if ( sbrError || (hAacConfig->audioObjectType!=aot) ) {
+ if (sbrError) {
return AACENC_INIT_SBR_ERROR;
}
@@ -915,7 +1127,11 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
{
UINT flags = 0;
- FDKaacEnc_MapConfig(&hAacEncoder->coderConfig, config, hAacConfig);
+ FDKaacEnc_MapConfig(
+ &hAacEncoder->coderConfig,
+ config,
+ getSbrSignalingMode(hAacConfig->audioObjectType, config->userTpType, config->userTpSignaling, hAacConfig->sbrRatio),
+ hAacConfig);
/* create flags for transport encoder */
if (config->userTpAmxv == 1) {
@@ -958,7 +1174,7 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
INT inputDataDelay = DELAY_AAC(hAacConfig->framelength);
if ( isSbrActive(hAacConfig) && hSbrEncoder!=NULL) {
- inputDataDelay = 2*inputDataDelay + sbrEncoder_GetInputDataDelay(*hSbrEncoder);
+ inputDataDelay = hAacConfig->sbrRatio*inputDataDelay + sbrEncoder_GetInputDataDelay(*hSbrEncoder);
}
if ( FDK_MetadataEnc_Init(hAacEncoder->hMetadataEnc,
@@ -1033,8 +1249,8 @@ AACENC_ERROR aacEncOpen(
/* Determine max channel configuration. */
if (maxChannels==0) {
- hAacEncoder->nMaxAacChannels = (6);
- hAacEncoder->nMaxSbrChannels = (6);
+ hAacEncoder->nMaxAacChannels = (8);
+ hAacEncoder->nMaxSbrChannels = (8);
}
else {
hAacEncoder->nMaxAacChannels = (maxChannels&0x00FF);
@@ -1042,15 +1258,15 @@ AACENC_ERROR aacEncOpen(
hAacEncoder->nMaxSbrChannels = (maxChannels&0xFF00) ? (maxChannels>>8) : hAacEncoder->nMaxAacChannels;
}
- if ( (hAacEncoder->nMaxAacChannels>(6)) || (hAacEncoder->nMaxSbrChannels>(6)) ) {
+ if ( (hAacEncoder->nMaxAacChannels>(8)) || (hAacEncoder->nMaxSbrChannels>(8)) ) {
err = AACENC_INVALID_CONFIG;
goto bail;
}
} /* maxChannels==0 */
/* Max number of elements could be tuned any more. */
- hAacEncoder->nMaxAacElements = fixMin((6), hAacEncoder->nMaxAacChannels);
- hAacEncoder->nMaxSbrElements = fixMin((6), hAacEncoder->nMaxSbrChannels);
+ hAacEncoder->nMaxAacElements = fixMin((8), hAacEncoder->nMaxAacChannels);
+ hAacEncoder->nMaxSbrElements = fixMin((8), hAacEncoder->nMaxSbrChannels);
hAacEncoder->nMaxSubFrames = (1);
@@ -1108,7 +1324,7 @@ AACENC_ERROR aacEncOpen(
goto bail;
}
else {
- C_ALLOC_SCRATCH_START(pLibInfo, LIB_INFO, FDK_MODULE_LAST);
+ C_ALLOC_SCRATCH_START(pLibInfo, LIB_INFO, FDK_MODULE_LAST);
FDKinitLibInfo( pLibInfo);
transportEnc_GetLibInfo( pLibInfo );
@@ -1343,8 +1559,12 @@ AACENC_ERROR aacEncEncode(
for (i=0; i<(INT)nMetaDataExtensions; i++) { /* Get meta data extension payload. */
hAacEncoder->extPayload[nExtensions++] = pMetaDataExtPayload[i];
}
- if (matrix_mixdown_idx!=-1) { /* Set matrix mixdown coefficient. */
- UINT pceValue = (UINT)( (1<<3) | ((matrix_mixdown_idx&0x2)<<1) | 1 );
+
+ if ( (matrix_mixdown_idx!=-1)
+ && ((hAacEncoder->extParam.userChannelMode==MODE_1_2_2)||(hAacEncoder->extParam.userChannelMode==MODE_1_2_2_1)) )
+ {
+ /* Set matrix mixdown coefficient. */
+ UINT pceValue = (UINT)( (1<<3) | ((matrix_mixdown_idx&0x3)<<1) | 1 );
if (hAacEncoder->extParam.userPceAdditions != pceValue) {
hAacEncoder->extParam.userPceAdditions = pceValue;
hAacEncoder->InitFlags |= AACENC_INIT_TRANSPORT;
@@ -1375,7 +1595,7 @@ AACENC_ERROR aacEncEncode(
}
else {
/* Add SBR extension payload */
- for (i = 0; i < (6); i++) {
+ for (i = 0; i < (8); i++) {
if (hAacEncoder->extPayloadSize[nPayload][i] > 0) {
hAacEncoder->extPayload[nExtensions].pData = hAacEncoder->extPayloadData[nPayload][i];
{
@@ -1573,7 +1793,6 @@ AACENC_ERROR aacEncoder_SetParam(
}
case AOT_AAC_LC:
case AOT_MP2_AAC_LC:
- case AOT_ER_AAC_LC:
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_AAC))) {
@@ -1636,7 +1855,7 @@ AACENC_ERROR aacEncoder_SetParam(
}
if ( (pConfig->nElements > hAacEncoder->nMaxAacElements)
|| (pConfig->nChannelsEff > hAacEncoder->nMaxAacChannels)
- || !((value>=1) && (value<=6))
+ || !(((value>=1) && (value<=7))||((value>=33) && (value<=34)))
)
{
err = AACENC_INVALID_CONFIG;
@@ -1691,6 +1910,16 @@ AACENC_ERROR aacEncoder_SetParam(
}
}
break;
+ case AACENC_SBR_RATIO:
+ if (settings->userSbrRatio != value) {
+ if (! ((value==0) || (value==1) || (value==2)) ) {
+ err = AACENC_INVALID_CONFIG;
+ break;
+ }
+ settings->userSbrRatio = value;
+ hAacEncoder->InitFlags |= AACENC_INIT_CONFIG | AACENC_INIT_STATES | AACENC_INIT_TRANSPORT;
+ }
+ break;
case AACENC_SBR_MODE:
if (settings->userSbrEnabled != value) {
settings->userSbrEnabled = value;
@@ -1812,7 +2041,7 @@ UINT aacEncoder_GetParam(
value = (UINT)hAacEncoder->aacConfig.bitrateMode;
break;
case AACENC_SAMPLERATE:
- value = (UINT)settings->userSamplerate;
+ value = (UINT)hAacEncoder->coderConfig.extSamplingRate;
break;
case AACENC_CHANNELMODE:
value = (UINT)hAacEncoder->aacConfig.channelMode;
@@ -1829,6 +2058,9 @@ UINT aacEncoder_GetParam(
case AACENC_GRANULE_LENGTH:
value = (UINT)hAacEncoder->aacConfig.framelength;
break;
+ case AACENC_SBR_RATIO:
+ value = isSbrActive(&hAacEncoder->aacConfig) ? hAacEncoder->aacConfig.sbrRatio : 0;
+ break;
case AACENC_SBR_MODE:
value = (UINT) (hAacEncoder->aacConfig.syntaxFlags & AC_SBR_PRESENT) ? 1 : 0;
break;
@@ -1836,7 +2068,7 @@ UINT aacEncoder_GetParam(
value = (UINT)settings->userTpType;
break;
case AACENC_SIGNALING_MODE:
- value = (UINT)settings->userTpSignaling;
+ value = (UINT)getSbrSignalingMode(hAacEncoder->aacConfig.audioObjectType, settings->userTpType, settings->userTpSignaling, hAacEncoder->aacConfig.sbrRatio);
break;
case AACENC_PROTECTION:
value = (UINT)settings->userTpProtection;
diff --git a/libAACenc/src/aacenc_pns.cpp b/libAACenc/src/aacenc_pns.cpp
index 4d81268..b9640d9 100644
--- a/libAACenc/src/aacenc_pns.cpp
+++ b/libAACenc/src/aacenc_pns.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/aacenc_pns.h b/libAACenc/src/aacenc_pns.h
index ce82071..3bda9de 100644
--- a/libAACenc/src/aacenc_pns.h
+++ b/libAACenc/src/aacenc_pns.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/aacenc_tns.cpp b/libAACenc/src/aacenc_tns.cpp
index 00b2bca..85aea65 100644
--- a/libAACenc/src/aacenc_tns.cpp
+++ b/libAACenc/src/aacenc_tns.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -83,7 +83,7 @@ amm-info@iis.fraunhofer.de
/******************************** MPEG Audio Encoder **************************
- Initial author: Alex Groeschel
+ Initial author: Alex Groeschel, Tobias Chalupka
contents/description: Temporal noise shaping
******************************************************************************/
@@ -281,7 +281,6 @@ static INT getTnsMaxBands(
int maxBandsTabSize = 0;
switch (granuleLength) {
- case 960:
case 1024:
pMaxBandsTab = tnsMaxBandsTab1024;
maxBandsTabSize = sizeof(tnsMaxBandsTab1024)/sizeof(TNS_MAX_TAB_ENTRY);
@@ -404,7 +403,6 @@ AAC_ENCODER_ERROR FDKaacEnc_InitTnsConfiguration(INT bitRate,
tC->lpcStopLine = pC->sfbOffset[tC->lpcStopBand];
switch (granuleLength) {
- case 960:
case 1024:
/* TNS start line: skip lower MDCT lines to prevent artifacts due to filter mismatch */
tC->lpcStartBand[LOFILT] = (blockType == SHORT_WINDOW) ? 0 : ((sampleRate < 18783) ? 4 : 8);
diff --git a/libAACenc/src/aacenc_tns.h b/libAACenc/src/aacenc_tns.h
index 519fd69..f2b731f 100644
--- a/libAACenc/src/aacenc_tns.h
+++ b/libAACenc/src/aacenc_tns.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/adj_thr.cpp b/libAACenc/src/adj_thr.cpp
index a779357..6433633 100644
--- a/libAACenc/src/adj_thr.cpp
+++ b/libAACenc/src/adj_thr.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -123,6 +123,117 @@ static const FIXP_DBL SnrLdMin4 = (FIXP_DBL)0x02000000; /*FL2FXCONST_DBL(FDKlog
static const FIXP_DBL SnrLdMin5 = (FIXP_DBL)0xfc000000; /*FL2FXCONST_DBL(FDKlog(0.25) /FDKlog(2.0)/LD_DATA_SCALING);*/
+/*
+The bits2Pe factors are choosen for the case that some times
+the crash recovery strategy will be activated once.
+*/
+
+typedef struct {
+ INT bitrate;
+ LONG bits2PeFactor_mono;
+ LONG bits2PeFactor_mono_slope;
+ LONG bits2PeFactor_stereo;
+ LONG bits2PeFactor_stereo_slope;
+ LONG bits2PeFactor_mono_scfOpt;
+ LONG bits2PeFactor_mono_scfOpt_slope;
+ LONG bits2PeFactor_stereo_scfOpt;
+ LONG bits2PeFactor_stereo_scfOpt_slope;
+
+} BIT_PE_SFAC;
+
+typedef struct {
+ const INT sampleRate;
+ const BIT_PE_SFAC * pPeTab;
+ const INT nEntries;
+
+} BITS2PE_CFG_TAB;
+
+static const BIT_PE_SFAC S_Bits2PeTab16000[] = {
+ { 10000, 0x228F5C29, 0x02FEF55D, 0x1D70A3D7, 0x09BC9D6D, 0x228F5C29, 0x02FEF55D, 0x1C28F5C3, 0x0CBB92CA},
+ { 24000, 0x23D70A3D, 0x029F16B1, 0x2199999A, 0x07DD4413, 0x23D70A3D, 0x029F16B1, 0x2199999A, 0x07DD4413},
+ { 32000, 0x247AE148, 0x11B1D92B, 0x23851EB8, 0x01F75105, 0x247AE148, 0x110A137F, 0x23851EB8, 0x01F75105},
+ { 48000, 0x2D1EB852, 0x6833C600, 0x247AE148, 0x014F8B59, 0x2CCCCCCD, 0x68DB8BAC, 0x247AE148, 0x01F75105},
+ { 64000, 0x60000000, 0x00000000, 0x251EB852, 0x154C985F, 0x60000000, 0x00000000, 0x2570A3D7, 0x154C985F},
+ { 96000, 0x60000000, 0x00000000, 0x39EB851F, 0x088509C0, 0x60000000, 0x00000000, 0x3A3D70A4, 0x088509C0},
+ {128000, 0x60000000, 0x00000000, 0x423D70A4, 0x18A43BB4, 0x60000000, 0x00000000, 0x428F5C29, 0x181E03F7},
+ {148000, 0x60000000, 0x00000000, 0x5147AE14, 0x00000000, 0x60000000, 0x00000000, 0x5147AE14, 0x00000000}
+};
+
+static const BIT_PE_SFAC S_Bits2PeTab22050[] = {
+ { 16000, 0x1a8f5c29, 0x1797cc3a, 0x128f5c29, 0x18e75793, 0x175c28f6, 0x221426fe, 0x00000000, 0x5a708ede},
+ { 24000, 0x2051eb85, 0x092ccf6c, 0x18a3d70a, 0x13a92a30, 0x1fae147b, 0xbcbe61d, 0x16147ae1, 0x18e75793},
+ { 32000, 0x228f5c29, 0x029f16b1, 0x1d70a3d7, 0x088509c0, 0x228f5c29, 0x29f16b1, 0x1c28f5c3, 0x0b242071},
+ { 48000, 0x23d70a3d, 0x014f8b59, 0x2199999a, 0x03eea20a, 0x23d70a3d, 0x14f8b59, 0x2199999a, 0x03eea20a},
+ { 64000, 0x247ae148, 0x08d8ec96, 0x23851eb8, 0x00fba882, 0x247ae148, 0x88509c0, 0x23851eb8, 0x00fba882},
+ { 96000, 0x2d1eb852, 0x3419e300, 0x247ae148, 0x00a7c5ac, 0x2ccccccd, 0x346dc5d6, 0x247ae148, 0x00fba882},
+ {128000, 0x60000000, 0x00000000, 0x251eb852, 0x029f16b1, 0x60000000, 0x00000000, 0x2570a3d7, 0x009f16b1},
+ {148000, 0x60000000, 0x00000000, 0x26b851ec, 0x00000000, 0x60000000, 0x00000000, 0x270a3d71, 0x00000000}
+};
+
+static const BIT_PE_SFAC S_Bits2PeTab24000[] = {
+ { 16000, 0x19eb851f, 0x13a92a30, 0x1147ae14, 0x164840e1, 0x1999999a, 0x12599ed8, 0x00000000, 0x46c764ae},
+ { 24000, 0x1eb851ec, 0x0d1b7176, 0x16b851ec, 0x18e75793, 0x1e147ae1, 0x0fba8827, 0x1147ae14, 0x2c9081c3},
+ { 32000, 0x21eb851f, 0x049667b6, 0x1ccccccd, 0x07357e67, 0x21eb851f, 0x03eea20a, 0x1c28f5c3, 0x07357e67},
+ { 48000, 0x2428f5c3, 0x014f8b59, 0x2051eb85, 0x053e2d62, 0x23d70a3d, 0x01f75105, 0x1fae147b, 0x07357e67},
+ { 64000, 0x24cccccd, 0x05e5f30e, 0x22e147ae, 0x01a36e2f, 0x24cccccd, 0x05e5f30e, 0x23333333, 0x014f8b59},
+ { 96000, 0x2a8f5c29, 0x24b33db0, 0x247ae148, 0x00fba882, 0x2a8f5c29, 0x26fe718b, 0x247ae148, 0x00fba882},
+ {128000, 0x4e666666, 0x1cd5f99c, 0x2570a3d7, 0x010c6f7a, 0x50a3d70a, 0x192a7371, 0x2570a3d7, 0x010c6f7a},
+ {148000, 0x60000000, 0x00000000, 0x26147ae1, 0x00000000, 0x60000000, 0x00000000, 0x26147ae1, 0x00000000}
+};
+
+static const BIT_PE_SFAC S_Bits2PeTab32000[] = {
+ { 16000, 0x1199999a, 0x20c49ba6, 0x00000000, 0x4577d955, 0x00000000, 0x60fe4799, 0x00000000, 0x00000000},
+ { 24000, 0x1999999a, 0x0fba8827, 0x10f5c28f, 0x1b866e44, 0x17ae147b, 0x0fba8827, 0x00000000, 0x4d551d69},
+ { 32000, 0x1d70a3d7, 0x07357e67, 0x17ae147b, 0x09d49518, 0x1b851eb8, 0x0a7c5ac4, 0x12e147ae, 0x110a137f},
+ { 48000, 0x20f5c28f, 0x049667b6, 0x1c7ae148, 0x053e2d62, 0x20a3d70a, 0x053e2d62, 0x1b333333, 0x05e5f30e},
+ { 64000, 0x23333333, 0x029f16b1, 0x1f0a3d71, 0x02f2f987, 0x23333333, 0x029f16b1, 0x1e147ae1, 0x03eea20a},
+ { 96000, 0x25c28f5c, 0x2c3c9eed, 0x21eb851f, 0x01f75105, 0x25c28f5c, 0x0a7c5ac4, 0x21eb851f, 0x01a36e2f},
+ {128000, 0x50f5c28f, 0x18a43bb4, 0x23d70a3d, 0x010c6f7a, 0x30000000, 0x168b5cc0, 0x23851eb8, 0x0192a737},
+ {148000, 0x60000000, 0x00000000, 0x247ae148, 0x00dfb23b, 0x3dc28f5c, 0x300f4aaf, 0x247ae148, 0x01bf6476},
+ {160000, 0x60000000, 0xb15b5740, 0x24cccccd, 0x053e2d62, 0x4f5c28f6, 0xbefd0072, 0x251eb852, 0x04fb1184},
+ {200000, 0x00000000, 0x00000000, 0x2b333333, 0x0836be91, 0x00000000, 0x00000000, 0x2b333333, 0x0890390f},
+ {320000, 0x00000000, 0x00000000, 0x4947ae14, 0x00000000, 0x00000000, 0x00000000, 0x4a8f5c29, 0x00000000}
+};
+
+static const BIT_PE_SFAC S_Bits2PeTab44100[] = {
+ { 16000, 0x10a3d70a, 0x1797cc3a, 0x00000000, 0x00000000, 0x00000000, 0x59210386, 0x00000000, 0x00000000},
+ { 24000, 0x16666666, 0x1797cc3a, 0x00000000, 0x639d5e4a, 0x15c28f5c, 0x12599ed8, 0x00000000, 0x5bc01a37},
+ { 32000, 0x1c28f5c3, 0x049667b6, 0x1851eb85, 0x049667b6, 0x1a3d70a4, 0x088509c0, 0x16666666, 0x053e2d62},
+ { 48000, 0x1e666666, 0x05e5f30e, 0x1a8f5c29, 0x049667b6, 0x1e666666, 0x05e5f30e, 0x18f5c28f, 0x05e5f30e},
+ { 64000, 0x2147ae14, 0x0346dc5d, 0x1ccccccd, 0x02f2f987, 0x2147ae14, 0x02f2f987, 0x1bd70a3d, 0x039abf34},
+ { 96000, 0x247ae148, 0x068db8bb, 0x1fae147b, 0x029f16b1, 0x2428f5c3, 0x0639d5e5, 0x1f5c28f6, 0x029f16b1},
+ {128000, 0x2ae147ae, 0x1b435265, 0x223d70a4, 0x0192a737, 0x2a3d70a4, 0x1040bfe4, 0x21eb851f, 0x0192a737},
+ {148000, 0x3b851eb8, 0x2832069c, 0x23333333, 0x00dfb23b, 0x3428f5c3, 0x2054c288, 0x22e147ae, 0x00dfb23b},
+ {160000, 0x4a3d70a4, 0xc32ebe5a, 0x23851eb8, 0x01d5c316, 0x40000000, 0xcb923a2b, 0x23333333, 0x01d5c316},
+ {200000, 0x00000000, 0x00000000, 0x25c28f5c, 0x0713f078, 0x00000000, 0x00000000, 0x2570a3d7, 0x072a4f17},
+ {320000, 0x00000000, 0x00000000, 0x3fae147b, 0x00000000, 0x00000000, 0x00000000, 0x3fae147b, 0x00000000}
+};
+
+static const BIT_PE_SFAC S_Bits2PeTab48000[] = {
+ { 16000, 0x0f5c28f6, 0x31ceaf25, 0x00000000, 0x00000000, 0x00000000, 0x74a771c9, 0x00000000, 0x00000000},
+ { 24000, 0x1b851eb8, 0x029f16b1, 0x00000000, 0x663c74fb, 0x1c7ae148, 0xe47991bd, 0x00000000, 0x49667b5f},
+ { 32000, 0x1c28f5c3, 0x029f16b1, 0x18f5c28f, 0x07357e67, 0x15c28f5c, 0x0f12c27a, 0x11eb851f, 0x13016484},
+ { 48000, 0x1d70a3d7, 0x053e2d62, 0x1c7ae148, 0xfe08aefc, 0x1d1eb852, 0x068db8bb, 0x1b333333, 0xfeb074a8},
+ { 64000, 0x20000000, 0x03eea20a, 0x1b851eb8, 0x0346dc5d, 0x2051eb85, 0x0346dc5d, 0x1a8f5c29, 0x039abf34},
+ { 96000, 0x23d70a3d, 0x053e2d62, 0x1eb851ec, 0x029f16b1, 0x23851eb8, 0x04ea4a8c, 0x1e147ae1, 0x02f2f987},
+ {128000, 0x28f5c28f, 0x14727dcc, 0x2147ae14, 0x0218def4, 0x2851eb85, 0x0e27e0f0, 0x20f5c28f, 0x0218def4},
+ {148000, 0x3570a3d7, 0x1cd5f99c, 0x228f5c29, 0x01bf6476, 0x30f5c28f, 0x18777e75, 0x223d70a4, 0x01bf6476},
+ {160000, 0x40000000, 0xcb923a2b, 0x23333333, 0x0192a737, 0x39eb851f, 0xd08d4bae, 0x22e147ae, 0x0192a737},
+ {200000, 0x00000000, 0x00000000, 0x251eb852, 0x06775a1b, 0x00000000, 0x00000000, 0x24cccccd, 0x06a4175a},
+ {320000, 0x00000000, 0x00000000, 0x3ccccccd, 0x00000000, 0x00000000, 0x00000000, 0x3d1eb852, 0x00000000}
+};
+
+static const BITS2PE_CFG_TAB bits2PeConfigTab[] = {
+ { 16000, S_Bits2PeTab16000, sizeof(S_Bits2PeTab16000)/sizeof(BIT_PE_SFAC) },
+ { 22050, S_Bits2PeTab22050, sizeof(S_Bits2PeTab22050)/sizeof(BIT_PE_SFAC) },
+ { 24000, S_Bits2PeTab24000, sizeof(S_Bits2PeTab24000)/sizeof(BIT_PE_SFAC) },
+ { 32000, S_Bits2PeTab32000, sizeof(S_Bits2PeTab32000)/sizeof(BIT_PE_SFAC) },
+ { 44100, S_Bits2PeTab44100, sizeof(S_Bits2PeTab44100)/sizeof(BIT_PE_SFAC) },
+ { 48000, S_Bits2PeTab48000, sizeof(S_Bits2PeTab48000)/sizeof(BIT_PE_SFAC) }
+};
+
+
+
/* values for avoid hole flag */
enum _avoid_hole_state {
NO_AH =0,
@@ -135,6 +246,99 @@ enum _avoid_hole_state {
#define Q_BITFAC (24) /* Q scaling used in FDKaacEnc_bitresCalcBitFac() calculation */
#define Q_AVGBITS (17) /* scale bit values */
+
+/*****************************************************************************
+ functionname: FDKaacEnc_InitBits2PeFactor
+ description: retrieve bits2PeFactor from table
+*****************************************************************************/
+static void FDKaacEnc_InitBits2PeFactor(
+ FIXP_DBL *bits2PeFactor_m,
+ INT *bits2PeFactor_e,
+ const INT bitRate,
+ const INT nChannels,
+ const INT sampleRate,
+ const INT advancedBitsToPe,
+ const INT invQuant
+ )
+{
+ /* default bits2pe factor */
+ FIXP_DBL bit2PE_m = FL2FXCONST_DBL(1.18f/(1<<(1)));
+ INT bit2PE_e = 1;
+
+ /* make use of advanced bits to pe factor table */
+ if (advancedBitsToPe) {
+
+ int i;
+ const BIT_PE_SFAC *peTab = NULL;
+ INT size = 0;
+
+
+ /* Get correct table entry */
+ for (i=0; i<(INT)(sizeof(bits2PeConfigTab)/sizeof(BITS2PE_CFG_TAB)); i++) {
+ if (sampleRate >= bits2PeConfigTab[i].sampleRate) {
+ peTab = bits2PeConfigTab[i].pPeTab;
+ size = bits2PeConfigTab[i].nEntries;
+ }
+ }
+
+ if ( (peTab!=NULL) && (size!=0) ) {
+
+ INT startB = -1;
+ LONG startPF = 0;
+ LONG peSlope = 0;
+
+ /* stereo or mono mode and invQuant used or not */
+ for (i=0; i<size-1; i++)
+ {
+ if ((peTab[i].bitrate<=bitRate) && ((peTab[i+1].bitrate>bitRate) || ((i==size-2)) ))
+ {
+ if (nChannels==1)
+ {
+ startPF = (!invQuant) ? peTab[i].bits2PeFactor_mono : peTab[i].bits2PeFactor_mono_scfOpt;
+ peSlope = (!invQuant) ? peTab[i].bits2PeFactor_mono_slope : peTab[i].bits2PeFactor_mono_scfOpt_slope;
+ /*endPF = (!invQuant) ? peTab[i+1].bits2PeFactor_mono : peTab[i+1].bits2PeFactor_mono_scfOpt;
+ endB=peTab[i+1].bitrate;*/
+ startB=peTab[i].bitrate;
+ break;
+ }
+ else
+ {
+ startPF = (!invQuant) ? peTab[i].bits2PeFactor_stereo : peTab[i].bits2PeFactor_stereo_scfOpt;
+ peSlope = (!invQuant) ? peTab[i].bits2PeFactor_stereo_slope : peTab[i].bits2PeFactor_stereo_scfOpt_slope;
+ /*endPF = (!invQuant) ? peTab[i+1].bits2PeFactor_stereo : peTab[i+1].bits2PeFactor_stereo_scfOpt;
+ endB=peTab[i+1].bitrate;*/
+ startB=peTab[i].bitrate;
+ break;
+ }
+ }
+ } /* for i */
+
+ /* if a configuration is available */
+ if (startB!=-1) {
+ /* linear interpolate to actual PEfactor */
+ FIXP_DBL peFac = fMult((FIXP_DBL)(bitRate-startB)<<14, (FIXP_DBL)peSlope) << 2;
+ FIXP_DBL bit2PE = peFac + (FIXP_DBL)startPF; /* startPF_float = startPF << 2 */
+
+ /* sanity check if bits2pe value is high enough */
+ if ( bit2PE >= (FL2FXCONST_DBL(0.35f) >> 2) ) {
+ bit2PE_m = bit2PE;
+ bit2PE_e = 2; /* table is fixed scaled */
+ }
+ } /* br */
+ } /* sr */
+ } /* advancedBitsToPe */
+
+
+ /* return bits2pe factor */
+ *bits2PeFactor_m = bit2PE_m;
+ *bits2PeFactor_e = bit2PE_e;
+}
+
+
+/*****************************************************************************
+functionname: FDKaacEnc_bits2pe2
+description: convert from bits to pe
+*****************************************************************************/
static INT FDKaacEnc_bits2pe2(
const INT bits,
const FIXP_DBL factor_m,
@@ -450,22 +654,23 @@ void FDKaacEnc_calcWeighting(PE_DATA *peData,
FIXP_DBL nrgSum14, nrgSum12, nrgSum34, nrgTotal;
FIXP_DBL nrgFacLd_14, nrgFacLd_12, nrgFacLd_34;
INT usePatch, exePatch;
- int sfb, nLinesSum = 0;
+ int sfb, sfbGrp, nLinesSum = 0;
nrgSum14 = nrgSum12 = nrgSum34 = nrgTotal = FL2FXCONST_DBL(0.f);
/* calculate flatness of audible spectrum, i.e. spectrum above masking threshold. */
- for (sfb = 0; sfb < psyOutChan->sfbCnt; sfb++) {
-
- FIXP_DBL nrgFac12 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfb]>>1); /* nrg^(1/2) */
- FIXP_DBL nrgFac14 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfb]>>2); /* nrg^(1/4) */
+ for (sfbGrp = 0;sfbGrp < psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutChannel[ch]->sfbPerGroup) {
+ for (sfb=0; sfb<psyOutChannel[ch]->maxSfbPerGroup; sfb++) {
+ FIXP_DBL nrgFac12 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1); /* nrg^(1/2) */
+ FIXP_DBL nrgFac14 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>2); /* nrg^(1/4) */
/* maximal number of bands is 64, results scaling factor 6 */
- nLinesSum += peData->peChannelData[ch].sfbNLines[sfb]; /* relevant lines */
- nrgTotal += ( psyOutChan->sfbEnergy[sfb] >> 6 ); /* sum up nrg */
+ nLinesSum += peData->peChannelData[ch].sfbNLines[sfbGrp+sfb]; /* relevant lines */
+ nrgTotal += ( psyOutChan->sfbEnergy[sfbGrp+sfb] >> 6 ); /* sum up nrg */
nrgSum12 += ( nrgFac12 >> 6 ); /* sum up nrg^(2/4) */
nrgSum14 += ( nrgFac14 >> 6 ); /* sum up nrg^(1/4) */
nrgSum34 += ( fMult(nrgFac14, nrgFac12) >> 6 ); /* sum up nrg^(3/4) */
+ }
}
nrgTotal = CalcLdData(nrgTotal); /* get ld64 of total nrg */
@@ -479,32 +684,35 @@ void FDKaacEnc_calcWeighting(PE_DATA *peData,
usePatch = (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.78125f));
exePatch = ((usePatch) && (adjThrStateElement->lastEnFacPatch[ch]));
- for (sfb = 0; sfb < psyOutChan->sfbCnt; sfb++) {
+ for (sfbGrp = 0;sfbGrp < psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutChannel[ch]->sfbPerGroup) {
+ for (sfb=0; sfb<psyOutChannel[ch]->maxSfbPerGroup; sfb++) {
+
INT sfbExePatch;
/* for MS coupled SFBs, also execute patch in side channel if done in mid channel */
- if ((ch == 1) && (toolsInfo->msMask[sfb])) {
+ if ((ch == 1) && (toolsInfo->msMask[sfbGrp+sfb])) {
sfbExePatch = exePatchM;
}
else {
sfbExePatch = exePatch;
}
- if ( (sfbExePatch) && (psyOutChan->sfbEnergy[sfb]>FL2FXCONST_DBL(0.f)) )
+ if ( (sfbExePatch) && (psyOutChan->sfbEnergy[sfbGrp+sfb]>FL2FXCONST_DBL(0.f)) )
{
/* execute patch based on spectral flatness calculated above */
if (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.8125f)) {
- qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_14 + (psyOutChan->sfbEnergyLdData[sfb]+(psyOutChan->sfbEnergyLdData[sfb]>>1)))>>1 ); /* sfbEnergy^(3/4) */
+ qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_14 + (psyOutChan->sfbEnergyLdData[sfbGrp+sfb]+(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1)))>>1 ); /* sfbEnergy^(3/4) */
}
else if (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.796875f)) {
- qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_12 + psyOutChan->sfbEnergyLdData[sfb])>>1 ); /* sfbEnergy^(2/4) */
+ qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_12 + psyOutChan->sfbEnergyLdData[sfbGrp+sfb])>>1 ); /* sfbEnergy^(2/4) */
}
else {
- qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_34 + (psyOutChan->sfbEnergyLdData[sfb]>>1))>>1 ); /* sfbEnergy^(1/4) */
+ qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_34 + (psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1))>>1 ); /* sfbEnergy^(1/4) */
}
- qcOutChannel[ch]->sfbEnFacLd[sfb] = fixMin(qcOutChannel[ch]->sfbEnFacLd[sfb],(FIXP_DBL)0);
+ qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = fixMin(qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb],(FIXP_DBL)0);
}
+ }
} /* sfb loop */
adjThrStateElement->lastEnFacPatch[ch] = usePatch;
@@ -735,7 +943,6 @@ static FIXP_DBL FDKaacEnc_calcChaosMeasure(PSY_OUT_CHANNEL *psyOutChannel,
return chaosMeasure;
}
-
/* apply reduction formula for VBR-mode */
static void FDKaacEnc_reduceThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
PSY_OUT_CHANNEL* psyOutChannel[(2)],
@@ -923,7 +1130,6 @@ static void FDKaacEnc_reduceThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
}
}
-
/*****************************************************************************
functionname: FDKaacEnc_correctThresh
description: if pe difference deltaPe between desired pe and real pe is small enough,
@@ -931,12 +1137,12 @@ the difference can be distributed among the scale factor bands.
New thresholds can be derived from this pe-difference
*****************************************************************************/
static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
- QC_OUT_ELEMENT* qcElement[(6)],
- PSY_OUT_ELEMENT* psyOutElement[(6)],
- UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB],
- FIXP_DBL thrExp[(6)][(2)][MAX_GROUPED_SFB],
- const FIXP_DBL redVal[(6)],
- const SCHAR redValScaling[(6)],
+ QC_OUT_ELEMENT* qcElement[(8)],
+ PSY_OUT_ELEMENT* psyOutElement[(8)],
+ UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB],
+ FIXP_DBL thrExp[(8)][(2)][MAX_GROUPED_SFB],
+ const FIXP_DBL redVal[(8)],
+ const SCHAR redValScaling[(8)],
const INT deltaPe,
const INT processElements,
const INT elementOffset)
@@ -947,8 +1153,8 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
PE_CHANNEL_DATA *peChanData;
FIXP_DBL thrFactorLdData;
FIXP_DBL sfbEnLdData, sfbThrLdData, sfbThrReducedLdData;
- FIXP_DBL *sfbPeFactorsLdData[(6)][(2)];
- FIXP_DBL sfbNActiveLinesLdData[(2)][MAX_GROUPED_SFB];
+ FIXP_DBL *sfbPeFactorsLdData[(8)][(2)];
+ FIXP_DBL sfbNActiveLinesLdData[(8)][(2)][MAX_GROUPED_SFB];
INT normFactorInt;
FIXP_DBL normFactorLdData;
@@ -979,13 +1185,13 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
for (sfb=0; sfb<psyOutChan->maxSfbPerGroup; sfb++) {
if ( peChanData->sfbNActiveLines[sfbGrp+sfb] == 0 ) {
- sfbNActiveLinesLdData[ch][sfbGrp+sfb] = FL2FXCONST_DBL(-1.0f);
+ sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] = FL2FXCONST_DBL(-1.0f);
}
else {
/* Both CalcLdInt and CalcLdData can be used!
* No offset has to be subtracted, because sfbNActiveLinesLdData
* is shorted while thrFactor calculation */
- sfbNActiveLinesLdData[ch][sfbGrp+sfb] = CalcLdInt(peChanData->sfbNActiveLines[sfbGrp+sfb]);
+ sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] = CalcLdInt(peChanData->sfbNActiveLines[sfbGrp+sfb]);
}
if ( ((ahFlag[elementId][ch][sfbGrp+sfb] < AH_ACTIVE) || (deltaPe > 0)) &&
peChanData->sfbNActiveLines[sfbGrp+sfb] != 0 )
@@ -1002,14 +1208,14 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
- (FIXP_DBL)(minScale<<(DFRACT_BITS-1-LD_DATA_SHIFT));
if (sumLd < FL2FXCONST_DBL(0.f)) {
- sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb] - sumLd;
+ sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - sumLd;
}
else {
- if ( sfbNActiveLinesLdData[ch][sfbGrp+sfb] > (FL2FXCONST_DBL(-1.f) + sumLd) ) {
- sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb] - sumLd;
+ if ( sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] > (FL2FXCONST_DBL(-1.f) + sumLd) ) {
+ sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - sumLd;
}
else {
- sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb];
+ sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb];
}
}
@@ -1050,7 +1256,7 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
}
else {
/* new threshold */
- FIXP_DBL tmp = CalcInvLdData(sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] + normFactorLdData - sfbNActiveLinesLdData[ch][sfbGrp+sfb] - FL2FXCONST_DBL((float)LD_DATA_SHIFT/LD_DATA_SCALING));
+ FIXP_DBL tmp = CalcInvLdData(sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] + normFactorLdData - sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - FL2FXCONST_DBL((float)LD_DATA_SHIFT/LD_DATA_SCALING));
/* limit thrFactor to 60dB */
tmp = (deltaPe<0) ? tmp : (-tmp);
@@ -1102,9 +1308,9 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm,
reducing minSnr
*****************************************************************************/
void FDKaacEnc_reduceMinSnr(CHANNEL_MAPPING* cm,
- QC_OUT_ELEMENT* qcElement[(6)],
- PSY_OUT_ELEMENT* psyOutElement[(6)],
- UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB],
+ QC_OUT_ELEMENT* qcElement[(8)],
+ PSY_OUT_ELEMENT* psyOutElement[(8)],
+ UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB],
const INT desiredPe,
INT* redPeGlobal,
const INT processElements,
@@ -1204,10 +1410,10 @@ bail:
bands have to be quantized to zero
*****************************************************************************/
static void FDKaacEnc_allowMoreHoles(CHANNEL_MAPPING* cm,
- QC_OUT_ELEMENT* qcElement[(6)],
- PSY_OUT_ELEMENT* psyOutElement[(6)],
- ATS_ELEMENT* AdjThrStateElement[(6)],
- UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB],
+ QC_OUT_ELEMENT* qcElement[(8)],
+ PSY_OUT_ELEMENT* psyOutElement[(8)],
+ ATS_ELEMENT* AdjThrStateElement[(8)],
+ UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB],
const INT desiredPe,
const INT currentPe,
const int processElements,
@@ -1439,17 +1645,17 @@ functionname: FDKaacEnc_adaptThresholdsToPe
description: two guesses for the reduction value and one final correction of the thresholds
*****************************************************************************/
static void FDKaacEnc_adaptThresholdsToPe(CHANNEL_MAPPING* cm,
- ATS_ELEMENT* AdjThrStateElement[(6)],
- QC_OUT_ELEMENT* qcElement[(6)],
- PSY_OUT_ELEMENT* psyOutElement[(6)],
+ ATS_ELEMENT* AdjThrStateElement[(8)],
+ QC_OUT_ELEMENT* qcElement[(8)],
+ PSY_OUT_ELEMENT* psyOutElement[(8)],
const INT desiredPe,
const INT processElements,
const INT elementOffset)
{
- FIXP_DBL redValue[(6)];
- SCHAR redValScaling[(6)];
- UCHAR pAhFlag[(6)][(2)][MAX_GROUPED_SFB];
- FIXP_DBL pThrExp[(6)][(2)][MAX_GROUPED_SFB];
+ FIXP_DBL redValue[(8)];
+ SCHAR redValScaling[(8)];
+ UCHAR pAhFlag[(8)][(2)][MAX_GROUPED_SFB];
+ FIXP_DBL pThrExp[(8)][(2)][MAX_GROUPED_SFB];
int iter;
INT constPartGlobal, noRedPeGlobal, nActiveLinesGlobal, redPeGlobal;
@@ -1683,7 +1889,6 @@ static void FDKaacEnc_adaptThresholdsToPe(CHANNEL_MAPPING* cm,
}
-
/* similar to FDKaacEnc_adaptThresholdsToPe(), for VBR-mode */
void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
PSY_OUT_CHANNEL* psyOutChannel[(2)],
@@ -1692,8 +1897,14 @@ void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
PE_DATA *peData,
const INT nChannels)
{
- UCHAR pAhFlag[(2)][MAX_GROUPED_SFB];
- FIXP_DBL pThrExp[(2)][MAX_GROUPED_SFB];
+ UCHAR (*pAhFlag)[MAX_GROUPED_SFB];
+ FIXP_DBL (*pThrExp)[MAX_GROUPED_SFB];
+
+ /* allocate scratch memory */
+ C_ALLOC_SCRATCH_START(_pAhFlag, UCHAR, (2)*MAX_GROUPED_SFB)
+ C_ALLOC_SCRATCH_START(_pThrExp, FIXP_DBL, (2)*MAX_GROUPED_SFB)
+ pAhFlag = (UCHAR(*)[MAX_GROUPED_SFB])_pAhFlag;
+ pThrExp = (FIXP_DBL(*)[MAX_GROUPED_SFB])_pThrExp;
/* thresholds to the power of redExp */
FDKaacEnc_calcThreshExp(pThrExp, qcOutChannel, psyOutChannel, nChannels);
@@ -1711,6 +1922,9 @@ void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)],
AdjThrStateElement->vbrQualFactor,
&AdjThrStateElement->chaosMeasureOld);
+ /* free scratch memory */
+ C_ALLOC_SCRATCH_END(_pThrExp, FIXP_DBL, (2)*MAX_GROUPED_SFB)
+ C_ALLOC_SCRATCH_END(_pAhFlag, UCHAR, (2)*MAX_GROUPED_SFB)
}
@@ -2002,95 +2216,112 @@ bail:
functionname: FDKaacEnc_AdjThrInit
description: initialize ADJ_THR_STATE
*****************************************************************************/
-void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr,
- const INT meanPe,
- ELEMENT_BITS *elBits[(6)],
- INT nElements,
- FIXP_DBL vbrQualFactor)
+void FDKaacEnc_AdjThrInit(
+ ADJ_THR_STATE *hAdjThr,
+ const INT meanPe,
+ ELEMENT_BITS *elBits[(8)],
+ INT invQuant,
+ INT nElements,
+ INT nChannelsEff,
+ INT sampleRate,
+ INT advancedBitsToPe,
+ FIXP_DBL vbrQualFactor
+ )
{
- INT i;
-
- FIXP_DBL POINT8 = FL2FXCONST_DBL(0.8f);
- FIXP_DBL POINT6 = FL2FXCONST_DBL(0.6f);
+ INT i;
+
+ FIXP_DBL POINT8 = FL2FXCONST_DBL(0.8f);
+ FIXP_DBL POINT6 = FL2FXCONST_DBL(0.6f);
+
+ /* common for all elements: */
+ /* parameters for bitres control */
+ hAdjThr->bresParamLong.clipSaveLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */
+ hAdjThr->bresParamLong.clipSaveHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */
+ hAdjThr->bresParamLong.minBitSave = (FIXP_DBL)0xf999999a; /* FL2FXCONST_DBL(-0.05f); */
+ hAdjThr->bresParamLong.maxBitSave = (FIXP_DBL)0x26666666; /* FL2FXCONST_DBL(0.3f); */
+ hAdjThr->bresParamLong.clipSpendLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */
+ hAdjThr->bresParamLong.clipSpendHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */
+ hAdjThr->bresParamLong.minBitSpend = (FIXP_DBL)0xf3333333; /* FL2FXCONST_DBL(-0.10f); */
+ hAdjThr->bresParamLong.maxBitSpend = (FIXP_DBL)0x33333333; /* FL2FXCONST_DBL(0.4f); */
+
+ hAdjThr->bresParamShort.clipSaveLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
+ hAdjThr->bresParamShort.clipSaveHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */
+ hAdjThr->bresParamShort.minBitSave = (FIXP_DBL)0x00000000; /* FL2FXCONST_DBL(0.0f); */
+ hAdjThr->bresParamShort.maxBitSave = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
+ hAdjThr->bresParamShort.clipSpendLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
+ hAdjThr->bresParamShort.clipSpendHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */
+ hAdjThr->bresParamShort.minBitSpend = (FIXP_DBL)0xf9999998; /* FL2FXCONST_DBL(-0.05f); */
+ hAdjThr->bresParamShort.maxBitSpend = (FIXP_DBL)0x40000000; /* FL2FXCONST_DBL(0.5f); */
+
+ /* specific for each element: */
+ for (i=0; i<nElements; i++) {
+ ATS_ELEMENT* atsElem = hAdjThr->adjThrStateElem[i];
+ MINSNR_ADAPT_PARAM *msaParam = &atsElem->minSnrAdaptParam;
+ INT chBitrate = elBits[i]->chBitrateEl;
- /* common for all elements: */
/* parameters for bitres control */
- hAdjThr->bresParamLong.clipSaveLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */
- hAdjThr->bresParamLong.clipSaveHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */
- hAdjThr->bresParamLong.minBitSave = (FIXP_DBL)0xf999999a; /* FL2FXCONST_DBL(-0.05f); */
- hAdjThr->bresParamLong.maxBitSave = (FIXP_DBL)0x26666666; /* FL2FXCONST_DBL(0.3f); */
- hAdjThr->bresParamLong.clipSpendLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */
- hAdjThr->bresParamLong.clipSpendHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */
- hAdjThr->bresParamLong.minBitSpend = (FIXP_DBL)0xf3333333; /* FL2FXCONST_DBL(-0.10f); */
- hAdjThr->bresParamLong.maxBitSpend = (FIXP_DBL)0x33333333; /* FL2FXCONST_DBL(0.4f); */
-
- hAdjThr->bresParamShort.clipSaveLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
- hAdjThr->bresParamShort.clipSaveHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */
- hAdjThr->bresParamShort.minBitSave = (FIXP_DBL)0x00000000; /* FL2FXCONST_DBL(0.0f); */
- hAdjThr->bresParamShort.maxBitSave = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
- hAdjThr->bresParamShort.clipSpendLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */
- hAdjThr->bresParamShort.clipSpendHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */
- hAdjThr->bresParamShort.minBitSpend = (FIXP_DBL)0xf9999998; /* FL2FXCONST_DBL(-0.05f); */
- hAdjThr->bresParamShort.maxBitSpend = (FIXP_DBL)0x40000000; /* FL2FXCONST_DBL(0.5f); */
-
- /* specific for each element: */
- for (i=0; i<nElements; i++) {
- ATS_ELEMENT* atsElem = hAdjThr->adjThrStateElem[i];
- MINSNR_ADAPT_PARAM *msaParam = &atsElem->minSnrAdaptParam;
- INT chBitrate = elBits[i]->chBitrateEl;
+ atsElem->peMin = fMultI(POINT8, meanPe) >> 1;
+ atsElem->peMax = fMultI(POINT6, meanPe);
- /* parameters for bitres control */
- atsElem->peMin = fMultI(POINT8, meanPe) >> 1;
- atsElem->peMax = fMultI(POINT6, meanPe);
+ /* for use in FDKaacEnc_reduceThresholdsVBR */
+ atsElem->chaosMeasureOld = FL2FXCONST_DBL(0.3f);
- /* for use in FDKaacEnc_reduceThresholdsVBR */
- atsElem->chaosMeasureOld = FL2FXCONST_DBL(0.3f);
+ /* additional pe offset to correct pe2bits for low bitrates */
+ atsElem->peOffset = 0;
- /* additional pe offset to correct pe2bits for low bitrates */
- atsElem->peOffset = 0;
+ /* vbr initialisation */
+ atsElem->vbrQualFactor = vbrQualFactor;
+ if (chBitrate < 32000)
+ {
+ atsElem->peOffset = fixMax(50, 100-fMultI((FIXP_DBL)0x666667, chBitrate));
+ }
- /* vbr initialisation */
- atsElem->vbrQualFactor = vbrQualFactor;
- if (chBitrate < 32000)
- {
- atsElem->peOffset = fixMax(50, 100-fMultI((FIXP_DBL)0x666667, chBitrate));
- }
+ /* avoid hole parameters */
+ if (chBitrate > 20000) {
+ atsElem->ahParam.modifyMinSnr = TRUE;
+ atsElem->ahParam.startSfbL = 15;
+ atsElem->ahParam.startSfbS = 3;
+ }
+ else {
+ atsElem->ahParam.modifyMinSnr = FALSE;
+ atsElem->ahParam.startSfbL = 0;
+ atsElem->ahParam.startSfbS = 0;
+ }
- /* avoid hole parameters */
- if (chBitrate > 20000) {
- atsElem->ahParam.modifyMinSnr = TRUE;
- atsElem->ahParam.startSfbL = 15;
- atsElem->ahParam.startSfbS = 3;
- }
- else {
- atsElem->ahParam.modifyMinSnr = FALSE;
- atsElem->ahParam.startSfbL = 0;
- atsElem->ahParam.startSfbS = 0;
- }
+ /* minSnr adaptation */
+ msaParam->maxRed = FL2FXCONST_DBL(0.00390625f); /* 0.25f/64.0f */
+ /* start adaptation of minSnr for avgEn/sfbEn > startRatio */
+ msaParam->startRatio = FL2FXCONST_DBL(0.05190512648f); /* ld64(10.0f) */
+ /* maximum minSnr reduction to minSnr^maxRed is reached for
+ avgEn/sfbEn >= maxRatio */
+ /* msaParam->maxRatio = 1000.0f; */
+ /*msaParam->redRatioFac = ((float)1.0f - msaParam->maxRed) / ((float)10.0f*log10(msaParam->startRatio/msaParam->maxRatio)/log10(2.0f)*(float)0.3010299956f);*/
+ msaParam->redRatioFac = FL2FXCONST_DBL(-0.375f); /* -0.0375f * 10.0f */
+ /*msaParam->redOffs = (float)1.0f - msaParam->redRatioFac * (float)10.0f * log10(msaParam->startRatio)/log10(2.0f) * (float)0.3010299956f;*/
+ msaParam->redOffs = FL2FXCONST_DBL(0.021484375); /* 1.375f/64.0f */
+
+ /* init pe correction */
+ atsElem->peCorrectionFactor_m = FL2FXCONST_DBL(0.5f); /* 1.0 */
+ atsElem->peCorrectionFactor_e = 1;
+
+ atsElem->dynBitsLast = -1;
+ atsElem->peLast = 0;
+
+ /* init bits to pe factor */
+
+ /* init bits2PeFactor */
+ FDKaacEnc_InitBits2PeFactor(
+ &atsElem->bits2PeFactor_m,
+ &atsElem->bits2PeFactor_e,
+ chBitrate, /* bitrate/channel*/
+ nChannelsEff, /* number of channels */
+ sampleRate,
+ advancedBitsToPe,
+ invQuant
+ );
+
+ } /* for nElements */
- /* minSnr adaptation */
- msaParam->maxRed = FL2FXCONST_DBL(0.00390625f); /* 0.25f/64.0f */
- /* start adaptation of minSnr for avgEn/sfbEn > startRatio */
- msaParam->startRatio = FL2FXCONST_DBL(0.05190512648f); /* ld64(10.0f) */
- /* maximum minSnr reduction to minSnr^maxRed is reached for
- avgEn/sfbEn >= maxRatio */
- /* msaParam->maxRatio = 1000.0f; */
- /*msaParam->redRatioFac = ((float)1.0f - msaParam->maxRed) / ((float)10.0f*log10(msaParam->startRatio/msaParam->maxRatio)/log10(2.0f)*(float)0.3010299956f);*/
- msaParam->redRatioFac = FL2FXCONST_DBL(-0.375f); /* -0.0375f * 10.0f */
- /*msaParam->redOffs = (float)1.0f - msaParam->redRatioFac * (float)10.0f * log10(msaParam->startRatio)/log10(2.0f) * (float)0.3010299956f;*/
- msaParam->redOffs = FL2FXCONST_DBL(0.021484375); /* 1.375f/64.0f */
-
- /* init pe correction */
- atsElem->peCorrectionFactor_m = FL2FXCONST_DBL(0.5f); /* 1.0 */
- atsElem->peCorrectionFactor_e = 1;
-
- atsElem->dynBitsLast = -1;
- atsElem->peLast = 0;
-
- /* init bits to pe factor */
- atsElem->bits2PeFactor_m = FL2FXCONST_DBL(1.18f/(1<<(1)));
- atsElem->bits2PeFactor_e = 1;
- }
}
@@ -2154,6 +2385,67 @@ static void FDKaacEnc_FDKaacEnc_calcPeCorrection(
}
+static void FDKaacEnc_calcPeCorrectionLowBitRes(
+ FIXP_DBL *const correctionFac_m,
+ INT *const correctionFac_e,
+ const INT peLast,
+ const INT bitsLast,
+ const INT bitresLevel,
+ const INT nChannels,
+ const FIXP_DBL bits2PeFactor_m,
+ const INT bits2PeFactor_e
+ )
+{
+ /* tuning params */
+ const FIXP_DBL amp = FL2FXCONST_DBL(0.005);
+ const FIXP_DBL maxDiff = FL2FXCONST_DBL(0.25f);
+
+ if (bitsLast > 0) {
+
+ /* Estimate deviation of granted and used dynamic bits in previous frame, in PE units */
+ const int bitsBalLast = peLast - FDKaacEnc_bits2pe2(
+ bitsLast,
+ bits2PeFactor_m,
+ bits2PeFactor_e);
+
+ /* reserve n bits per channel */
+ int headroom = (bitresLevel>=50*nChannels) ? 0 : (100*nChannels);
+
+ /* in PE units */
+ headroom = FDKaacEnc_bits2pe2(
+ headroom,
+ bits2PeFactor_m,
+ bits2PeFactor_e);
+
+ /*
+ * diff = amp * ((bitsBalLast - headroom) / (bitresLevel + headroom)
+ * diff = max ( min ( diff, maxDiff, -maxDiff)) / 2
+ */
+ FIXP_DBL denominator = (FIXP_DBL)FDKaacEnc_bits2pe2(bitresLevel, bits2PeFactor_m, bits2PeFactor_e) + (FIXP_DBL)headroom;
+
+ int scaling = 0;
+ FIXP_DBL diff = (bitsBalLast>=headroom)
+ ? fMult(amp, fDivNorm( (FIXP_DBL)(bitsBalLast - headroom), denominator, &scaling))
+ : -fMult(amp, fDivNorm(-(FIXP_DBL)(bitsBalLast - headroom), denominator, &scaling)) ;
+
+ scaling -= 1; /* divide by 2 */
+
+ diff = (scaling<=0) ? FDKmax( FDKmin (diff>>(-scaling), maxDiff>>1), -maxDiff>>1)
+ : FDKmax( FDKmin (diff, maxDiff>>(1+scaling)), -maxDiff>>(1+scaling)) << scaling;
+
+ /*
+ * corrFac += diff
+ * corrFac = max ( min ( corrFac/2.f, 1.f/2.f, 0.75f/2.f ) )
+ */
+ *correctionFac_m = FDKmax(FDKmin((*correctionFac_m)+diff, FL2FXCONST_DBL(1.0f/2.f)), FL2FXCONST_DBL(0.75f/2.f)) ;
+ *correctionFac_e = 1;
+ }
+ else {
+ *correctionFac_m = FL2FXCONST_DBL(0.75/2.f);
+ *correctionFac_e = 1;
+ }
+}
+
void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
ATS_ELEMENT *AdjThrStateElement,
PSY_OUT_CHANNEL *psyOutChannel[(2)],
@@ -2166,7 +2458,7 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
const INT bitresBits,
const INT maxBitresBits,
const FIXP_DBL maxBitFac,
- const INT bitDistributenMode)
+ const INT bitDistributionMode)
{
FIXP_DBL bitFactor;
INT noRedPe = peData->pe;
@@ -2184,7 +2476,7 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
}
if (grantedDynBits >= 1) {
- if (bitDistributenMode!=0) {
+ if (bitDistributionMode!=0) {
*grantedPe = FDKaacEnc_bits2pe2(grantedDynBits, AdjThrStateElement->bits2PeFactor_m, AdjThrStateElement->bits2PeFactor_e);
}
else
@@ -2208,16 +2500,32 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
}
/* correction of pe value */
- {
- FDKaacEnc_FDKaacEnc_calcPeCorrection(
- &AdjThrStateElement->peCorrectionFactor_m,
- &AdjThrStateElement->peCorrectionFactor_e,
- fixMin(*grantedPe, noRedPe),
- AdjThrStateElement->peLast,
- AdjThrStateElement->dynBitsLast,
- AdjThrStateElement->bits2PeFactor_m,
- AdjThrStateElement->bits2PeFactor_e
+ switch (bitDistributionMode) {
+ case 2:
+ case 1:
+ FDKaacEnc_calcPeCorrectionLowBitRes(
+ &AdjThrStateElement->peCorrectionFactor_m,
+ &AdjThrStateElement->peCorrectionFactor_e,
+ AdjThrStateElement->peLast,
+ AdjThrStateElement->dynBitsLast,
+ bitresBits,
+ nChannels,
+ AdjThrStateElement->bits2PeFactor_m,
+ AdjThrStateElement->bits2PeFactor_e
);
+ break;
+ case 0:
+ default:
+ FDKaacEnc_FDKaacEnc_calcPeCorrection(
+ &AdjThrStateElement->peCorrectionFactor_m,
+ &AdjThrStateElement->peCorrectionFactor_e,
+ fixMin(*grantedPe, noRedPe),
+ AdjThrStateElement->peLast,
+ AdjThrStateElement->dynBitsLast,
+ AdjThrStateElement->bits2PeFactor_m,
+ AdjThrStateElement->bits2PeFactor_e
+ );
+ break;
}
*grantedPeCorr = (INT)(fMult((FIXP_DBL)(*grantedPe<<Q_AVGBITS), AdjThrStateElement->peCorrectionFactor_m) >> (Q_AVGBITS-AdjThrStateElement->peCorrectionFactor_e));
@@ -2232,10 +2540,10 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
functionname: FDKaacEnc_AdjustThresholds
description: adjust thresholds
*****************************************************************************/
-void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)],
- QC_OUT_ELEMENT* qcElement[(6)],
+void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(8)],
+ QC_OUT_ELEMENT* qcElement[(8)],
QC_OUT* qcOut,
- PSY_OUT_ELEMENT* psyOutElement[(6)],
+ PSY_OUT_ELEMENT* psyOutElement[(8)],
INT CBRbitrateMode,
CHANNEL_MAPPING* cm)
{
@@ -2291,20 +2599,19 @@ void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)],
} /* -end- element loop */
}
- for (i=0; i<cm->nElements; i++) {
- int ch,sfb,sfbGrp;
- /* no weighting of threholds and energies for mlout */
- /* weight energies and thresholds */
- for (ch=0; ch<cm->elInfo[i].nChannelsInEl; ch++) {
- QC_OUT_CHANNEL* pQcOutCh = qcElement[i]->qcOutChannel[ch];
- for (sfbGrp = 0;sfbGrp < psyOutElement[i]->psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutElement[i]->psyOutChannel[ch]->sfbPerGroup) {
- for (sfb=0; sfb<psyOutElement[i]->psyOutChannel[ch]->maxSfbPerGroup; sfb++) {
- pQcOutCh->sfbThresholdLdData[sfb+sfbGrp] += pQcOutCh->sfbEnFacLd[sfb+sfbGrp];
- }
+ for (i=0; i<cm->nElements; i++) {
+ int ch,sfb,sfbGrp;
+ /* no weighting of threholds and energies for mlout */
+ /* weight energies and thresholds */
+ for (ch=0; ch<cm->elInfo[i].nChannelsInEl; ch++) {
+ QC_OUT_CHANNEL* pQcOutCh = qcElement[i]->qcOutChannel[ch];
+ for (sfbGrp = 0;sfbGrp < psyOutElement[i]->psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutElement[i]->psyOutChannel[ch]->sfbPerGroup) {
+ for (sfb=0; sfb<psyOutElement[i]->psyOutChannel[ch]->maxSfbPerGroup; sfb++) {
+ pQcOutCh->sfbThresholdLdData[sfb+sfbGrp] += pQcOutCh->sfbEnFacLd[sfb+sfbGrp];
}
}
}
-
+ }
}
void FDKaacEnc_AdjThrClose(ADJ_THR_STATE** phAdjThr)
@@ -2313,7 +2620,7 @@ void FDKaacEnc_AdjThrClose(ADJ_THR_STATE** phAdjThr)
ADJ_THR_STATE* hAdjThr = *phAdjThr;
if (hAdjThr!=NULL) {
- for (i=0; i<(6); i++) {
+ for (i=0; i<(8); i++) {
if (hAdjThr->adjThrStateElem[i]!=NULL) {
FreeRam_aacEnc_AdjThrStateElement(&hAdjThr->adjThrStateElem[i]);
}
diff --git a/libAACenc/src/adj_thr.h b/libAACenc/src/adj_thr.h
index 83d4c49..69b1dcc 100644
--- a/libAACenc/src/adj_thr.h
+++ b/libAACenc/src/adj_thr.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -98,23 +98,28 @@ amm-info@iis.fraunhofer.de
#include "interface.h"
-
-void FDKaacEnc_peCalculation(PE_DATA *peData,
- PSY_OUT_CHANNEL* psyOutChannel[(2)],
- QC_OUT_CHANNEL* qcOutChannel[(2)],
- struct TOOLSINFO *toolsInfo,
- ATS_ELEMENT* adjThrStateElement,
- const INT nChannels);
+void FDKaacEnc_peCalculation(
+ PE_DATA *peData,
+ PSY_OUT_CHANNEL* psyOutChannel[(2)],
+ QC_OUT_CHANNEL* qcOutChannel[(2)],
+ struct TOOLSINFO *toolsInfo,
+ ATS_ELEMENT* adjThrStateElement,
+ const INT nChannels
+ );
INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE** phAdjThr,
INT nElements);
void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr,
const INT peMean,
- ELEMENT_BITS* elBits[(6)],
+ ELEMENT_BITS* elBits[(8)],
+ INT invQuant,
INT nElements,
+ INT nChannelsEff,
+ INT sampleRate,
+ INT advancedBitsToPe,
FIXP_DBL vbrQualFactor);
-
+
void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
ATS_ELEMENT *AdjThrStateElement,
@@ -128,12 +133,12 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState,
const INT bitresBits,
const INT maxBitresBits,
const FIXP_DBL maxBitFac,
- const INT bitDistributenMode);
+ const INT bitDistributionMode);
-void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)],
- QC_OUT_ELEMENT* qcElement[(6)],
+void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(8)],
+ QC_OUT_ELEMENT* qcElement[(8)],
QC_OUT* qcOut,
- PSY_OUT_ELEMENT* psyOutElement[(6)],
+ PSY_OUT_ELEMENT* psyOutElement[(8)],
INT CBRbitrateMode,
CHANNEL_MAPPING* cm);
diff --git a/libAACenc/src/adj_thr_data.h b/libAACenc/src/adj_thr_data.h
index d209a51..3eb7678 100644
--- a/libAACenc/src/adj_thr_data.h
+++ b/libAACenc/src/adj_thr_data.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -144,7 +144,7 @@ typedef struct {
typedef struct {
BRES_PARAM bresParamLong, bresParamShort;
- ATS_ELEMENT* adjThrStateElem[(6)];
+ ATS_ELEMENT* adjThrStateElem[(8)];
} ADJ_THR_STATE;
#endif
diff --git a/libAACenc/src/band_nrg.cpp b/libAACenc/src/band_nrg.cpp
index 0e46b45..861f7a8 100644
--- a/libAACenc/src/band_nrg.cpp
+++ b/libAACenc/src/band_nrg.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/band_nrg.h b/libAACenc/src/band_nrg.h
index cf4c4cb..540a8ef 100644
--- a/libAACenc/src/band_nrg.h
+++ b/libAACenc/src/band_nrg.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/bandwidth.cpp b/libAACenc/src/bandwidth.cpp
index f6ca8ef..6fc7d87 100644
--- a/libAACenc/src/bandwidth.cpp
+++ b/libAACenc/src/bandwidth.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -204,7 +204,6 @@ static INT GetBandwidthEntry(
INT bwTabSize = 0;
switch (frameLength) {
- case 960:
case 1024:
pBwTab = bandWidthTable;
bwTabSize = sizeof(bandWidthTable)/sizeof(BANDWIDTH_TAB);
@@ -253,7 +252,6 @@ static INT GetBandwidthEntry(
chanBitRate < pBwTab[i+1].chanBitRate)
{
switch (frameLength) {
- case 960:
case 1024:
bandwidth = (entryNo==0)
? pBwTab[i].bandWidthMono
@@ -318,6 +316,8 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
case MODE_1_2_2:
case MODE_1_2_2_1:
case MODE_1_2_2_2_1:
+ case MODE_7_1_REAR_SURROUND:
+ case MODE_7_1_FRONT_CENTER:
*bandWidth = bandWidthTableVBR[bitrateMode].bandWidth2AndMoreChan;
break;
default:
@@ -348,6 +348,8 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
case MODE_1_2_2: /* sce + cpe + cpe */
case MODE_1_2_2_1: /* (5.1) sce + cpe + cpe + lfe */
case MODE_1_2_2_2_1: /* (7.1) sce + cpe + cpe + cpe + lfe */
+ case MODE_7_1_REAR_SURROUND:
+ case MODE_7_1_FRONT_CENTER:
entryNo = 1; /* use stereo bandwith settings */
break;
diff --git a/libAACenc/src/bandwidth.h b/libAACenc/src/bandwidth.h
index 61c7f93..2e92453 100644
--- a/libAACenc/src/bandwidth.h
+++ b/libAACenc/src/bandwidth.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/bit_cnt.cpp b/libAACenc/src/bit_cnt.cpp
index e89710e..926ee49 100644
--- a/libAACenc/src/bit_cnt.cpp
+++ b/libAACenc/src/bit_cnt.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/bit_cnt.h b/libAACenc/src/bit_cnt.h
index 8650566..7c4b59e 100644
--- a/libAACenc/src/bit_cnt.h
+++ b/libAACenc/src/bit_cnt.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/bitenc.cpp b/libAACenc/src/bitenc.cpp
index d2cb5af..8e477aa 100644
--- a/libAACenc/src/bitenc.cpp
+++ b/libAACenc/src/bitenc.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -1360,7 +1360,7 @@ AAC_ENCODER_ERROR FDKaacEnc_WriteBitstream(HANDLE_TRANSPORTENC hTpEnc,
if ( (syntaxFlags & AC_ER) && !(syntaxFlags & AC_DRM) )
{
- UCHAR channelElementExtensionWritten[(6)][(1)]; /* 0: extension not touched, 1: extension already written */
+ UCHAR channelElementExtensionWritten[(8)][(1)]; /* 0: extension not touched, 1: extension already written */
FDKmemclear(channelElementExtensionWritten, sizeof(channelElementExtensionWritten));
diff --git a/libAACenc/src/bitenc.h b/libAACenc/src/bitenc.h
index 337ce38..498be7c 100644
--- a/libAACenc/src/bitenc.h
+++ b/libAACenc/src/bitenc.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/block_switch.cpp b/libAACenc/src/block_switch.cpp
index 96fcb08..7b3e275 100644
--- a/libAACenc/src/block_switch.cpp
+++ b/libAACenc/src/block_switch.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -83,7 +83,7 @@ amm-info@iis.fraunhofer.de
/***************************** MPEG-4 AAC Encoder **************************
- Author(s): M. Werner
+ Author(s): M. Werner, Tobias Chalupka
Description: Block switching
******************************************************************************/
@@ -100,9 +100,11 @@ amm-info@iis.fraunhofer.de
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWndIdx);
-static void FDKaacEnc_CalcWindowEnergy( BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl,
- INT windowLen);
-
+static void FDKaacEnc_CalcWindowEnergy(
+ BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl,
+ INT windowLen,
+ const INT_PCM *pTimeSignal
+ );
/****************** Constants *****************************/
/* LONG START SHORT STOP LOWOV */
@@ -145,20 +147,9 @@ static const FIXP_DBL minAttackNrg = (FL2FXCONST_DBL(1e+6f*NORM_PCM_ENERGY)>>BLO
/**************** internal function prototypes ***********/
-static INT FDKaacEnc_GetWindowIndex(INT blockSwWindowIndex);
-
-static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT shortWndIdx);
-
-static void FDKaacEnc_CalcWindowEnergy( BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl,
- INT windowLen);
-
-
-
/****************** Routines ****************************/
void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay)
{
- /* note: the pointer to timeSignal can be zeroed here, because it is initialized for every call
- to FDKaacEnc_BlockSwitching anew */
FDKmemclear (blockSwitchingControl, sizeof(BLOCK_SWITCHING_CONTROL));
if (isLowDelay)
@@ -214,7 +205,7 @@ static const INT chgWndSqLkAhd[2][2][N_BLOCKTYPES] =
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW, WRONG_WINDOW, WRONG_WINDOW} } /* attack */
};
-int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE)
+int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal)
{
UINT i;
FIXP_DBL enM1, enMax;
@@ -263,7 +254,7 @@ int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, con
/* Calculate unfiltered and filtered energies in subwindows and combine to segments */
- FDKaacEnc_CalcWindowEnergy(blockSwitchingControl, granuleLength>>(nBlockSwitchWindows==4? 2:3 ));
+ FDKaacEnc_CalcWindowEnergy(blockSwitchingControl, granuleLength>>(nBlockSwitchWindows==4? 2:3 ), pTimeSignal);
/* now calculate if there is an attack */
@@ -335,8 +326,7 @@ static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWnd
}
-
-static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen)
+static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen, const INT_PCM *pTimeSignal)
{
INT i;
UINT w;
@@ -344,8 +334,6 @@ static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSw
FIXP_SGL hiPassCoeff0 = hiPassCoeff[0];
FIXP_SGL hiPassCoeff1 = hiPassCoeff[1];
- INT_PCM *timeSignal = blockSwitchingControl->timeSignal;
-
/* sum up scalarproduct of timesignal as windowed Energies */
for (w=0; w < blockSwitchingControl->nBlockSwitchWindows; w++) {
@@ -361,9 +349,9 @@ static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSw
FIXP_DBL tempUnfiltered, tempFiltred, t1, t2;
/* tempUnfiltered is scaled with 1 to prevent overflows during calculation of tempFiltred */
#if SAMPLE_BITS == DFRACT_BITS
- tempUnfiltered = (FIXP_DBL) *timeSignal++ >> 1;
+ tempUnfiltered = (FIXP_DBL) *pTimeSignal++ >> 1;
#else
- tempUnfiltered = (FIXP_DBL) *timeSignal++ << (DFRACT_BITS-SAMPLE_BITS-1);
+ tempUnfiltered = (FIXP_DBL) *pTimeSignal++ << (DFRACT_BITS-SAMPLE_BITS-1);
#endif
t1 = fMultDiv2(hiPassCoeff1, tempUnfiltered-temp_iirState0);
t2 = fMultDiv2(hiPassCoeff0, temp_iirState1);
diff --git a/libAACenc/src/block_switch.h b/libAACenc/src/block_switch.h
index 179e16b..e94b6f5 100644
--- a/libAACenc/src/block_switch.h
+++ b/libAACenc/src/block_switch.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -107,7 +107,6 @@ amm-info@iis.fraunhofer.de
/****************** Structures ***************************/
typedef struct{
- INT_PCM *timeSignal;
INT lastWindowSequence;
INT windowShape;
INT lastWindowShape;
@@ -136,7 +135,7 @@ typedef struct{
void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay);
-int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE);
+int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal);
int FDKaacEnc_SyncBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
diff --git a/libAACenc/src/channel_map.cpp b/libAACenc/src/channel_map.cpp
index 6eddd47..99ed2b5 100644
--- a/libAACenc/src/channel_map.cpp
+++ b/libAACenc/src/channel_map.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -124,7 +124,7 @@ amm-info@iis.fraunhofer.de
typedef struct {
CHANNEL_MODE encoderMode;
- INT channel_assignment[/*(6)*/12];
+ INT channel_assignment[/*(8)*/12];
} CHANNEL_ASSIGNMENT_INFO_TAB;
@@ -139,6 +139,8 @@ static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabMpeg[] =
{ MODE_1_2_2, { 0, 1, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */
{ MODE_1_2_2_1, { 0, 1, 2, 3, 4, 5,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */
{ MODE_1_2_2_2_1, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */
+ { MODE_7_1_REAR_SURROUND, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */
+ { MODE_7_1_FRONT_CENTER, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} } /* 7.1ch */
};
static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWav[] =
@@ -150,7 +152,9 @@ static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWav[] =
{ MODE_1_2_1, { 2, 0, 1, 3,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 4ch */
{ MODE_1_2_2, { 2, 0, 1, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */
{ MODE_1_2_2_1, { 2, 0, 1, 4, 5, 3,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */
- { MODE_1_2_2_2_1, { 2, 0, 1, 6, 7, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
+ { MODE_1_2_2_2_1, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
+ { MODE_7_1_REAR_SURROUND, { 2, 0, 1, 6, 7, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
+ { MODE_7_1_FRONT_CENTER, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
};
static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWg4[] =
@@ -177,6 +181,8 @@ static const CHANNEL_MODE_CONFIG_TAB channelModeConfig[] =
{ MODE_1_2_2, 5, 5, 3 }, /* SCE,CPE,CPE */
{ MODE_1_2_2_1, 6, 5, 4 }, /* SCE,CPE,CPE,LFE */
{ MODE_1_2_2_2_1, 8, 7, 5 }, /* SCE,CPE,CPE,CPE,LFE */
+ { MODE_7_1_REAR_SURROUND, 8, 7, 5 },
+ { MODE_7_1_FRONT_CENTER, 8, 7, 5 },
};
#define MAX_MODES (sizeof(assignmentInfoTabWav)/sizeof(CHANNEL_ASSIGNMENT_INFO_TAB))
@@ -329,6 +335,8 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER
break;
case MODE_1_2_2_2_1:
+ case MODE_7_1_REAR_SURROUND:
+ case MODE_7_1_FRONT_CENTER:
/* (7.1) sce + cpe + cpe + cpe + lfe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.18f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
@@ -336,14 +344,13 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER
FDKaacEnc_initElement(&cm->elInfo[3], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.04f));
break;
-
default:
//*chMap=0;
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
};
- FDK_ASSERT(cm->nElements<=(6));
+ FDK_ASSERT(cm->nElements<=(8));
return AAC_ENC_OK;
@@ -456,19 +463,18 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
break;
}
-
- case MODE_1_2_2_2_1:{
- /* (7.1) sce + cpe + cpe + cpe + lfe */
- hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
- hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
- hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
- hQC->elementBits[3]->relativeBitsEl = cm->elInfo[3].relativeBits;
- hQC->elementBits[4]->relativeBitsEl = cm->elInfo[4].relativeBits;
- FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
- FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits;
- FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits;
- FIXP_DBL cpe3Rate = cm->elInfo[3].relativeBits;
- FIXP_DBL lfeRate = cm->elInfo[4].relativeBits;
+ case MODE_7_1_REAR_SURROUND:
+ case MODE_7_1_FRONT_CENTER:
+ case MODE_1_2_2_2_1: {
+ int cpe3Idx = 3;
+ int lfeIdx = 4;
+
+ /* (7.1) sce + cpe + cpe + cpe + lfe */
+ FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
+ FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits;
+ FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits;
+ FIXP_DBL cpe3Rate = hQC->elementBits[cpe3Idx]->relativeBitsEl = cm->elInfo[cpe3Idx].relativeBits;
+ FIXP_DBL lfeRate = hQC->elementBits[lfeIdx]->relativeBitsEl = cm->elInfo[lfeIdx].relativeBits;
int maxBitsTot = maxChannelBits * 7; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits,averageBitsTot));
@@ -480,17 +486,16 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
- hQC->elementBits[3]->chBitrateEl = fMult(cpe3Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
- hQC->elementBits[4]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
+ hQC->elementBits[cpe3Idx]->chBitrateEl = fMult(cpe3Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1);
+ hQC->elementBits[lfeIdx]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2*maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2*maxChannelBits;
- hQC->elementBits[3]->maxBitsEl = 2*maxChannelBits;
- hQC->elementBits[4]->maxBitsEl = maxLfeBits;
+ hQC->elementBits[cpe3Idx]->maxBitsEl = 2*maxChannelBits;
+ hQC->elementBits[lfeIdx]->maxBitsEl = maxLfeBits;
break;
}
-
default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}
@@ -532,6 +537,8 @@ ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode){
case MODE_1_2_2:
case MODE_1_2_2_1:
case MODE_1_2_2_2_1:
+ case MODE_7_1_REAR_SURROUND:
+ case MODE_7_1_FRONT_CENTER:
monoStereoSetting = EL_MODE_STEREO;
break;
default: /* error */
diff --git a/libAACenc/src/channel_map.h b/libAACenc/src/channel_map.h
index 6d135d2..2cfb486 100644
--- a/libAACenc/src/channel_map.h
+++ b/libAACenc/src/channel_map.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/chaosmeasure.cpp b/libAACenc/src/chaosmeasure.cpp
index 9d6d77e..4e56e9e 100644
--- a/libAACenc/src/chaosmeasure.cpp
+++ b/libAACenc/src/chaosmeasure.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/chaosmeasure.h b/libAACenc/src/chaosmeasure.h
index 732cb09..44301c5 100644
--- a/libAACenc/src/chaosmeasure.h
+++ b/libAACenc/src/chaosmeasure.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/dyn_bits.cpp b/libAACenc/src/dyn_bits.cpp
index 8cac2ef..0c07109 100644
--- a/libAACenc/src/dyn_bits.cpp
+++ b/libAACenc/src/dyn_bits.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/dyn_bits.h b/libAACenc/src/dyn_bits.h
index e7f219b..ae78a4c 100644
--- a/libAACenc/src/dyn_bits.h
+++ b/libAACenc/src/dyn_bits.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/grp_data.cpp b/libAACenc/src/grp_data.cpp
index 4355295..465865f 100644
--- a/libAACenc/src/grp_data.cpp
+++ b/libAACenc/src/grp_data.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/grp_data.h b/libAACenc/src/grp_data.h
index eddd694..f061855 100644
--- a/libAACenc/src/grp_data.h
+++ b/libAACenc/src/grp_data.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/intensity.cpp b/libAACenc/src/intensity.cpp
index 632620a..3807233 100644
--- a/libAACenc/src/intensity.cpp
+++ b/libAACenc/src/intensity.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -450,23 +450,24 @@ FDKaacEnc_finalizeIntensityDecision(const FIXP_DBL *hrrErr,
const INT maxSfbPerGroup)
{
INT sfb,sfboffs, j;
- INT startIsSfb = 0;
- INT inIsBlock;
- INT currentIsSfbCount;
- FIXP_DBL overallHrrError;
FIXP_DBL isScaleLast = FL2FXCONST_DBL(0.0f);
- FIXP_DBL isRegionLoudness;
+ INT isStartValueFound = 0;
for (sfboffs = 0; sfboffs < sfbCnt; sfboffs += sfbPerGroup) {
- inIsBlock = 0;
- currentIsSfbCount = 0;
- overallHrrError = FL2FXCONST_DBL(0.0f);
- isRegionLoudness = FL2FXCONST_DBL(0.0f);
+ INT startIsSfb = 0;
+ INT inIsBlock = 0;
+ INT currentIsSfbCount = 0;
+ FIXP_DBL overallHrrError = FL2FXCONST_DBL(0.0f);
+ FIXP_DBL isRegionLoudness = FL2FXCONST_DBL(0.0f);
+
for (sfb = 0; sfb < maxSfbPerGroup; sfb++) {
if (isMask[sfboffs + sfb] == 1) {
if (currentIsSfbCount == 0) {
startIsSfb = sfboffs + sfb;
+ }
+ if (isStartValueFound==0) {
isScaleLast = realIsScale[sfboffs + sfb];
+ isStartValueFound = 1;
}
inIsBlock = 1;
currentIsSfbCount++;
@@ -510,6 +511,14 @@ FDKaacEnc_finalizeIntensityDecision(const FIXP_DBL *hrrErr,
for(j = startIsSfb; j <= sfboffs + sfb; j++) {
isMask[j] = 0;
}
+ isScaleLast = FL2FXCONST_DBL(0.0f);
+ isStartValueFound = 0;
+ for (j=0; j < startIsSfb; j++) {
+ if (isMask[j]!=0) {
+ isScaleLast = realIsScale[j];
+ isStartValueFound = 1;
+ }
+ }
}
currentIsSfbCount = 0;
overallHrrError = FL2FXCONST_DBL(0.0f);
diff --git a/libAACenc/src/intensity.h b/libAACenc/src/intensity.h
index 12be8bc..2acc292 100644
--- a/libAACenc/src/intensity.h
+++ b/libAACenc/src/intensity.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/interface.h b/libAACenc/src/interface.h
index a1c3a96..51fb72a 100644
--- a/libAACenc/src/interface.h
+++ b/libAACenc/src/interface.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -92,6 +92,7 @@ amm-info@iis.fraunhofer.de
#define _INTERFACE_H
#include "common_fix.h"
+#include "FDK_audio.h"
#include "psy_data.h"
#include "aacenc_tns.h"
@@ -155,9 +156,14 @@ typedef struct {
typedef struct {
- PSY_OUT_ELEMENT* psyOutElement[(6)];
- PSY_OUT_CHANNEL* pPsyOutChannels[(6)];
+ PSY_OUT_ELEMENT* psyOutElement[(8)];
+ PSY_OUT_CHANNEL* pPsyOutChannels[(8)];
}PSY_OUT;
+inline int isLowDelay( AUDIO_OBJECT_TYPE aot )
+{
+ return (aot==AOT_ER_AAC_LD || aot==AOT_ER_AAC_ELD);
+}
+
#endif /* _INTERFACE_H */
diff --git a/libAACenc/src/line_pe.cpp b/libAACenc/src/line_pe.cpp
index ba7a25d..f3c0dab 100644
--- a/libAACenc/src/line_pe.cpp
+++ b/libAACenc/src/line_pe.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/line_pe.h b/libAACenc/src/line_pe.h
index 2fcc958..3d5cfd5 100644
--- a/libAACenc/src/line_pe.h
+++ b/libAACenc/src/line_pe.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/metadata_compressor.cpp b/libAACenc/src/metadata_compressor.cpp
index 852c8bc..876de57 100644
--- a/libAACenc/src/metadata_compressor.cpp
+++ b/libAACenc/src/metadata_compressor.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -421,7 +421,7 @@ static FIXP_DBL tc2Coeff(
result = f2Pow(-exponent, DFRACT_BITS-1-METADATA_FRACT_BITS, &e_res);
/* result = 1.0 - exp(-1.0/((t) * (f))) */
- result = FL2FXCONST_DBL(1.0f) - scaleValue(result, e_res);
+ result = (FIXP_DBL)MAXVAL_DBL - scaleValue(result, e_res);
return result;
}
@@ -539,14 +539,25 @@ INT FDK_DRC_Generator_Initialize(
drcComp->channelIdx[RS] = channelMapping.elInfo[2].ChannelIndex[1];
break;
case MODE_1_2_2_2_1: /* 7.1 ch */
- drcComp->channelIdx[L] = channelMapping.elInfo[1].ChannelIndex[0];
- drcComp->channelIdx[R] = channelMapping.elInfo[1].ChannelIndex[1];
- drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0];
- drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0];
- drcComp->channelIdx[LS] = channelMapping.elInfo[2].ChannelIndex[0];
- drcComp->channelIdx[RS] = channelMapping.elInfo[2].ChannelIndex[1];
- drcComp->channelIdx[LS2] = channelMapping.elInfo[3].ChannelIndex[0];
- drcComp->channelIdx[RS2] = channelMapping.elInfo[3].ChannelIndex[1];
+ case MODE_7_1_FRONT_CENTER:
+ drcComp->channelIdx[L] = channelMapping.elInfo[2].ChannelIndex[0]; /* l */
+ drcComp->channelIdx[R] = channelMapping.elInfo[2].ChannelIndex[1]; /* r */
+ drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0]; /* c */
+ drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0]; /* lfe */
+ drcComp->channelIdx[LS] = channelMapping.elInfo[3].ChannelIndex[0]; /* ls */
+ drcComp->channelIdx[RS] = channelMapping.elInfo[3].ChannelIndex[1]; /* rs */
+ drcComp->channelIdx[LS2] = channelMapping.elInfo[1].ChannelIndex[0]; /* lc */
+ drcComp->channelIdx[RS2] = channelMapping.elInfo[1].ChannelIndex[1]; /* rc */
+ break;
+ case MODE_7_1_REAR_SURROUND:
+ drcComp->channelIdx[L] = channelMapping.elInfo[1].ChannelIndex[0]; /* l */
+ drcComp->channelIdx[R] = channelMapping.elInfo[1].ChannelIndex[1]; /* r */
+ drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0]; /* c */
+ drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0]; /* lfe */
+ drcComp->channelIdx[LS] = channelMapping.elInfo[3].ChannelIndex[0]; /* lrear */
+ drcComp->channelIdx[RS] = channelMapping.elInfo[3].ChannelIndex[1]; /* rrear */
+ drcComp->channelIdx[LS2] = channelMapping.elInfo[2].ChannelIndex[0]; /* ls */
+ drcComp->channelIdx[RS2] = channelMapping.elInfo[2].ChannelIndex[1]; /* rs */
break;
case MODE_1_1:
case MODE_1_1_1_1:
@@ -832,12 +843,12 @@ INT FDK_DRC_Generator_Calc(
FIXP_DBL accu;
/* drcComp->smoothLevel[i] = (1-alpha) * drcComp->smoothLevel[i] + alpha * level; */
- accu = fMult((FL2FXCONST_DBL(1.f)-alpha), drcComp->smoothLevel[i]);
+ accu = fMult(((FIXP_DBL)MAXVAL_DBL-alpha), drcComp->smoothLevel[i]);
accu += fMult(alpha,level);
drcComp->smoothLevel[i] = accu;
/* drcComp->smoothGain[i] = (1-alpha) * drcComp->smoothGain[i] + alpha * gain; */
- accu = fMult((FL2FXCONST_DBL(1.f)-alpha), drcComp->smoothGain[i]);
+ accu = fMult(((FIXP_DBL)MAXVAL_DBL-alpha), drcComp->smoothGain[i]);
accu += fMult(alpha,gain);
drcComp->smoothGain[i] = accu;
}
@@ -941,7 +952,7 @@ INT FDK_DRC_Generator_Calc(
if ((drcComp->channelIdx[LS] >= 0) && (drcComp->channelIdx[LS2] >= 0)) tmp = fMult(FL2FXCONST_DBL(0.707f), tmp); /* 7.1ch */
/*if ((drcComp->channelIdx[RS] >= 0) && (drcComp->channelIdx[RS2] >= 0)) tmp *=0.707f;*/ /* 7.1ch */
if (drcComp->channelIdx[S] >= 0) tmp += fMultDiv2(slev, fMult(FL2FXCONST_DBL(0.7f), (FIXP_PCM)pSamples[drcComp->channelIdx[S]]))>>(DOWNMIX_SHIFT-1); /* S */
- if (drcComp->channelIdx[C] >= 0) tmp += fMultDiv2(clev, (FIXP_PCM)pSamples[drcComp->channelIdx[C]])>>(DOWNMIX_SHIFT-1); /* C */
+ if (drcComp->channelIdx[C] >= 0) tmp += fMult(clev, (FIXP_PCM)pSamples[drcComp->channelIdx[C]])>>(DOWNMIX_SHIFT-1); /* C (2*clev) */
tmp += (FX_PCM2FX_DBL((FIXP_PCM)pSamples[drcComp->channelIdx[L]])>>DOWNMIX_SHIFT); /* L */
tmp += (FX_PCM2FX_DBL((FIXP_PCM)pSamples[drcComp->channelIdx[R]])>>DOWNMIX_SHIFT); /* R */
@@ -973,7 +984,7 @@ INT FDK_DRC_Generator_Calc(
* + 0.2f*2^(-METADATA_FRACT_BITS) + drcComp->smoothGain[i]
*/
peak[i] = fMult((FIXP_DBL)(10<<(METADATA_FRACT_BITS+LD_DATA_SHIFT)), fMult( FL2FX_DBL(2*0.30102999566398119521373889472449f), ld_peak));
- peak[i] += (FL2FX_DBL(0.2f)>>METADATA_INT_BITS); /* add a little bit headroom */
+ peak[i] += (FL2FX_DBL(0.5f)>>METADATA_INT_BITS); /* add a little bit headroom */
peak[i] += drcComp->smoothGain[i];
}
diff --git a/libAACenc/src/metadata_compressor.h b/libAACenc/src/metadata_compressor.h
index c77e79e..ff639b5 100644
--- a/libAACenc/src/metadata_compressor.h
+++ b/libAACenc/src/metadata_compressor.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/metadata_main.cpp b/libAACenc/src/metadata_main.cpp
index 45763a1..e920793 100644
--- a/libAACenc/src/metadata_main.cpp
+++ b/libAACenc/src/metadata_main.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/metadata_main.h b/libAACenc/src/metadata_main.h
index f747f9f..bfc8ae1 100644
--- a/libAACenc/src/metadata_main.h
+++ b/libAACenc/src/metadata_main.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/ms_stereo.cpp b/libAACenc/src/ms_stereo.cpp
index ab0cb1c..306d490 100644
--- a/libAACenc/src/ms_stereo.cpp
+++ b/libAACenc/src/ms_stereo.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/ms_stereo.h b/libAACenc/src/ms_stereo.h
index 5657ae2..2f3addb 100644
--- a/libAACenc/src/ms_stereo.h
+++ b/libAACenc/src/ms_stereo.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/noisedet.cpp b/libAACenc/src/noisedet.cpp
index 178a2ad..f3c51de 100644
--- a/libAACenc/src/noisedet.cpp
+++ b/libAACenc/src/noisedet.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/noisedet.h b/libAACenc/src/noisedet.h
index bccf4ee..8d5e365 100644
--- a/libAACenc/src/noisedet.h
+++ b/libAACenc/src/noisedet.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/pns_func.h b/libAACenc/src/pns_func.h
index d1d8fb1..efa44ef 100644
--- a/libAACenc/src/pns_func.h
+++ b/libAACenc/src/pns_func.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/pnsparam.cpp b/libAACenc/src/pnsparam.cpp
index 3426ac3..afc5bdd 100644
--- a/libAACenc/src/pnsparam.cpp
+++ b/libAACenc/src/pnsparam.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/pnsparam.h b/libAACenc/src/pnsparam.h
index 53a2704..08bb83e 100644
--- a/libAACenc/src/pnsparam.h
+++ b/libAACenc/src/pnsparam.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/pre_echo_control.cpp b/libAACenc/src/pre_echo_control.cpp
index b1f9041..3dfd8ed 100644
--- a/libAACenc/src/pre_echo_control.cpp
+++ b/libAACenc/src/pre_echo_control.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/pre_echo_control.h b/libAACenc/src/pre_echo_control.h
index c2743d7..9224db0 100644
--- a/libAACenc/src/pre_echo_control.h
+++ b/libAACenc/src/pre_echo_control.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/psy_configuration.cpp b/libAACenc/src/psy_configuration.cpp
index 96f6a71..4393fa1 100644
--- a/libAACenc/src/psy_configuration.cpp
+++ b/libAACenc/src/psy_configuration.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/psy_configuration.h b/libAACenc/src/psy_configuration.h
index 3d8ad0b..3629246 100644
--- a/libAACenc/src/psy_configuration.h
+++ b/libAACenc/src/psy_configuration.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/psy_const.h b/libAACenc/src/psy_const.h
index 0195931..d9c9f43 100644
--- a/libAACenc/src/psy_const.h
+++ b/libAACenc/src/psy_const.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -98,7 +98,6 @@ amm-info@iis.fraunhofer.de
#define FRAME_MAXLEN_SHORT ((1024)/TRANS_FAC)
#define FRAME_LEN_SHORT_128 ((1024)/TRANS_FAC)
-#define FRAME_LEN_SHORT_120 (FRAME_LEN_LONG_960/TRANS_FAC)
/* Filterbank type*/
enum FB_TYPE {
diff --git a/libAACenc/src/psy_data.h b/libAACenc/src/psy_data.h
index 2219f24..7183955 100644
--- a/libAACenc/src/psy_data.h
+++ b/libAACenc/src/psy_data.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/psy_main.cpp b/libAACenc/src/psy_main.cpp
index 672619e..59193c7 100644
--- a/libAACenc/src/psy_main.cpp
+++ b/libAACenc/src/psy_main.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -116,11 +116,6 @@ static const FIXP_DBL fadeOutFactor[FADE_OUT_LEN] = {1840644096, 1533870080, 122
/* forward definitions */
-static inline int isLowDelay( AUDIO_OBJECT_TYPE aot )
-{
- return (aot==AOT_ER_AAC_LD || aot==AOT_ER_AAC_ELD);
-}
-
/*****************************************************************************
functionname: FDKaacEnc_PsyNew
@@ -513,28 +508,28 @@ AAC_ENCODER_ERROR FDKaacEnc_psyMain(INT channels,
for(ch = 0; ch < channels; ch++)
{
- C_ALLOC_SCRATCH_START(timeSignal, INT_PCM, (1024));
- psyStatic[ch]->blockSwitchingControl.timeSignal = timeSignal;
+ C_ALLOC_SCRATCH_START(pTimeSignal, INT_PCM, (1024))
/* deinterleave input data and use for block switching */
- FDKaacEnc_deinterleaveInputBuffer( psyStatic[ch]->blockSwitchingControl.timeSignal,
+ FDKaacEnc_deinterleaveInputBuffer( pTimeSignal,
&pInput[chIdx[ch]],
psyConf->granuleLength,
totalChannels);
FDKaacEnc_BlockSwitching (&psyStatic[ch]->blockSwitchingControl,
- psyConf->granuleLength
- ,psyStatic[ch]->isLFE
+ psyConf->granuleLength,
+ psyStatic[ch]->isLFE,
+ pTimeSignal
);
/* fill up internal input buffer, to 2xframelength samples */
FDKmemcpy(psyStatic[ch]->psyInputBuffer+blockSwitchingOffset,
- psyStatic[ch]->blockSwitchingControl.timeSignal,
+ pTimeSignal,
(2*psyConf->granuleLength-blockSwitchingOffset)*sizeof(INT_PCM));
- C_ALLOC_SCRATCH_END(timeSignal, INT_PCM, (1024));
+ C_ALLOC_SCRATCH_END(pTimeSignal, INT_PCM, (1024))
}
/* synch left and right block type */
@@ -1345,7 +1340,7 @@ void FDKaacEnc_PsyClose(PSY_INTERNAL **phPsyInternal,
if (hPsyInternal)
{
- for (i=0; i<(6); i++) {
+ for (i=0; i<(8); i++) {
if (hPsyInternal->pStaticChannels[i]) {
if (hPsyInternal->pStaticChannels[i]->psyInputBuffer)
FreeRam_aacEnc_PsyInputBuffer(&hPsyInternal->pStaticChannels[i]->psyInputBuffer); /* AUDIO INPUT BUFFER */
@@ -1354,7 +1349,7 @@ void FDKaacEnc_PsyClose(PSY_INTERNAL **phPsyInternal,
}
}
- for (i=0; i<(6); i++) {
+ for (i=0; i<(8); i++) {
if (hPsyInternal->psyElement[i])
FreeRam_aacEnc_PsyElement(&hPsyInternal->psyElement[i]); /* PSY_ELEMENT */
}
@@ -1368,12 +1363,12 @@ void FDKaacEnc_PsyClose(PSY_INTERNAL **phPsyInternal,
for (n=0; n<(1); n++) {
if (phPsyOut[n])
{
- for (i=0; i<(6); i++) {
+ for (i=0; i<(8); i++) {
if (phPsyOut[n]->pPsyOutChannels[i])
FreeRam_aacEnc_PsyOutChannel(&phPsyOut[n]->pPsyOutChannels[i]); /* PSY_OUT_CHANNEL */
}
- for (i=0; i<(6); i++) {
+ for (i=0; i<(8); i++) {
if (phPsyOut[n]->psyOutElement[i])
FreeRam_aacEnc_PsyOutElements(&phPsyOut[n]->psyOutElement[i]); /* PSY_OUT_ELEMENTS */
}
diff --git a/libAACenc/src/psy_main.h b/libAACenc/src/psy_main.h
index 9670f4a..7bdcc38 100644
--- a/libAACenc/src/psy_main.h
+++ b/libAACenc/src/psy_main.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -117,8 +117,8 @@ typedef struct {
typedef struct {
PSY_CONFIGURATION psyConf[2]; /* LONG / SHORT */
- PSY_ELEMENT* psyElement[(6)];
- PSY_STATIC* pStaticChannels[(6)];
+ PSY_ELEMENT* psyElement[(8)];
+ PSY_STATIC* pStaticChannels[(8)];
PSY_DYNAMIC* psyDynamic;
INT granuleLength;
diff --git a/libAACenc/src/qc_data.h b/libAACenc/src/qc_data.h
index d37ea92..a9309c8 100644
--- a/libAACenc/src/qc_data.h
+++ b/libAACenc/src/qc_data.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -127,7 +127,7 @@ typedef struct {
INT nChannels;
INT nChannelsEff;
INT nElements;
- ELEMENT_INFO elInfo[(6)];
+ ELEMENT_INFO elInfo[(8)];
} CHANNEL_MAPPING;
typedef struct {
@@ -143,6 +143,8 @@ struct QC_INIT{
INT maxBits; /* maximum number of bits in reservoir */
INT averageBits; /* average number of bits we should use */
INT bitRes;
+ INT sampleRate; /* output sample rate */
+ INT advancedBitsToPe; /* if set, calc bits2PE factor depending on samplerate */
INT staticBits; /* Bits per frame consumed by transport layers. */
QCDATA_BR_MODE bitrateMode;
INT meanPe;
@@ -215,8 +217,8 @@ typedef struct
typedef struct
{
- QC_OUT_ELEMENT *qcElement[(6)];
- QC_OUT_CHANNEL *pQcOutChannels[(6)];
+ QC_OUT_ELEMENT *qcElement[(8)];
+ QC_OUT_CHANNEL *pQcOutChannels[(8)];
QC_OUT_EXTENSION extension[(2+2)]; /* global extension payload */
INT nExtensions; /* number of extension payloads for this AU */
INT maxDynBits; /* maximal allowed dynamic bits in frame */
@@ -252,7 +254,7 @@ typedef struct
INT minBitsPerFrame; /* minimal allowd bits per fram, superframing - DRM */
INT nElements;
QCDATA_BR_MODE bitrateMode;
- INT bitDistributenMode; /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir */
+ INT bitDistributionMode; /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir */
INT bitResTot;
INT bitResTotMax;
INT maxIterations; /* Maximum number of allowed iterations before FDKaacEnc_crashRecovery() is applied. */
@@ -263,7 +265,7 @@ typedef struct
PADDING padding;
- ELEMENT_BITS *elementBits[(6)];
+ ELEMENT_BITS *elementBits[(8)];
BITCNTR_STATE *hBitCounter;
ADJ_THR_STATE *hAdjThr;
diff --git a/libAACenc/src/qc_main.cpp b/libAACenc/src/qc_main.cpp
index d7e76c7..b74510a 100644
--- a/libAACenc/src/qc_main.cpp
+++ b/libAACenc/src/qc_main.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -382,10 +382,10 @@ AAC_ENCODER_ERROR FDKaacEnc_QCInit(QC_STATE *hQC,
if ( isConstantBitrateMode(hQC->bitrateMode) ) {
INT bitresPerChannel = (hQC->bitResTotMax / init->channelMapping->nChannelsEff);
/* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir */
- hQC->bitDistributenMode = (bitresPerChannel>50) ? 0 : (bitresPerChannel>0) ? 1 : 2;
+ hQC->bitDistributionMode = (bitresPerChannel>100) ? 0 : (bitresPerChannel>0) ? 1 : 2;
}
else {
- hQC->bitDistributenMode = 0; /* full bitreservoir */
+ hQC->bitDistributionMode = 0; /* full bitreservoir */
}
@@ -420,11 +420,17 @@ AAC_ENCODER_ERROR FDKaacEnc_QCInit(QC_STATE *hQC,
break;
}
- FDKaacEnc_AdjThrInit(hQC->hAdjThr,
- init->meanPe,
- hQC->elementBits, /* or channelBitrates, was: channelBitrate */
- init->channelMapping->nElements,
- hQC->vbrQualFactor);
+ FDKaacEnc_AdjThrInit(
+ hQC->hAdjThr,
+ init->meanPe,
+ hQC->elementBits, /* or channelBitrates, was: channelBitrate */
+ hQC->invQuant,
+ init->channelMapping->nElements,
+ init->channelMapping->nChannelsEff,
+ init->sampleRate, /* output sample rate */
+ init->advancedBitsToPe, /* if set, calc bits2PE factor depending on samplerate */
+ hQC->vbrQualFactor
+ );
return AAC_ENC_OK;
}
@@ -505,7 +511,7 @@ AAC_ENCODER_ERROR FDKaacEnc_AdjustBitrate(QC_STATE *RESTRICT hQC,
}
static AAC_ENCODER_ERROR FDKaacEnc_distributeElementDynBits(QC_STATE* hQC,
- QC_OUT_ELEMENT* qcElement[(6)],
+ QC_OUT_ELEMENT* qcElement[(8)],
CHANNEL_MAPPING* cm,
INT codeBits)
{
@@ -604,7 +610,7 @@ static AAC_ENCODER_ERROR FDKaacEnc_prepareBitDistribution(QC_STATE* h
PSY_OUT** psyOut,
QC_OUT** qcOut,
CHANNEL_MAPPING* cm,
- QC_OUT_ELEMENT* qcElement[(1)][(6)],
+ QC_OUT_ELEMENT* qcElement[(1)][(8)],
INT avgTotalBits,
INT *totalAvailableBits,
INT *avgTotalDynBits)
@@ -655,7 +661,7 @@ static AAC_ENCODER_ERROR FDKaacEnc_prepareBitDistribution(QC_STATE* h
hQC->elementBits[i]->bitResLevelEl,
hQC->elementBits[i]->maxBitResBitsEl,
hQC->maxBitFac,
- hQC->bitDistributenMode);
+ hQC->bitDistributionMode);
*totalAvailableBits += hQC->elementBits[i]->bitResLevelEl;
/* get total corrected granted PE */
@@ -671,7 +677,7 @@ static AAC_ENCODER_ERROR FDKaacEnc_prepareBitDistribution(QC_STATE* h
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static AAC_ENCODER_ERROR FDKaacEnc_updateUsedDynBits(INT* sumDynBitsConsumed,
- QC_OUT_ELEMENT* qcElement[(6)],
+ QC_OUT_ELEMENT* qcElement[(8)],
CHANNEL_MAPPING* cm)
{
INT i;
@@ -714,7 +720,7 @@ static INT FDKaacEnc_getTotalConsumedDynBits(QC_OUT** qcOut,
}
static INT FDKaacEnc_getTotalConsumedBits(QC_OUT** qcOut,
- QC_OUT_ELEMENT* qcElement[(1)][(6)],
+ QC_OUT_ELEMENT* qcElement[(1)][(8)],
CHANNEL_MAPPING* cm,
INT globHdrBits,
INT nSubFrames)
@@ -814,7 +820,7 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC,
/*-------------------------------------------- */
/* helper pointer */
- QC_OUT_ELEMENT* qcElement[(1)][(6)];
+ QC_OUT_ELEMENT* qcElement[(1)][(8)];
/* work on a copy of qcChannel and qcElement */
for (i=0; i<cm->nElements; i++)
@@ -891,10 +897,10 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC,
} /* -end- sub frame counter */
/*-------------------------------------------- */
- INT iterations[(1)][(6)];
- INT chConstraintsFulfilled[(1)][(6)][(2)];
- INT calculateQuant[(1)][(6)][(2)];
- INT constraintsFulfilled[(1)][(6)];
+ INT iterations[(1)][(8)];
+ INT chConstraintsFulfilled[(1)][(8)][(2)];
+ INT calculateQuant[(1)][(8)][(2)];
+ INT constraintsFulfilled[(1)][(8)];
/*-------------------------------------------- */
@@ -1241,7 +1247,7 @@ static AAC_ENCODER_ERROR FDKaacEnc_reduceBitConsumption(int* iterati
AAC_ENCODER_ERROR FDKaacEnc_updateFillBits(CHANNEL_MAPPING* cm,
QC_STATE* qcKernel,
- ELEMENT_BITS* RESTRICT elBits[(6)],
+ ELEMENT_BITS* RESTRICT elBits[(8)],
QC_OUT** qcOut)
{
switch (qcKernel->bitrateMode) {
@@ -1597,10 +1603,10 @@ void FDKaacEnc_QCClose (QC_STATE **phQCstate, QC_OUT **phQC)
for (n=0;n<(1);n++) {
if (phQC[n] != NULL) {
QC_OUT *hQC = phQC[n];
- for (i=0; i<(6); i++) {
+ for (i=0; i<(8); i++) {
}
- for (i=0; i<(6); i++) {
+ for (i=0; i<(8); i++) {
if (hQC->qcElement[i])
FreeRam_aacEnc_QCelement(&hQC->qcElement[i]);
}
@@ -1620,7 +1626,7 @@ void FDKaacEnc_QCClose (QC_STATE **phQCstate, QC_OUT **phQC)
if (hQCstate->hBitCounter != NULL)
FDKaacEnc_BCClose(&hQCstate->hBitCounter);
- for (i=0; i<(6); i++) {
+ for (i=0; i<(8); i++) {
if (hQCstate->elementBits[i]!=NULL) {
FreeRam_aacEnc_ElementBits(&hQCstate->elementBits[i]);
}
diff --git a/libAACenc/src/qc_main.h b/libAACenc/src/qc_main.h
index dadac8e..4e8c042 100644
--- a/libAACenc/src/qc_main.h
+++ b/libAACenc/src/qc_main.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -140,7 +140,7 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC,
AAC_ENCODER_ERROR FDKaacEnc_updateFillBits(CHANNEL_MAPPING* cm,
QC_STATE* qcKernel,
- ELEMENT_BITS* RESTRICT elBits[(6)],
+ ELEMENT_BITS* RESTRICT elBits[(8)],
QC_OUT** qcOut);
diff --git a/libAACenc/src/quantize.cpp b/libAACenc/src/quantize.cpp
index 1f7402b..5380e35 100644
--- a/libAACenc/src/quantize.cpp
+++ b/libAACenc/src/quantize.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -127,10 +127,7 @@ static void FDKaacEnc_quantizeLines(INT gain,
accu = fMultDiv2(FDKaacEnc_mTab_3_4[tabIndex],FDKaacEnc_quantTableE[totalShift&3]);
totalShift = (16-4)-(3*(totalShift>>2));
FDK_ASSERT(totalShift >=0); /* MAX_QUANT_VIOLATION */
- if (totalShift < 32)
- accu>>=totalShift;
- else
- accu = 0;
+ accu >>= fixMin(totalShift,DFRACT_BITS-1);
quaSpectrum[line] = (SHORT)(-((LONG)(k + accu) >> (DFRACT_BITS-1-16)));
}
else if(accu > FL2FXCONST_DBL(0.0f))
@@ -143,10 +140,7 @@ static void FDKaacEnc_quantizeLines(INT gain,
accu = fMultDiv2(FDKaacEnc_mTab_3_4[tabIndex],FDKaacEnc_quantTableE[totalShift&3]);
totalShift = (16-4)-(3*(totalShift>>2));
FDK_ASSERT(totalShift >=0); /* MAX_QUANT_VIOLATION */
- if (totalShift < 32)
- accu>>=totalShift;
- else
- accu = 0;
+ accu >>= fixMin(totalShift,DFRACT_BITS-1);
quaSpectrum[line] = (SHORT)((LONG)(k + accu) >> (DFRACT_BITS-1-16));
}
else
diff --git a/libAACenc/src/quantize.h b/libAACenc/src/quantize.h
index 72dd851..975b98e 100644
--- a/libAACenc/src/quantize.h
+++ b/libAACenc/src/quantize.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/sf_estim.cpp b/libAACenc/src/sf_estim.cpp
index c5512cb..72b75a6 100644
--- a/libAACenc/src/sf_estim.cpp
+++ b/libAACenc/src/sf_estim.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/sf_estim.h b/libAACenc/src/sf_estim.h
index 3338a26..b5ac000 100644
--- a/libAACenc/src/sf_estim.h
+++ b/libAACenc/src/sf_estim.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/spreading.cpp b/libAACenc/src/spreading.cpp
index 5141b6e..852da1e 100644
--- a/libAACenc/src/spreading.cpp
+++ b/libAACenc/src/spreading.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/spreading.h b/libAACenc/src/spreading.h
index 078cc7f..e1b506c 100644
--- a/libAACenc/src/spreading.h
+++ b/libAACenc/src/spreading.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/tns_func.h b/libAACenc/src/tns_func.h
index 8f9bd26..6ee0edb 100644
--- a/libAACenc/src/tns_func.h
+++ b/libAACenc/src/tns_func.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/tonality.cpp b/libAACenc/src/tonality.cpp
index befff74..7246a34 100644
--- a/libAACenc/src/tonality.cpp
+++ b/libAACenc/src/tonality.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/tonality.h b/libAACenc/src/tonality.h
index dcd82a8..fbe78ee 100644
--- a/libAACenc/src/tonality.h
+++ b/libAACenc/src/tonality.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/transform.cpp b/libAACenc/src/transform.cpp
index fb57b14..690b82e 100644
--- a/libAACenc/src/transform.cpp
+++ b/libAACenc/src/transform.cpp
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
diff --git a/libAACenc/src/transform.h b/libAACenc/src/transform.h
index 212f5f0..5053174 100644
--- a/libAACenc/src/transform.h
+++ b/libAACenc/src/transform.h
@@ -2,7 +2,7 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
+© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
All rights reserved.
1. INTRODUCTION
@@ -105,7 +105,7 @@ amm-info@iis.fraunhofer.de
* LONG_WINDOW, START_WINDOW, SHORT_WINDOW or STOP_WINDOW.
* \param windowShape index indicating the window slope type to be used.
* Values allowed are either SINE_WINDOW or KBD_WINDOW.
- * \param frameLength length of the block. Either 1024 or 960.
+ * \param frameLength length of the block.
* \param mdctData_e pointer to an INT where the exponent of the frequency
* domain output data is stored into.
* \return 0 in case of success, non-zero in case of error (inconsistent parameters).